Page 254 - Scratch Programming Playground
P. 254
this is how the define handle ground block decides
whether it should run change y by -1 (so the Cat sprite
can’t go up through the ceiling) or run change y by 1 (so
the Cat sprite is lifted up out of the ground). either way, if the
Cat sprite is touching the Ground sprite (which it is if the code
inside the repeat until not touching Ground block is run-
ning), the y velocity variable should be set to 0 so that the Cat
sprite stops falling or jumping.
Save Point
Click the green flag to test the code so far. Make the cat walk
under the low platform and jump. Make sure the cat bumps
into the platform but does not go above it. then click the red
stop sign and save your program.
If you’re lost, open platformer5.sb in the resources ZIp file
and continue reading from this point.
E Use a Hitbox for the
cat Sprite
there’s another problem with the
game. Because the code relies on
the Cat sprite touching the Ground
sprite, any part of the Cat sprite
can be “standing” on the ground,
even its whiskers or cheek! In this
figure, the cat isn’t falling because
its cheek has “landed” on the plat-
form, which isn’t very realistic.
228 Chapter 9

