Help! Bitmap animation!

Started by
4 comments, last by apexsolar 22 years, 4 months ago
ok, i want to make my guy look like he is walking, i want to cycle through my tiles, 1 - 2 - 3 - 2 - 1, but i have no idea how to do it! can anybody help? thanks!
Advertisement
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
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?
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!
post your code. (input/render oof the animation) sounds like yoru are not handling input correctly.
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]

This topic is closed to new replies.

Advertisement