Sign in to follow this  
ultimate_tiger

How can I alternate my character movements in SDL?

Recommended Posts

ultimate_tiger    100
Hi, I am new at this, SDL /cpp and game development in general, but I would like to know, how can alternate the movements of my character? To be more specific: Look at a Mario game for example,let's say Mario Bros (nes), if you press the directional buttons Mario obviously walks, but if you press "B" + "directional button" mario start running. That's what I want to do, that if someone presses the directional buttons the character can walk, but that if you press a button + a directional button the character can run. Or if you press twice the same directional button can do the same thing. I already managed to make my character walk but I want to make him run too. If some of you could show me an example how it can be done, I would really apreciate it.

Share this post


Link to post
Share on other sites
Dunge    405
This have nothing to do with SDL. If you already know how to make it walk, it means you already know how to handle input events.

This is actually gameplay code. When you catch a "run button" press, you should simply set a state variable on the character class saying running is active, and on the button release, clear that flag. When you get to game logic update and rendering code, you check if the flag is active, and make it advance faster/render with another picture.

Share this post


Link to post
Share on other sites

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