MouseEngineInit Actionscript

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

RCSfile: MouseEngineInit.as,v  Revision: 1.4  Date: 2003/01/29 16:40:19  

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.


This script prepares the different aspects of the mouse engine. The user must input: clip_width, clip_height, clip_x, clip_y, delay, acceleration and friction, or they will be given default values. Regarding the cliprect, this will be based on the default flash movie size 550x400 (which very likely will be wrong, so remember to set the size in the flash movie). See MouseEngineLoop for further details.
author      Olaf Havnes
version     Revision: 1.4  Date: 2003/01/29 16:40:19  
since       SWFIT1.0


DEFAULT_CLIP_X = 50;
DEFAULT_CLIP_Y = 50;

DEFAULT_CLIP_WIDTH  = 550 - DEFAULT_CLIP_X * 2;
DEFAULT_CLIP_HEIGHT = 400 - DEFAULT_CLIP_Y * 2;


x_min = clip_x    ne "" ? clip_x      : DEFAULT_CLIP_X;
y_min = clip_y    ne "" ? clip_y      : DEFAULT_CLIP_Y;

cw = clip_width   ne "" ? clip_width  : DEFAULT_CLIP_WIDTH;
ch = clip_height  ne "" ? clip_height : DEFAULT_CLIP_HEIGHT;

x_cnt = x_min + cw / 2;
y_cnt = y_min + ch / 2;

x_max = x_min + cw;
y_max = y_min + ch;


values for the bouncing mouse tracker

DEFAULT_ACCELERATION = 0.5;
DEFAULT_FRICTION     = 0.1;


fr = friction     ne "" ? friction     : DEFAULT_FRICTION;
ac = acceleration ne "" ? acceleration : DEFAULT_ACCELERATION;

used for delayed mouse tracking

DEFAULT_DELAY = 10;
dl = delay ne "" ? delay : DEFAULT_DELAY;


some values for the simple camera model

DEFAULT_CAMERA_ROLL = 0;
croll = camera_roll ne "" ? camera_roll: DEFAULT_CAMERA_ROLL;

DEFAULT_CAMERA_DEPTH = 3;
cdepth = camera_depth ne "" ? camera_depth : DEFAULT_CAMERA_DEPTH;
cam_z = Math.sqrt (cdepth * cdepth - 2);

save some divisions and multiplications later

cam_len_sq = cdepth * cdepth;

cr_2 = croll / 2;
cw_2 = cw / 2;
ch_2 = ch / 2;

xwa = - (x_min + cw_2) / cw_2;
ywa =   (y_min + ch_2) / ch_2;

the radius of the camera back wall (45 degrees)

cos_max_cangle = 0.5;

precompute some values and store at _level0 for other scripts

/:cisect = cam_len_sq * cos_max_cangle * cos_max_cangle;
/:cam_len_sq = cam_len_sq;
/:cam_len = cam_z;

neded later

xh = 1;
yv = 1;

set the ball rolling

startDrag ("", true);