Let's make the game end if the sprite collides with an enemy.

  • Drag in a Collision with Other Sprite event. Change the name in the event handler to your sprite's name.
  • Change my_var to name. Check if name is equal to "snake".
  • If so, Remove the hit_sprite, Hide your character.
  • Use Text to display "Game Over" on the stage.

To navigate the page using the TAB key, first press ESC to exit the code editor.

# THIS ACTIVITY IS IN PREVIEW ONLY MODE
  • Run Code
  • Submit Work
  • Next Activity
  • Show Console
  • Reset Code Editor
  • Codesters How To (opens in a new tab)