RoboMetricsLoop Actionscript

Table of contents | Previous document | Download RoboMetricsLoop.as | SWF!T Homepage

RCSfile: RoboMetricsLoop.as,v  Revision: 1.3  Date: 2003/04/22 14:28:12  

Copyright 2003 Orgdot AS. All Rights Reserved. http://dev.swfit.com
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.


Loop script for the geometric robot.
author      Olaf Havnes
version     Revision: 1.3  Date: 2003/04/22 14:28:12  
since       SWFIT1.0


We have gotten an upward push from the leg - and the body is pulling us down.

body_acc_sum = BODY_ACC + leg_push * LEG_PUSH_ACC - (body_y / 100);
body_speed += body_acc_sum - body_speed * BODY_FR;
body_y += body_speed;
body._y = body_y;
leg_push = 0;

Do the rotation...

body_angle = body.rotation_mult;
i = 0;
while (i < body.NUM_PEGS)
{

The clip to manipulate

   leg_name = "leg_" add i;

Rotate the leg pieces. Find upward thrust.

   set (leg_name add ":body_angle", body_angle);
   call (leg_name add ":rotate");

Test for ground hit.

   val_x = eval (leg_name add ":leg_x");
   #include "_scripts/GroundLookup.as"
   if (eval (leg_name add ":leg_y") > val_y)
   {
       set (leg_name add ":touch_ground", true);
       set (leg_name add ":ground_y", val_y);
   }
   else
   {
       set (leg_name add ":touch_ground", false);
   }

Render the leg pieces

   call (leg_name add ":render");

Go to the next leg

   i++;
   body_angle += body.peg_angle_step;
   if (body_angle >= /:NUM_DEG) body_angle -= /:NUM_DEG;
}