home *** CD-ROM | disk | FTP | other *** search
/ The Net: Ultimate Internet Guide / WWLCD1.ISO / pc / java / enxle1f6 / src / games / battle / client / clientapplet / clientlook.java < prev    next >
Encoding:
Java Source  |  1996-08-14  |  2.4 KB  |  85 lines

  1. /*
  2.  * @(#)ClientLook.java
  3.  */
  4. package games.Battle.client.ClientApplet;
  5.  
  6. import java.awt.Image;
  7. import java.awt.Graphics;
  8. import java.awt.Component;
  9.  
  10. /**
  11.  * ClientLook is a base class which defines the interface (and some
  12.  * implementation) for a set of classes used to implement the "look"
  13.  * of the client. By deriving a new class from ClientLook and 
  14.  * overriding the update(b) and updateTerrain() methods, an entirely
  15.  * new look can be written for the client.
  16.  *
  17.  * Typically the terrain is generated once at the beginning of the
  18.  * game after the client has received the TerrainInit packet from
  19.  * the server. After that, updateTerrain() should not need to be
  20.  * called again. update() is called on every turn and allows all
  21.  * of the troops and pipes to be drawn.
  22.  *
  23.  * The original Europa client has two look classes: ClientLookArcade
  24.  * and ClientLookTraditional.
  25.  *
  26.  * @author Alex Nicolaou
  27.  * @author Jay Steele
  28.  */
  29. public abstract class ClientLook {
  30.  
  31.     /**
  32.      * A reference to the ClientBoardComponent's offscreen image.
  33.      */
  34.     protected Image offScreenImage = null;
  35.  
  36.     /** 
  37.      * A graphics context to the offscren image.
  38.      */
  39.     protected Graphics offGC = null;
  40.  
  41.     /**
  42.      * A graphics context to the ClientBoardComponent's drawing area.
  43.      */
  44.     protected Graphics onGC = null;
  45.  
  46.     /**
  47.      * A reference to the ClientBoardComponent instance for this game board.
  48.      */
  49.     protected ClientBoardComponent component = null;
  50.  
  51.     /**
  52.      * Initialize the ClientLook data members. It basically references
  53.      * the ClientBoardComponent's offscreen bitmap (which the look
  54.      * draws into) and builds a graphics context for the offscreen
  55.      * bitmap and the onscreen bitmap.
  56.      * @param c the ClientBoardComponent we are drawing into
  57.      */
  58.     public ClientLook(ClientBoardComponent c) {
  59.         offScreenImage = c.getOffScreenImage();
  60.         offGC = offScreenImage.getGraphics();
  61.         onGC = c.getGraphics();
  62.         component = c;
  63.         c.setLook(this);
  64.     }
  65.  
  66.     /**
  67.      * Abstract method redefined in subclasses to actually physically
  68.      * update the graphical state of the board during the game.
  69.      */
  70.     public abstract void update(ClientBoard b);
  71.  
  72.     /**
  73.      * Abstract method redefined in subclasses to update the 
  74.      * background terrain of the game board.
  75.      */
  76.     public abstract void updateTerrain(ClientBoard b);
  77.  
  78.     /**
  79.      * Forces the offscreen graphic to draw on the ClientBoardComponent.
  80.      */
  81.     public void updateDisplay() {
  82.         onGC.drawImage(offScreenImage, 0, 0, component);
  83.     }
  84. }
  85.