Search code examples
javakeyboardpong

How Do I Add Keyboard Support For My Game?


I have been trying to make a Pong clone as sort of a beginner's project, and I've hit a road block. I have tried various methods to implement keyboard support, but none have worked.

For reference here is my Pong.java(the main class): http://pastebin.com/8d7BqK4x

Here is the Board.java(Graphics): http://pastebin.com/N9fLMzFT


Solution

  • Just some general advice, you can add keyboard listeners and then interpret the input, here's a link with some advice on keyboard listeners: http://download.oracle.com/javase/tutorial/uiswing/events/keylistener.html. For a game, I recommend using a "key pressed" event.