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



Knute Johnson wrote:
Philipp wrote:
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



Fixed! It still has a few other little bugs. Feel free to recommend fixes.


Instead of using fillRect for the ball, you might as well use fillOval. It looks so much nicer :-) (but maybe less Commodore-64 era)
.



Relevant Pages

  • Re: Spiderman code update - 1.6 is now available
    ... didn't play anymore games to see yet if it happens again. ... Fixed a bug with resetting the ... instead of waiting for the ball to be ... ball when battle royale or super hero are ...
    (rec.games.pinball)
  • Re: Getaway: Free Ride bug
    ... That bug is fun, imho.. ... whole game at the end, ... Hit the ball into the Tunnel to light ... It was highly amusing to see someone who barely knows how to play pinball deal with this. ...
    (rec.games.pinball)
  • 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?
    ... 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)
  • 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)