Sign in to follow this  
hop

Question About Keyboard Hits

Recommended Posts

Hello Everyone, I recently created my first game using C++, a very simple Pong Game. The only problem with the game is the paddle you control doesn't stop moving when you release the key (although it does when you press another key, which makes sense to me but is not ideal). When I fix this, the program returns that the key is being pressed as if it were typing (so you press the key and it registers once then you wait a bit and it starts repeating at a low rate). The code that tests whether you are pressing the key is as follows (in the version where it keeps moving): if (kbhit() == TRUE) c = getch(); There must be a better way to do this. Is there some function I should be using? And here is the enitre code (this is the version where it stops moving)(and sorry I don't know how to do links yet for these forums): http://www.sitesled.com/members/fusiongames/Pong.txt And if anyone wants to test the .exe, here it is: http://www.sitesled.com/members/fusiongames/Pong.exe (1st vers) http://www.sitesled.com/members/fusiongames/Pong2.exe (2nd vers) Thanks for helping this noob! // edit - added title

Share this post


Link to post
Share on other sites

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