santa's cloud race -...

31
Santa's Cloud Race We're going to create a game in which Santa has to steer his sleigh around a 'cloud track', at ever-increasing speed. Can you keep his trail within the track? Getting starter: Importing Santa Open Scratch, right-click onto the default cat sprite, and delete it. Santa's Cloud Race. (www.lttonline.net). Page 1

Upload: others

Post on 19-Jan-2020

2 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Santa's Cloud Race - Squarespacestatic.squarespace.com/static/51545d53e4b0ebbbab48bec7/t/... · Santa's Cloud Race We're going to create a game in which Santa has to steer his sleigh

Santa's Cloud RaceWe're going to create a game in which Santa has to steer his sleigharound a 'cloud track', at ever-increasing speed. Can you keep his trailwithin the track?

Getting starter: Importing SantaOpen Scratch, right-click onto the default cat sprite, and delete it.

Santa's Cloud Race. (www.lttonline.net). Page 1

Page 2: Santa's Cloud Race - Squarespacestatic.squarespace.com/static/51545d53e4b0ebbbab48bec7/t/... · Santa's Cloud Race We're going to create a game in which Santa has to steer his sleigh

Click on the Choose new sprite button ...

... and browse to the Santa image, click onto it to select, then click OK.

Santa will appear on the stage.

Santa's Cloud Race. (www.lttonline.net). Page 2

Page 3: Santa's Cloud Race - Squarespacestatic.squarespace.com/static/51545d53e4b0ebbbab48bec7/t/... · Santa's Cloud Race We're going to create a game in which Santa has to steer his sleigh

Click onto the name field for the santa sprite (it will be called Sprite1 initially)and rename it.

Also click onto the only face left-right button. This will limit the rotation of thesprite to prevent it from flipping upside down when facing in come directions.

Getting Santa movingNow it's time to get Santa moving. He will move by following the player'smouse pointer around the stage. Make sure that you have clicked onto theScripts tab for santa, then click onto the orange Control button.

Santa's Cloud Race. (www.lttonline.net). Page 3

Page 4: Santa's Cloud Race - Squarespacestatic.squarespace.com/static/51545d53e4b0ebbbab48bec7/t/... · Santa's Cloud Race We're going to create a game in which Santa has to steer his sleigh

Drag in a When green flag is clicked instruction ...

... and a forever loop ...

Santa's Cloud Race. (www.lttonline.net). Page 4

Page 5: Santa's Cloud Race - Squarespacestatic.squarespace.com/static/51545d53e4b0ebbbab48bec7/t/... · Santa's Cloud Race We're going to create a game in which Santa has to steer his sleigh

... and then click onto the Motion button and drag in a point towardsinstruction.

Arrange the instructions as shown then click onto the drop-down box for thepoint towards command and select mouse-pointer. The algorithm now reads'When the green flag is clicked, continually point Santa at the mouse pointer'.

Santa's Cloud Race. (www.lttonline.net). Page 5

Page 6: Santa's Cloud Race - Squarespacestatic.squarespace.com/static/51545d53e4b0ebbbab48bec7/t/... · Santa's Cloud Race We're going to create a game in which Santa has to steer his sleigh

Finally drag in a 'move 10 steps' command as shown, then edit the numberfrom 10 to 1 step. The algorithm now reads 'When the green flag is clicked,continually point Santa at the mouse pointer, and move Santa 1 step towardsit'.

Now test the algorithm. Click onto the green flag and move the mouse pointeraround the stage. Santa should follow your pointer.

Santa's Cloud Race. (www.lttonline.net). Page 6

Page 7: Santa's Cloud Race - Squarespacestatic.squarespace.com/static/51545d53e4b0ebbbab48bec7/t/... · Santa's Cloud Race We're going to create a game in which Santa has to steer his sleigh

Creating the trackNow we're going to design the background and track. Click onto the Stage ...

... then click on the Backgrounds tab ...

... and click onto the Edit button for the background.

Santa's Cloud Race. (www.lttonline.net). Page 7

Page 8: Santa's Cloud Race - Squarespacestatic.squarespace.com/static/51545d53e4b0ebbbab48bec7/t/... · Santa's Cloud Race We're going to create a game in which Santa has to steer his sleigh

An editing window will appear.

First we are going to fill the background with a sky colour. Select the Fill tool.

Now select a colour for the background ...

Santa's Cloud Race. (www.lttonline.net). Page 8

Page 9: Santa's Cloud Race - Squarespacestatic.squarespace.com/static/51545d53e4b0ebbbab48bec7/t/... · Santa's Cloud Race We're going to create a game in which Santa has to steer his sleigh

... and click onto the background to fill it with the colour.

Santa's Cloud Race. (www.lttonline.net). Page 9

Page 10: Santa's Cloud Race - Squarespacestatic.squarespace.com/static/51545d53e4b0ebbbab48bec7/t/... · Santa's Cloud Race We're going to create a game in which Santa has to steer his sleigh

Now we are going to import a skyline image onto the stage. Click onto theImport button ...

... and browse to the skyline image, click onto and click OK.

