|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectgame.Trajectory
public class Trajectory
Describe the trajectory of a dart with gravity present. Units are in pixels and seconds unless otherwise noted. Warning! It is a good idea to have a separate Trajectory object associated with each MovingBody. This way, the time tracking within each one is separate. If you have an instance of a Trajectory t, then you can get a copy of it by t.copyFromStart() A better design might be to have Trajectory work on absolute time rather than increments, as then it could be shared by many MvingBody objects.
| Constructor Summary | |
|---|---|
Trajectory(Point start)
Falling body constructor for default gravity |
|
Trajectory(Point start,
Vector initialVelocity)
Constructor compatible with last week's studio. |
|
Trajectory(Point start,
Vector initialVelocity,
Vector gravity)
Most general constructor, takes in gravity as a parameter. |
|
| Method Summary | |
|---|---|
int |
advanceTime(int milliseconds)
Mark the time that has passed in milliseconds. |
static Vector |
computeGravity(int numPixels,
int t)
Compute the acceleration of gravity based on the supplied parameters, starting at rest. |
Trajectory |
copyFromStart()
Provide a copy of this trajectory back at time=0 |
Point |
getLocation()
Returns the current location. |
protected Point |
getLocation(int atTime)
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public Trajectory(Point start,
Vector initialVelocity)
start - initial pointinitialVelocity - in pixels/second, standard raster coordinates
public Trajectory(Point start,
Vector initialVelocity,
Vector gravity)
start - initialVelocity - gravity - public Trajectory(Point start)
start - | Method Detail |
|---|
public Trajectory copyFromStart()
public static Vector computeGravity(int numPixels,
int t)
numPixels - The number of pixels to be coveredt - The time taken to cover the number of pixelsprotected Point getLocation(int atTime)
atTime - specified time since start
public Point getLocation()
getLocation in interface Trackablepublic int advanceTime(int milliseconds)
advanceTime in interface Trackable
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||