Page 119 - KEC Khaitan C4 Flipbook
P. 119
3. Animate the Scene with Code
Start the Game:
o Use the when green flag clicked block to initialize the game.
Move the Player Sprite:
o Use when [arrow key] pressed blocks to control the player’s movement.
Collect Food Items:
o Use Sensing blocks like if <touching [food item]> then to detect collisions.
o Add points using Variables (change [score] by [1]).
4. Avoid Obstacles:
Use conditional blocks to end the game if the player touches an obstacle:
scratch
CopyEdit
if <touching [Obstacle]> then
stop [all]
say [Game Over!] for (2) seconds
end
5. Play Sounds:
Add sound effects (play sound [name] until done) when food items are collected,
or obstacles are hit.
Sample Code:
Lighting_Obstacle
Dinosaur4 Vada Samosa
Touching
Creating an Advanced Game in Scratch 117

