Catch and Egg
image missing Catch and Egg

Demostrate the use of:

  • Setting initial conditions before forever loop
  • Variables
  • Broadcast messages
  • Speed controled by a variable

When the game starts, the ball falls towards the floor.

When the ball is touched by the mouse-pointer it glides to the top of the stage and start to fall faster. Were at the top of the stage is a random point between x = -150 to 150 and y = 170

If the ball touches the floor the script sends the message “you lose” to the lose sprite and then stops.

This game uses scratch variables and broadcast messages. The variable holds the ball's falling speed and the broadcast message is used to communicate between sprites.

  Start Scratch and delete the cat.
image missing Create a variable called speed. This is how fast the ball falls towards the floor. The speed increases each time you catch the egg.
  Create a new sprite called ball. You can draw one or use one of the balls already available in Scratch.

Drag the sprite ball to the top of the stage.

image missing Draw a sprite called floor. It must go from one side of the stage to the other.

Drag the sprite floor to the bottom of the stage.

image missing Draw a sprite called lose that contains the text “you loose!!”

Drag the sprite lose to the middle of the stage.

Try different fonts and font sizes.

image missing Add this script to the sprite ball.

If the ball touches the mouse-pointer it glides to the top of the stage and start to fall again. The speed is increased by 1. (The ball falls faster.)

If the ball touches the floor, broadcast the message "you lose" and stops.

image missing Add this code to the sprite lose.

When you click on the green flag to start the game, the sprite lose hides. When it receives the message “you lose” it shows itself.

  Save and try it out!

Try this…

Add a variable to keep track of the number of times you save the egg. If you save it six times, display a message that says “You win!!” and stop the game.

Add sounds.

Make fancier lose message. Make it dance around.

Add more that one ball to the game.

What do you do if you don’t want show the variable speed on the stage?