Sprites....multiple images

hog

Well-known member
Joined
Mar 17, 2003
Messages
984
Location
UK
Just talking out loud here and hope someone can assist?

Say I have a sprite class which has a new method which takes the image path to load it into its internal bmpImage property and a draw method which uses this property to draw on screen.

Now this would work fine for a sprite with a single image. But what of sprites with multiple images?

Would I need to redefine my sprite class to hold and array of bitmaps or should I leave it as is and the answer is to have an array of sprites?

Try to get my head around this to produce an animated spaceship rotating 360 degress.

Thnx
 
What is usually done in those cases is having one bitmap which contains all the frames of the image. Then based on what you need, you draw a given part of that image.
 
Id go for an array of bitmaps - that way the sprite class itself can handle things like timings, sequences etc internally without the client application having to understand the internal workings of the sprite.

The sprite can then be given methods like RotateClockwise, RotateAnticlockwise, DisplayExplosion etc.
 
Very interesting views, thnx you have given me something to think about:)
 
Mmm your comments have jogged my memory. I think I took the approach of having all sprites stored in a single .jpg file and then loading them into an array of images in the sprite object when I programmed my space invader game. But that was in 1995 and not only have I since lost the code which was written in C++ which I dont know anymore I have also been drunk too many times to remember:)
 
If you plan on doing it that way, do not divide the image into other image objects then, that is what I think you are doing from reading your post. Instead, create an array of Rectangle strucutres which specify the part of image that is the given frame.
 
OK Thanks. Is there an advantage then doing it that way rather than assigning each frame to its own bitmap object. Is memory saving the issue here?

Ta
 
Back
Top