Class SpaceGame

java.lang.Object
  extended bySpaceGame

public class SpaceGame
extends java.lang.Object

Author:
bachmaer, opyrchal Driver class for a simple networked space game. Opponents try to destroy each other by ramming. Head on collisions destroy both ships. Ships move and turn through GUI mouse clicks. All friendly and alien ships are displayed on a 2D interface.

Field Summary
(package private)  SpaceGui gui
           
(package private)  int ownPort
           
(package private)  Receiver receive
           
(package private)  Sector sector
           
(package private)  Sender send
           
 
Constructor Summary
SpaceGame()
          Creates all components needed to start a space game.
 
Method Summary
 void join()
          Creates a new sector.ownShip if one does not exist.
static void main(java.lang.String[] args)
           
 void moveFoward()
          Causes sector.ownShip to move forward and sends an update message for the position change.
 void turnLeft()
          Causes sector.ownShip to turn and sends an update message for the heading change.
 void turnRight()
          Causes sector.ownShip to turn and sends an update message for the heading change.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

sector

Sector sector

gui

SpaceGui gui

send

Sender send

receive

Receiver receive

ownPort

int ownPort
Constructor Detail

SpaceGame

public SpaceGame()
Creates all components needed to start a space game. Creates Sector canvas, GUI interface, a Sender obeject for sending update messages, a Reciever object for receiving messages.

Method Detail

turnRight

public void turnRight()
Causes sector.ownShip to turn and sends an update message for the heading change.


turnLeft

public void turnLeft()
Causes sector.ownShip to turn and sends an update message for the heading change.


moveFoward

public void moveFoward()
Causes sector.ownShip to move forward and sends an update message for the position change. Checks for a collision with an alien ship in the sector. If collision occurs it sends a remove message for the alien impacted. If the collision was head on the sector.ownShip will become null and a remove message is sent for the sector.ownShip. If there is an obstacle in front of the ship it will not move forward and a message is not sent.


join

public void join()
Creates a new sector.ownShip if one does not exist. Sends a join message for the new ship.


main

public static void main(java.lang.String[] args)