-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPath.java
More file actions
43 lines (39 loc) · 1.06 KB
/
Path.java
File metadata and controls
43 lines (39 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import java.awt.Point;
/**
* This class stores and processes paths that sprites can follow.
*
* @author John Kurlak (kurlak)
* Weston Thayer (weston5)
* Panhavorn Hok (onehok1)
* @version 12.07.09
*/
public class Path
{
private String xFunction;
private String yFunction;
/**
* This constructor creates a new path for a sprite to follow.
*
* @param xPath A parameterized function of t representing the x
* coordinate
* @param yPath A parameterized function of t representing the y
* coordinate
*/
public Path(String xPath, String yPath)
{
xFunction = xPath;
yFunction = yPath;
}
/**
* This method retrieves the location of the sprite for a given value of t.
*
* @param t The time at which you would like to get the location
* @return Returns a point corresponding to the sprite's location
*/
public Point getLocation(int t)
{
int x = ExpressionParser.evaluate(xFunction, t);
int y = ExpressionParser.evaluate(yFunction, t);
return new Point(x, y);
}
}