diff options
author | Peter Wu <lekensteyn@gmail.com> | 2013-12-20 00:31:38 +0100 |
---|---|---|
committer | Peter Wu <lekensteyn@gmail.com> | 2013-12-20 00:31:38 +0100 |
commit | 3ab8042ed072d34aee3e270f3aa4fcb053939ee5 (patch) | |
tree | b1ecf6282174960ff4e6641b60d695dd08eb455a /src/Robot.java | |
parent | 11c44ac986042590121f00d02c660a57bcc51aa7 (diff) | |
download | 2iv60-robots-3ab8042ed072d34aee3e270f3aa4fcb053939ee5.tar.gz |
WIP: robot movements, adapt Helicopter view to new code
Misc fixes: fix up vector when changing to default view, fix wrong
scale for getPointForLane, fix comment typo in
Robot.thisFunctionDoesAbsolutelyNothing.
New bugs: robot does not look forward; to be done: do not use
static speed.
Diffstat (limited to 'src/Robot.java')
-rw-r--r-- | src/Robot.java | 35 |
1 files changed, 34 insertions, 1 deletions
diff --git a/src/Robot.java b/src/Robot.java index 3fe4377..ba90dea 100644 --- a/src/Robot.java +++ b/src/Robot.java @@ -36,6 +36,16 @@ class Robot extends BetterBase { private boolean asStickFigure; /** + * Robot speed (on track) in meters per second. + */ + private double speed; + + /** + * Location of the robot on the track (in terms of GlobalState time). + */ + private double robot_time_pos; + + /** * Constructs the robot with initial parameters. */ public Robot(Material material) { @@ -308,8 +318,31 @@ class Robot extends BetterBase { /** * This function does nothing, its use is described at the caller in - * Rboot.draw(). + * Robot.draw(). */ private void thisFunctionDoesAbsolutelyNothing() { } + + /** + * Determine the location of the robot on the track. + * @return A positive number (time). + */ + public double getTimePos() { + return robot_time_pos; + } + + /** + * Set the speed (meters per second) for this robot. + */ + public void setSpeed(double speed) { + this.speed = speed; + } + + /** + * Move the robot with the number of seconds based on its current speed. + */ + public void walkSome(double seconds) { + assert seconds >= 0 : "Robot cannot walk backwards!"; + robot_time_pos += speed * seconds; + } } |