Class CollisionHandler

java.lang.Object
  |
  +--CollisionHandler

public class CollisionHandler
extends java.lang.Object
implements LocationHandler

This class implements the simple two dimensional collision handling.


Field Summary
protected static int FIELD_HIGH
          Playfield high
protected static int FIELD_WIDTH
          Playfield width
protected  boolean m_bCollision
          Collision state
protected static byte[][] m_byarrCollision
          Two dimensional collision array
protected  javax.vecmath.Point3f m_cCollPoint
          Collision location
protected  int m_iLastX
          Previous player location at the last frame.
protected  int m_iLastY
          Previous player location at the last frame.
protected static Tron3D m_theApp
          Reference to main application
 
Constructor Summary
CollisionHandler(javax.vecmath.Point3f cStartPoint)
          Initializes the collision array and sets the surrounding walls.
 
Method Summary
 void AddCorner(javax.vecmath.Point3f p)
          This method should be called at each turn of the player.
 javax.vecmath.Point3f getCollPoint()
          Returns the location of the collision.
 boolean isCollision()
          Returns the status of a collision.
 void SetLocation(javax.vecmath.Point3f p)
          Sets the current location of the player in the collision matrix and checks for a collision.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FIELD_WIDTH

protected static final int FIELD_WIDTH
Playfield width

FIELD_HIGH

protected static final int FIELD_HIGH
Playfield high

m_byarrCollision

protected static byte[][] m_byarrCollision
Two dimensional collision array

m_theApp

protected static Tron3D m_theApp
Reference to main application

m_bCollision

protected boolean m_bCollision
Collision state

m_iLastX

protected int m_iLastX
Previous player location at the last frame.

m_iLastY

protected int m_iLastY
Previous player location at the last frame.

m_cCollPoint

protected javax.vecmath.Point3f m_cCollPoint
Collision location
Constructor Detail

CollisionHandler

public CollisionHandler(javax.vecmath.Point3f cStartPoint)
Initializes the collision array and sets the surrounding walls.
Parameters:
cStartPoint - Start point of the player
Method Detail

isCollision

public final boolean isCollision()
Returns the status of a collision.
Returns:
true if a collision happened. false for no collision.

getCollPoint

public final javax.vecmath.Point3f getCollPoint()
Returns the location of the collision.
Returns:
The two dimensional collision point.

SetLocation

public void SetLocation(javax.vecmath.Point3f p)
Sets the current location of the player in the collision matrix and checks for a collision. This method should be called once per frame.
Specified by:
SetLocation in interface LocationHandler
Parameters:
p - Current location of the player.

AddCorner

public void AddCorner(javax.vecmath.Point3f p)
This method should be called at each turn of the player. (Has currently no special function but could be used for future enhancements).
Specified by:
AddCorner in interface LocationHandler
Parameters:
p - Location of the corner.