Sign in to follow this  

Key Presses vs Key States

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

If you read the first part of his Key State tutorial, you would have seen:
Quote:
Sometimes just checking is a key is up or down is easier than monitoring events.

This tutorial will teach you to check if the key is pressed, rather than monitoring key events.

From what I've seen (I haven't used SDL before) "Key States" works on a buffer, while the tutorial "Key Presses" uses event handlers and all that.
I'd suggest key buffers for making a game, since you only want to buffer key presses once per frame, rather than directly checking it at each instruction (well, each 'key' conditional), so you have somewhat uniform results.
Plus, if you create a buffer to store a previous key state, you can check if a user just pressed the key down (!prev && cur), is holding it (prev && cur), and just released it (prev && !cur).

EDIT: Didn't read the part on efficiency... I'm not sure how exactly they work, so I can't say. However, your best choice is probably buffers (Key States).

Share this post


Link to post
Share on other sites

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