SCRATCH GOLD II
SCRATCH GOLD I
2 of 3

6.10 Challenge: add an enemy

If you want, you can also add patrolling enemies to your game. If the player sprite touches an enemy, the game ends.

  • Your game already contains an enemy sprite. Add code to the enemy sprite so that it only appears in room 2.
  • Add code to move the enemy sprite and to end the game if the enemy sprite touches the player sprite. It’s easier to do this in separate code blocks. Here’s how your enemy sprite code might look:
  • Test out your new code to make sure that:
    • The enemy sprite only visible in room 2
    • The enemy sprite patrols the room
    • The game ends if the player sprite touches the enemy sprite

Can you create another enemy sprite in room 3 that patrols up and down through the gap in the wall?

×
×

Cart