Re: how do i put an image as a background on a JFrame?



Knute Johnson wrote:
Andrew Thompson wrote:
Knute Johnson wrote:
.
www.knutejohnson.com

Hey, cool. When did you get the domain name?

BTW - love the sounds you put to 'Pong', they cracked me up. :-)


I've had it for a while but I linked it up a couple of months ago.

I told Jeff Higgins, my wife hates the sounds and leaves the room whenever I play the game :-).

I got a little bug while playing. When the ball hits an upper corner more or less exactly (depends on speed), it stays glued to the top line. This is because the following Y condition

// if ball is hitting top bounce off
} else if (ballY <= 0) {
veloY = -veloY;
bink.play();
}

Should not be "else" to the X condition.

If the ball crosses both conditions (X&Y) in the same step, the veloY will be added twice to ballY before the Y condition is evaluated and so the condition (ballY <= 0) will now be true forever (with the veloY changing sign at each frame).

So take out this "else".

:-)

Phil


.



Relevant Pages

  • Re: how do i put an image as a background on a JFrame?
    ... I told Jeff Higgins, my wife hates the sounds and leaves the room whenever I play the game :-). ... When the ball hits an upper corner more or less exactly, it stays glued to the top line. ... If the ball crosses both conditions in the same step, the veloY will be added twice to ballY before the Y condition is evaluated and so ...
    (comp.lang.java.gui)
  • Re: how do i put an image as a background on a JFrame?
    ... my wife hates the sounds and leaves the room whenever I play the game :-). ... I got a little bug while playing. ... When the ball hits an upper corner more or less exactly, it stays glued to the top line. ... If the ball crosses both conditions in the same step, the veloY will be added twice to ballY before the Y condition is evaluated and ...
    (comp.lang.java.gui)
  • Re: how do i put an image as a background on a JFrame?
    ... BTW - love the sounds you put to 'Pong', ... I got a little bug while playing. ... When the ball hits an upper corner more or less exactly, it stays glued to the top line. ... If the ball crosses both conditions in the same step, the veloY will be added twice to ballY before the Y condition is evaluated and ...
    (comp.lang.java.gui)