1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

First Pong Game.

Discussion in 'Java' started by Plutonic, Jul 6, 2007.

  1. Plutonic

    Plutonic New Member

    Joined:
    Jul 6, 2007
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    0
    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 a moderator: Jul 6, 2007
  2. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,285
    Likes Received:
    364
    Trophy Points:
    83
    Please take the pain of explaining what problem you are facing rather than attaching the complete source code. I have removed the attachment.
     
  3. Plutonic

    Plutonic New Member

    Joined:
    Jul 6, 2007
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    0
    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.
     
  4. Plutonic

    Plutonic New Member

    Joined:
    Jul 6, 2007
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    0
    In simpler terms, I want to move a graphics via the use of input (such as arrow keys.)
     

Share This Page