Moving a player while holding down a key.

Started by
20 comments, last by MylesEvans 11 years, 3 months ago

[quote name='GDsnakes' timestamp='1357237203' post='5017200']
I tried that method. It was the first thing I tried
If I hold down the key the payer doesn't move. I have to repeatedly tap the key.
[/quote]

Yeah, but you have to call handleKeys() on EVERY LOOP, not just when an SDL Key Event is triggered.

If you are checking the key state every single loop, then you will always see the key is down, and it WILL always move.

My Gamedev Journal: 2D Game Making, the Easy Way

---(Old Blog, still has good info): 2dGameMaking
-----
"No one ever posts on that message board; it's too crowded." - Yoga Berra (sorta)

Advertisement

I tried that method. It was the first thing I tried
If I hold down the key the payer doesn't move. I have to repeatedly tap the key.

Yeah, but you have to call handleKeys() on EVERY LOOP, not just when an SDL Key Event is triggered.

If you are checking the key state every single loop, then you will always see the key is down, and it WILL always move.

ahhh thank you very much. I just figured it out lol. You were right.

I love the Gamedev community! you guys are a big help.

This topic is closed to new replies.

Advertisement