Santa's Cloud Race. (www.lttonline.net). Page 10

Page 11: Santa's Cloud Race - Squarespacestatic.squarespace.com/static/51545d53e4b0ebbbab48bec7/t/... · Santa's Cloud Race We're going to create a game in which Santa has to steer his sleigh

The image will be imported.

Imeediately drag the skyline image to the bottom of the editing window, beforeclicking away. If you click away onto another tool, thus 'stamping' the skylineimage into the wrong location, click onto the 'Undo' button and import theimage again.

Santa's Cloud Race. (www.lttonline.net). Page 11

Page 12: Santa's Cloud Race - Squarespacestatic.squarespace.com/static/51545d53e4b0ebbbab48bec7/t/... · Santa's Cloud Race We're going to create a game in which Santa has to steer his sleigh

Now we are going to draw the track onto the stage. Select the Paintbrush tool...

... and click onto a colour for the 'track' - in this case, I've chosen white (with theidea that the track is made of clouds ...)

Also click onto the drop-down for the Brush size ...

... and select the largest brush size.

Santa's Cloud Race. (www.lttonline.net). Page 12

Page 13: Santa's Cloud Race - Squarespacestatic.squarespace.com/static/51545d53e4b0ebbbab48bec7/t/... · Santa's Cloud Race We're going to create a game in which Santa has to steer his sleigh

Then draw a wide, loop to create a track.

Santa's Cloud Race. (www.lttonline.net). Page 13

Page 14: Santa's Cloud Race - Squarespacestatic.squarespace.com/static/51545d53e4b0ebbbab48bec7/t/... · Santa's Cloud Race We're going to create a game in which Santa has to steer his sleigh

Now drag Santa to an appropriate starting point on the track.

Santa looks a bit big to move him around the track, so we'll shrink him a little.Click onto the Shrink sprite button ...

Santa's Cloud Race. (www.lttonline.net). Page 14

Page 15: Santa's Cloud Race - Squarespacestatic.squarespace.com/static/51545d53e4b0ebbbab48bec7/t/... · Santa's Cloud Race We're going to create a game in which Santa has to steer his sleigh

... the click repeatedly onto Santa to shrink him down.

Click on the green flag to the top-right of the stage ...

... and see whether you can move Santa around the track safely.

Santa's Cloud Race. (www.lttonline.net). Page 15

Page 16: Santa's Cloud Race - Squarespacestatic.squarespace.com/static/51545d53e4b0ebbbab48bec7/t/... · Santa's Cloud Race We're going to create a game in which Santa has to steer his sleigh

Using the pen tool to mark Santa's path.Let's mark Santa's route with the pen tool as he moves around the track. Clickonto Santa in the area beneath the stage ...

... and select the Scripts tab.

Santa's Cloud Race. (www.lttonline.net). Page 16

Page 17: Santa's Cloud Race - Squarespacestatic.squarespace.com/static/51545d53e4b0ebbbab48bec7/t/... · Santa's Cloud Race We're going to create a game in which Santa has to steer his sleigh

Click onto the Pen button to reveal instructions related to the pen.

Drag in a pen down command into the algorithm we created earlier ...

Santa's Cloud Race. (www.lttonline.net). Page 17

Page 18: Santa's Cloud Race - Squarespacestatic.squarespace.com/static/51545d53e4b0ebbbab48bec7/t/... · Santa's Cloud Race We're going to create a game in which Santa has to steer his sleigh

... and click onto the green flag to begin the game again. Can you movearound the track without the pen line touching the edge of the track?

You'll notice that if you click on the green flag again the pen lines from theprevious game remain. We'd also like to change the pen colour. Let's solvethese problems.

Santa's Cloud Race. (www.lttonline.net). Page 18

Page 19: Santa's Cloud Race - Squarespacestatic.squarespace.com/static/51545d53e4b0ebbbab48bec7/t/... · Santa's Cloud Race We're going to create a game in which Santa has to steer his sleigh

Drag in a 'set pen color to' command (then click on the colour to change thecolour) and a clear command. Arrange the commands as shown. If you beginthe game again, you will see that previous pen lines clear now.

Adding a lap countIt would be nice to see how many laps Santa has done. We're going to create avariable. A variable is a named value that can change its value as a programruns. Click onto the Variables button and then onto the Make a Variablebutton.

Santa's Cloud Race. (www.lttonline.net). Page 19

Page 20: Santa's Cloud Race - Squarespacestatic.squarespace.com/static/51545d53e4b0ebbbab48bec7/t/... · Santa's Cloud Race We're going to create a game in which Santa has to steer his sleigh

Let's call the variable Lap.

You'll see that a box containing the current value of the Lap variables appearson the stage. Drag that to an appropriate place.

Santa's Cloud Race. (www.lttonline.net). Page 20

Page 21: Santa's Cloud Race - Squarespacestatic.squarespace.com/static/51545d53e4b0ebbbab48bec7/t/... · Santa's Cloud Race We're going to create a game in which Santa has to steer his sleigh

To track the number of laps that Santa has achieved, we need to create a line.When Santa crosses this line, he will begin a new lap. Click onto the Stage ...

