I'm a beginner c++ programmer. I use Win XP and CodeBlocks. I'm trying to make a pong game, I already have the controls programmed, but I need a method to do the following: Check for user input, if they don't input for x milliseconds, then continue with the loop so the ball's path can be updated. Or something that could check input and move the ball at the same time. Any Suggestions? Thank you!

Recommended Answers

All 3 Replies

Is this still a console program (the answer is in my reply to one of your other threads), or have you moved onto a GUI program?

GUI's are typically event driven, so you don't read the keys as such, but you do get key events as part of the normal flow of events.

Console, I'm using setcursor position x and y.

Why not 'just check' for key presses, if there's none just update the ball and not the pads. add a delay at the end of every loop to ensure your program won't run way too fast ;)

the loop's like this:

check for keypresses
if true update pads
update ball
add delay x milliseconds

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.