|
Animating Player |
Jeff Bernard
Member #6,698
December 2005
|
I'm looking for some tips on animating the player. There's 16 different frames, and 3 in the running animations (3 seperate for left and right, well, more like 2 since the left/right standing frame is used in them). Anway, I've got a really long function that checks pretty much every key combination to get the frame to use (X is my jump key). I'm sure there's gotta be a better way though...right? Also, here's my current hero.bmp so you can see what each frame is...it's 0-7 on top and then 8-15 on the bottom.
-- |
Onewing
Member #6,152
August 2005
|
First thing I noticed is you have 3 if(key[KEY_RIGHT]) situations, each returning 8, 9, or 10. That means that function is return 9 give or take 1. What I do is have the key determine the base frame in the set of frames. Another, completely separate function is checking the time they've been going in whatever direction and if enough time has gone by, increase or decrease an offset that picks out the right part of the animation in that direction. Basically, my logic is have a input function which determines which direction they're going and an animate function which gets the right frame within that direction. Make any sense? ------------ |
Jeff Bernard
Member #6,698
December 2005
|
Ah, thank you very much, Steven Silvey. I now only have it check the key pressed once and then I pass a value to a function which then determines the correct frame of animations. It's way better now. -- |
|