End the Game

In some games, the point is to finish some task or get to the highest level. In other games, there is a score that the player can try to beat the next time he or she plays. Our game includes both kinds of goals. The player is rewarded for surviving long enough for one hundred enemies to appear, and at the same time the game counts how many enemies the player destroys. Our game ends in one of three ways:

  • One hundred enemy ships have appeared. Yay! The player has survived the wave of enemies.

  • An enemy ship has hit the player ship. The player ship is destroyed, but hopefully blew up some enemies first.

  • The player ship flew out of the top of the window. The enemy mother ship has destroyed the player ship.

However the game ends, it ...

Get Learn Game Programming with Ruby now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.