summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrank v/d Haterd <f.h.a.v.d.haterd@student.tue.nl>2013-11-29 20:19:00 +0100
committerFrank v/d Haterd <f.h.a.v.d.haterd@student.tue.nl>2013-11-29 20:19:00 +0100
commit2249b8e339be17f809d4a021f63ffa57a760454c (patch)
tree7126e37a81a06ed25b41888faa7d1f08239c954f
parentd5ff8057382a4e1dd2c84fc77b563095b63324ed (diff)
download2iv60-robots-2249b8e339be17f809d4a021f63ffa57a760454c.tar.gz
drawRobots method in RobotRace class added. 3 out of 4 materials modified to reflect assignment.
minor changes
-rw-r--r--src/RobotRace.java41
1 files changed, 21 insertions, 20 deletions
diff --git a/src/RobotRace.java b/src/RobotRace.java
index 6919422..77dcd98 100644
--- a/src/RobotRace.java
+++ b/src/RobotRace.java
@@ -203,29 +203,31 @@ public class RobotRace extends Base {
drawAxisFrame();
}
- // Draw the first robot
- robots[0].draw(gs.showStick);
-
+ // Draw the robots
+ drawRobots();
+
// Draw race track
raceTrack.draw(gs.trackNr);
// Draw terrain
terrain.draw();
-
- // Unit box around origin.
- //glut.glutWireCube(1f);
-
- // Move in x-direction.
- gl.glTranslatef(2f, 0f, 0f);
-
- // Rotate 30 degrees, around z-axis.
- gl.glRotatef(30f, 0f, 0f, 1f);
-
- // Scale in z-direction.
- gl.glScalef(1f, 1f, 2f);
-
- // Translated, rotated, scaled box.
- //glut.glutWireCube(1f);
+ }
+
+ /**
+ * Draw all four robots in the robots array on the scene
+ */
+ private void drawRobots() {
+ // Draw all four robots on the x-axis
+ for (int i = 0; i < 4; i++) {
+ gl.glPushMatrix();
+
+ // Place the robots on a line based on the current robot
+ gl.glTranslatef(-1.5f + i * 1f, 0f, 0f);
+
+ // Draw the current robot
+ robots[i].draw(gs.showStick);
+ gl.glPopMatrix();
+ }
}
/**
@@ -305,6 +307,5 @@ public class RobotRace extends Base {
System.out.println("JOGL version: " +
com.jogamp.opengl.JoglVersion.getInstance().getImplementationBuild());
RobotRace robotRace = new RobotRace();
- }
-
+ }
}