Advertisement

Animation handling in 2d sprite based game

Started by May 13, 2019 10:10 AM
1 comment, last by Alberth 5 years, 9 months ago

Hi everyone,

I am new to game development and currently working on a sprite based 2d side view game. I am writing in c++ using sdl2.

Currently i am taking a clip and rendering it for multiple frames and then i change the clip. For example if ihave 4 clips for run animation so i am running each clip for 5 frames (@60 fps) so basically it takes 20 frames to complete a run animation.

Similarly i have jump and shoot animations with 3 clips each. But the problem is once an animation is running i am disabling all the keys. So basically when i shoot while running the player will stop and then shoot. Once the animation is completed then i have to click the button again to start running, but what i want my player to start running automatically once the animation is over and i my forward button is not keyed up.

So you need to continue processing the keys while the animation is running, store that information but not act on it. Processing keys, and animation become two 'independent' steps in the loop.

Once the animation ends, you access the stored information. If it has a next action, you perform that action, otherwise you're idle, and wait until the player presses a key.

 

Advertisement

This topic is closed to new replies.

Advertisement