... then onto the Backgrounds tab and then Edit.

Santa's Cloud Race. (www.lttonline.net). Page 21

Page 22: Santa's Cloud Race - Squarespacestatic.squarespace.com/static/51545d53e4b0ebbbab48bec7/t/... · Santa's Cloud Race We're going to create a game in which Santa has to steer his sleigh

The editing window will open again. Click onto the line tool ...

... and select a colour for the line. This must be a different colour to thebackground (sky) colour.

Santa's Cloud Race. (www.lttonline.net). Page 22

Page 23: Santa's Cloud Race - Squarespacestatic.squarespace.com/static/51545d53e4b0ebbbab48bec7/t/... · Santa's Cloud Race We're going to create a game in which Santa has to steer his sleigh

Click and drag to draw a line, as shown, then click OK to change thebackground in the game.

Santa's Cloud Race. (www.lttonline.net). Page 23

Page 24: Santa's Cloud Race - Squarespacestatic.squarespace.com/static/51545d53e4b0ebbbab48bec7/t/... · Santa's Cloud Race We're going to create a game in which Santa has to steer his sleigh

Changing the lap variableClick onto the santa sprite.

Now click onto the Control tab and drag in a When green flag is clickedcommand and forever if command. Then click onto the touching colourcommand and drag this in too ...

Santa's Cloud Race. (www.lttonline.net). Page 24

Page 25: Santa's Cloud Race - Squarespacestatic.squarespace.com/static/51545d53e4b0ebbbab48bec7/t/... · Santa's Cloud Race We're going to create a game in which Santa has to steer his sleigh

... before arranging them as shown. This algorithm is going to check to seewhether Santa is touching the start line.

We need to change the colour that is being checked to the colour of the line.Click onto the colour block.

... then click onto the line on the stage to select its colour.

The colour in the touching colour block should change to be the colour of theline.

Santa's Cloud Race. (www.lttonline.net). Page 25

Page 26: Santa's Cloud Race - Squarespacestatic.squarespace.com/static/51545d53e4b0ebbbab48bec7/t/... · Santa's Cloud Race We're going to create a game in which Santa has to steer his sleigh

Now we are going to tell Scratch what happens when Santa touches the line.Click onto the Variables button, and drag in a change Lap by 1 command.

Place it into the algortihm like this. Now when Santa touches the line, thenumber of laps will increase by 1 ...

Santa's Cloud Race. (www.lttonline.net). Page 26

Page 27: Santa's Cloud Race - Squarespacestatic.squarespace.com/static/51545d53e4b0ebbbab48bec7/t/... · Santa's Cloud Race We're going to create a game in which Santa has to steer his sleigh

... however, when we test this, we realise there is a problem. When Santatouches the line, the number of laps increases by much more than 1! Can thechildren work out why? Can they suggest a possible solution?

The reason why this happens is that Santa remains in contact with the line for aperiod of time as he passes over it - during this time, the number of laps willincrease repeatedly. Let's solve this problem. Click onto the Control button,and drag in a wait command.

Santa's Cloud Race. (www.lttonline.net). Page 27

Page 28: Santa's Cloud Race - Squarespacestatic.squarespace.com/static/51545d53e4b0ebbbab48bec7/t/... · Santa's Cloud Race We're going to create a game in which Santa has to steer his sleigh

Drag it in as shown ...

... and change the time for the wait to 3 seconds. Now, when Santa hits theline, the number of laps will increase by one, but there will then be a 3 secondwait before Scratch checks again to see whether he is touching the line. Duringthat time, he has passed over the line.

Santa's Cloud Race. (www.lttonline.net). Page 28

Page 29: Santa's Cloud Race - Squarespacestatic.squarespace.com/static/51545d53e4b0ebbbab48bec7/t/... · Santa's Cloud Race We're going to create a game in which Santa has to steer his sleigh

Let's make sure that the number of laps is reset every time the game is started.Drag in a set Lap to command ...

... drop it in place as shown, and change the set lap to 1.

Santa's Cloud Race. (www.lttonline.net). Page 29

Page 30: Santa's Cloud Race - Squarespacestatic.squarespace.com/static/51545d53e4b0ebbbab48bec7/t/... · Santa's Cloud Race We're going to create a game in which Santa has to steer his sleigh

Adding challengeWe can play the game now, but you can probably keep the pen lines within thetrack quite easily. Let's add some challenge. We're going to make Santa movemore quickly with every lap.

Click onto the Variables button, and drag in the lap variable ...

Santa's Cloud Race. (www.lttonline.net). Page 30

Page 31: Santa's Cloud Race - Squarespacestatic.squarespace.com/static/51545d53e4b0ebbbab48bec7/t/... · Santa's Cloud Race We're going to create a game in which Santa has to steer his sleigh

... and replace the number of steps that Santa moves with this variable. Now asSanta laps the track, his speed will increase every time!

Play the gamePlay the game. How many laps can you do without the line striking theedge of the track?

Santa's Cloud Race. (www.lttonline.net). Page 31