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.
-
DN
- This is used by various objects to represent the DOWN direction.
-
LT
- This is used by various objects to represent the LEFT direction.
-
RT
- This is used by various objects to represent the RIGHT direction.
-
UP
- This is used by various objects to represent the UP direction.
-
bImageLoadingError
-
-
debug
-
-
sBadImage
-
-
imageUpdate(Image, int, int, int, int, int)
-
-
init()
- Initialize the applet.
-
keyDown(Event, int)
- Process any key hit by the user.
-
mouseMove(Event, int, int)
- Our gunsight tracks the mouse, so reset the aiming coordinates to
the current mouse position.
-
mouseUp(Event, int, int)
- Either start the game, if not started, or take a shot if the game is
in progress.
-
moveTheirsTo(int, int, int)
- We received a message saying an enemy ship has moved.
-
newEnemy(int, int, int, String)
- We received a message stating that a new player has landed on the
board.
-
paintBorder(Graphics)
- Paint the border surrounding the entire game.
-
paintExplosions(Graphics, Explosion[])
- Paint an array of Explosions within an existing Graphics
context.
-
paintShip(Graphics, Ship)
- Paint a single Ship within an existing Graphics context.
-
paintStatusStrings(Graphics)
- Paint the status strings - fuel, ammo, life, position - within an
existing Graphics context.
-
removeEnemy(int)
- We received a message that an enemy has left the game.
-
run()
- The main loop for the main thread.
-
scoreHitOn(int, int, int, int)
- We received a message that someone in the game has been hit.
-
scoredHit(int, int, int)
- We received a message that a shot from someone landed on an enemy
Ship.
-
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.
-
setupHitGifs()
- Setup the 60 permutations of the hit image - 15 stages of
explosion times 4 directions of travel.
-
shotByLandedAt(int, int, int)
- We received a message that someone fired a shot.
-
start()
- Start the main thread for this game.
-
startGame()
- Start the game.
-
startRobot()
- Start the local robot.
-
stop()
- Stop this thread.
-
update(Graphics)
- Update the window, erasing things from their old positions and
painting them anew at their current positions.
UP
public final int UP
- This is used by various objects to represent the UP direction.
DN
public final int DN
- This is used by various objects to represent the DOWN direction.
RT
public final int RT
- This is used by various objects to represent the RIGHT direction.
LT
public final int LT
- This is used by various objects to represent the LEFT direction.
bImageLoadingError
public boolean bImageLoadingError
sBadImage
public String sBadImage
debug
public static boolean debug
start
public void start()
- Start the main thread for this game.
- Overrides:
- start in class Applet
imageUpdate
public synchronized boolean imageUpdate(Image img,
int infoflags,
int x,
int y,
int width,
int height)
- Overrides:
- imageUpdate in class Component
stop
public void stop()
- Stop this thread.
- Overrides:
- stop in class Applet
run
public void run()
- The main loop for the main thread.
startRobot
public void startRobot()
- Start the local robot.
init
public void init()
- Initialize the applet. Resize and load images.
- Overrides:
- init in class Applet
setupHitGifs
public void setupHitGifs()
- Setup the 60 permutations of the hit image - 15 stages of
explosion times 4 directions of travel.
startGame
public void startGame()
- Start the game. NOT CALLED by constructor. MUST be called
independently.
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.
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.
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.
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.
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.
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.
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.
paintShip
public void paintShip(Graphics g,
Ship s)
- Paint a single Ship within an existing Graphics context.
paintExplosions
public void paintExplosions(Graphics g,
Explosion ex[])
- Paint an array of Explosions within an existing Graphics
context.
paintStatusStrings
public void paintStatusStrings(Graphics g)
- Paint the status strings - fuel, ammo, life, position - within an
existing Graphics context.
paintBorder
public void paintBorder(Graphics g)
- Paint the border surrounding the entire game. There is no border
around the board itself.
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
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
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
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