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,
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.
all
@explosions
. Also, explosions that have finished their animation (displayed
the last frame) are removed from
@explosions
array.
their
current_frame
.