Page 16 - Scratch Programming Playground
P. 16
E . Make Asteroids Split in Two When Hit . . . . . . . . . . . . . . . . . . . . . . . . . 196
6 . Add the Asteroid’s Splitting Code . . . . . . . . . . . . . . . . . . . . . . . . . 196
7 . Add the Asteroid Blasted Message Code to
the Energy Blast Sprite . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 198
F . Keep Score and Make a Timer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 199
8 . Create the Out of Time Sprite . . . . . . . . . . . . . . . . . . . . . . . . . . . . 199
G . Make the Spaceship Explode If It Is Hit . . . . . . . . . . . . . . . . . . . . . . . . . 200
9 . Upload the Explosion Sprite . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 201
10 . Add the Code for the Explosion Sprite . . . . . . . . . . . . . . . . . . . . . 201
11 . Add the Explode Code to the Spaceship Sprite . . . . . . . . . . . . . . 202
Version 2 .0: Limited Ammo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 204
Cheat Mode: Starburst Bomb . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 206
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 207
Review Questions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 208
9
Making an advanced Platformer 209
Sketch Out the Design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 210
A . Create Gravity, Falling, and Landing . . . . . . . . . . . . . . . . . . . . . . . . . . . 212
1 . Create the Ground Sprite . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 212
2 . Add the Gravity and Landing Code . . . . . . . . . . . . . . . . . . . . . . . . 213
3 . Make the Cat Walk and Wrap Around the Stage . . . . . . . . . . . . . 215
4 . Remove the Ground Lift Delay . . . . . . . . . . . . . . . . . . . . . . . . . . . . 216
B . Handle Steep Slopes and Walls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 218
5 . Add the Steep Slope Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 218
C . Make the Cat Jump High and Low . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 222
6 . Add the Jumping Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 222
D . Add Ceiling Detection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 224
7 . Add a Low Platform to the Ground Sprite . . . . . . . . . . . . . . . . . . . 224
8 . Add the Ceiling Detection Code . . . . . . . . . . . . . . . . . . . . . . . . . . . 225
E . Use a Hitbox for the Cat Sprite . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 228
9 . Add a Hitbox Costume to the Cat Sprite . . . . . . . . . . . . . . . . . . . . 229
10 . Add the Hitbox Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 230
F . Add a Better Walking Animation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 231
11 . Add the new Costumes to the Cat Sprite . . . . . . . . . . . . . . . . . . 232
12 . Create the Set Correct Costume Block . . . . . . . . . . . . . . . . . . . . 233
G . Create the Level . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 239
13 . Download and Add the Stage Backdrop . . . . . . . . . . . . . . . . . . . 239
14 . Create a Hitbox Costume for the Ground Sprite . . . . . . . . . . . . . 240
15 . Add the Ground Sprite’s Code . . . . . . . . . . . . . . . . . . . . . . . . . . . 241
16 . Add More Wrap-Around Code to the Cat Sprite . . . . . . . . . . . . . 242
xiv COnTEnTS In DETAIL

