summaryrefslogtreecommitdiff
path: root/src/Robot.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/Robot.java')
-rw-r--r--src/Robot.java13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/Robot.java b/src/Robot.java
index 5e24a36..612ecec 100644
--- a/src/Robot.java
+++ b/src/Robot.java
@@ -87,7 +87,8 @@ class Robot extends BetterBase {
this.boneSize = 0.02f;
this.depth = 0.24f;
this.laneNo = laneNo;
- this.walkAnim = new DumbWalkAnimation();
+ this.walkAnim = new SmarterWalkAnimation(legLength / 2,
+ legLength / 2 + footHeight);
}
/**
@@ -102,14 +103,16 @@ class Robot extends BetterBase {
gl.glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, material.diffuse, 0);
gl.glMaterialfv(GL_FRONT, GL_SPECULAR, material.specular, 0);
+ // calculate rotation angles and positions for movements.
+ walkAnim.updatePosition(robot_pos_meters);
+
// save positions so it can be restored easily later
gl.glPushMatrix();
// position the center of the torso above the Z axis such that the foot
// stands on the XY plane.
- gl.glTranslatef(0, 0, torsoHeight / 2 + legLength + footHeight);
-
- // calculate rotation angles and positions for movements.
- walkAnim.updatePosition(robot_pos_meters);
+ gl.glTranslatef(0, 0, torsoHeight / 2);
+ // the length of the legs and foot are included.
+ gl.glTranslated(0, 0, walkAnim.getBottomOffset());
// Draw the robot, everything is relative to the center of torso.