Sign in
Home
Online Classes
Instructors
Tutorials
☰
Register
Sign in
Online Classes
Instructors
Tutorials
1. Create a hero sprite
2. (Group Activity) Coordinates and Gravity
3. Program the "flappy" movement
4. Program a penalty for falling off the screen
5. Design an obstacle sprite
6. Clone your obstacle
7. Make your clones move
8. Add a penalty if the hero touches an obstacle
9. (Group Activity) How do we win this game?
10. (Optional) Add a trail effect behind your hero
Project 442: Infinite Flying Game
4. Program a penalty for falling off the screen
The game should stop if you let your main character fall - or fly too high up.
Starting point file for this challenge
Your goal
Hint: show steps
Steps
1. Start a new piece of code with an if-statement
Hint: show details
Grab a yellow "when green flag clicked." Next, grab the if-statement block we used before.
Hint: show image
2. Check if the hero's Y position is less than -170
Hint: show details
The bottom most part of the screen on Scratch is -180, so if the hero goes below -170, it's definitely off the screen.
Grab a green "operators" block, " ___ < ___." In the first blank, check the hero's "y position" (a dark blue block.) In the second blank, type -170.
Put this green block into the "if" blank of the if-statement.
Hint: show image
3. Add a "stop all" block as a result
Hint: show details
Put a "stop all" block in the "then" part of the if-statement. This block is found in the "control" section.
Hint: show image
4. Test it out!
Hint: show details
Make sure the game ends if you touch the bottom of the screen before moving on to the rest! Click the green flag to test things out.
5. Repeat last 2 steps, but for the top of the screen
Hint: show details
The top of the screen in Scratch is 180, so we want to check if the hero's y position is above 170. If so, then stop the game again.
Hint: show image
6. Repeat your code with a forever loop
Hint: show details
Currently, the game is only checking if the player is out of bounds at the start of the game, but if you put a forever loop around the entire code, the game will check for the whole game.
Hint: show image
×
×
Provide your email address for immediate project access
Email
Check your email for instructions on how to create a full DA account