feud.testgame.model
Class LocalObject

java.lang.Object
  extended byfeud.testgame.model.LocalObject
Direct Known Subclasses:
LocalBullet, LocalPlayerObject

public class LocalObject
extends java.lang.Object

The base class for any kind of object in the game world. A LocalObject can exist on the server as well as on the client. It contains everything needed to describe an object but doesn't represent the actual (3D-) view of it.


Constructor Summary
LocalObject()
          Create a new local object.
LocalObject(int clientID)
          Create a new local object for that client.
 
Method Summary
 void addToValue(int val)
          Add a number to the objects value.
 void copyFrom(LocalObject src)
          Copies the data from another local object to this one.
 boolean equals(java.lang.Object obj)
           
 int getAnimation()
          Returns the animation.
 int getAnimationSpeed()
          Returns the speed of the animation.
 int getClientID()
          Returns the client ID of this object.
 int getObjectID()
          Gets the object ID.
 com.threed.jpct.SimpleVector getPosition()
          Returns the current positoin of the object.
 com.threed.jpct.Matrix getRotation()
          Returns the current rotation matrix.
 com.threed.jpct.SimpleVector getSpeed()
          Returns a vector indicating the direction/speed of this object's current movement.
 int getType()
          Gets the type.
 int getValue()
          Returns the value of this object.
 ClientObject getView()
          Returns the view object.
 boolean hasCollided()
          Returns if this object has collided with another one.
 int hashCode()
           
 void setAnimation(int anim)
          Sets the animation.
 void setAnimationSpeed(int speed)
          Sets the speed of the animation.
 void setCollided(boolean has)
          Set a flag that this object was part of a collision (like when a bullet hits a target).
 void setObjectID(int oid)
          Sets the object id.
 void setPosition(com.threed.jpct.SimpleVector pos)
          Sets the current position of the object.
 void setRotation(com.threed.jpct.Matrix mat)
          Sets the current rotation for this object, i.e. its direction.
 void setSpeed(com.threed.jpct.SimpleVector spd)
          Sets the "speed" of the object, i.e. the direction and speed in which it's moving.
 void setType(int type)
          Sets the type of this object.
 void setValue(int val)
          Sets the objects value.
 void setView(ClientObject obj)
          Sets the view for this local object.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LocalObject

public LocalObject()
Create a new local object. Is is used to create new objects on the server that are not triggered by the client.


LocalObject

public LocalObject(int clientID)
Create a new local object for that client. This is used to create objects for a specific client. This can happen on the server as well as on a client.

Parameters:
clientID - the unique ID of that client to which this object belongs
Method Detail

addToValue

public void addToValue(int val)
Add a number to the objects value. What this value represents in the actual game context is up to the implementation of the game. Without any given context, it's simply a generic value.

Parameters:
val - the value that has to be added

getValue

public int getValue()
Returns the value of this object. What this value represents in the actual game context is up to the implementation of the game. Without any given context, it's simply a generic value.

Returns:
int

setValue

public void setValue(int val)
Sets the objects value. What this value represents in the actual game context is up to the implementation of the game. Without any given context, it's simply a generic value.

Parameters:
val - the value

setCollided

public void setCollided(boolean has)
Set a flag that this object was part of a collision (like when a bullet hits a target).

Parameters:
has - collided?

hasCollided

public boolean hasCollided()
Returns if this object has collided with another one.

Returns:
boolean true or false

copyFrom

public void copyFrom(LocalObject src)
Copies the data from another local object to this one. This is used to copy the transfered state of a remote object to the corresponding local object.

Parameters:
src - the source object

setView

public void setView(ClientObject obj)
Sets the view for this local object. On the server, there is no view. The coupling between model and view is done here. It's not very loose, because ClientObject is always a 3D-object. It doesn't matter in this example, but if you want to write a 2D client ;-), you'll have to improve this.

Parameters:
obj - the view object

getView

public ClientObject getView()
Returns the view object.

Returns:
ClientObject the view object

setAnimation

public void setAnimation(int anim)
Sets the animation. This is a constant from Animations. It's just a number. It doesn't imply an actual animation. How the view reacts to this value is up to it.

Parameters:
anim - the animation

getAnimation

public int getAnimation()
Returns the animation.

Returns:
int the animation

setAnimationSpeed

public void setAnimationSpeed(int speed)
Sets the speed of the animation.

Parameters:
speed - the speed

getAnimationSpeed

public int getAnimationSpeed()
Returns the speed of the animation.

Returns:
int the speed

setType

public void setType(int type)
Sets the type of this object. The type is a number, usually taken from a constant in ClientObjectFactory, like PLAYER or BULLET.

Parameters:
type - the type

getType

public int getType()
Gets the type.

Returns:
int the type

getClientID

public int getClientID()
Returns the client ID of this object. It has one, if it has been initialy created on a client even if it's a representation of a remote object.

Returns:
int the ID

setObjectID

public void setObjectID(int oid)
Sets the object id. This usually is the ID of the view object for this local object.

Parameters:
oid - the object ID

getObjectID

public int getObjectID()
Gets the object ID.

Returns:
int the ID

setPosition

public void setPosition(com.threed.jpct.SimpleVector pos)
Sets the current position of the object.

Parameters:
pos - the position

getPosition

public com.threed.jpct.SimpleVector getPosition()
Returns the current positoin of the object.

Returns:
SimpleVector the position

setRotation

public void setRotation(com.threed.jpct.Matrix mat)
Sets the current rotation for this object, i.e. its direction.

Parameters:
mat - the rotation matrix

getRotation

public com.threed.jpct.Matrix getRotation()
Returns the current rotation matrix.

Returns:
Matrix the rotation

setSpeed

public void setSpeed(com.threed.jpct.SimpleVector spd)
Sets the "speed" of the object, i.e. the direction and speed in which it's moving.

Parameters:
spd - the speed

getSpeed

public com.threed.jpct.SimpleVector getSpeed()
Returns a vector indicating the direction/speed of this object's current movement.

Returns:
SimpleVector the speed

equals

public boolean equals(java.lang.Object obj)

hashCode

public int hashCode()