From 3d92b15c6c0388f8e6407f3e4b1030b30006549b Mon Sep 17 00:00:00 2001 From: Peter Wu Date: Thu, 28 Nov 2013 16:26:01 +0100 Subject: Put robot on axis instead of center, fix stick figure control --- src/RobotRace.java | 12 +++++++++--- 1 file 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(); } /** -- cgit v1.2.1