Java Missile Defender: Design and Implementation

A multi-threaded clone of the classic arcade game Missile Command was designed and implemented as a runnable applet object using the Java 2 API. The game design required a class that builds the GUI and initializes object locations. This class also assigns values to numerous global variables for the score, the number of missiles, cities and turrets to create, the size and graphic for each image, the current game state, etc.

The basic idea for game initialization is to render a scene with missiles starting at the top, which head towards a specified target either a city or a turret on the bottom of the screen. The missiles will reach and destroy their designated targets unless the player is able to destroy them with a laser blast. The player can destroy a missile by left clicking on the mouse with the mouse pointer placed at a point close to the descending missile, i.e., within five pixels in the x direction and within ten pixels in the y direction.

Once the applet is initialized, the player must click on the Start button to start the game. This calls routines from a separate inner class that handles graphics display and animation. The Pause and Resume buttons call methods that suspend and resume game play. The Restart button causes the removal of all objects from the screen, resets the graphics and the score, and reinitializes object locations and trajectories.

A Missile class encapsulates data members needed to store positions, time delays, and other variables for the missile objects. Other data members are used to determine size, color, and information on the current states of each instance of the classes. They also include methods to draw and destroy these objects.

A collision detection routine determines missile to target interaction during game play. This routine tracks the positions of all missile objects on the screen and compares these to the positions of the cities and the turrets.

Each new missile is a thread that runs concurrently with other missile threads. The player can suspend all thread activity by pressing the Pause button. By pressing the Resume button, the player calls a resume to all suspended missile threads.

The top level class is an applet, which is itself a runnable thread object that calls multiple Missile threads. Each Missile thread runs concurrently with other threads until a call is made to flag a false condition in its run method, resulting in the completion of the thread's process. This mechanism was used for thread management since the stop method has been deprecated in the Java 2 API.

An applet tag referring to the game class was embedded into an HTML document, and a Web site featuring information about the game was designed and published. A product called the Java Plug-in, which acts as either a Netscape Navigator plug-in or as an Internet Explorer ActiveX control, was used to add Java 1.3 support for browsers.

Student Name: 
Andrew Kendall