Archived

This topic is now archived and is closed to further replies.

Help! Bitmap animation!

This topic is 5847 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

you do it just as you said. you store a counter and loop through all your tiles in the animation. of course you could ask a more specific question for a better answer.

just to add:

int curFrame=0;
int df=1;

if(curFrame>=maxFrame)
df=-1;
if(curFrame<=0)
df=1;
curFrame+=df;

hope that explains it nicly.

Edited by - a person on December 12, 2001 11:24:28 PM

Share this post


Link to post
Share on other sites
sorry for the loosly structured question, basically, what i am getting at, is i want to push lets say the right arrow key, and when i push it, i want it to animate my guy walking and move him. I am having problems, if i push the button down once, it works fine, however, if i hold the button it just stays on that one frame, i''m lost, do you get what i mean?

Share this post


Link to post
Share on other sites
enum Directions { UP = 1, RIGHT, DOWN, LEFT };
int *animframes[4];
animframes[RIGHT] = new int[5];
int *pFrms = animframes[RIGHT];
pFrms[0] = 1;
pFrms[1] = 2;
pFrms[2] = 3;
pFrms[3] = 2;
pFrms[4] = 1;

That''s the general idea. Since I expect you to be reading the data from a file, you''ll probably be able to place it in a loop and make other such logical optimizations.

[ GDNet Start Here | GDNet FAQ | MS RTFM | STL | Google ]
Thanks to Kylotan for the idea!

Share this post


Link to post
Share on other sites
ok i got some ''crude'' animation thing going, it kinda works now

tile = 1;

if(keystate[DIK_RIGHT])
{
sprite_posx+=5;
tickcount++;

if(tickcount < 15)//0 - 15 tickcounts, takes it to frame 2
{
tile++;
}

//from 15 - 30 tickcounts it displays tile 1


if(tickcount > 30)//resets tickcount
{
tickcount = 0;
}

}//end keystate[dik_right]

Share this post


Link to post
Share on other sites