Jump to content

Keyboard input for simple games

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
1 reply to this topic

#1
Osnarf

Osnarf

    Learning Programmer

  • Members
  • PipPipPip
  • 31 posts
I want to make a simple pong game. How do I get the input to move the paddle without making the ball thats moving around pause to wait for input?

#2
Guest

Guest

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 3,414 posts
Depending on the library you use, there may already be a function that gets input without pausing. In TI-BASIC, I could put a getkey function in a while loop. If a key was pressed, getkey would return a number of the corresponding key, otherwise it just returns 0.

If that's not available, you could use a forking program or something similar. One process would wait for input, and the other would do normal game operations.
The fork() System Call
Root Beer == System Administrator's Beer
Download the new operating system programming kit! (some assembly required)