Jump to content
  • Advertisement
saurabh singh

Animation handling in 2d sprite based game

Recommended Posts

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.

Share this post


Link to post
Share on other sites
Advertisement

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.

 

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!