Go4Expert (http://www.go4expert.com/)
-   Java (http://www.go4expert.com/forums/java/)
-   -   First Pong Game. (http://www.go4expert.com/forums/first-pong-game-t5130/)

Plutonic 6Jul2007 09:11

First Pong Game.
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.

shabbir 6Jul2007 11:23

Re: First Pong Game.
Please take the pain of explaining what problem you are facing rather than attaching the complete source code. I have removed the attachment.

Plutonic 6Jul2007 17:12

Re: First Pong Game.
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 7Jul2007 16:45

Re: First Pong Game.
In simpler terms, I want to move a graphics via the use of input (such as arrow keys.)

All times are GMT +5.5. The time now is 00:19.