![]() |
|
Looking for animation classes |
Rick
Member #3,572
June 2003
![]() |
Anyone here care to share their animation class with me? I've written so many (that I never saved) and I don't want to write another one. I'd love to use someone else's if they would be kind to share with a little doc. ======================================================== |
Neil Walker
Member #210
April 2000
![]() |
Check out my sig. axl includes an animation library that can be used by itself. the direct link to the online manual is here: Neil. wii:0356-1384-6687-2022, kart:3308-4806-6002. XBOX:chucklepie |
ImLeftFooted
Member #3,935
October 2003
![]() |
Obviously dependant on the datafile, stopwatch, bitmap and log modules of my engine which I haven't included. |
Rick
Member #3,572
June 2003
![]() |
My question with these is, what happens if I have multiples of the same unit? It would seem I would have duplicates of the images loaded into memory with these classes. ======================================================== |
Wilson Saunders
Member #5,872
May 2005
![]() |
Rick said: It would seem I would have duplicates of the images loaded into memory with these classes.
Well with amount of memory in most modern computers storing a new copy of a bitmap for each unit of a RTS probably will not cause much troubles. If you want to be efficient about it remember Allegro deals with (BITMAP *) pointers. That means you can set multiple units bitmap images to point at one bitmap in memory. int itor; BITMAT * GruntStand = LoadBitmap("GruntStand.bmp"); for(itor =0; itor < NUMGRUNTS; itor++){ Army[itor] = new Grunt; Army[itor]->Image = GruntStand; } Will only store one copy of the Bitmap GruntStand.bmp in memory but all the Grunt instances will be able to access it as their own class variable. ________________________________________________ |
Rick
Member #3,572
June 2003
![]() |
Yeah I know. The 2 animation classes above store bitmaps and a current frame variable together. That means one of two things. A) Every like unit animates the same I think I'll end up writting my own to handle these issues. Basically the currentFrame should be seperately stored from the bitmaps that make up the animation. That way each unit can have different currentFrame values and just get the image from a manager type class from this units currentFrame. ======================================================== |
ImLeftFooted
Member #3,935
October 2003
![]() |
Quote: My question with these is, what happens if I have multiples of the same unit? It would seem I would have duplicates of the images loaded into memory with these classes. The animation class has no concept of storing one copy of a bitmap. The Bitmap class handles that. |
Rick
Member #3,572
June 2003
![]() |
I see now Dustin, you are using an already loaded datafile. ======================================================== |
piccolo
Member #3,163
January 2003
![]() |
hey rick check out my game character editor I'm making it to were all animations are reusable wow |
23yrold3yrold
Member #1,134
March 2001
![]() |
Posting the animation classes for The Mighty Stupid. It's two main classes; an animation class that holds all the animation data for a given entity, and a tracking class, which references the animation and handles all playback and frame tracking. That way I can have one animation loaded and have 20 different enemies (with 20 different trackers) running off it without wasting memory. Just the interfaces ....
Explanations available upon request, but I think it's pretty self explanitory. Implementations are left as an exercise for the reader. -- |
ImLeftFooted
Member #3,935
October 2003
![]() |
Quote: I see now Dustin, you are using an already loaded datafile. Actually the images in the datafile are loaded into textures, which is handled by Bitmap. Bitmap maintains a lookup table with pointers to items in the datafile as the key and the texture IDs as the value. If passed a pointer to a bitmap that is already in the lookup table, that texture ID is used, otherwise the upload is performed. Obviously there is the minute chance that a bitmap could be passed with the same address of an old bitmap that was deallocated, but the work-around for this is speed and memory demanding. And I'm keeping the whole datafile loaded into memory anyway. |
piccolo
Member #3,163
January 2003
![]() |
23yrold3yrold said: That way I can have one animation loaded and have 20 different enemies (with 20 different trackers) running off it without wasting memory.
character editor I'm making it to were all animations are reusable:P wow |
|