Game dev, Suit’em up – Animations in different directions
|
We have released a friends & family beta test and gotten some statistics of the current status of our game. You are welcome to participate, here is the link to the feedback: feedback-form And here is a link to the game, please fill in feedback if you play!: SuitEmUp FnF pre-beta I have made animations work in different directions for enemies and the player. This is not implemented in the version I linked above but I will explain what is different now. The enemies now have animations in four directions. When they move in a direction, all moving objects have a direction vector. It is a normalized vector, meaning it can only be between 1.0 and -1.0. And since this game is in 2D and we use SFML we have an sf::Vector2f with two different dimensions, x and y. Each one of these are normalized and the calculation for moving an object goes something like this:
This picture might make it more clear: So when setting animations on enemies I want to check what way they are going. I then use the enemies direction to decide which animation to change to. So check this out, between the red lines is where I want to change the animations. The direction/animation check is run each update but there is a check if the current animation already is correct. I only _change_ the animation if the animation isn’t correct. I’m not certain that my code is optimal for this, but here is what it looks like:
We are thinking about making this so that the up/down animations only trigger within 0.3 direction up/down instead of 0.5, which makes the right/left within 0.7 left/right which makes it kind of like this:
We will try it out and see if it looks okay. I have also split up Barney’s sprites even more. Previously there were four different sprites: the body, weapon, legs and shadow. The head was part of the body sprite. That is the one I’ve split off. The body is still only changed in two directions but the head in four. The head sprite follows the same logic as with the enemies direction animation but it checks the direction between Barney and the mouse. This change makes Barney look more responsive and robot-y. I have also changed the positions from which the direction of Barney -> the mouse is calculated. It now it exactly at the throat. I need to polish up the weapon sprite angle calculation because it points in the wrong way when holding the mouse close to Barney. The problem with this is that the sprite origin needs to be set right where the arm is connected to the body and the angle-calculation needs to be made from different points depending on the direction. I will continue to polish this some time soon, but for now it looks okay. Thanks for reading! |




