Jump to content
  • Advertisement
Sign in to follow this  
SKATIN_HARD

sdl key state question

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

In my current demo you have to press the 'p' key to pause the game. The only problem is the game resumes after you release the 'p' key. Is there an easy way to make it so that when I push the 'p' key the game will pause until the 'p' key is pushed again??? Thanks for any tips or tricks on the matter.

Share this post


Link to post
Share on other sites
Advertisement
It's because you get an event when you press the key and one when you release it. Since you don't check what type of event it is (only if it's related to the 'p' key), you toggle the pause when the key is pressed and when it's released. Toggling the pause state only when the event is a SDL_KEYDOWN (and not when it's SDL_KEYUP) should do the trick.

FWIW, I answered your question here already. [grin]

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!