Game Development Reference
In-Depth Information
The easiest way to produce a good explosion is to use an animated sprite. Figure
10.9 shows a keyframe texture map of an explosion. This texture was created
using a procedural explosion generator available for free from Positech games
( http://www.positech.co.uk/content/explosion/explosiongenerator.html).
Figure 10.9 has 16 frames in total; four frames in height and four frames in
length. An animated sprite can be created by reading in this texture and changing
the U,V coordinates so that it moves from the first frame to the last frame as time
passes. An animated sprite is really just a different type of sprite, so to create it,
we can extend the existing Sprite class. An animated sprite is something
that can be used by many different games, so it should be created in the Engine
project rather than the game project.
public class AnimatedSprite : Sprite
{
int _framesX;
int _framesY;
int _currentFrame ¼ 0;
double _currentFrameTime ¼ 0.03;
public double Speed { get; set; } // seconds per frame
Figure 10.9
Animated explosion texture map.
 
Search WWH ::




Custom Search