initial commit
[applet-bots.git] / src / appletbots / WorldObjectData.java
blob4e5e9d32c0e818f5ee4e4fbbee6614041344b583
1 /*
2 * Copyright (c) 2002 Erik Rasmussen - All Rights Reserverd
3 */
4 package appletbots;
6 import appletbots.geometry.Point;
7 import appletbots.geometry.Vector;
9 /**
10 * This object contains the location and velocity values for an object in the
11 * world
13 * @author Erik Rasmussen
15 public class WorldObjectData
17 /**
18 * The object's location
20 private Point location;
21 /**
22 * The object's velocity
24 private Vector velocity;
25 /**
26 * The object
28 private WorldObject object;
30 /**
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;
42 this.object = object;
45 /**
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();
58 /**
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();
68 /**
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();
81 /**
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());
93 /**
94 * Returns the object
96 * @return The object
98 public WorldObject getObject()
100 return object;