Class gamesrv.GameSrv
All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class gamesrv.GameSrv

java.lang.Object
   |
   +----java.awt.Component
           |
           +----java.awt.Container
                   |
                   +----java.awt.Panel
                           |
                           +----java.applet.Applet
                                   |
                                   +----gamesrv.GameSrv

public class GameSrv
extends Applet
implements Runnable
Class GameSrv is the main class (entry point) for the Battle of the Java Sea, multi-user, WWW game.

Variable Index

 o DN
This is used by various objects to represent the DOWN direction.
 o LT
This is used by various objects to represent the LEFT direction.
 o RT
This is used by various objects to represent the RIGHT direction.
 o UP
This is used by various objects to represent the UP direction.
 o bImageLoadingError
 o debug
 o sBadImage

Method Index

 o imageUpdate(Image, int, int, int, int, int)
 o init()
Initialize the applet.
 o keyDown(Event, int)
Process any key hit by the user.
 o mouseMove(Event, int, int)
Our gunsight tracks the mouse, so reset the aiming coordinates to the current mouse position.
 o mouseUp(Event, int, int)
Either start the game, if not started, or take a shot if the game is in progress.
 o moveTheirsTo(int, int, int)
We received a message saying an enemy ship has moved.
 o newEnemy(int, int, int, String)
We received a message stating that a new player has landed on the board.
 o paintBorder(Graphics)
Paint the border surrounding the entire game.
 o paintExplosions(Graphics, Explosion[])
Paint an array of Explosions within an existing Graphics context.
 o paintShip(Graphics, Ship)
Paint a single Ship within an existing Graphics context.
 o paintStatusStrings(Graphics)
Paint the status strings - fuel, ammo, life, position - within an existing Graphics context.
 o removeEnemy(int)
We received a message that an enemy has left the game.
 o run()
The main loop for the main thread.
 o scoreHitOn(int, int, int, int)
We received a message that someone in the game has been hit.
 o scoredHit(int, int, int)
We received a message that a shot from someone landed on an enemy Ship.
 o setMyIDandScore(int, int)
We received a message from the network server or ServerThread that we have been accepted to the game with the specified id and starting score.
 o setupHitGifs()
Setup the 60 permutations of the hit image - 15 stages of explosion times 4 directions of travel.
 o shotByLandedAt(int, int, int)
We received a message that someone fired a shot.
 o start()
Start the main thread for this game.
 o startGame()
Start the game.
 o startRobot()
Start the local robot.
 o stop()
Stop this thread.
 o update(Graphics)
Update the window, erasing things from their old positions and painting them anew at their current positions.

Variables

 o UP
  public final int UP
This is used by various objects to represent the UP direction.
 o DN
  public final int DN
This is used by various objects to represent the DOWN direction.
 o RT
  public final int RT
This is used by various objects to represent the RIGHT direction.
 o LT
  public final int LT
This is used by various objects to represent the LEFT direction.
 o bImageLoadingError
  public boolean bImageLoadingError
 o sBadImage
  public String sBadImage
 o debug
  public static boolean debug

Methods

 o start
  public void start()
Start the main thread for this game.
Overrides:
start in class Applet
 o imageUpdate
  public synchronized boolean imageUpdate(Image img,
                                          int infoflags,
                                          int x,
                                          int y,
                                          int width,
                                          int height)
Overrides:
imageUpdate in class Component
 o stop
  public void stop()
Stop this thread.
Overrides:
stop in class Applet
 o run
  public void run()
The main loop for the main thread.
 o startRobot
  public void startRobot()
Start the local robot.
 o init
  public void init()
Initialize the applet. Resize and load images.
Overrides:
init in class Applet
 o setupHitGifs
  public void setupHitGifs()
Setup the 60 permutations of the hit image - 15 stages of explosion times 4 directions of travel.
 o startGame
  public void startGame()
Start the game. NOT CALLED by constructor. MUST be called independently.
 o scoreHitOn
  public void scoreHitOn(int who,
                         int x,
                         int y,
                         int byWhom)
We received a message that someone in the game has been hit. If it was our shot, increment our score. In any case, show the hit by setting the explosionSize.
 o shotByLandedAt
  public void shotByLandedAt(int who,
                             int x,
                             int y)
We received a message that someone fired a shot. If it hit us, show the hit on us. If it didn't hit us, then we don't know whether it was a hit or a miss on anyone else, but we show it as a miss anyway.
 o moveTheirsTo
  public void moveTheirsTo(int who,
                           int x,
                           int y)
We received a message saying an enemy ship has moved. Set their reported position to the new position.
 o newEnemy
  public void newEnemy(int who,
                       int x,
                       int y,
                       String name)
We received a message stating that a new player has landed on the board. Create a new Ship for him and place him in the array of enemies.
 o removeEnemy
  public void removeEnemy(int who)
We received a message that an enemy has left the game. Sink him. His Ship will be removed from the enemies array AFTER the sinking sequence.
 o scoredHit
  public void scoredHit(int who,
                        int x,
                        int y)
We received a message that a shot from someone landed on an enemy Ship. Show the hit on that enemy by setting his explosionSize.
 o setMyIDandScore
  public void setMyIDandScore(int id,
                              int score)
We received a message from the network server or ServerThread that we have been accepted to the game with the specified id and starting score.
 o paintShip
  public void paintShip(Graphics g,
                        Ship s)
Paint a single Ship within an existing Graphics context.
 o paintExplosions
  public void paintExplosions(Graphics g,
                              Explosion ex[])
Paint an array of Explosions within an existing Graphics context.
 o paintStatusStrings
  public void paintStatusStrings(Graphics g)
Paint the status strings - fuel, ammo, life, position - within an existing Graphics context.
 o paintBorder
  public void paintBorder(Graphics g)
Paint the border surrounding the entire game. There is no border around the board itself.
 o update
  public void update(Graphics g)
Update the window, erasing things from their old positions and painting them anew at their current positions.
Overrides:
update in class Component
 o mouseUp
  public boolean mouseUp(Event e,
                         int x,
                         int y)
Either start the game, if not started, or take a shot if the game is in progress.
Overrides:
mouseUp in class Component
 o mouseMove
  public boolean mouseMove(Event e,
                           int x,
                           int y)
Our gunsight tracks the mouse, so reset the aiming coordinates to the current mouse position.
Overrides:
mouseMove in class Component
 o keyDown
  public boolean keyDown(Event e,
                         int key)
Process any key hit by the user. 'r' Reprovision our ship, filling life, fuel and ammo and subtracting from score. '6' This is the num-locked right arrow, so move our ship one right. '8' This is the num-locked up arrow, so move our ship one up. '4' This is the num-locked left arrow, so move our ship one left. '2' This is the num-locked down arrow, so move our ship one down. Report any position change or score change to the game server.
Overrides:
keyDown in class Component

All Packages  Class Hierarchy  This Package  Previous  Next  Index