Summary
Highlights
A 'Score' variable is created. If a spike touches the edge, the score increases by 1, and the clone is deleted. If the player touches a spike, the game ends. The player sprite broadcasts an 'End' message and hides. Upon receiving 'End', all spike clones are deleted, and a 'spawn spikes' variable is set to 0 to stop further spike generation.
An 'End Screen' sprite is created with 'You Lost' text and a 'Restart' button. When the 'End' message is received, the end screen appears, showing the background and a clickable restart button (a clone of the end screen sprite). When the restart button is clicked, it broadcasts a 'restart' message, the end screen hides, the score resets to zero, and the 'spawn spikes' variable is set to 1 to resume spike generation.
The video introduces a mouse dodging game in Scratch where the player, a cube, avoids spikes. The first step is to delete the default cat sprite and create a new 'Player' sprite. The player's movement is then coded to follow the mouse pointer with a smoothing algorithm to prevent jittery movement. This involves using 'go to x and y' blocks with calculations based on the player's current position and the mouse's coordinates, divided by a 'smoothness' value (e.g., 3).
Next, a 'Spike' sprite is created, shaped as a triangle, by deleting one node from a square. Spikes are designed to spawn as clones. The main spike sprite is hidden, and clones are created with a random delay (3 to 7 seconds). Each cloned spike appears and then randomly picks a starting position from the top, bottom, left, or right edges of the screen using nested 'if else' statements.
Spikes move towards the player by pointing towards the player and repeating 'move 10 steps' until they touch the player or the edge. To prevent immediate deletion when spawned at the edge, a 'repeat until not touching edge' block is used. Multiple spikes can be spawned simultaneously by using a 'repeat' loop (2 to 4 times) for creating clones.