nankin.zheng.gatem.util
Class Env

java.lang.Object
  |
  +--nankin.zheng.gatem.util.Env

public abstract class Env
extends java.lang.Object

This class defines the basic constants for the game environment.

All the environment variables listed here are common variables that are necessary for almost all the games.

Some of them can be defined directly here as constants, so they appear to be public and final.

The others should be specified differently according to different games, so they appear to be protected and not final. They can be visited by getXXX() methods, but should not be modified after initialization. A certain game should extend this class, implement the init() method to specify these game-dependent variables.

NOTE that all the protected fields must be initialized properly by its subclass. They should never change throughout the game.

Version:
1.0, Date 2003-04-11
Author:
ZHENG Zhong

Field Summary
private  int BACKGROUND_HEIGHT
          Background height (logical coordonate)
private  int BACKGROUND_WIDTH
          Background width (logical coordonate)
static int DOWN
           
static int DOWN_LEFT
           
static int DOWN_RIGHT
           
protected static java.lang.Class FILE_LOCATOR
          File locator, a Class object to locate game resources.
static int LEFT
           
protected static int MS_PER_FRAME
          Frame updating speed.
protected static int MS_PER_FRAME_MIN
          Frame updating speed limit.
static int RIGHT
           
protected  int STEP_X
          Mapping from logical coordonate to physical coordonate.
protected  int STEP_Y
          Mapping from logical coordonate to physical coordonate.
static int STILL
           
static int UP
           
static int UP_LEFT
           
static int UP_RIGHT
           
protected  int VIEWPORT_HEIGHT
          Viewport height (logical coordonate)
protected  int VIEWPORT_MARGIN
          Viewport margin (logical coordonate).
protected  int VIEWPORT_START_X
          Viewport start x (physical coordonate)
protected  int VIEWPORT_START_Y
          Viewport start y (physical coordonate)
protected  int VIEWPORT_WIDTH
          Viewport width (logical coordonate)
protected static int WINDOW_HEIGHT
          Window height (physical coordonate)
protected static int WINDOW_WIDTH
          Window width (physical coordonate)
 
Constructor Summary
Env()
          Constructor.
 
Method Summary
 int getBackgroundHeight()
          Get BACKGROUND_HEIGHT.
 int getBackgroundWidth()
          Get BACKGROUND_WIDTH.
static java.lang.Class getFileLocator()
          Get file locator.
static int getMsPerFrame()
          Get MS_PER_FRAME.
static int getMsPerFrameMin()
          Get MS_PER_FRAME_MIN.
 int getStepX()
          Get STEP_X.
 int getStepY()
          Get STEP_Y.
 int getViewportHeight()
          Get VIEWPORT_HEIGHT.
 int getViewportMargin()
          Get VIEWPORT_MARGIN.
 int getViewportStartX()
          Get VIEWPORT_START_X.
 int getViewportStartY()
          Get VIEWPORT_START_Y.
 int getViewportWidth()
          Get VIEWPORT_WIDTH.
static int getWindowHeight()
          Get WINDOW_HEIGHT.
static int getWindowWidth()
          Get WINDOW_WIDTH.
protected abstract  void init()
          Initialize all game-dependent environment variables.
 void setBackgroundHeight(int bgheight)
          Set BACKGROUND_HEIGHT.
 void setBackgroundWidth(int bgwidth)
          Set BACKGROUND_WIDTH.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

STILL

public static final int STILL
See Also:
Constant Field Values

UP

public static final int UP
See Also:
Constant Field Values

DOWN

public static final int DOWN
See Also:
Constant Field Values

LEFT

public static final int LEFT
See Also:
Constant Field Values

RIGHT

public static final int RIGHT
See Also:
Constant Field Values

UP_LEFT

public static final int UP_LEFT
See Also:
Constant Field Values

DOWN_RIGHT

public static final int DOWN_RIGHT
See Also:
Constant Field Values

UP_RIGHT

public static final int UP_RIGHT
See Also:
Constant Field Values

DOWN_LEFT

public static final int DOWN_LEFT
See Also:
Constant Field Values

