Class Asteroids
java.lang.Object
Asteroids
public class Asteroids
extends java.lang.Object
Asteroids.java - A clone of classic Atari arcade game Asteroids
Algorithm:
- Create gamecontroller with public scope to give all objects access
- Load images and highscore, exit if error occurs
- Create game main menu with start and exit options
- If player selects exit skip to
- If player selects start clear menu and make game window
- Create three starting asteroids in game
- Put player at middle of screen
- Player turns with left and right, moves with up, and shoots with space
- Check all bullets for collisions with asteroids, skip to step if none
- Destroy bullet and asteroid and increment score
- Check all bullets for collisions with player, skip to step if none
- Destroy bullet and player and decrement lives
- Check all asteroids for collisions with player, skip to step if none
- Destroy asteroid and player and decrement lives
- If player lives reach zero, display game over message and return to step 3, updating highscore if necessary
- If player lives above zero, return to step 9
- Save high scores and terminate program
-
Field Summary
Fields Modifier and Type Field Description static intCANVAS_HEIGHTstatic intCANVAS_WIDTHstatic GameControllergc -
Constructor Summary
Constructors Constructor Description Asteroids() -
Method Summary
Modifier and Type Method Description static voidmain(java.lang.String[] args)
-
Field Details
-
CANVAS_WIDTH
public static final int CANVAS_WIDTH- See Also:
- Constant Field Values
-
CANVAS_HEIGHT
public static final int CANVAS_HEIGHT- See Also:
- Constant Field Values
-
gc
-
-
Constructor Details
-
Asteroids
public Asteroids()
-
-
Method Details
-
main
public static void main(java.lang.String[] args)
-