Ada Lovelace Computing Level 3 Scratch Project ROAD RACER
ANALYSIS (what will your program do) For my project I will create a game in Scratch called Road Racer. The object of the game is to control a car up, down, left and right and gather as many points as you can by collecting coins, which randomly appear on screen. Every time the player collects a coin it will add 1 to their score. There will also be two other cars which move down the screen. If the player s car touches them they will lose 1 life. A dog will also randomly move around the screen. If the player s car touches the dog then they will lose a life. Once the lives reach 0 the game will stop and a Game Over screen will appear. I will need a score variable to hold the current score of the player. The score variable will start at 0. I will need a lives variable to hold the current lives of the player. The lives variable will start at 3. I will include the following objects to create my game: stage redcar bluecar yellowcar dog coin Variable score lives Purpose This will store the current score and will start at 0. This will store the current number of lives and start at 3.
DESIGN (how will your solution work) Algorithm Object redcar Operations FOREVER IF press up arrow move up IF press down arrow move down IF press left arrow move left IF press right arrow move right IF touching the grass bounce off IF touching the edge bounce off IF touching the bluecar go to start position take 1 away from lives IF touching the yellowcar take 1 away from lives IF touching the dog take 1 away from lives IF lives = 0 display GAME OVER hide the redcar go to start position SET lives TO 3 SET score TO 0 hide the redcar
bluecar hide the bluecar show the blue car FOREVER move 3 steps IF touching the edge hide the bluecar wait for 3 seconds show the bluecar yellowcar hide the bluecar hide the yellowcar show the yellowcar car FOREVER move 3 steps IF touching the edge hide the yellowcar wait for 3 seconds show the yellowcar dog hide the yellowcar show the dog FOREVER move the dog to a random X and Y coordinate every 2 seconds hide the dog wait for 2 seconds show the dog hide the dog
coin show the coin move the coin to a random X and Y coordinate FOREVER IF touching the redcar add 1 to the score hide the coin wait for 2 seconds move the coin to a random X and Y coordinate show the coin hide the coin stage WHEN game starts show level 1 stage show game over stage User Interface See my attached user interface design sketches.
IMPLEMENTATION (build your solution) Object redcar Code
bluecar yellowcar
dog coin stage
User Interface
TESTING (testing your solution to ensure the correct outputs) TEST MY EXPECTED OUTPUT When I press the arrow keys the redcar will move up, down, left and right. COMPUTER OUTPUT The redcar moved up, down, and left but not right when I move the arrow keys. Yellow and blue cars both move down the screen then reappeared at the top. Dog moved randomly around the screen every 2 seconds. COMMENT Redcar moves up, down left and right I had accidently set the right arrow key to point left before moving, so I changed the line of code to point right. Yellow and Blue cars move down the screen Yellow and blue cars move down the screen hide, then re-appear at the top of the screen. Dog will randomly move around the screen every 2 seconds. Coin will randomly appear. If touched by the redcar the score goes up by 1 then will disappear.. When the red car touches the blue car, yellow car or dog the lives goes down by 1. Dog moves around the screen. Coin appears randomly on screen and score increases when touched Coin appeared randomly. Whan the redcar touched it the score increased by 1. A life was lost when the redcar touched the bluecar or dog, but not when it touched the yellowcar. The game ended when lives reached 0 and the game over screen appeared. But the cars and the dog still appeared on screen. Life lost if touching the blue car or yellow car or dog. I changed my code so that IF the redcar touches the yellowcar then it will go back to its start position and a life is lost. Game ends When lives reaches 0, the Game Over screen appears and the game stops. I changed my code so that when all the cars and the dog received gameover they were set to hide.
EVALUATION (reporting on your solution) Did my program meet the requirements? The game met all the requirements because the main character (the red car), had the objective of gaining as many points as possible before losing all its lives. The red car was controlled by the keyboard. The blue car and yellow car appeared randomly and moved down the screen. If the red car touched the other cars a life was lost. The game used two variables to hold the score and lives. The game ended when lives reached zero. The program used IF commands to make decisions and FOREVER commands to repeat code. It also used random numbers to move objects around the screen. During the development of the program the dog was added to move randomly around the screen and if touched the player lost a life. I added this to my analysis and changed my design to include this function in the game before adding it to the program. How I could improve my program? I could improve the game: By adding a timer so that to object of the game is to get as many point as possible in 30 seconds or before all 3 lives are lost. To do this I would need to add another variable called timer By including scrolling trees which move down the screen, to look like realistic driving movement. By adding a Level 2, I could make the next level much more difficult by getting the player to drive around a maze, collecting more coins and avoiding more enemy objects. Problems I had and how I solved them I discovered a number of problems when testing my game: First of all when I pressed the right arrow the red car moved left. This was correct in my design, so I changed this line of code to point right before moving five steps. Secondly, a life was not lost when the yellow car touched the red car. I changed the red car code so that IF it touched the yellow car, it went back to the start position and lost a lift. Finally, I made sure each sprite was set to hide when game over was broadcast and they didn t appear on screen when the game over screen was displayed.