• Advertisement
Sign in to follow this  

How can I alternate my character movements in SDL?

This topic is 2939 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

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
Advertisement
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
Sign in to follow this  

  • Advertisement