diff options
author | Peter Wu <lekensteyn@gmail.com> | 2013-11-28 16:26:01 +0100 |
---|---|---|
committer | Peter Wu <lekensteyn@gmail.com> | 2013-11-28 16:26:01 +0100 |
commit | 3d92b15c6c0388f8e6407f3e4b1030b30006549b (patch) | |
tree | 2fa96333c069b317570f9e403431e9787c504814 | |
parent | 38646f392acabc9cefc1f13180a497cbe14cf0b6 (diff) | |
download | 2iv60-robots-3d92b15c6c0388f8e6407f3e4b1030b30006549b.tar.gz |
Put robot on axis instead of center, fix stick figure control
-rw-r--r-- | src/RobotRace.java | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/RobotRace.java b/src/RobotRace.java index c7733a3..c4f9aec 100644 --- a/src/RobotRace.java +++ b/src/RobotRace.java @@ -197,7 +197,7 @@ public class RobotRace extends Base { } // Draw the first robot - robots[0].draw(false); + robots[0].draw(gs.showStick); // Draw race track raceTrack.draw(gs.trackNr); @@ -364,7 +364,11 @@ public class RobotRace extends Base { * Draws this robot (as a {@code stickfigure} if specified). */ public void draw(boolean stickFigure) { - if (stickFigure) { + // as the components are drawn with the torso as center, move it up + gl.glPushMatrix(); + gl.glTranslatef(0, 0, torsoHeight / 2 + legLength); + + if (!stickFigure) { // Draw the robot drawTorso(); // Torso drawShoulders(); // Shoulders @@ -375,7 +379,9 @@ public class RobotRace extends Base { // Draw the stick figure drawStickFigure(); } - + + // restore position + gl.glPopMatrix(); } /** |