Using MIT Scratch for Programming and Control Exercise

  • Slides: 18
Download presentation
Using MIT Scratch for Programming and Control Exercise 6 – Creating a Scratch Packman

Using MIT Scratch for Programming and Control Exercise 6 – Creating a Scratch Packman Year 9 ICT Autumn Term 2007

What you will learn: • • • To design a maze background To resize

What you will learn: • • • To design a maze background To resize a sprite To move a sprite under keyboard control Stop the sprite moving over the background To get ‘prizes’ to disappear To score with the prizes To get the prize to appear again unexpectedly To choose your own prizes To randomly alter the grid.

Stage 1 of Packman Maze Score ‘Prize’ Explorer

Stage 1 of Packman Maze Score ‘Prize’ Explorer

Stage 2 of Packman Explorer moves

Stage 2 of Packman Explorer moves

Stage 3 of Packman Score goes up Explorer grabs prize

Stage 3 of Packman Score goes up Explorer grabs prize

Stage 4 of Packman Explorer moves on

Stage 4 of Packman Explorer moves on

Stage 5 of Packman ‘Prize’ reappears

Stage 5 of Packman ‘Prize’ reappears

What you need to decide • To decide on a maze background grid. •

What you need to decide • To decide on a maze background grid. • To decide on the sprite as the explorer. • To plan the ‘prizes’ – the sprites and the points for each. • To plan for how long a prize would disappear. • To decide if the background will change to a new level or will the grid alter randomly.

Design a background • The background must have one colour that the sprite cannot

Design a background • The background must have one colour that the sprite cannot cross (blue in the example. ) • The passage ways must be broad enough to take the sprite.

Replace the Cat 1. Delete the cat sprite. 2. Choose a new sprite –

Replace the Cat 1. Delete the cat sprite. 2. Choose a new sprite – use the central button under the stage. I called it the explorer. 3. Resize the sprite to make it small enough to follow the passages. Step 1 Step 2 Step 3

Get the Sprite to Move • Use the starting code as below – make

Get the Sprite to Move • Use the starting code as below – make sure all directions work.

Keep the Sprite on Track • Stop the sprite moving over the background by

Keep the Sprite on Track • Stop the sprite moving over the background by … • … checking if it has moved too far. • If so, move back 5

Add a “Prize” • • Add a “prize” – a banana. Place it in

Add a “Prize” • • Add a “prize” – a banana. Place it in a passageway. There should be a forever loop The script should hide the banana if it is touching the explorer. • Remember to save your Scratch program.

Score Grabbing a Prize • There are 2 parts • A variable to store

Score Grabbing a Prize • There are 2 parts • A variable to store the score • The score needs to increase when the prize is grabbed.

Restore the Prize • The banana needs to reappear and at a random time

Restore the Prize • The banana needs to reappear and at a random time makes a difference. • Use the pick random 1 to 10 from Numbers • Put it inside a wait. • Decide on the longest and shortest waits • Remember to save your Scratch program.

Introduce another Prize • Introduce other sprites as prizes. • Resize and add the

Introduce another Prize • Introduce other sprites as prizes. • Resize and add the correct script to each. • Choose where each is to go, what effect it will have on the score, how quickly each should reappear. • Remember to save your Scratch program.

Make your code efficient • The script to stop the sprite going onto the

Make your code efficient • The script to stop the sprite going onto the grid might be more efficient. • Do you have this section only once? • Are there any other parts to be improved?

Further ideas • Does the score set to zero for each game? • Is

Further ideas • Does the score set to zero for each game? • Is there a time limit or a target score? • Further sprites could be added to block/unblock sections of the grid. • This could make the game change as it is played. • There could be different levels with the background changing after a time. • There could be tunnels which move the player to a new maze background …