If you've read the previous few DirectX tutorials, you've likely already figured out how to do animation, it's not too hard. If not, read on!
Dim Ship(39) as DirectDrawSurface7
Dim i As Integer
For i = 0 To UBound(Ship)
First we have to declare a bunch of surface variables (I've done it here in an array) to hold
the different frames of animation. In this case, we will have 40 different frames, each one
containing a picture of a ship facing a slightly different direction. We can then create the
illusion that the ship is rotating by flipping from one surface to the next in line.
LoadSprite Ship(i), "vegan" & i, SpriteWidth, SpriteHeight, vbBlack
Next
"LoadSprite" is a function (not shown here) that loads a bitmap onto a given surface. If you don't know how to do this, have a look at the Loading and Displaying a Bitmap tutorial. The loop here will load all 40 bitmaps (from "Vegan0.BMP" to "Vegan39.BMP") into the array "Ship".
Dim Direction as Integer
BackBuffer.Blt DestRect, Ship(Direction), SrcRect, DDBLT_KEYSRC Or DDBLT_WAIT
Have a look at my DirectX 7 sample project to see it in action.