Sign in to follow this  

SDL and sprite animation's continuation...

This topic is 4766 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Right, so im working on a small little game, where if the player presses a key (lets say K), the sprite runs the animation from the first to last frame. But..because the player only 'holds' down the key for maybe 1 or 2 loops, the animation only runs for that many, so it gets stuck one or two frames in. If the player holds the key down then the animation runs over and over, but i want the animation to run completely with one keypress, regardless of the frame time or gamespeed. does anyone know how to implement this? i looked around on here but nothing really answers my question... thanks!

Share this post


Link to post
Share on other sites
Sure, I'm also learning how to creature animations etc. right now with SDL.

Here's a good tutorial how to create a sprite system: http://cone3d.gamedev.net/cgi-bin/index.pl?page=tutorials/gfxsdl/tut3

It's a bit difficult, but usefull.

If you also want to know how to load images and how to set up a screen etc. also follow these tuts:

http://cone3d.gamedev.net/cgi-bin/index.pl?page=tutorials/gfxsdl/tut1

http://cone3d.gamedev.net/cgi-bin/index.pl?page=tutorials/gfxsdl/tut2

hope it helps :)

Share this post


Link to post
Share on other sites
You should research "finite state machines". Basically the idea is that when your player is sitting still, it's in a "idle state" or whatever name you want to call it. When it's running or doing the running animation, it's in the "running" state (or again whatever state name you want to call it). A simple solution to your problem would be to set the sprite to the running state and have it continually run until it reaches the end of the animation and then set it's current state back to the "idle" state. You should also have it ignore commands to restart the animation until, it returns back to the "idle" state. hope this helps
-JDev

Share this post


Link to post
Share on other sites

This topic is 4766 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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