Sign in to follow this  
Gardon

Whooo, I'm back...flipcode sucks.. I got a real question this time

Recommended Posts

So I'm trying to optimize my code for having character movement with sprites. What's the best way to do it? Should I just load every animation I'm using throughout the entire game in the beginning, or should I spread it out? As of right now, whenever the player hits the left key, the character turns left, and goes into his automated stance position. Right key, he goes right, up, up, etc. Is it best to make an enum with different states the character is in: Example: enum KeyState { Keystate_left, ... etc. and have different declaration of surfaces in the different states to initialize the animation? (when the user presses the left key, I'd have the same functions with the same animation functions, but different bitmaps according to the direction of the character) Or what? Please not if I'm unclear. It's late and I'm surprised I typed this much :P All in all, what's the best way to animate a character, optimization wise. How would YOU animate him, according to different key presses, mouse clicks, etc. Note: I'm using SDL if anyone's interested Thanks, Gardon

Share this post


Link to post
Share on other sites
Quote:
Original post by Gardon
All in all, what's the best way to animate a character, optimization wise. How would YOU animate him, according to different key presses, mouse clicks, etc.


I think the fastest and the most simple way are one and the same. Simply have a player_anim_state variable. If the left key is pressed, simply change the animation state variable to ANIM_WALKLEFT or whatever you name that. You can then have the animator part of the program check the animation to display, then display it. There are a few little quirks that you will run into doing this, but it wouldn't be any fun if I gave them up to you right away. They have very reasonable solutions.

Share this post


Link to post
Share on other sites
is it possible to have one function call to animate the frames, but based on the state the player is in (or the key pressed) will generate a different bitmap?

What about loading bitmaps of the character? They're individual bitmaps, so they have a huge ass function to call them from.

this also is an isometric game. I just played diablo (the original) to get a feel for isometricism. I hated how it was all jerky and he couldn't walk straight in the direction i wanted him to go in. Is this how all isometric games are? I mean, i want my game to look decent, especially if people are willing to pay for it (I'm way away from payment, I'm still developing, obviously), and a top-down 2d RPG seems kinda dumb. Any suggestions for what to do to make a game look cool, but not be jerky like diablo?

Thanks,

Gardon

Share this post


Link to post
Share on other sites
Quote:

is it possible to have one function call to animate the frames, but based on the state the player is in (or the key pressed) will generate a different bitmap?

Not 100% sure what you ask here, but yes, depending on how you do it.

Quote:

What about loading bitmaps of the character? They're individual bitmaps, so they have a huge ass function to call them from.

Why not have all the animations of the character in the same image file, and then "split it up" in to smaller frames?

Quote:

this also is an isometric game. I just played diablo (the original) to get a feel for isometricism. I hated how it was all jerky and he couldn't walk straight in the direction i wanted him to go in. Is this how all isometric games are? I mean, i want my game to look decent, especially if people are willing to pay for it (I'm way away from payment, I'm still developing, obviously), and a top-down 2d RPG seems kinda dumb. Any suggestions for what to do to make a game look cool, but not be jerky like diablo?

Oh it was a LONG time since i played Diablo, but do you mean the character can only walk in lines equal to the tile grid (Should be down-right, down-left, up-left and up-right)? Again, depending on how you do it, i would say it's possible to get him moving in any direction.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this