During this workshop, participants will be taught to use the Scratch programming tool to make a simple level monster-hunting video game. Participants will learn simple tasks like creating sprites and animating them via programming blocks.
Preparation time for facilitator
Time needed to complete activity (for learner)
Name of author
Support material needed for training
Resource originally created in
The goal of this tutorial is to create a simple monster hunt game. Monsters will invade our garden – we will have to shoot them to get rid of them.
Creating the garden
We will first create the stage. Go to stage in the bottom right of the creation screen and click on the icon. Now choose a backdrop from the Scratch library, for example ‘Garden Rock’ from the ‘Outdoors’ category.
Adding a projectile and a monster
Delete the default sprite. Click on the sprite icon near the backdrop icon shown previously and add a new one. Choose from the library (for example ‘Ball’ in the ‘All’ category) or draw one yourself (under the ‘Costume’ tab). Do the same to add a monster sprite.
Click on the title window above the sprite icons to change their names.
Animating the monster
We will now program our monster to have him move from left to right and then from right to left indefinitely.
Add the following blocks to the monster’s script:
When the green arrow is clicked, the monster will be placed on the stage. Its rotation sense will be set as ‘left-right’. It will now move indefinitely – ‘forever’ – at a speed of 5 and will ricochet if it touches the edge. Click on the green flag to test the code. The monster should move around the stage.
Playing hide and seek
To vary the monster’s behaviour, add the following blocks to make it disappear and reappear randomly:
When the green flag is clicked, the monster will appear, stay in this state for between 1 and 3 seconds (randomly determined duration), then will disappear and stay this way again between 1 and 3 seconds. This cycle will repeat indefinitely.
Throwing the ball
Now we need to be able to hunt the monster. We need to have it so that every time the player clicks, a ball is thrown. For this, copy the following code in Ball’s script.
When the flag is clicked (i.e. when the game begins) the computer will wait 0.5 seconds. Then, indefinitely (‘forever’), the computer will make the ball move horizontally following the cursor (‘go to x: mouse x’). If the player clicks, the ball will move towards the top of the screen at a speed of 5. It will continue to move until it either touches the edge or the monster. Test the result by clicking the green flag.
Hitting the monster
When we touch the monster it needs be stopped! We also want to count the points won when we do so. Go to ‘variables’ and click ‘Make a Variable’. Name this new variable ‘Counter’ and tick the box ‘For all Sprites’.
Go to the ball’s script and add the following blocks so that the sprite reacts when it makes contact with the monster:
If the ball touches the monster, the variable ‘Counter’ increases by 1. The verity of this condition is perpetually checked.
Setting a time limit
For the game to have a definitive end goal, we will need to add a timer. The game will end when the timer reaches zero and the goal will be set to shoot the most monsters possible within the time limit. Add a new variable ‘Timer’ and again select ‘For all Sprites’. The point counter has to start at 0 and the timer at 10. The timer will reduce by 1 per second. Add the following blocks to the script of the stage:
When the green flag is clicked, ‘Counter’ is set at 0 and ‘Timer is set at 10. After waiting 1 initial second, the value of ‘Timer’ will be changed by -1 then wait an additional second. This will repeat until the variable is equal to 0, at which point the whole program stops. Once it reaches 0, the whole program stops. Click the green flag to test the code. The round should last 10 seconds then stop.
Here are a few tips to improve the game:
- Add different monster types, being able to for example move at different speeds or carry more points
- Add special objects, for example something the adds to the timer (to increase the duration of the round) or make the ball temporarily larger (so it can hit the monster more easily).