wyvern.kernel.player
Class MapCamera

java.lang.Object
  extended bywyvern.kernel.maps.AbstractCamera
      extended bywyvern.kernel.player.MapCamera
All Implemented Interfaces:
Camera, RPCDataSource

public class MapCamera
extends AbstractCamera

This object maintains a view of the game map for a client.

Version:
1.0, Dec 31, 1997, 1.1, Sept 7, 1998
Author:
Steve Yegge

Field Summary
static int fullCount_
           
static int fullTime_
           
static int partialCount_
           
static int partialTime_
           
 
Fields inherited from class wyvern.kernel.maps.AbstractCamera
bounds_, client_, completelyInvalid_, frame_, hasMoved_, height_, left_, map_, player_, ready_, size_, top_, width_, xoffset_, yoffset_
 
Constructor Summary
MapCamera(RemoteClient client, Dimension viewsize, Player player)
          Constructs a new MapCamera.
 
Method Summary
protected  boolean handleUpdate(Frame frame)
          Sends frame information to client.
 DisplayPolicy makeFrame()
          A factory method that instantiates an DisplayPolicy subclass appropriate for this camera.
 void sendFullScreen(Frame frame)
          Sends the entire frame.
protected  boolean sendPartialScreen(Frame frame)
          Sends a set of changes (as opposed to the whole screen).
 void setMap(GameMap map, int x, int y)
          Centers the camera view around the passed position.
 java.lang.String toString()
          Returns a string description of this camera.
 boolean updateClient(DisplayPolicy frame)
          Main entry point to the camera - sends current set of changes to the client.
 
Methods inherited from class wyvern.kernel.maps.AbstractCamera
forceInvalidate, getCenter, getFrame, getMap, getOwner, getPosition, getViewRect, getViewSize, hasBeenMoved, invalidate, invalidateNoRayCast, isHandheld, isInvalid, isShutDown, markReady, markValid, move, moveFrame, setHandheld, setMap, setMoved, setPosition, setViewRect, setViewSize, shutDown, tryUpdate, validate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

partialCount_

public static int partialCount_

partialTime_

public static int partialTime_

fullCount_

public static int fullCount_

fullTime_

public static int fullTime_
Constructor Detail

MapCamera

public MapCamera(RemoteClient client,
                 Dimension viewsize,
                 Player player)
          throws java.lang.Exception
Constructs a new MapCamera.

Parameters:
client - the remote networking layer to talk to
viewsize - the initial size of the camera
player - the player we're attached to
Method Detail

updateClient

public boolean updateClient(DisplayPolicy frame)
Main entry point to the camera - sends current set of changes to the client. Sends either the full screen, if the camera is marked completely invalid, else a partial screen. Called by superclass when in addInvalRegions(), if the camera has been asked for more data by the network layer.

Specified by:
updateClient in class AbstractCamera
Parameters:
frame - the DisplayPolicy containing the update information
Returns:
true if any data was sent

handleUpdate

protected boolean handleUpdate(Frame frame)
                        throws java.lang.Exception
Sends frame information to client.

Parameters:
frame - the Frame containing the update information
Returns:
true if data was sent
Throws:
java.lang.Exception

sendFullScreen

public void sendFullScreen(Frame frame)
Sends the entire frame.

Parameters:
frame - the Frame containing the updates

sendPartialScreen

protected boolean sendPartialScreen(Frame frame)
                             throws java.io.IOException
Sends a set of changes (as opposed to the whole screen).

Parameters:
frame - the Frame containing the updates
Returns:
true if any data was actually sent
Throws:
java.io.IOException

makeFrame

public DisplayPolicy makeFrame()
A factory method that instantiates an DisplayPolicy subclass appropriate for this camera. The object is obtained later by calls to getFrame().

Returns:
a DisplayPolicy implementation suitable for rendering the data

setMap

public void setMap(GameMap map,
                   int x,
                   int y)
Centers the camera view around the passed position.

Specified by:
setMap in interface Camera
Overrides:
setMap in class AbstractCamera

toString

public java.lang.String toString()
Returns a string description of this camera.

Overrides:
toString in class AbstractCamera
Returns:
String representation