MS_PER_FRAME

protected static int MS_PER_FRAME
Frame updating speed. How many ms does one frame last?


MS_PER_FRAME_MIN

protected static int MS_PER_FRAME_MIN
Frame updating speed limit. The actual game updating speed cannot be faster than this one.


STEP_X

protected int STEP_X
Mapping from logical coordonate to physical coordonate. how many pixels is the width of a logical coordonate block?


STEP_Y

protected int STEP_Y
Mapping from logical coordonate to physical coordonate. how many pixels is the height of a logical coordonate block?


WINDOW_WIDTH

protected static int WINDOW_WIDTH
Window width (physical coordonate)


WINDOW_HEIGHT

protected static int WINDOW_HEIGHT
Window height (physical coordonate)


VIEWPORT_START_X

protected int VIEWPORT_START_X
Viewport start x (physical coordonate)


VIEWPORT_START_Y

protected int VIEWPORT_START_Y
Viewport start y (physical coordonate)


BACKGROUND_WIDTH

private int BACKGROUND_WIDTH
Background width (logical coordonate)


BACKGROUND_HEIGHT

private int BACKGROUND_HEIGHT
Background height (logical coordonate)


VIEWPORT_WIDTH

protected int VIEWPORT_WIDTH
Viewport width (logical coordonate)


VIEWPORT_HEIGHT

protected int VIEWPORT_HEIGHT
Viewport height (logical coordonate)


VIEWPORT_MARGIN

protected int VIEWPORT_MARGIN
Viewport margin (logical coordonate).


FILE_LOCATOR

protected static java.lang.Class FILE_LOCATOR
File locator, a Class object to locate game resources.

Constructor Detail

Env

public Env()
Constructor. This constructor calls init() to initialize all game-dependent environment variables.

Method Detail

getMsPerFrame

public static int getMsPerFrame()
Get MS_PER_FRAME.

Returns:
MS_PER_FRAME

getMsPerFrameMin

public static int getMsPerFrameMin()
Get MS_PER_FRAME_MIN.

Returns:
MS_PER_FRAME_MIN.

getStepX

public int getStepX()
Get STEP_X.

Returns:
STEP_X

getStepY

public int getStepY()
Get STEP_Y.

Returns:
STEP_Y

getWindowWidth

public static int getWindowWidth()
Get WINDOW_WIDTH.

Returns:
WINDOW_WIDTH

getWindowHeight

public static int getWindowHeight()
Get WINDOW_HEIGHT.

Returns:
WINDOW_HEIGHT

getViewportStartX

public int getViewportStartX()
Get VIEWPORT_START_X.

Returns:
VIEWPORT_START_X

getViewportStartY

public int getViewportStartY()
Get VIEWPORT_START_Y.

Returns:
VIEWPORT_START_Y

setBackgroundWidth

public void setBackgroundWidth(int bgwidth)
Set BACKGROUND_WIDTH.

Parameters:
bgwidth - BACKGROUND_WIDTH

getBackgroundWidth

public int getBackgroundWidth()
Get BACKGROUND_WIDTH.

Returns:
BACKGROUND_WIDTH.

setBackgroundHeight

public void setBackgroundHeight(int bgheight)
Set BACKGROUND_HEIGHT.


getBackgroundHeight

public int getBackgroundHeight()
Get BACKGROUND_HEIGHT.

Returns:
BACKGROUND_HEIGHT.

getViewportWidth

public int getViewportWidth()
Get VIEWPORT_WIDTH.

Returns:
VIEWPORT_WIDTH

getViewportHeight

public int getViewportHeight()
Get VIEWPORT_HEIGHT.

Returns:
VIEWPORT_HEIGHT

getViewportMargin

public int getViewportMargin()
Get VIEWPORT_MARGIN.

Returns:
VIEWPORT_MARGIN

getFileLocator

public static java.lang.Class getFileLocator()
Get file locator.

Returns:
a Class object locating at the root of resource file system.

init

protected abstract void init()
Initialize all game-dependent environment variables. NOTE that this method should be overwritten by its subclasses to specify all the protected environment vairables.