GroundLookup Actionscript
Table of contents | Previous document | Download GroundLookup.as | SWF!T Homepage RCSfile: GroundLookup.as,v Revision: 1.1 Date: 2003/04/20 13:13:18
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.
Lookup script for the ground generator. We should input a x-value inside a clip that we want to compare to the ground. Both the ground clip and this clip should reside in the same movie clip.
author Olaf Havnes
version Revision: 1.1 Date: 2003/04/20 13:13:18
since SWFIT1.0
Adjust for offset
find_point_x = _x + val_x + 1;
Find the left-most block of the landscape
which_left = _parent.ground.clip_counter + 1;
if (which_left == _parent.ground.NUM_CLIPS) which_left = 0;
left_point = _parent.ground._x + getProperty ("../ground/clip_" add which_left, _x);
Find the difference
diff = find_point_x - left_point;
block0 = int (diff / _parent.ground.STEP) + which_left;
block1 = block0 + 1;
Make sure we don't loop over the top
if (block0 >= _parent.ground.NUM_CLIPS) block0 -= _parent.ground.NUM_CLIPS;
if (block1 >= _parent.ground.NUM_CLIPS) block1 -= _parent.ground.NUM_CLIPS;
Measure the x values
dp0 = find_point_x - _parent.ground._x - getProperty ("../ground/clip_" add block0, _x);
dp1 = _parent.ground._x + getProperty ("../ground/clip_" add block1, _x) - find_point_x;
Measure the y values
val_y =
_parent.ground._y - _y +
(
dp1 * getProperty ("../ground/clip_" add block0, _y) +
dp0 * getProperty ("../ground/clip_" add block1, _y)
) / _parent.ground.STEP;
|
|