From 0b144c7df87bb0c6a42bdd95267a7927bd6a20e9 Mon Sep 17 00:00:00 2001 From: Frank v/d Haterd Date: Thu, 16 Jan 2014 16:33:05 +0100 Subject: Camera: FPS mode now follows last robot in race (see assignment). New getLastRobot method and getter in Robot.java --- src/Camera.java | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) 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; -- cgit v1.2.1