HandLoop Actionscript
Table of contents | Previous document | Download HandLoop.as | SWF!T Homepage RCSfile: HandLoop.as,v Revision: 1.6 Date: 2003/03/05 19:52:16
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 ACGT dispenser.
author Olaf Havnes
version Revision: 1.6 Date: 2003/03/05 19:52:16
since SWFIT1.0
if (dragging)
{
Implement the mouse interface.
xp += /:change_mouse_x;
xv = /:change_mouse_x;
Set the lock point to the closest lock point
pos_lock = int ( (xp - x_min) / pos_wdt);
gap = xp - x_min - pos_lock * pos_wdt;
if (gap > pos_hlf) pos_lock += 1;
}
else
{
Implement the keyboard interface.
xd = (x_min + pos_lock * pos_wdt) - xp;
Compute the speed based on distance we have to travel.
xv += ac * xd - fr * xv;
Set the new x pos.
xp += xv;
}
If we hit a wall, reverse the speed
if (xp < x_min)
{
xv = - xv;
xp = 2 * x_min - xp;
}
else if (xp > x_max)
{
xv = - xv;
xp = 2 * x_max - xp;
}
Are we close to a lock pos ?
x_lock = x_min + pos_lock * pos_wdt;
if ((xp - x_lock) * (xp - x_lock) < 0.5)
{
xp = x_lock;
if (drop_init && xv * xv < 0.5 && eval ("../:drag_name") ne "")
{
We are at rest, and the drop button has been pressed
drop_init = false;
drop_done = true;
Mark the drag piece with our lock pos
set ("../" add eval ("../:drag_name") add ":pos_lock", pos_lock + 1);
Play a "droppy" sound
/:drop_acgt_audio_play ++;
}
}
_x = int (xp);
if (drop_drag)
{
if (eval ("../:drag_name") ne "")
setProperty ("../" add eval ("../:drag_name"), _x, int (xp) + piece_shift);
}
|
|