summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Wu <lekensteyn@gmail.com>2014-01-08 13:41:15 +0100
committerPeter Wu <lekensteyn@gmail.com>2014-01-08 13:41:15 +0100
commit4910928e236a4a2e783934952cce74eb58872f9e (patch)
treef6bb6ac634132749a695ce038945211cb3961dba
parent803ddd508a6057ad6fc4efd6999f6027dc23ae47 (diff)
download2iv60-robots-4910928e236a4a2e783934952cce74eb58872f9e.tar.gz
Make RobotRace instance available to Robot
-rw-r--r--src/Robot.java8
-rw-r--r--src/RobotRace.java2
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