Jump to content
  • Advertisement
Sign in to follow this  
Bladelock

How to process keystroke inputs in C++?

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

Well, I've been learning C++ with SFML lately. I know how to load a sprite through SFML now; however, I don't really know how to make my sprite move with the touch of an arrow key.
I've done my part in trying to Google the solution, but I can't seem to find any solid solution. This is why I am asking it here. I'm really stumped now.

Is there any way to accept the push of a key as some form of input in Native C++?
If none, is there any simple alternative to gain the desired effect (such as moving the sprite with the keyboard's arrow keys)?
Is there some kind of programming term that describes the processing of keystrokes into some kind of input?



Cheers.

Share this post


Link to post
Share on other sites
Advertisement
Very good. Please take extra care in understanding the difference between [font="'Courier New"]TextEntered [/font]and [font="'Courier New"]KeyPressed[/font]/[font="'Courier New"]KeyReleased[/font]. To my own surprise, a lot of people seem to just not understand the point. In 2011, that would be a shame.

Share this post


Link to post
Share on other sites

Input like that isn't part of the C++ standard libraries (C++ doesn't even assume the existence of a keyboard...). But since you are using SFML have a look at the SFML Event Tutorial.


It somehow did the trick. Thanks.

I still had some issues regarding copies of the sprite being left behind, so for any of those concerned, I posted a specific SFML prob, right in the SFML forums itself. I hope it helps other newbs like me.

Cheers!

My Post: http://www.sfml-dev.org/forum/viewtopic.php?p=38331#38331

Another potentially useful post (not by me): http://www.cplusplus.com/forum/beginner/49409/

Share this post


Link to post
Share on other sites

I still had some issues regarding copies of the sprite being left behind, so for any of those concerned, I posted a specific SFML prob, right in the SFML forums itself. I hope it helps other newbs like me.


You might not be clearing the screen every frame.

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!