MathPathRollerLoop Actionscript

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

RCSfile: MathPathRollerLoop.as,v  Revision: 1.3  Date: 2003/02/17 01:09:49  

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 for the MathPath roller sprite.
author      Olaf Havnes
version     Revision: 1.3  Date: 2003/02/17 01:09:49  
since       SWFIT1.0


_visible = true;

x += _parent.x_speed;
if (x > x1)
{
   _parent.tot_coins --;
   removeMovieClip ("");
}

We roll along a cubic polygon. (Remember that a negative Y is up.)

path_y = - ( 2 * x * x * x + x * x - x);

Compute the Y-speed

v -= mg;
old_y = y;
y += v;

if (y > old_y) top = y;

Should we make a sound ?

gap = path_y - y;
if (gap * gap < gap_size * gap_size && (top - y) > fall_size)
{
   tellTarget ("clink")
   {
       gotoAndPlay ("clink");
   }
}

Are we below the path ?

if (y < path_y)
{
   y = path_y + gap;
   v = - v * fr;
   y_max = y;
   if (roto_step < max_roto) roto_step += roto_grow;
}

_x = /:SCALE_FACTOR_X * x;
_y = - /:SCALE_FACTOR_Y * y;

roll_g._rotation += roto_step;
roll_g._xscale = 100;
roll_g._yscale = 100;