Game Development Reference
In-Depth Information
Explosion tileset
Given that explosion.png tileset is 1024x1024 pixels big, and it has 8 rows of
8 tiles per row, it is easy to tell that there are 64 tiles 128x128 pixels each. So,
@animation[0] holds 128x128 Gosu::Image with
top-left
tile,
and
@animation[63] - the bottom-right one.
Gosu doesn't handle animation, it's something you have full control over. We have to draw
each tile in a sequence ourselves. You can also use tiles to hold map graphics The logic
behind this is pretty simple:
1. Explosion knows it's @current_frame number. It begins with 0.
2. Explosion#frame_expired? checks the last time when
@current_frame was rendered, and when it is older than
Explosion::FRAME_DELAY milliseconds, @current_frame is increased.
3. When GameWindow#update is called, @current_frame is recalculated for
all @explosions . Also, explosions that have finished their animation (displayed
the last frame) are removed from @explosions array.
4. GameWindow#draw draws background image and all @explosions draw
their current_frame .
Search WWH ::




Custom Search