Chapter 5Managing Lots of Sprites

Our Sector Five game now has only one enemy ship. In this chapter we add more, so a constant stream of enemies falls from above. Then we let our player ship shoot them with bullets, and when bullets hit enemies they explode. This means we’ll have dozens of enemy ships, bullets, and explosions all in our window at once. We need a way to deal with tons of sprites in our game—adding them, deleting them, and managing all their interactions.

images/many_sprites.png

You’ll learn how to create and handle all of these sprites with one great tool, the array. An array holds a list of objects, which in this game are sprites. When you need a new ...

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.