2 * Copyright (c) 2002 Erik Rasmussen - All Rights Reserverd
6 import appletbots
.geometry
.Point
;
7 import appletbots
.geometry
.Vector
;
10 * This object contains the location and velocity values for an object in the
13 * @author Erik Rasmussen
15 public class WorldObjectData
18 * The object's location
20 private Point location
;
22 * The object's velocity
24 private Vector velocity
;
28 private WorldObject object
;
31 * Constructs a new WorldObjectData with the given location and velocity
32 * values for the given object
34 * @param location The location of the object
35 * @param velocity The velocity of the object
36 * @param object The object
38 public WorldObjectData(final Point location
, final Vector velocity
, final WorldObject object
)
40 this.location
= location
;
41 this.velocity
= velocity
;
46 * Returns the location of the object. Note that the point returned is a
47 * clone of the internal location point, so changing the returned point
48 * will not affect the object's location. To modify the object's location,
49 * use setLocation(Point).
51 * @return The location of the object
53 public Point
getLocation()
55 return (Point
) location
.clone();
59 * Sets the location of the object
61 * @param location Sets the location of the object
63 public void setLocation(final Point location
)
65 this.location
= (Point
) location
.clone();
69 * Returns the velocity of the object. Note that the vector returned is a
70 * clone of the internal velocity vector, so changing the returned vector
71 * will not affect the object's velocity. To modify the object's velocity,
72 * use setVelocity(Vector).
74 * @return The velocity of the object
76 public Vector
getVelocity()
78 return (Vector
) velocity
.clone();
82 * Sets the velocity of the object
84 * @param velocity The velocity of the object
86 public void setVelocity(final Vector velocity
)
88 this.velocity
= (Vector
) velocity
.clone();
89 if (this.velocity
.getLength() > object
.getMaxSpeed())
90 this.velocity
= this.velocity
.setLength(object
.getMaxSpeed());
98 public WorldObject
getObject()