From: sam AT greenaumARSE!ARSE!ARSE!.demon.co.uk Newsgroups: comp.os.msdos.djgpp Subject: Re: animation question Date: Thu, 11 Mar 1999 21:51:57 GMT Organization: Rossum's Universal Robots Message-ID: <36e93af5.376420@158.152.254.70> References: <152025CEF5220CB5 DOT 90226E0BA58BCA7A DOT 49313DA9A036C58F AT library-proxy DOT airnews DOT net> NNTP-Posting-Host: greenaum.demon.co.uk X-NNTP-Posting-Host: greenaum.demon.co.uk:194.222.71.189 X-Trace: news.demon.co.uk 921189158 nnrp-06:22726 NO-IDENT greenaum.demon.co.uk:194.222.71.189 X-Complaints-To: abuse AT demon DOT net X-Newsreader: Forte Agent 1.5/32.452 X-No-Archive: yes MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Lines: 33 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com I (actually Andre Lamothe) use a struct for each sprite. It contains x and y position, oldx and oldy for erasing, a current frame counter, the number of frames, a frame delay, a frame delay increment, and an array of pointers to bitmaps. How it works is, on every game loop you increment the frame delay increment. When it reaches the value set in frame delay, you reset it, and it's time to change to the next frame. So your animation can be one frame every 4 game loops, say. When it's time to change to the next frame, we add to the frame counter. This gets modulated by the maximum number of frames, so it loops round. Then in your sprite draw routine (mine, and Andre's, just takes one argument, a pointer to the sprite you want to draw), you just draw whatever bitmap sprite.frames[sprite.currentframe] is pointing to. How I do it, you have to decide the absolute maximum number of frames any sprite can have at compile-time, the array of pointers to the bitmaps is a set size, I think my sprite.frames[16] is set as 16 pointers, but it could be dynamic if you could be bothered coding it, it's only 60 bytes at most wasted per sprite so it's no big deal. ------------------------------------------------------------------------ The person who said he was a crap presenter knows nothing because compared to the outwardly camp stuart miles, speech impediment Katy Hill and nothing upstairs Konnie Huq, he was a true professional. Heh heh heh.