A Scratch tutorial
Description: You have 6 bullets to shoot at 2 targets. Every time you hit any of them you get two extra bullets but the targets get 10% smaller every time you hit them. Once both of them become less than 10% of their original size – you win, otherwise – game over!
Variables Bullets – start with 6 Score – starts with 0
Sprites Aim Flash Target1 Target2 gameover
Aim is controlled by the mouse The “forever” block controls the rest of the program Aim follows the mouse When the mouse button is pressed a signal is sent to Targets, if they are touching Aim they are “shot” When all bullets are gone – Game over! When both targets become tiny – you win!
Target1 runs around and gets shot at Try different initial sizes to make the game interesting That starts the game and initialises all settings Randomly glides around the screen If less than 10% in size – goes to lower corner, out of the way and stops its movement by halting its script When receive a signal that a shot has been fired, checks if was touching the Aim in the moment of the shot.
Flash follows the Aim and appears only for short moments of the shots fired. Two blocks in the Flash area The first one initialises the size to 100% and makes the flash normally invisible It also turns on the “forever” block to follow wherever the Aim is The second one makes the Flash appear and Shrink 10 time.
Gameover message Invisible at the start of the game (Ghost=100% is invisible) Then made visible at the end. (Ghost=0% is visible)
Extension activities: Put more targets Put Trees and other objects behind which the Targets can hide (how can you program that?) Also, you will notice that it is very easy to lose all bullets in one go, can we fix that?