From 4910928e236a4a2e783934952cce74eb58872f9e Mon Sep 17 00:00:00 2001 From: Peter Wu Date: Wed, 8 Jan 2014 13:41:15 +0100 Subject: Make RobotRace instance available to Robot --- src/Robot.java | 8 +++++++- src/RobotRace.java | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/Robot.java b/src/Robot.java index 043cc1c..aa6c539 100644 --- a/src/Robot.java +++ b/src/Robot.java @@ -9,6 +9,11 @@ import javax.media.opengl.fixedfunc.GLLightingFunc; */ class Robot extends BetterBase { private final Color boneColor = Colors.CHOCOLATE; + /** + * The robot race in which this robot it participating (used for texture + * stuff for example). + */ + private final RobotRace race; /** The material from which this robot is built. */ private final Material material; @@ -54,7 +59,8 @@ class Robot extends BetterBase { /** * Constructs the robot with initial parameters. */ - public Robot(Material material, int laneNo) { + public Robot(RobotRace race, Material material, int laneNo) { + this.race = race; /* Set all parameters of the robot */ this.material = material; this.torsoHeight = 0.6f; diff --git a/src/RobotRace.java b/src/RobotRace.java index b38ea18..7a7689b 100644 --- a/src/RobotRace.java +++ b/src/RobotRace.java @@ -165,7 +165,7 @@ public class RobotRace extends Base { assert materials.length == robots.length; for (int i = 0; i < materials.length; i++) { // different material color; each robot walks its own lane. - robots[i] = new Robot(materials[i], i); + robots[i] = new Robot(this, materials[i], i); } // Initialize the race track -- cgit v1.2.1