Class Mappy.Block

java.lang.Object
  |
  +--Mappy.Block
Enclosing class:
Mappy

public class Mappy.Block
extends java.lang.Object

Mappy Block v1.10

This class represents a Block as used by Mappy.

A Block may contain up to 4 layers of images (1 background layer and 3 foreground layers), 7 fields of User data, quadratic collision information and 4 other flags.


Field Summary
 int BACKGROUND
          A Block Image layer.
 int COLLISION_BOTTOM_LEFT
          A flag used in collision detection.
 int COLLISION_BOTTOM_RIGHT
          A flag used in collision detection.
 int COLLISION_TOP_LEFT
          A flag used in collision detection.
 int COLLISION_TOP_RIGHT
          A flag used in collision detection.
 int FOREGROUND1
          A Block Image layer.
 int FOREGROUND2
          A Block Image layer.
 int FOREGROUND3
          A Block Image layer.
 int MAX_USER_DATA
          A minimum index for User Data.
 int MIN_USER_DATA
          A minimum index for User Data.
 int TRIGGER
          A User defined flag.
 int UNUSED1
          A User defined flag.
 int UNUSED2
          A User defined flag.
 int UNUSED3
          A User defined flag.
 
Constructor Summary
protected Mappy.Block()
          Only Mappycan contruct Block classes.
 
Method Summary
 void debug(java.lang.String strText)
          Logs the Block's current state.
 boolean getFlag(int intFlag)
          Returns the specified Flag.
 int getImageIndex(int intImageLayer)
          Returns the Image index of the given Block layer.
 int getUserData(int intIndex)
          Returns the specified User Data.
 void setFlag(int intFlag, boolean blnNewFlag)
          Sets the specified Flag.
 void setImageIndex(int intImageLayer, int intNewImageIndex)
          Sets the Image of the given Block layer.
 void setUserData(int intIndex, int intNewUserData)
          Sets the specified User Data.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BACKGROUND

public final int BACKGROUND
A Block Image layer.

See Also:
setImageIndex(int, int), getImageIndex(int), Constant Field Values

FOREGROUND1

public final int FOREGROUND1
A Block Image layer.

See Also:
setImageIndex(int, int), getImageIndex(int), Constant Field Values

FOREGROUND2

public final int FOREGROUND2
A Block Image layer.

See Also:
setImageIndex(int, int), getImageIndex(int), Constant Field Values

FOREGROUND3

public final int FOREGROUND3
A Block Image layer.

See Also:
setImageIndex(int, int), getImageIndex(int), Constant Field Values

MIN_USER_DATA

public final int MIN_USER_DATA
A minimum index for User Data.

See Also:
setUserData(int, int), getUserData(int), Constant Field Values

MAX_USER_DATA

public final int MAX_USER_DATA
A minimum index for User Data.

See Also:
setUserData(int, int), getUserData(int), Constant Field Values

COLLISION_TOP_LEFT

public final int COLLISION_TOP_LEFT
A flag used in collision detection.

See Also:
setFlag(int, boolean), getFlag(int), Constant Field Values

COLLISION_TOP_RIGHT

public final int COLLISION_TOP_RIGHT
A flag used in collision detection.

See Also:
setFlag(int, boolean), getFlag(int), Constant Field Values

COLLISION_BOTTOM_LEFT

public final int COLLISION_BOTTOM_LEFT
A flag used in collision detection.

See Also:
setFlag(int, boolean), getFlag(int), Constant Field Values

COLLISION_BOTTOM_RIGHT

public final int COLLISION_BOTTOM_RIGHT
A flag used in collision detection.

See Also:
setFlag(int, boolean), getFlag(int), Constant Field Values

TRIGGER

public final int TRIGGER
A User defined flag.

See Also:
setFlag(int, boolean), getFlag(int), Constant Field Values

UNUSED1

public final int UNUSED1
A User defined flag.

See Also:
setFlag(int, boolean), getFlag(int), Constant Field Values

UNUSED2

public final int UNUSED2
A User defined flag.

See Also:
setFlag(int, boolean), getFlag(int), Constant Field Values

UNUSED3

public final int UNUSED3
A User defined flag.

See Also:
setFlag(int, boolean), getFlag(int), Constant Field Values
Constructor Detail

Mappy.Block

protected Mappy.Block()
Only Mappycan contruct Block classes.

Method Detail

setImageIndex

public void setImageIndex(int intImageLayer,
                          int intNewImageIndex)
Sets the Image of the given Block layer.

If either the Image layer or Image index is out of bounds then an error is logged (not thrown) and the method aborted.

Parameters:
intImageLayer - the layer who's image is to be updated.
intNewImageIndex - the index of the new Image.
See Also:
getImageIndex(int), BACKGROUND, FOREGROUND1, FOREGROUND2, FOREGROUND3

getImageIndex

public int getImageIndex(int intImageLayer)
Returns the Image index of the given Block layer.

If the Image layer is out of bounds then an error is logged (not thrown) and the method aborted.

Parameters:
intImageLayer - the Block layer who's Image index is to be returned.
Returns:
the Image index of the given Block layer.
See Also:
setImageIndex(int, int), BACKGROUND, FOREGROUND1, FOREGROUND2, FOREGROUND3

setUserData

public void setUserData(int intIndex,
                        int intNewUserData)
Sets the specified User Data.

If intIndex is out of bounds then an error is logged (not thrown) and the method aborted.

Parameters:
intIndex - the User Data to be updated.
intNewUserData - the new User Data.
See Also:
getUserData(int), MIN_USER_DATA, MAX_USER_DATA

getUserData

public int getUserData(int intIndex)
Returns the specified User Data.

If intIndex is out of bounds then an error is logged (not thrown) and the method aborted.

Parameters:
intIndex - the User Data to be returned.
Returns:
intNewUserData the specified User Data.
See Also:
setUserData(int, int), MIN_USER_DATA, MAX_USER_DATA

setFlag

public void setFlag(int intFlag,
                    boolean blnNewFlag)
Sets the specified Flag.

If intFlag is unknown then an error is logged (not thrown) and the method aborted.

Parameters:
intFlag - the Flag to be set.
blnNewFlag - the new Flag.
See Also:
getFlag(int), COLLISION_TOP_LEFT, COLLISION_TOP_RIGHT, COLLISION_BOTTOM_LEFT, COLLISION_BOTTOM_RIGHT, TRIGGER, UNUSED1, UNUSED2, UNUSED3

getFlag

public boolean getFlag(int intFlag)
Returns the specified Flag.

If intFlag is unknown then an error is logged (not thrown) and the method aborted.

Parameters:
intFlag - the Flag to be returned.
Returns:
blnNewFlag the specified Flag.
See Also:
setFlag(int, boolean), COLLISION_TOP_LEFT, COLLISION_TOP_RIGHT, COLLISION_BOTTOM_LEFT, COLLISION_BOTTOM_RIGHT, TRIGGER, UNUSED1, UNUSED2, UNUSED3

debug

public void debug(java.lang.String strText)
Logs the Block's current state.

Parameters:
strText - the purpose of the debug, this decription is logged along with the Block's state.