short attention span
home
luminance
project blogs
documentation
video clips
behind the screen
links
contact us


A late fish movement prototype. The orange fish in this version react more drastically to the cursor and to being touched, and there is a deeper layer of non-interactive fish to give more context to the scene.

The basic movement is governed by the custom functions:

private function turn(){
var xRef = this._x - destX;
var yRef = this._y - destY;
var rad = Math.atan2(yRef, xRef);
this._rotation = (rad*180/Math.PI);
}
and
private function move(){
var xRate = (destX - this._x)/swimRate;
var yRate = (destY - this._y)/swimRate;
if(Math.abs(xRate * yRate) > 20){
this.gotoAndStop("fast");
}
else if(Math.abs(xRate * yRate) > 5){
this.gotoAndStop("medium");
}
else{
this.gotoAndStop("slow");
}
oldX = this._x;
oldY = this._y;
this._x += xRate;
this._y += yRate;
}

which were both written by Scott. These govern the movement and rotation of the fish, as well as the swapping of the swim animation to reflect different movement speeds. The interactive functions are very similar to those used in the Eye.

Basically, each fish has a 'destination point' on the stage that it swims toward, starting at a higher speed and algorithmically decelerating as it gets closer. This destination point is programmed to wander randomly at a very low speed. If the fish manages to get close enough this point, a new point is chosen.

Since the fish's movement speed decreases in direct proportion to its proximity, this is a rough example of Zeno's Paradox. While this poses the risk of collapsing linear time, we sidestep this problem by setting a distance threshold of 9 pixels that triggers choosing a new destination point. As an added bonus, we get a neat little behavior where the fish seems to linger at its destination as if it found something of interest there before it gets "bored" and moves on.

back to Behind the Screen

Last Update Date: March 15, 2005



Creative Commons License
This work is licensed under a Creative Commons License.