First Pong Game.

Newbie Member
6Jul2007,09:11   #1
Plutonic's Avatar
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.
Go4Expert Founder
6Jul2007,11:23   #2
shabbir's Avatar
Please take the pain of explaining what problem you are facing rather than attaching the complete source code. I have removed the attachment.
Newbie Member
6Jul2007,17:12   #3
Plutonic's Avatar
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.
Newbie Member
7Jul2007,16:45   #4
Plutonic's Avatar
In simpler terms, I want to move a graphics via the use of input (such as arrow keys.)