Page 12 - Scratch Programming Playground
P. 12
The Complete Program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
Turbo Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
Version 2 .0: Rainbow Triangles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
Version 3 .0: Two Rainbow Lines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
Version 4 .0: You Decide! . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
Review Questions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
3
Maze Runner 35
Sketch Out the Design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
A . Make the Cat Walk Around . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
Explore: X- and Y-Coordinates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
1 . Add Movement Code to the Player Sprite . . . . . . . . . . . . . . . . . . . . 40
2 . Duplicate the Movement Code for the Cat Sprite . . . . . . . . . . . . . . 41
B . Make the Maze Levels . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
3 . Download the Maze Images . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
4 . Change the Backdrop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
5 . Start at the First Maze . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
C . Keep the Cat from Walking Through Walls . . . . . . . . . . . . . . . . . . . . . . . 44
6 . Check Whether the Cat Is Touching the Walls . . . . . . . . . . . . . . . . 44
D . Make a Goal at the End of the Maze . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
7 . Create the Apple Sprite . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
8 . Detect When the Player Reaches the Apple . . . . . . . . . . . . . . . . . . 47
9 . Add the Broadcast Handling Code to the Maze Sprite . . . . . . . . . . 49
The Complete Program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
Version 2 .0: Two-Player Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
Duplicate the Apple Sprite . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
Modify the Apple2 Sprite’s Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
Duplicate the Orange Cat Sprite . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
Modify the Code for the Blue Cat Sprite . . . . . . . . . . . . . . . . . . . . . . . 53
Go Back to the Starting Position . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
Version 3 .0: Traps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
Draw a new Sprite for the Traps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
Create a Second Costume for the Traps . . . . . . . . . . . . . . . . . . . . . . . 57
Add Cloning Code for the Traps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
Modify the Orange Cat Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
Copy the Code from Orange Cat to Blue Cat . . . . . . . . . . . . . . . . . . . . 61
Cheat Mode: Walk Through Walls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
Add the Walk-Through-Walls Code to Orange Cat . . . . . . . . . . . . . . . 63
Add the Walk-Through-Walls Code to Blue Cat . . . . . . . . . . . . . . . . . 63
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64
Review Questions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
x COnTEnTS In DETAIL

