! Dodge ! Now we’re going to make another simple game based off of the basic cat movement you learned in the Control lesson. In this game, your cat will move around and try to dodge objects that fly at him. ! ! -Start by opening Scratch and loading up your Control lesson project. It’s a good idea to make a copy of the project file and use that so that you’ll still have the original Control lesson file as a starting point for other games. ! ! -Choose or draw a new sprite for your first falling object. ! -Now open up the new sprite’s scripts, and start with a block. We’re going to make the object fall from the top of the screen until it hits the bottom, and then start at the top again (in a different place). ! -You actually already know most of what you need to make this happen! Attach a block (important: this is different from the ‘forever if’ blocks you used earlier - this one has no condition). ! -Inside, put a ‘go to’ followed by a ‘glide’ block. The ‘go to’ should get a y-value near the top of the screen, and the glide should be for a y-value at the bottom of the screen. ! -The x-coordinate is more interesting. We want this to change randomly each time and Scratch has a block for that! Switch to the section now, and find the block . You can drag that over the number next to ‘x:’ in the ‘go to’ block and it’ll fit right in. -The ‘pick random’ should choose somewhere along the entire width of the Scratch window, so we need it to pick a number between the left side x-coordinate and the right side x-coordinate. Figure out what those should be, and fill them in the boxes. ! ! -What about the ‘glide’ block? If you want it to fall straight down, you need to tell it to glide to the same x-coordinate that it’s already at. If you switch back to the motion section, near the bottom of the list you’ll find the block . You can drag this into the glide’s ‘x: _’ box. ! -Try it out! When you’re satisfied with how it works, it’s time to add collisions. Recall how you did this in Sensing: start with a , and then put a ‘forever if’ block to keep checking. ! -What are we checking this time? Well, there’s a block in the sensing section called , which checks for collisions between sprites. Put this as the condition for the ‘forever if’, and then click the arrow inside the box to choose the right sprite to collide with. ! ! -Finally, we need the game to end when the cat gets hit. In the future, we’ll learn more creative ways to say GAME OVER, but for now we can get the job done with a control block called . Put this inside the ‘forever if’. ! ! -Your game should work! You’ve got an object falling from the sky that you have to dodge, or it’s game over. Before you move on to polishing your game, let’s make it a bit more difficult. Your challenge: add another object to the game that travels sideways across the window, and also ends the game when it hits the cat. ! -If you want another challenge, make a third object that moves diagonally! ! Good luck and remember to save!
© Copyright 2025 Paperzz