Results 1 to 5 of 5

Thread: Pong game

  1. #1
    hannes is offline Member
    Join Date
    Nov 2009
    Posts
    54
    Rep Power
    0

    Default Pong game

    Hi,

    I'm making a kind of pong game with one ball and two beams wich you can move up and down to bounce the ball and so on. You can move the two beams with A and Q and arrow up and arrow down. My problem is that when i move one beam, i can't move the other and otherwise. I've tried to use a thread in my keylistener but that didn't work. Any suggestions?

    Hannes
    Last edited by hannes; 04-14-2010 at 07:34 PM.

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    No need for a background thread as a Swing Timer would do the trick nicely (although it does use a background thread behind the scenes to accomplish its tasks).

  3. #3
    hannes is offline Member
    Join Date
    Nov 2009
    Posts
    54
    Rep Power
    0

    Default

    But what should i do then? When i press on A to get the first beam higher, then i can't get the second beam down when i press on arrow up;

  4. #4
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    Quote Originally Posted by hannes View Post
    But what should i do then? When i press on A to get the first beam higher, then i can't get the second beam down when i press on arrow up;
    It's very hard to say without knowing what your code is doing. Myself, I'd use a Swing Timer and key bindings. I would not use a KeyListener for this.

    I also would try to work on just this problem in isolation, in a small program that does nothing but move two rectangles. Once solved in the small program, then and only then integrate it into the large program. If the small program doesn't work, then post it here (we definitely don't want to see the whole big program).

    Best of luck.

  5. #5
    kevinpeter Guest

    Default

    riving a VGA monitor
    A VGA monitor requires 5 signals to display a picture:

    * R, G and B (red, green and blue signals).
    * HS and VS (horizontal and vertical synchronization).

    The R, G and B are analog signals, while HS and VS are digital signals.

Similar Threads

  1. Ping pong game
    By adam405 in forum New To Java
    Replies: 8
    Last Post: 10-20-2010, 03:52 PM
  2. Replies: 2
    Last Post: 08-05-2010, 04:49 AM
  3. The bug in the Pong game
    By Phoeenix in forum New To Java
    Replies: 4
    Last Post: 07-21-2009, 07:13 PM
  4. Pong Paddle Not Stopping Ball At Certain Speed
    By JDCAce in forum Java Applets
    Replies: 3
    Last Post: 04-01-2009, 11:07 PM
  5. Help with pong game
    By Eric in forum New To Java
    Replies: 2
    Last Post: 07-03-2007, 07:02 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •