   Need some guidance getting explosions into my allegro game
  I'm making a 2D scrolling shooter atm, and its going very well, although I've now got to the point where I need to add in explosions when lasers, missiles etc hit things (aswell as when aliens and the player loose all their life). Anyway, I'm new to getting sprites to work using allegro. I know how to test for when the player gets hit (the health system works fine atm), but I'm not sure how to get the sprite to actually become animated in the game. I get the basic principle of having a series of smaller bitmaps within a bitmap file and then just displaying part of the bitmap at a time, although I can't think of an elegant way of doing this. Also, I'm confused how time will be kept, because the only ways I can think of doing this would result in the explosion sequence looking way too fast. Any suggestions would be helpful.   
  You need some type of timing, the easiest which is to just count the number of frames since the beginning of your program, which you increase every loop. Then you keep track of every frame for each graphic, and the time each is supposed to be displayed.Something like:struct Graphic { Frame *frames; int frameCount;};struct Frame { Image *image; int time;};struct Sprite { int currentTime; Graphic *graphic;};Then each frame you have some function to handle your sprite, which increases its time, and draws its graphic.handleSprite(Sprite *sprite) { drawGraphic(sprite->graphic, sprite->currentTime);  sprite->currentTime++;}void drawGraphic(Graphic *graphic, int currentTime) { int frameIndex = 0; while(currentTime > graphic->frames[frameIndex].time) {  currentTime -= graphic->frames[frameIndex].time;  frameIndex++; }  drawImage(graphic->frames[frameIndex]->image);}To get it to work well you might have to implement looping when drawing a graphic, if the animation should loop more than once, or check so that you can't go past the last frame to avoid going out of bounds on the array.Also, as you said, you can keep all frames in the same image, instead of having each frame have its own image. It is probably a smarter solution. In this case you just have to keep one image per graphic, and have each frame contain information on where in the image it is located, and draw the correct part of the image depending on which frame is active.The very easiest way, if each frame is displayed the same amount of time, and has the same size, is to just have a wider image with each frame side by side, then calculate the position of the current frame from the time.frameOffset = (currentTime / timePerFrame) * frameWidth, which will be the left part of the rectangle containing that frame.   