This program moves a gif (the spaceship) around over a gif (the comet/background).
It has two files: mover and ship. Mover is identical to Bouncer. It set up the user interface and starts the thread. Ship is almost identical to Ball. It moves the ship and draws it.
| Image picture; Image back; |
Two additional instance variables to hold the two pictures. |
| picture = Toolkit.getDefaultToolkit ().getImage ("ship.gif"); back = Toolkit.getDefaultToolkit ().getImage ("comet.jpg"); |
Added to the constructor to get the two images. |
| public void paint (Graphics g) { g.drawImage (back, 0, 0, this); |
In paint, instead of drawing the ball, you draw the background and then the ship on top of it. |