AP Java Assignment 12
Finishing Asteroids

Press '4' to rotate left, '5' to accelerate, '6' to rotate right, '2' for hyperspace, '8' to shoot
You may need to "click" on the applet to give it the "focus"

Finishing the game

To finish our Asteroids game, we need to write a new class that represents Bullets. We will store the Bullets in an ArrayList much like we did with the Asteroids. Once we can shoot the bullets and destroy Asteroids, we will have a working game. Your Asteroids game doesn't have to look like the one above. Feel free to modify it in any way you wish.

Steps to completing this assignment

  1. Create a duplicate of your previous assignment by following steps #1 - 6 again, this time saving your class as ApJava12.java
  2. Write a Bullet class that extends Floater. You will need to:
  3. Now, add just one bullet to your applet. First, just draw it to the screen. Make sure you can see it before continuing to the next step.
  4. Now, move the bullet in the run method.
  5. Now create an ArrayList of Bullets. The list should be empty to start with. Everytime you press the key to "shoot", add a new Bullet to the ArrayList. Modify paint and run with loops that draw and move all the bullets in the ArrayList
  6. To check for collisions between the bullets and the Asteroids, you will need a loop within a loop. Everytime you move one asteroid you will need:

You will need a web page to display your applet. Your homepage should have a link to the web page for this assignment.

Submit the URL of your applet with the attached Java code (the .java file(s)) in an email message to mrsimon@lycos.com.