O'Reilly logo

Learn Game Programming with Ruby by Mark Sobkowicz

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Make Animated Explosions

We could make an explosion with a single image, but it wouldn’t look very convincing. Our explosion starts as a bright yellow ball of flame and then fades away, turning a darker orange and getting smaller. You do this by drawing sixteen images in the same location. When the explosion first appears, you draw the first in the sequence of images. Each subsequent time the game runs the draw method, the next image in the sequence is drawn.

Use a Sprite Sheet

One way to load your images would be to copy sixteen individual image files into your project and then load them into an array of images. This would work fine, though it might involve a lot of typing. Game artists often group related images together by stitching them ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required