Update 004 - Animation ... and some News

posted in BlueStar03
Published January 26, 2015
Advertisement
The Alpha 004 update is up at http://bluestar03.com/Chronicle/Alpha as well on the Windows Phone Store. Unfortunately, it was taken down from the Windows 8 Store because it isn't feature complete. Bummer. Additionally, this update has been up for a while, but my day job got in the way of doing anything for a while. Sooo.... first the animation, then the News

I really like how simple and elegant the animation system is. First, a state system. So far, the player can only do two things, Stand and Walk. More will be added later. the current state is stored in the variable [font='courier new']action_state[/font], and I use the enum [font='courier new']action_type [/font]to keep track of all the actions, currently only stand and walk. right now, based on the speed, the [font='courier new']action_state [/font]is determined. This will grow in complexity, but makes the next part easy, what sprite to draw?

Instead of relying on the currently drawn sprite to determine what the player can do next, I separated that into the state system. And I just assigned the sprite depending on what state it is on. if [font='courier new']action_state==action_type.stand { sprite_index=sprPlayerStand }; [/font]However, if only it were that easy. The game is Isometric, so I have to do more. I originally had planed for using different sprite on each direction, [font='courier new']sprPlayerUp[/font], [font='courier new']sprPlayerUpLeft[/font], and so on. but I was able to flex my Math Skills, and found and elegant solution.

First of, to correct a small lie, I store the sprite to be used in a temporary variable [font='courier new']ss, [/font]and not assigned it directly to [font='courier new']sprite_index[/font], since I will use some math on it before getting the final result. When trying to find a way to keep all the directions for the walk and stand sprite, I realize that it was divisible by 8. Since I was using 8 direction, no mater how long the animation was, it was repeated 8 times, once for each of the 8 directions. so each sub animation on each sprite was the full length divided by 8. Now I have the length of the animation ,stored in the temporary variable [font='courier new']ll[/font], but where do I start it from? The [font='courier new']dir [/font]variable stores the direction the player is facing, but from 0 to 7, or [font='courier new']dir=Control.input_direction / 45;[/font] so [font='courier new']dir * ll [/font]gets me the start of the animation, but what about the current frame? Well, keep track of it with the variable [font='courier new']sindex[/font]. Each step add the variable [font='courier new']sspd[/font], for sprite speed, and if its grater than [font='courier new']ll[/font], set it back to 0. so I add the number to where my sub animation starts and I get the image to draw, stored in the temporary variable [font='courier new']v[/font].

Long explanation short, if I arrange my sprite with all direction next to each other with Right being the first one, and going clockwise, and do all the math above to find which image of which sub animation to use, the sprites will animate properly and face the right direction. DONE

Now for the news, some bad, some good. The Bad one, because of the long hiatus, I don't know where in the project I am. with variable names like [font='courier new']ss[/font], [font='courier new']ll [/font]and [font='courier new']v[/font], and minimum comments, it is easy to get lost. So I will be rebuilding everything from scratch. I'll try to document everything as much as possible. So it will be a even longer while before a new update is up. on the Good news, I'll will be going to GDC expo this year, hopefully I'll have finished the rebuilding, and added more stuff by the time I go. have about a Month to do that, so I'd best get started biggrin.png
1 likes 2 comments

Comments

Aardvajk
Just had a quick play, the animation looks pretty good. Is that a render 3D model to sprite frames gig you have going on there?
January 27, 2015 07:58 AM
zBuLe

Yep, the animation is done in Blender.

January 27, 2015 12:10 PM
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Profile
Author
Advertisement
Advertisement