spacewar
Class Game

java.lang.Object
  |
  +--java.lang.Thread
        |
        +--spacewar.Game
All Implemented Interfaces:
java.lang.Runnable

public class Game
extends java.lang.Thread

The Game class is the root of the spacewar game. To start a spacewar game, you can either call the main method, or instantiate this class directly. The synchronization is done by the GameSynchronization aspect at the end of this file.


Fields inherited from class java.lang.Thread
inheritableThreadLocals, MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY, threadLocals
 
Constructor Summary
Game(java.lang.String mode)
          
Advised by: spacewar.Display To run the game, simply instantiate this class.
 
Method Summary
(package private)  void ()
          
(package private)  void addRobot()
          
(package private)  void clockTick()
          
Advised by: spacewar.Display
(package private)  void error(java.lang.Object o)
          
(package private)  int getHeight()
          
(package private)  Pilot getPilot1()
          
(package private)  Pilot getPilot2()
          
(package private)  Registry getRegistry()
          
(package private)  int getWidth()
          
(package private)  void handleCollisions()
          
Advised by: coordination.Coordinator
(package private) static boolean isCollision(SpaceObject a, SpaceObject b)
          
static void main(java.lang.String[] args)
           To run the game from top level, simply say Java Game, as usual.
(package private)  Player newPlayer(int number)
          
(package private)  Robot newRobot(int number)
          
(package private)  Ship newShip(Pilot pilot)
          
Advised by: spacewar.Display2.ShipDA, coordination.Coordinator, spacewar.Display1.ShipDA
(package private)  void quit()
          
(package private)  void resetShips()
          
 void run()
          
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setName, setPriority, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Game

public Game(java.lang.String mode)

Advised by: spacewar.Display To run the game, simply instantiate this class. It runs in its own thread. You can instantiate multiple games at once. For the time being the only way to end the game is to exit from the Java VM.
Parameters:
isDemo - Controls whether the game runs in demo mode or not. True means it is a demo, false means it runs in normal 2 player mode.
Method Detail

void ()
Overrides:
in class java.lang.Thread

main

public static void main(java.lang.String[] args)
To run the game from top level, simply say Java Game, as usual. Passing an argument makes the game run in demo mode. Without an argument it runs in the normal player mode.

getRegistry

Registry getRegistry()

getPilot1

Pilot getPilot1()

getPilot2

Pilot getPilot2()

getWidth

int getWidth()

getHeight

int getHeight()

run

public void run()
Overrides:
run in class java.lang.Thread

addRobot

void addRobot()

resetShips

void resetShips()

quit

void quit()

error

void error(java.lang.Object o)

newPlayer

Player newPlayer(int number)

newRobot

Robot newRobot(int number)

newShip

Ship newShip(Pilot pilot)

Advised by: spacewar.Display2.ShipDA, coordination.Coordinator, spacewar.Display1.ShipDA

clockTick

void clockTick()

Advised by: spacewar.Display

handleCollisions

void handleCollisions()

Advised by: coordination.Coordinator

isCollision

static boolean isCollision(SpaceObject a,
                           SpaceObject b)