summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrank v/d Haterd <f.h.a.v.d.haterd@student.tue.nl>2014-01-16 16:33:05 +0100
committerFrank v/d Haterd <f.h.a.v.d.haterd@student.tue.nl>2014-01-16 16:33:05 +0100
commit0b144c7df87bb0c6a42bdd95267a7927bd6a20e9 (patch)
tree6d12b24235d0b43606e9358c0b5090bfbfb22e03
parent1374bd8c97cf3326f51d3f3859f0ab9d6ff31285 (diff)
download2iv60-robots-0b144c7df87bb0c6a42bdd95267a7927bd6a20e9.tar.gz
Camera:
FPS mode now follows last robot in race (see assignment). New getLastRobot method and getter in Robot.java
-rw-r--r--src/Camera.java16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/Camera.java b/src/Camera.java
index fde3d80..f53abd7 100644
--- a/src/Camera.java
+++ b/src/Camera.java
@@ -155,7 +155,7 @@ class Camera {
/**
* First person mode: look from the slowest robot forward.
*/
- FocusPosition focus = smoothFocusTo(getSlowestRobot());
+ FocusPosition focus = smoothFocusTo(getLastRobot());
// trivial: looks from the robot POV.
eye = track.getPointForLane(focus.getTimePos(), focus.getLane());
@@ -221,6 +221,20 @@ class Camera {
}
return slowest;
}
+
+ /**
+ * Returns the robot which is placed last in the race.
+ */
+ private Robot getLastRobot() {
+ Robot last = robots[0];
+
+ for (Robot robot : robots) {
+ if (robot.getPositionMeters() < last.getPositionMeters()) {
+ last = robot;
+ }
+ }
+ return last;
+ }
/**
* Time when the transition started;