summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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();
- }
-
+ }
}