First Pong Game.

Plutonic's Avatar, Join Date: Jul 2007
Newbie Member
Hi, I'm programming my first game with Java, and I was wondering if anyone could push me in the right direction with creating my input for one of the paddles. I've made the ball bounce around the screen so far, and I've included my source code for the class that does most of the work.

Last edited by shabbir; 6Jul2007 at 11:22.. Reason: Attachment removed.
shabbir's Avatar, Join Date: Jul 2004
Go4Expert Founder
Please take the pain of explaining what problem you are facing rather than attaching the complete source code. I have removed the attachment.
Plutonic's Avatar, Join Date: Jul 2007
Newbie Member
Ok, well I want to create an input to move a graphic object around. I know I have to import java.awt.event and implement KeyListener. Now with KeyListener I want it to recieve input as either the char 'D' or 'A.' Recieveing 'D' will make my graphic (which is a line) move to the right by adding to the Xvalues in a rate proportional to the time I press 'D' down, and the same goes for the 'A' key but instead it will takeaway to the Xvalues and therefore make my object go left.

I've already done some of these by creating a variable called p1XPosition to equal 200, and in the graphics object I want to move, draws a line from p1Xposition to (p1xPosition + (getSize().width / 10)). All I really need to do is to create the input to increase p1xPosition and to repaint the graphics object.
Plutonic's Avatar, Join Date: Jul 2007
Newbie Member
In simpler terms, I want to move a graphics via the use of input (such as arrow keys.)