Build a simple game
Plan a catch game, then build it in Scratch with movement, falling objects, a score variable and your own ideas.
Let's plan and build a simple catch game in Scratch. Most games have three things, a goal, rules, and a way to keep score. Let's plan a simple game. A basket catches falling mangoes, and each mango caught scores a point.
Plan before you code
First, the goal. Catch as many mangoes as you can. Second, the sprites. A basket and a mango. Third, the controls. The left and right arrow keys move the basket. And fourth, the score. One point for every mango caught.
Code the basket
First, the basket. When green flag clicked. Forever. If the right arrow key is pressed, then. Change x by ten, which moves the basket to the right. Make a copy for the left arrow, with minus ten.
Code the mango
Now the mango. When green flag clicked. Go to a random spot at the top of the screen. Forever. Change y by minus five. That makes the mango fall down the screen. If it's touching the basket, then. Change score by one, and send the mango back to the top.
New word: Variable
Score is a variable. A variable is a named box that stores a value. It starts at zero, and the game adds one every time the basket catches a mango.
Make it yours
Add a timer, so players have thirty seconds to score. Make the mango fall faster as the score goes up. Add a sound for each catch. And draw your own sprites in the paint editor.
Quick check
Quick check. In the game, what does the variable called score do? It stores the number of points, and goes up by one with each catch. Options: Stores the number of points; Moves the basket; Draws the mango; Ends the game.
Recap
Plan your game's goal, sprites, controls and score. Change x moves sprites left and right. Change y moves them up and down. And a variable keeps the score.
Key points
- {'Plan your game first': 'the goal, the sprites, the controls and the score.'}
- "change x by" moves a sprite left or right; "change y by" moves it up or down.
- A forever loop with an if block checks for key presses and collisions.
- A variable is a named box that stores a value, like the score.
Try it: Build your catch game
Build the game on a computer or tablet at scratch.mit.edu.