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 ...

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

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.