Section 1
//ABowmanLink (ABowmanLink)
package {
import flash.display.*;
import flash.events.*;
import flash.text.*;
import flash.net.*;
class ABowmanLink extends Sprite {
private var myFont:Class;
var aBowman:Sprite;
var mask_minWidth:Number;// = 18
var aBowmanMask:Sprite;
var aBowmanCon:Sprite;
var mask_width:Number;
var mask_maxWidth:Number;// = 70
var mask_height:Number;// = 25
function ABowmanLink(_arg1:String, _arg2:Number){
mask_maxWidth = 70;
mask_minWidth = 18;
mask_height = 25;
mask_width = mask_minWidth;
super();
init(_arg1, _arg2);
}
function init(_arg1:String, _arg2:Number){
var pupcat:Font;
var request:URLRequest;
var field:TextField;
var fmt:TextFormat;
var expand:Function;
var shrink:Function;
var url = _arg1;
var color = _arg2;
expand = function (){
mask_width = (mask_width + ((mask_maxWidth - mask_width) * 0.2));
if ((mask_maxWidth - mask_width) < 0.1){
aBowman.removeEventListener(Event.ENTER_FRAME, expand);
trace("expand removed");
};
renderMask();
};
shrink = function (){
mask_width = (mask_width - ((mask_width - mask_minWidth) * 0.2));
if ((mask_width - mask_minWidth) < 0.1){
aBowman.removeEventListener(Event.ENTER_FRAME, shrink);
trace("shrink removed");
};
renderMask();
};
pupcat = new Pupcat();
request = new URLRequest(url);
field = new TextField();
fmt = new TextFormat();
fmt.color = 0xFFFFFF;
fmt.font = pupcat.fontName;
fmt.size = 18;
field.embedFonts = true;
field.defaultTextFormat = fmt;
field.text = "aBowman";
aBowmanCon = new Sprite();
aBowman = new Sprite();
addChild(aBowman);
aBowman.addChild(field);
aBowmanMask = new Sprite();
addChild(aBowmanMask);
aBowman.addEventListener(MouseEvent.ROLL_OVER, function (){
aBowman.removeEventListener(Event.ENTER_FRAME, shrink);
aBowman.addEventListener(Event.ENTER_FRAME, expand);
});
aBowman.addEventListener(MouseEvent.ROLL_OUT, function (){
aBowman.removeEventListener(Event.ENTER_FRAME, expand);
aBowman.addEventListener(Event.ENTER_FRAME, shrink);
});
aBowman.buttonMode = true;
aBowman.mouseChildren = false;
aBowman.addEventListener(MouseEvent.MOUSE_UP, function (){
navigateToURL(request, "_top");
});
renderMask();
aBowman.mask = aBowmanMask;
}
function renderMask(){
aBowmanMask.graphics.clear();
aBowmanMask.graphics.beginFill(0);
aBowmanMask.graphics.drawRect(0, 0, mask_width, mask_height);
aBowmanMask.graphics.endFill();
}
}
}//package
Section 2
//Application (Application)
package {
import flash.display.*;
import flash.events.*;
import flash.geom.*;
import flash.filters.*;
public class Application extends MovieClip {
var link:ABowmanLink;
var waterB:Sprite;
var water:Shape;
var groundColor:Number;// = 0xEEEEEE
var stageH:Number;
var numflakes:Number;// = 27
var mouseOver:Boolean;
var stageW:Number;
var msActive:Boolean;// = false
var inactiveFlakes:Array;
var slider1:Slider;
var msInactiveCnt:Number;// = 0
var ground:Sprite;
var numTurtles:Number;// = 2
var msInactiveMax:Number;// = 300
var turtles:Array;
var waterColor:Number;// = 13688037
var activeFlakes:Array;
var rampWidth:Number;// = 40
var percentWater:Number;// = 0.75
var waterWidth:Number;
public function Application(){
numflakes = 27;
rampWidth = 40;
waterColor = 13688037;
groundColor = 0xEEEEEE;
numTurtles = 2;
percentWater = 0.75;
msActive = false;
msInactiveCnt = 0;
msInactiveMax = 300;
super();
addEventListener(Event.ENTER_FRAME, getStageDimensions);
}
function makeFoodInactive(_arg1:Food){
var _local2:*;
var _local3:*;
inactiveFlakes.push(_arg1);
_arg1.visible = false;
_local2 = activeFlakes.length;
_local3 = 0;
while (_local3 < _local2) {
if (activeFlakes[_local3] == _arg1){
activeFlakes.splice(_local3, 1);
break;
};
_local3++;
};
}
public function init(_arg1:Event=null){
var _local2:Number;
var _local3:Number;
var _local4:Number;
var _local5:Number;
var _local6:String;
var _local7:String;
var _local8:Object;
var _local9:Array;
var _local10:Array;
var _local11:Array;
var _local12:Number;
var _local13:Number;
var _local14:Number;
var _local15:Number;
var _local16:Number;
stageW = stage.stageWidth;
stageH = stage.stageHeight;
addEventListener(MouseEvent.MOUSE_MOVE, mouseMoveListener);
_local2 = 13421619;
_local3 = 8553040;
_local4 = 8553040;
_local5 = 6710847;
_local8 = root.loaderInfo.parameters;
if (_local8.up_numTurtles != undefined){
numTurtles = _local8.up_numTurtles;
};
if (_local8.up_width != undefined){
stageW = _local8.up_width;
};
if (_local8.up_height != undefined){
stageH = _local8.up_height;
};
if (_local8.up_waterColor != undefined){
waterColor = parseInt(("0x" + _local8.up_waterColor));
};
if (_local8.up_groundColor != undefined){
groundColor = parseInt(("0x" + _local8.up_groundColor));
};
if (_local8.up_foodColor != undefined){
_local2 = parseInt(("0x" + _local8.up_foodColor));
};
if (_local8.up_percentWater != undefined){
percentWater = _local8.up_percentWater;
};
if (percentWater >= 1){
percentWater = 1.5;
};
waterWidth = (stageW * percentWater);
for (_local6 in _local8) {
_local7 = String(_local8[_local6]);
trace(((_local6 + ":") + _local7));
};
inactiveFlakes = new Array();
activeFlakes = new Array();
_local9 = new Array();
_local10 = new Array();
_local11 = new Array();
_local12 = 0;
while (_local12 < numTurtles) {
if (_local8[(("up_turtle" + (_local12 + 1)) + "HeadColor")] != undefined){
_local9[_local12] = parseInt(("0x" + _local8[(("up_turtle" + (_local12 + 1)) + "HeadColor")]));
} else {
_local9[_local12] = _local3;
};
if (_local8[(("up_turtle" + (_local12 + 1)) + "ShellColor")] != undefined){
_local11[_local12] = parseInt(("0x" + _local8[(("up_turtle" + (_local12 + 1)) + "ShellColor")]));
} else {
_local11[_local12] = _local4;
};
if (_local8[(("up_turtle" + (_local12 + 1)) + "LegColor")] != undefined){
_local10[_local12] = parseInt(("0x" + _local8[(("up_turtle" + (_local12 + 1)) + "LegColor")]));
} else {
_local10[_local12] = _local5;
};
_local12++;
};
ground = new Sprite();
ground.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownListener);
ground.addEventListener(MouseEvent.MOUSE_UP, checkPickedUp);
addChild(ground);
waterB = new Sprite();
waterB.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownListener);
waterB.addEventListener(MouseEvent.MOUSE_UP, checkPickedUp);
addChild(waterB);
addEventListener(Event.ENTER_FRAME, update);
turtles = new Array();
_local12 = 0;
while (_local12 < numTurtles) {
turtles[_local12] = new Turtle({headColor:_local9[_local12], legColor:_local10[_local12], shellColor:_local11[_local12], name:("" + _local12), app:this, food:activeFlakes, x:(30 + ((stageW - 60) * Math.random())), y:(30 + ((stageH - 60) * Math.random())), rotation:(360 * Math.random())});
addChild(turtles[_local12]);
_local12++;
};
_local12 = 0;
while (_local12 < numflakes) {
inactiveFlakes[_local12] = new Food({color:_local2, width:3});
addChild(inactiveFlakes[_local12]);
_local12++;
};
water = new Shape();
addChild(water);
update(null);
link = new ABowmanLink("http://abowman.com/google-modules/turtle/", Draw.calcGradient(waterColor, 85));
addChild(link);
drawBackground();
update();
}
public function getStageDimensions(_arg1:Event){
if (stage.stageWidth > 0){
removeEventListener(Event.ENTER_FRAME, getStageDimensions);
init();
};
}
function checkPickedUp(_arg1:Event){
var _local2:Turtle;
var _local3:Number;
_local3 = 0;
while (_local3 < numTurtles) {
_local2 = turtles[_local3];
if (_local2.state == Turtle.PICKED_UP){
_local2.shellOnRelease(_arg1);
return;
};
_local3++;
};
}
public function drawBackground(_arg1:Object=null){
var _local2:Matrix;
var _local3:Array;
var _local4:Array;
var _local5:Array;
stageW = stage.stageWidth;
stageH = stage.stageHeight;
if (_arg1 != null){
if (_arg1.groundColor != null){
groundColor = _arg1.groundColor;
};
if (_arg1.waterColor != null){
waterColor = _arg1.waterColor;
};
};
rampWidth = 60;
ground.graphics.clear();
waterWidth = (stageW * percentWater);
ground.graphics.beginFill(groundColor);
ground.graphics.drawRect(waterWidth, 0, stageW, stageH);
ground.graphics.endFill();
waterB.graphics.clear();
waterB.graphics.beginFill(waterColor);
waterB.graphics.drawRect(0, 0, (waterWidth - rampWidth), stageH);
waterB.graphics.endFill();
_local2 = new Matrix();
_local2.createGradientBox(rampWidth, stageH, 0, (waterWidth - rampWidth));
_local3 = [waterColor, groundColor];
_local4 = [1, 1];
_local5 = [0, 0xFF];
waterB.graphics.beginGradientFill(GradientType.LINEAR, _local3, _local4, _local5, _local2);
waterB.graphics.drawRect((waterWidth - rampWidth), 0, rampWidth, stageH);
waterB.graphics.endFill();
water.graphics.clear();
water.graphics.lineStyle(1, waterColor, 0.1);
water.graphics.beginFill(waterColor, 0.1);
water.graphics.drawRect(0, 0, waterWidth, stageH);
water.graphics.endFill();
}
private function mouseDownListener(_arg1:MouseEvent):void{
var _local2:Food;
if (activeFlakes.length < numflakes){
_local2 = Food(inactiveFlakes.pop());
_local2.drop(mouseX, mouseY);
activeFlakes.push(_local2);
if (mouseX > waterWidth){
setChildIndex(_local2, (getChildIndex(ground) + 1));
} else {
setChildIndex(_local2, getChildIndex(water));
};
};
}
public function update(_arg1:Event=null){
var _local2:Number;
var _local3:Number;
var _local4:Number;
var _local5:Turtle;
var _local6:Number;
var _local7:Object;
var _local8:*;
_local2 = (waterWidth - 20);
_local3 = (_local2 - rampWidth);
_local4 = 8;
_local6 = 0;
while (_local6 < numTurtles) {
_local5 = Turtle(turtles[_local6]);
if ((((_local5.xPos > _local3)) && ((_local5.xPos < _local2)))){
_local5.setDropShadow((_local4 * ((_local2 - _local5.xPos) / rampWidth)));
} else {
if ((((_local5.xPos > _local2)) && (!((_local5.shadowDist == 0))))){
_local5.setDropShadow(0);
} else {
if ((((_local5.xPos < _local3)) && (!((_local5.shadowDist == _local4))))){
_local5.setDropShadow(_local4);
};
};
};
if (_local5.xPos > _local2){
_local5.changeMove(Turtle.WALK);
} else {
_local5.changeMove(Turtle.SWIM);
};
_local5.update();
_local6++;
};
_local8 = activeFlakes.length;
_local6 = 0;
while (_local6 < _local8) {
_local7 = activeFlakes[_local6].pos;
if ((((((((_local7.x > 0)) && ((_local7.x < waterWidth)))) && ((_local7.y > 0)))) && ((_local7.y < stageH)))){
activeFlakes[_local6].update(_arg1);
};
_local6++;
};
if (msInactiveCnt < msInactiveMax){
msInactiveCnt++;
} else {
msActive = false;
};
}
function mouseMoveListener(_arg1:MouseEvent):void{
msInactiveCnt = 0;
msActive = true;
}
function resizeHandler(_arg1:Event):void{
drawBackground();
}
}
}//package
Section 3
//Draw (Draw)
package {
import flash.display.*;
class Draw {
static function drawWedge(_arg1:Graphics, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Number, _arg6:Number, _arg7:Number){
var _local9:Number;
var _local10:Number;
var _local11:Number;
var _local12:Number;
var _local13:Number;
var _local14:Number;
var _local15:Number;
var _local16:Number;
var _local17:Number;
var _local18:Number;
var _local19:Number;
var _local20:*;
if (arguments.length < 5){
return;
};
_arg1.moveTo(_arg2, _arg3);
if (!_arg7){
_arg7 = _arg6;
};
if (Math.abs(_arg5) > 360){
_arg5 = 360;
};
_local13 = Math.ceil((Math.abs(_arg5) / 45));
_local9 = (_arg5 / _local13);
_local10 = (-((_local9 / 180)) * Math.PI);
_local11 = (-((_arg4 / 180)) * Math.PI);
if (_local13 > 0){
_local14 = (_arg2 + (Math.cos(((_arg4 / 180) * Math.PI)) * _arg6));
_local15 = (_arg3 + (Math.sin(((-(_arg4) / 180) * Math.PI)) * _arg7));
_arg1.lineTo(_local14, _local15);
_local20 = 0;
while (_local20 < _local13) {
_local11 = (_local11 + _local10);
_local12 = (_local11 - (_local10 / 2));
_local16 = (_arg2 + (Math.cos(_local11) * _arg6));
_local17 = (_arg3 + (Math.sin(_local11) * _arg7));
_local18 = (_arg2 + (Math.cos(_local12) * (_arg6 / Math.cos((_local10 / 2)))));
_local19 = (_arg3 + (Math.sin(_local12) * (_arg7 / Math.cos((_local10 / 2)))));
_arg1.curveTo(_local18, _local19, _local16, _local17);
_local20++;
};
_arg1.lineTo(_arg2, _arg3);
};
}
static function RGBToHex(_arg1:Number, _arg2:Number, _arg3:Number):Number{
var _local4:Number;
_local4 = (((_arg1 << 16) ^ (_arg2 << 8)) ^ _arg3);
return (_local4);
}
static function calcGradient(_arg1:Number, _arg2:Number):Number{
var _local3:Object;
var _local4:Object;
_local3 = hexToRGB(_arg1);
_local4 = RGBToHLS(_local3.r, _local3.g, _local3.b);
RGBToHLS(_local3.r, _local3.g, _local3.b).l = (_local4.l * (_arg2 / 100));
if (_local4.l > 240){
_local4.l = 240;
};
if (_local4.l < 0){
_local4.l = 0;
};
_local3 = HLSToRGB(_local4.h, _local4.l, _local4.s);
return (RGBToHex(_local3.r, _local3.g, _local3.b));
}
static function drawOval(_arg1:Graphics, _arg2, _arg3, _arg4, _arg5){
_arg1.moveTo((_arg2 + _arg4), _arg3);
_arg1.curveTo((_arg4 + _arg2), ((0.4142 * _arg5) + _arg3), ((0.7071 * _arg4) + _arg2), ((0.7071 * _arg5) + _arg3));
_arg1.curveTo(((0.4142 * _arg4) + _arg2), (_arg5 + _arg3), _arg2, (_arg5 + _arg3));
_arg1.curveTo(((-0.4142 * _arg4) + _arg2), (_arg5 + _arg3), ((-0.7071 * _arg4) + _arg2), ((0.7071 * _arg5) + _arg3));
_arg1.curveTo((-(_arg4) + _arg2), ((0.4142 * _arg5) + _arg3), (-(_arg4) + _arg2), _arg3);
_arg1.curveTo((-(_arg4) + _arg2), ((-0.4142 * _arg5) + _arg3), ((-0.7071 * _arg4) + _arg2), ((-0.7071 * _arg5) + _arg3));
_arg1.curveTo(((-0.4142 * _arg4) + _arg2), (-(_arg5) + _arg3), _arg2, (-(_arg5) + _arg3));
_arg1.curveTo(((0.4142 * _arg4) + _arg2), (-(_arg5) + _arg3), ((0.7071 * _arg4) + _arg2), ((-0.7071 * _arg5) + _arg3));
_arg1.curveTo((_arg4 + _arg2), ((-0.4142 * _arg5) + _arg3), (_arg4 + _arg2), _arg3);
}
static function hexToRGB(_arg1:Number):Object{
var _local2:Object;
var _local3:Number;
_local2 = new Object();
_local2.r = (_arg1 >> 16);
_local3 = (_arg1 ^ (_local2.r << 16));
_local2.g = (_local3 >> 8);
_local2.b = (_local3 ^ (_local2.g << 8));
return (_local2);
}
static function drawRect(_arg1:Graphics, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Number){
_arg1.moveTo(_arg2, _arg3);
_arg1.lineTo((_arg2 + _arg4), _arg3);
_arg1.lineTo((_arg2 + _arg4), (_arg3 + _arg5));
_arg1.lineTo(_arg2, (_arg3 + _arg5));
_arg1.lineTo(_arg2, _arg3);
}
static function HLSToRGB(_arg1:Number, _arg2:Number, _arg3:Number):Object{
var _local4:Number;
var _local5:Number;
var _local6:Number;
var _local7:*;
var _local8:*;
var _local9:*;
var _local10:*;
var _local11:*;
if (_arg3 == 0){
_local6 = Math.round(((_arg2 / 240) * 0xFF));
_local5 = _local6;
_local4 = _local5;
} else {
_arg1 = (_arg1 / 240);
_arg2 = (_arg2 / 240);
_arg3 = (_arg3 / 240);
_local9 = ((_arg2)<0.5) ? (_arg2 * (_arg3 + 1)) : ((_arg2 + _arg3) - (_arg2 * _arg3));
_local10 = ((_arg2 * 2) - _local9);
_local11 = 0;
while (_local11 < 3) {
switch (_local11){
case 0:
_local8 = (_arg1 + (1 / 3));
break;
case 1:
_local8 = _arg1;
break;
case 2:
_local8 = (_arg1 - (1 / 3));
break;
};
if (_local8 < 0){
_local8++;
} else {
if (_local8 > 1){
_local8--;
};
};
if ((_local8 * 6) < 1){
_local7 = (_local10 + (((_local9 - _local10) * 6) * _local8));
} else {
if ((_local8 * 2) < 1){
_local7 = _local9;
} else {
if ((_local8 * 3) < 2){
_local7 = (_local10 + (((_local9 - _local10) * ((2 / 3) - _local8)) * 6));
} else {
_local7 = _local10;
};
};
};
switch (_local11){
case 0:
_local4 = Math.round((_local7 * 0xFF));
break;
case 1:
_local5 = Math.round((_local7 * 0xFF));
break;
case 2:
_local6 = Math.round((_local7 * 0xFF));
break;
};
_local11++;
};
};
return ({r:_local4, g:_local5, b:_local6});
}
static function drawArc(_arg1:Graphics, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Number, _arg6:Number, _arg7:Number):Object{
var _local9:Number;
var _local10:Number;
var _local11:Number;
var _local12:Number;
var _local13:Number;
var _local14:Number;
var _local15:Number;
var _local16:Number;
var _local17:Number;
var _local18:Number;
var _local19:Number;
var _local20:*;
if (arguments.length < 5){
return (null);
};
if (!_arg7){
_arg7 = _arg4;
};
if (Math.abs(_arg5) > 360){
_arg5 = 360;
};
_local13 = Math.ceil((Math.abs(_arg5) / 45));
_local9 = (_arg5 / _local13);
_local10 = (-((_local9 / 180)) * Math.PI);
_local11 = (-((_arg6 / 180)) * Math.PI);
_local14 = (_arg2 - (Math.cos(_local11) * _arg4));
_local15 = (_arg3 - (Math.sin(_local11) * _arg7));
if (_local13 > 0){
_local20 = 0;
while (_local20 < _local13) {
_local11 = (_local11 + _local10);
_local12 = (_local11 - (_local10 / 2));
_local16 = (_local14 + (Math.cos(_local11) * _arg4));
_local17 = (_local15 + (Math.sin(_local11) * _arg7));
_local18 = (_local14 + (Math.cos(_local12) * (_arg4 / Math.cos((_local10 / 2)))));
_local19 = (_local15 + (Math.sin(_local12) * (_arg7 / Math.cos((_local10 / 2)))));
_arg1.curveTo(_local18, _local19, _local16, _local17);
_local20++;
};
};
return ({x:_local16, y:_local17});
}
static function RGBToHLS(_arg1, _arg2, _arg3):Object{
var _local4:Number;
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:Number;
var _local9:Number;
_local7 = (Math.max(Math.max(_arg1, _arg2), _arg3) / 0xFF);
_local8 = (Math.min(Math.min(_arg1, _arg2), _arg3) / 0xFF);
_local9 = (_local7 - _local8);
_local5 = ((_local7 + _local8) / 2);
_local6 = ((_local7)==_local8) ? 0 : ((_local5)<=0.5) ? ((_local9 / _local5) / 2) : (_local9 / (2 - (_local5 * 2)));
if ((_arg1 / 0xFF) == _local7){
_local4 = (((_arg2 - _arg3) / _local9) / 0xFF);
} else {
if ((_arg2 / 0xFF) == _local7){
_local4 = (2 + (((_arg3 - _arg1) / _local9) / 0xFF));
} else {
if ((_arg3 / 0xFF) == _local7){
_local4 = (4 + (((_arg1 - _arg2) / _local9) / 0xFF));
};
};
};
_local4 = (_local4 * 40);
if (_local4 < 0){
_local4 = (_local4 + 240);
};
_local4 = Math.round(_local4);
return ({h:(isNaN(_local4)) ? 0 : _local4, l:Math.round((_local5 * 240)), s:Math.round((_local6 * 240))});
}
}
}//package
Section 4
//Easer (Easer)
package {
public class Easer {
public var time:Number;// = 0
public var beginY:Number;
private var chX:Number;
private var chY:Number;
public var beginX:Number;
private var duration:Number;// = 0
private var tX:Number;
private var tY:Number;
public var ease:Function;
public var x:Number;
public var y:Number;
public static const IN_OUT_QUAD = 1;
public static const OUT_CUBIC = 2;
public static const OUT_QUINTIC = 3;
public static const IN_OUT_CUBIC = 2;
public function Easer(){
duration = 0;
time = 0;
super();
}
public function update():void{
if (time < duration){
x = ease(time++, beginX, chX, duration);
y = ease(time, beginY, chY, duration);
};
}
public function init(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Number):void{
x = (this.beginX = _arg1);
chX = (_arg2 - _arg1);
y = (this.beginY = _arg3);
chY = (_arg4 - _arg3);
this.duration = _arg5;
time = 0;
ease = noEase;
}
function isMoving():Boolean{
return ((time < duration));
}
private function inOutQuad(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number):Number{
_arg1 = (_arg1 / _arg4);
return ((_arg2 + (_arg3 * _arg1)));
}
function inOutCubic(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number):Number{
var _local5:Number;
var _local6:Number;
_arg1 = (_arg1 / _arg4);
_local5 = (_arg1 * _arg1);
_local6 = (_local5 * _arg1);
return ((_arg2 + (_arg3 * ((-2 * _local6) + (3 * _local5)))));
}
function setTarget(_arg1:Number, _arg2:Number):void{
tX = _arg1;
tY = _arg2;
}
function outCubic(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number):Number{
var _local5:Number;
var _local6:Number;
_arg1 = (_arg1 / _arg4);
_local5 = (_arg1 * _arg1);
_local6 = (_local5 * _arg1);
return ((_arg2 + (_arg3 * ((_local6 + (-3 * _local5)) + (3 * _arg1)))));
}
function noEase(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number):Number{
_arg1 = (_arg1 / _arg4);
return ((_arg2 + (_arg3 * _arg1)));
}
public function setEase(_arg1:int):void{
switch (_arg1){
case IN_OUT_QUAD:
ease = inOutQuad;
break;
case IN_OUT_CUBIC:
ease = inOutCubic;
break;
case OUT_CUBIC:
ease = outCubic;
break;
case OUT_QUINTIC:
ease = outQuintic;
break;
};
}
function outQuintic(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number):Number{
var _local5:Number;
var _local6:Number;
_arg1 = (_arg1 / _arg4);
_local5 = (_arg1 * _arg1);
_local6 = (_local5 * _arg1);
return ((_arg2 + (_arg3 * (((((_local6 * _local5) + ((-5 * _local5) * _local5)) + (10 * _local6)) + (-10 * _local5)) + (5 * _arg1)))));
}
}
}//package
Section 5
//Food (Food)
package {
import flash.display.*;
import flash.events.*;
public class Food extends Sprite {
var pos:Object;
var color:Number;
var w:Number;
var vel:Object;
public function Food(_arg1:Object){
color = _arg1.color;
w = _arg1.width;
addEventListener(MouseEvent.MOUSE_DOWN, mouseDownListener);
addEventListener(MouseEvent.MOUSE_UP, mouseUpListener);
pos = {x:0, y:0};
vel = {x:0, y:0};
draw();
rotation = (360 * Math.random());
visible = false;
}
private function mouseUpListener(_arg1:Event){
}
private function draw(){
graphics.lineStyle(3, color);
graphics.moveTo((-(w) / 2), 0);
graphics.lineTo((w / 2), 0);
graphics.endFill();
}
private function mouseDownListener(_arg1:MouseEvent):void{
}
function drawOval(_arg1:Sprite, _arg2, _arg3, _arg4, _arg5){
_arg1.graphics.drawEllipse((_arg2 - _arg4), (_arg3 - _arg5), (_arg4 * 2), (_arg5 * 2));
}
public function update(_arg1:Event){
pos.x = (pos.x + vel.x);
pos.y = (pos.y + vel.y);
x = pos.x;
y = pos.y;
}
public function drop(_arg1:Number, _arg2:Number){
vel.x = ((Math.random() - 0.5) / 5);
vel.y = ((Math.random() - 0.5) / 5);
x = (pos.x = _arg1);
y = (pos.y = _arg2);
visible = true;
trace("drop");
}
}
}//package
Section 6
//Leg (Leg)
package {
import flash.display.*;
public class Leg extends Sprite {
var strokeA:Number;
var strokeH:Number;// = 0
var thrustDir:Number;// = 0
var strokeW:Number;// = 0
var front:Boolean;
var len:Number;
var jX:Number;
var strokeDir:Number;// = 0
var jY:Number;
var easer:Easer;
var ftY:Number;
var side:Number;
var restAngle:Number;
var ftX:Number;
var color:Number;
var thrust:Number;// = 0
var foot:Sprite;
public var stVel:Number;// = 0
var seg1:Sprite;
var seg2:Sprite;
var strokeRd:Number;// = 0
var startAngle:Number;// = 0
var strokeRt:Number;// = 0
var baseX:Number;
var baseY:Number;
public var stAng:Number;// = 0
var fb:Number;// = 1
var base:Object;
var length:Number;
var stFric:Number;// = 0.95
public function Leg(_arg1:Object){
startAngle = 0;
strokeH = 0;
strokeW = 0;
strokeRt = 0;
strokeRd = 0;
strokeDir = 0;
thrustDir = 0;
thrust = 0;
fb = 1;
stAng = 0;
stVel = 0;
stFric = 0.95;
super();
color = _arg1.color;
side = _arg1.side;
length = _arg1.length;
front = _arg1.front;
len = (length * 1.1);
color = _arg1.color;
restAngle = _arg1.restAngle;
easer = new Easer();
base = _arg1.base;
startAngle = _arg1.startAngle;
strokeA = _arg1.strokeA;
strokeRd = _arg1.strokeRd;
strokeRt = _arg1.strokeRt;
foot = new Sprite();
addChild(foot);
seg1 = new Sprite();
seg2 = new Sprite();
addChild(seg1);
addChild(seg2);
seg1.graphics.lineStyle(3, color);
seg1.graphics.lineTo((len / 2), 0);
seg2.graphics.lineStyle(3, color);
seg2.graphics.lineTo((len / 2), 0);
}
public function shiftFoot(_arg1:Number, _arg2:Number){
easer.x = (easer.x + _arg1);
easer.y = (easer.y + _arg2);
ftX = easer.x;
ftY = easer.y;
easer.beginX = (easer.beginX + _arg1);
easer.beginY = (easer.beginY + _arg2);
}
function setJoints(){
var _local1:Number;
var _local2:Number;
var _local3:Number;
var _local4:Number;
_local1 = (length * 0.5);
_local2 = angleTo(base.x, base.y, ftX, ftY);
_local3 = distTo(base.x, base.y, ftX, ftY);
_local4 = Math.asin(Math.min(1, ((_local3 / 2) / length)));
}
function stroke(_arg1:Number, _arg2:Number){
var _local3:Number;
var _local4:Number;
var _local5:Number;
var _local6:Number;
_arg1 = (_arg1 + startAngle);
baseX = (base.x + (Math.cos(((-(side) * strokeA) + _arg2)) * strokeRd));
baseY = (base.y + (Math.sin(((-(side) * strokeA) + _arg2)) * strokeRd));
_local5 = Math.sin((fb * _arg1));
_local6 = Math.sin(((fb * _arg1) + (Math.PI / 2)));
ftX = ((baseX + (((side * Math.cos((((side * strokeRt) + (Math.PI / 2)) + _arg2))) * _local6) * strokeW)) + ((Math.cos(((side * strokeRt) + _arg2)) * _local5) * strokeH));
ftY = ((baseY + (((side * Math.sin((((side * strokeRt) + (Math.PI / 2)) + _arg2))) * _local6) * strokeW)) + ((Math.sin(((side * strokeRt) + _arg2)) * _local5) * strokeH));
foot.scaleY = Math.sin((fb * _arg1));
setJoints();
}
function resetLeg(_arg1:Number, _arg2:Number){
var _local3:Number;
var _local4:Number;
_local3 = (base.x + (Math.cos((_arg1 - (side * restAngle))) * length));
_local4 = (base.y + (Math.sin((_arg1 - (side * restAngle))) * length));
easer.init(ftX, _local3, ftY, _local4, _arg2);
}
function setStroke(_arg1:Number, _arg2:Number){
this.strokeH = _arg1;
this.strokeW = _arg2;
}
public function swimMoveLegs(_arg1:Number, _arg2:Number, _arg3:Number=0.2){
if (_arg1 == 0){
if (stAng < 0){
stAng = (stAng + (Math.PI * 100));
};
if (stVel > 0){
stVel = (((Math.PI * 2) - ((stAng % Math.PI) * 2)) * 0.1);
} else {
stVel = (((-(stAng) % Math.PI) * 2) * 0.1);
};
};
stVel = (stVel + _arg1);
stVel = (stVel * stFric);
stVel = Math.min(_arg3, stVel);
stVel = Math.max(-(_arg3), stVel);
stAng = (stAng + stVel);
stroke(((stAng % Math.PI) * 2), _arg2);
}
function setLeg(_arg1:Number, _arg2:Number, _arg3:Number){
ftX = (base.x + (Math.cos((_arg3 - (side * restAngle))) * length));
ftY = (base.y + (Math.sin((_arg3 - (side * restAngle))) * length));
easer.init(ftX, ftX, ftY, ftY, 0);
}
public function drawFrontFoot(){
foot.graphics.lineStyle(2, color);
foot.graphics.lineTo(0, 0);
foot.graphics.lineTo((side * 4), 1);
foot.graphics.lineTo((side * 4), -1);
foot.graphics.lineTo(0, -1);
foot.graphics.lineTo(0, 1);
if (side == -1){
foot.rotation = 180;
};
}
public function drawRearFoot(){
foot.graphics.lineStyle(2, color);
foot.graphics.beginFill(color);
foot.graphics.lineTo(0, 1);
foot.graphics.lineTo((side * 6), 2);
foot.graphics.curveTo((side * 8), 0, (side * 6), -2);
foot.graphics.lineTo(0, -1);
foot.graphics.lineTo(0, 0);
foot.graphics.endFill();
if (side == -1){
foot.rotation = 180;
};
}
public function resetFoot(){
easer.init(ftX, ftX, ftY, ftY, 0);
}
private function angleTo(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number):Number{
var _local5:*;
var _local6:*;
_local5 = (_arg3 - _arg1);
_local6 = (_arg4 - _arg2);
return (Math.atan2(_local6, _local5));
}
function isStepping():Boolean{
return (easer.isMoving());
}
private function distTo(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number):Number{
var _local5:*;
var _local6:*;
_local5 = (_arg3 - _arg1);
_local6 = (_arg4 - _arg2);
return (Math.sqrt(((_local5 * _local5) + (_local6 * _local6))));
}
function render(){
var _local1:Number;
var _local2:Number;
var _local3:Number;
graphics.clear();
graphics.lineStyle(3, 9934488);
_local1 = angleTo(base.x, base.y, ftX, ftY);
_local2 = distTo(base.x, base.y, ftX, ftY);
x = base.x;
y = base.y;
rotation = ((_local1 * 180) / Math.PI);
_local3 = ((Math.acos(((_local2 * 0.5) / (len * 0.5))) * 180) / Math.PI);
if (isNaN(_local3)){
_local3 = 0;
};
if (side == -1){
seg1.rotation = (360 - _local3);
seg2.rotation = (180 + _local3);
} else {
seg1.rotation = _local3;
seg2.rotation = (180 - _local3);
};
seg2.x = _local2;
foot.x = _local2;
if (side == -1){
foot.rotation = (180 - (45 - (45 * ((_local2 / len) * 1.2))));
} else {
foot.rotation = (45 - (45 * ((_local2 / len) * 1.2)));
};
if (!front){
foot.rotation = (foot.rotation + (side * 30));
};
}
function step(){
easer.update();
ftX = easer.x;
ftY = easer.y;
}
function setTarget(_arg1:Number, _arg2:Number, _arg3:Number){
var _local4:Number;
var _local5:Number;
_local4 = (base.x + (Math.cos((_arg1 - (side * restAngle))) * length));
_local5 = (base.y + (Math.sin((_arg1 - (side * restAngle))) * length));
_local4 = (_local4 + (Math.cos(_arg1) * _arg2));
_local5 = (_local5 + (Math.sin(_arg1) * _arg2));
easer.init(ftX, _local4, ftY, _local5, _arg3);
}
}
}//package
Section 7
//Pupcat (Pupcat)
package {
import flash.text.*;
public dynamic class Pupcat extends Font {
}
}//package
Section 8
//Slider (Slider)
package {
import flash.display.*;
import flash.events.*;
import flash.geom.*;
public class Slider extends Sprite {
var onSlide:Function;
var trackLength:Number;
var maxVal:Number;
var handle:Sprite;
var trackWidth:Number;// = 200
var range:Number;
var trackHeight:Number;// = 10
var trackFill:Number;// = 0xDCDCDC
var onChange:Function;
var value:Number;
var minVal:Number;
var handleHeight:Number;// = 10
var handleWidth:Number;// = 10
var handleFill:Number;// = 0x999999
public function Slider(_arg1:Object){
trackFill = 0xDCDCDC;
trackHeight = 10;
trackWidth = 200;
handleFill = 0x999999;
handleWidth = 10;
handleHeight = 10;
super();
maxVal = _arg1.max;
minVal = _arg1.min;
range = (maxVal - minVal);
onSlide = _arg1.onSlide;
onChange = _arg1.onChange;
value = Math.min(Math.max(minVal, _arg1.start), maxVal);
if (_arg1.trackWidth){
this.trackWidth = _arg1.trackWidth;
//unresolved jump
};
if (_arg1.trackHeight){
this.trackHeight = _arg1.trackHeight;
//unresolved jump
};
if (_arg1.handleWidth){
this.handleWidth = _arg1.handleWidth;
//unresolved jump
};
if (_arg1.handleHeight){
this.handleHeight = _arg1.handleHeight;
//unresolved jump
};
if (_arg1.trackFill){
this.trackFill = _arg1.trackFill;
//unresolved jump
};
if (_arg1.handleFill){
this.handleFill = _arg1.handleFill;
//unresolved jump
};
trackLength = (trackWidth - handleWidth);
createHandle();
render();
}
function handleMove(_arg1:Event){
updateValue();
}
public function valueChanged():void{
onChange(value);
}
function setValue(_arg1:Number):void{
if (_arg1 != value){
if ((((_arg1 >= minVal)) && ((_arg1 <= maxVal)))){
value = _arg1;
} else {
if (_arg1 < minVal){
value = minVal;
} else {
if (_arg1 > maxVal){
value = maxVal;
};
};
};
handle.x = (((value - minVal) / range) * trackLength);
valueChanged();
};
}
function mouseUp(_arg1:MouseEvent):void{
handleOnRelease(_arg1);
}
function handleOnPress(_arg1:Event){
handle.startDrag(false, new Rectangle(0, ((trackHeight - handleHeight) / 2), (trackWidth - handleWidth), 0));
handle.addEventListener(MouseEvent.MOUSE_MOVE, handleMove);
stage.addEventListener(MouseEvent.MOUSE_MOVE, handleMove);
stage.addEventListener(MouseEvent.MOUSE_UP, mouseUp);
}
function createHandle():void{
handle = new Sprite();
handle.y = ((trackHeight - handleHeight) / 2);
handle.x = (((value - minVal) / range) * trackLength);
handle.addEventListener(MouseEvent.MOUSE_DOWN, handleOnPress);
handle.addEventListener(MouseEvent.MOUSE_UP, handleOnRelease);
this.addChild(handle);
}
public function updateValue(){
var _local1:Number;
_local1 = ((handle.x * (range / trackLength)) + minVal);
value = _local1;
onSlide(value);
}
function sliderOnPress():void{
var _local1:Number;
var _local2:Number;
_local1 = mouseX;
_local2 = (handleWidth / 2);
if ((((_local1 >= _local2)) && ((_local1 <= (trackWidth - _local2))))){
handle.x = (_local1 - _local2);
value = (((range * (_local1 - _local2)) / trackWidth) + minVal);
} else {
if (_local1 < _local2){
handle.x = 0;
value = minVal;
} else {
if (_local1 > (trackWidth - _local2)){
handle.x = (trackWidth - handleWidth);
value = maxVal;
};
};
};
}
function render():void{
graphics.lineStyle(1, 0);
graphics.beginFill(trackFill);
graphics.drawRect(0, 0, trackWidth, trackHeight);
graphics.endFill();
handle.graphics.lineStyle(1, 0);
handle.graphics.beginFill(handleFill);
handle.graphics.drawRect(0, 0, handleWidth, handleHeight);
handle.graphics.endFill();
}
function getValue():Number{
return (value);
}
function handleOnRelease(_arg1:Event){
handle.stopDrag();
updateValue();
handle.removeEventListener(MouseEvent.MOUSE_MOVE, handleMove);
stage.removeEventListener(MouseEvent.MOUSE_MOVE, handleMove);
stage.removeEventListener(MouseEvent.MOUSE_UP, mouseUp);
}
}
}//package
Section 9
//Turtle (Turtle)
package {
import flash.display.*;
import flash.events.*;
import flash.geom.*;
import flash.filters.*;
public class Turtle extends Sprite {
var size:Number;// = 1
var framesPerStep:Number;// = 20
var legColor:Number;// = 6710847
var initStride:Number;
var app:Application;
var legs:Array;
public var shell:Sprite;
var tail:Shape;
var thrust:Number;// = 0.05
private var neckLenMax:Number;// = 16
public var food:Array;
var prevMouseX:Number;
var prevMouseY:Number;
var h:Number;// = 30
var w:Number;// = 5
var currLeg:Leg;
private var headX:Number;
private var headY:Number;
private var neckLenTar:Number;// = 12
var maxSightAng:Number;// = 2.35619449019234
public var state:Number;
var shH:Number;// = 20
private var foodDistMin:Number;// = 0
var legNum:Number;// = 0
var mouseVelY:Number;
var shW:Number;// = 18
var prevAng:Number;
var mouseVelX:Number;
var dest:Object;
var xPos:Number;
var hips:Array;
var angle:Number;// = 0
var timeToSwim:Number;
var stride:Number;// = 8
var swimAcc:Number;// = 0.05
public var shadowDist:Number;
var timeDoneEat:Number;
var swimRotVel:Number;// = 0
var angToTarg:Number;// = 0
var friction:Number;// = 0.97
var neckAng:Number;// = 0
var swimVelX:Number;// = 0
var swimVelY:Number;// = 0
var midX:Number;
var midY:Number;
var shellColor:Number;// = 8553040
var yPos:Number;
var rearX:Number;
var rearY:Number;
private var neckLen:Number;// = 12
var tailBaseX:Number;
var tailBaseY:Number;
private var neckLenMin:Number;// = 8
var angDiffM:Number;// = 0
var closeDistInner:Number;// = 30
var numSteps:Number;// = 0
var angDiffT:Number;
var mouseDiffX:Number;
var mouseDiffY:Number;
var endRest:Number;// = 0
var closeDistOuter:Number;// = 60
var headColor:Number;// = 8553040
var angSpeedToM:Number;// = 0.014
var maxRest:Number;// = 500
var shellShape:Shape;
var tailAng:Number;// = 0
var minRest:Number;// = 0
var wait:Number;// = 20
var stVel:Number;// = 0
var flegs:Array;
var swimFric:Number;// = 0.95
public var target:Number;
var rlegs:Array;
var tailTipY:Number;
private var foodDistMax:Number;// = 35
var tailLen:Number;// = 20
var tailTipX:Number;
var bangle:Number;// = 0
var distToM:Number;
var swimRotFric:Number;// = 0.95
var distToTarg:Number;
var headWidth:Number;// = 10
private var neckLenOrg:Number;// = 12
var move:Function;
var swimRotAcc:Number;// = 0.002
private var neckX:Number;
private var neckY:Number;
public var head:Shape;
var maxSightDist:Number;// = 800
var counter:Number;// = 0
public static const SWIM_WALK = 4;
public static const MOUSE = 2;
public static const SWIM = 2;
public static const WALK = 1;
public static const NOTHING = 1;
public static const FOOD = 3;
public static const PICKED_UP = 3;
public static const RANDOM = 4;
public static const WALK_SWIM = 3;
public function Turtle(_arg1:Object){
var _local2:Number;
angle = 0;
bangle = 0;
w = 5;
h = 30;
shW = 18;
shH = 20;
stride = 8;
counter = 0;
wait = 20;
legNum = 0;
size = 1;
angSpeedToM = 0.014;
neckLenTar = 12;
neckLen = 12;
neckLenOrg = 12;
neckLenMax = 16;
neckLenMin = 8;
thrust = 0.05;
friction = 0.97;
framesPerStep = 20;
stVel = 0;
angToTarg = 0;
swimRotVel = 0;
swimRotAcc = 0.002;
swimRotFric = 0.95;
swimVelX = 0;
swimVelY = 0;
swimAcc = 0.05;
swimFric = 0.95;
neckAng = 0;
tailLen = 20;
tailAng = 0;
numSteps = 0;
closeDistInner = 30;
closeDistOuter = 60;
foodDistMax = 35;
foodDistMin = 0;
headWidth = 10;
angDiffM = 0;
headColor = 8553040;
legColor = 6710847;
shellColor = 8553040;
shellShape = new Shape();
maxSightDist = 800;
maxSightAng = (Math.PI * 0.75);
minRest = 0;
maxRest = 500;
endRest = 0;
super();
counter = int((Math.random() * 100));
app = _arg1.app;
food = _arg1.food;
name = _arg1.name;
shellColor = _arg1.shellColor;
legColor = _arg1.legColor;
headColor = _arg1.headColor;
xPos = _arg1.x;
setDropShadow(8);
if (xPos > app.waterWidth){
state = WALK;
move = walk;
} else {
state = SWIM;
move = swim;
};
legs = new Array();
rlegs = new Array();
flegs = new Array();
hips = new Array();
hips.push({x:0, y:0});
hips.push({x:0, y:0});
hips.push({x:0, y:0});
hips.push({x:0, y:0});
legs.push(new Leg({color:legColor, base:hips[0], length:(10 * size), side:-1, front:true, restAngle:((45 * Math.PI) / 180), strokeA:(Math.PI * 0.5), strokeRd:9, startAngle:(Math.PI * 0.5), strokeRt:0.3}));
legs.push(new Leg({color:legColor, base:hips[2], length:(10 * size), side:1, restAngle:((135 * Math.PI) / 180), strokeA:(Math.PI * 0.6), strokeRd:7, startAngle:-0.6, strokeRt:-0.1}));
legs.push(new Leg({color:legColor, base:hips[3], length:(10 * size), side:1, front:true, restAngle:((45 * Math.PI) / 180), strokeA:(Math.PI * 0.5), strokeRd:9, startAngle:(Math.PI * 0.5), strokeRt:0.3}));
legs.push(new Leg({color:legColor, base:hips[1], length:(10 * size), side:-1, restAngle:((135 * Math.PI) / 180), strokeA:(Math.PI * 0.6), strokeRd:7, startAngle:-0.6, strokeRt:-0.1}));
rlegs[0] = legs[3];
rlegs[1] = legs[1];
flegs[0] = legs[0];
flegs[1] = legs[2];
flegs[0].setStroke(8, 3);
rlegs[0].setStroke(10, 2);
flegs[1].setStroke(8, 3);
rlegs[1].setStroke(10, 2);
flegs[0].drawFrontFoot();
rlegs[0].drawRearFoot();
flegs[1].drawFrontFoot();
rlegs[1].drawRearFoot();
xPos = 150;
yPos = 150;
xPos = int(_arg1.x);
yPos = int(_arg1.y);
angle = (bangle = ((_arg1.rotation * Math.PI) / 180));
setHips();
_local2 = 0;
while (_local2 < 4) {
legs[_local2].setLeg(x, y, bangle);
addChild(legs[_local2]);
_local2++;
};
tail = new Shape();
tail.graphics.lineStyle(1);
tail.graphics.beginFill(shellColor);
tail.graphics.moveTo(0, -3);
tail.graphics.lineTo(tailLen, 0);
tail.graphics.lineTo(0, 3);
tail.graphics.lineTo(0, -3);
tail.graphics.endFill();
addChild(tail);
shell = new Sprite();
shellShape = new Shape();
shell.addChild(shellShape);
drawShell(shellShape, shW, shH, 0, shellColor);
shell.x = xPos;
shell.y = yPos;
shell.rotation = ((bangle * 180) / Math.PI);
shell.addEventListener(MouseEvent.MOUSE_DOWN, shellOnPress);
shell.addEventListener(MouseEvent.MOUSE_UP, shellOnRelease);
rearX = (xPos + ((Math.cos((bangle + Math.PI)) * h) / 2));
rearY = (yPos + ((Math.sin((bangle + Math.PI)) * h) / 2));
dest = {x:0, y:0};
tailBaseX = (xPos + ((hips[2].x - hips[3].x) / 2));
tailBaseY = (yPos + ((hips[2].y - hips[3].y) / 2));
tailTipX = (tailBaseX + (Math.cos((bangle + Math.PI)) * tailLen));
tailTipY = (tailBaseY + (Math.sin((bangle + Math.PI)) * tailLen));
head = new Shape();
drawHead(head, 12, headWidth, 0, headColor);
addChild(head);
addChild(shell);
render();
draw();
}
private function resetLegs(_arg1:Number){
var _local2:Number;
_local2 = 0;
while (_local2 < 4) {
legs[_local2].resetLeg(angle, _arg1);
_local2++;
};
}
private function getRotDir(_arg1:Number, _arg2:Number, _arg3:Number):Number{
var _local4:Number;
var _local5:Number;
_local5 = fixAngle((_arg1 - _arg2));
if ((((_local5 > ((_arg3 * Math.PI) / 180))) && ((_local5 < Math.PI)))){
_local4 = -1;
} else {
if ((((_local5 < (((360 - _arg3) * Math.PI) / 180))) && ((_local5 > Math.PI)))){
_local4 = 1;
} else {
_local4 = 0;
};
};
return (_local4);
}
private function setHips(){
var _local1:Number;
var _local2:Number;
var _local3:Number;
var _local4:Number;
_local3 = (h / 2);
_local4 = (bangle + (Math.PI / 4));
_local1 = (Math.cos(_local4) * _local3);
_local2 = (Math.sin(_local4) * _local3);
hips[0].x = (_local1 + xPos);
hips[0].y = (_local2 + yPos);
hips[1].x = (xPos - _local2);
hips[1].y = (_local1 + yPos);
hips[2].x = (xPos - _local1);
hips[2].y = (yPos - _local2);
hips[3].x = (xPos + _local2);
hips[3].y = (yPos - _local1);
}
public function setNeckLen(_arg1:Number){
if (distToTarg > closeDistOuter){
neckLenTar = neckLenMax;
} else {
if (distToTarg < closeDistInner){
neckLenTar = neckLenMin;
} else {
neckLenTar = neckLenOrg;
};
};
neckLen = (neckLen + ((neckLenTar - neckLen) * _arg1));
}
private function findMouse():Boolean{
var _local1:Number;
angToTarg = angleTo(xPos, yPos, mouseX, mouseY);
_local1 = getAngleDiff(bangle, angToTarg);
if (Math.abs(_local1) < maxSightAng){
distToTarg = distTo(xPos, yPos, mouseX, mouseY);
if (distToTarg < maxSightDist){
return (true);
};
};
return (false);
}
public function swim(){
var _local1:Number;
var _local2:Number;
var _local3:Number;
var _local4:Number;
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:Number;
var _local9:Number;
var _local10:Number;
var _local11:Number;
var _local12:Number;
_local1 = 0;
_local2 = 0;
_local3 = 0;
_local4 = 0;
_local5 = 0;
_local6 = 0;
swimRotVel = (swimRotVel + (getRotDir(bangle, angToTarg, 10) * swimRotAcc));
swimRotVel = (swimRotVel * swimRotFric);
angle = (bangle = (bangle + swimRotVel));
bangle = fixAngle(bangle);
if (target == FOOD){
closeDistOuter = 30;
} else {
closeDistOuter = 60;
};
if (distToTarg > closeDistOuter){
_local1 = 0.02;
_local6 = 0.05;
} else {
if (distToTarg < closeDistInner){
_local1 = -0.02;
_local6 = -0.05;
};
};
_local7 = (Math.cos(bangle) * _local6);
_local8 = (Math.sin(bangle) * _local6);
swimVelX = (swimVelX + _local7);
swimVelY = (swimVelY + _local8);
if (Math.abs(swimVelX) > 0.05){
swimVelX = (swimVelX * swimFric);
};
if (Math.abs(swimVelY) > 0.05){
swimVelY = (swimVelY * swimFric);
};
xPos = (xPos + swimVelX);
yPos = (yPos + swimVelY);
if (_local6 == 0){
if (swimRotVel > 0.01){
_local2 = 0.01;
if (swimRotVel > 0.02){
_local4 = 0.01;
};
} else {
if (swimRotVel < -0.01){
_local3 = 0.01;
if (swimRotVel < -0.02){
_local5 = 0.01;
};
};
};
};
_local9 = 0.2;
_local10 = 0.2;
_local11 = 0.2;
_local12 = 0.2;
if (_local1 > 0){
if (getAngleDiff(flegs[0].stAng, flegs[1].stAng) > (Math.PI / 2)){
_local9 = 0.22;
} else {
_local10 = 0.22;
};
if (getAngleDiff(rlegs[0].stAng, rlegs[1].stAng) > (Math.PI / 2)){
_local11 = 0.22;
} else {
_local12 = 0.22;
};
if (getAngleDiff(flegs[0].stAng, rlegs[0].stAng) > 0){
_local9 = (_local9 - 0.02);
_local10 = (_local10 - 0.02);
} else {
_local11 = (_local11 - 0.02);
_local12 = (_local12 - 0.02);
};
};
checkCollision();
setHips();
shell.rotation = ((bangle * 180) / Math.PI);
shell.x = xPos;
shell.y = yPos;
flegs[0].swimMoveLegs((_local1 + _local3), bangle, _local9);
rlegs[0].swimMoveLegs((_local1 + _local5), bangle, _local11);
flegs[1].swimMoveLegs((_local1 + _local2), bangle, _local10);
rlegs[1].swimMoveLegs((_local1 + _local4), bangle, _local12);
}
private function drawFrontPattern(_arg1:Shape, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Number){
var _local6:Number;
var _local7:Number;
_local6 = _arg3;
_local7 = (_arg2 * _arg4);
_arg1.graphics.lineStyle(1, _arg5);
_arg1.graphics.moveTo(0, (_local7 * 0.5));
_arg1.graphics.lineTo((_local6 * 0.28), (_local7 * 0.32));
_arg1.graphics.lineTo((_local6 * 0.5), (_local7 * 0.5));
_arg1.graphics.lineTo((_local6 * 0.7), (_local7 * 0.32));
_arg1.graphics.lineTo((_local6 * 0.9), (_local7 * 0.6));
_arg1.graphics.moveTo((_local6 * 0.28), (_local7 * 0.32));
_arg1.graphics.lineTo((_local6 * 0.28), 0);
_arg1.graphics.moveTo((_local6 * 0.5), (_local7 * 0.5));
_arg1.graphics.lineTo((_local6 * 0.5), (_local7 * 0.9));
_arg1.graphics.moveTo((_local6 * 0.7), (_local7 * 0.32));
_arg1.graphics.lineTo((_local6 * 0.7), 0);
_arg1.graphics.moveTo(0, (_local7 * 0.5));
_arg1.graphics.lineTo(0, _local7);
_arg1.graphics.lineTo((_local6 * 0.5), (_local7 * 0.9));
_arg1.graphics.lineTo((_local6 * 0.9), (_local7 * 0.6));
_arg1.graphics.lineTo(_local6, 0);
}
private function angleTo(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number):Number{
var _local5:*;
var _local6:*;
_local5 = (_arg3 - _arg1);
_local6 = (_arg4 - _arg2);
return (Math.atan2(_local6, _local5));
}
private function distTo(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number):Number{
var _local5:*;
var _local6:*;
_local5 = (_arg3 - _arg1);
_local6 = (_arg4 - _arg2);
return (Math.sqrt(((_local5 * _local5) + (_local6 * _local6))));
}
private function getAngleDiff(_arg1:Number, _arg2:Number):Number{
var _local3:Number;
var _local4:Number;
_local3 = _arg1;
_local4 = (_arg2 - _arg1);
_local4 = (_local4 % (Math.PI * 2));
if (_local4 < 0){
_local4 = (_local4 + (Math.PI * 2));
};
if (Math.abs(_local4) > Math.PI){
if (_local4 > 0){
_local4 = (_local4 - (Math.PI * 2));
} else {
_local4 = (_local4 + (Math.PI * 2));
};
};
return (_local4);
}
public function update(){
var _local1:Food;
var _local2:Number;
_local1 = findFood();
if (counter < timeDoneEat){
target = NOTHING;
move();
setNeckLen(0.1);
} else {
if (_local1 != null){
target = FOOD;
dest.x = _local1.pos.x;
dest.y = _local1.pos.y;
distToTarg = distTo(xPos, yPos, dest.x, dest.y);
angToTarg = angleTo(xPos, yPos, dest.x, dest.y);
move();
if ((((((distToTarg < foodDistMax)) && ((distToTarg > foodDistMin)))) && ((Math.abs(angDiffT) < 0.2)))){
neckLenTar = distToTarg;
neckLen = (neckLen + ((neckLenTar - neckLen) * 0.2));
_local2 = distTo(headX, headY, dest.x, dest.y);
if (_local2 < headWidth){
app.makeFoodInactive(_local1);
timeDoneEat = (20 + counter);
};
} else {
setNeckLen(0.1);
};
} else {
if (((app.msActive) && (findMouse()))){
target = MOUSE;
dest.x = mouseX;
dest.y = mouseY;
move();
setNeckLen(0.1);
} else {
if (counter < endRest){
target = NOTHING;
distToTarg = closeDistInner;
angToTarg = bangle;
dest.x = xPos;
dest.y = yPos;
move();
setNeckLen(0.1);
} else {
if (target != RANDOM){
target = RANDOM;
dest.x = (Math.random() * stage.stageWidth);
dest.y = (Math.random() * stage.stageHeight);
};
distToTarg = distTo(xPos, yPos, dest.x, dest.y);
angToTarg = angleTo(xPos, yPos, dest.x, dest.y);
if (distToTarg < closeDistOuter){
target = NOTHING;
endRest = ((counter + minRest) + (Math.random() * (maxRest - minRest)));
};
move();
setNeckLen(0.1);
};
};
};
};
setHead();
setTail();
head.rotation = (((neckAng + bangle) * 180) / Math.PI);
render();
counter++;
prevMouseX = mouseX;
prevMouseY = mouseY;
}
private function walkToSwim(){
setCenter();
setHips();
shell.x = xPos;
shell.y = yPos;
flegs[0].step();
rlegs[0].step();
flegs[1].step();
rlegs[1].step();
if (counter > timeToSwim){
move = swim;
state = SWIM;
swimVelX = Math.cos(bangle);
swimVelY = Math.sin(bangle);
};
}
public function shellOnRelease(_arg1:Event){
state = SWIM;
move = swim;
}
public function setDropShadow(_arg1:Number){
var _local2:DropShadowFilter;
var _local3:Array;
shadowDist = _arg1;
_local2 = new DropShadowFilter();
_local2.alpha = 0.15;
_local2.distance = _arg1;
_local2.blurX = 5;
_local2.blurY = 5;
_local3 = [_local2];
this.filters = _local3;
}
function checkCollision(){
var _local1:Number;
var _local2:Number;
var _local3:Turtle;
var _local4:Number;
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:Number;
var _local9:Number;
var _local10:Number;
var _local11:Number;
var _local12:Number;
var _local13:Number;
var _local14:Number;
var _local15:Number;
var _local16:Number;
var _local17:Array;
var _local18:Number;
var _local19:Number;
var _local20:Number;
var _local21:Number;
_local4 = 20;
_local11 = 0;
_local12 = 0;
_local13 = 15;
_local14 = 0;
_local15 = 0;
_local16 = ((45 * Math.PI) / 180);
_local17 = app.turtles;
_local18 = _local17.length;
_local19 = 0;
while (_local19 < _local18) {
_local14 = 0;
_local15 = 0;
_local11 = 0;
_local12 = 0;
_local3 = _local17[_local19];
if (_local3 != this){
_local2 = 40;
_local9 = distTo(_local3.xPos, _local3.yPos, xPos, yPos);
if (_local9 < (_local2 + _local13)){
_local1 = angleTo(_local3.xPos, _local3.yPos, xPos, yPos);
_local11 = getAngleDiff(bangle, (_local1 + Math.PI));
if (Math.abs(_local11) < _local16){
_local11 = (_local16 - Math.abs(_local11));
_local14 = (Math.sin(((Math.PI / 2) * (_local11 / _local16))) * _local13);
};
_local12 = getAngleDiff(_local3.bangle, _local1);
if (Math.abs(_local12) < _local16){
_local12 = (_local16 - Math.abs(_local12));
_local15 = (Math.sin(((Math.PI / 2) * (_local12 / _local16))) * _local13);
};
_local10 = (_local2 + (Math.sin(((Math.PI / 2) * (_local11 / _local16))) * Math.max(_local14, _local15)));
if (_local9 < _local10){
_local5 = (_local3.xPos + (Math.cos(_local1) * _local10));
_local6 = (_local3.yPos + (Math.sin(_local1) * _local10));
_local7 = (_local5 - xPos);
_local8 = (_local6 - yPos);
xPos = _local5;
yPos = _local6;
if ((((state == WALK)) || ((state == WALK_SWIM)))){
flegs[0].shiftFoot(_local7, _local8);
rlegs[0].shiftFoot(_local7, _local8);
flegs[1].shiftFoot(_local7, _local8);
rlegs[1].shiftFoot(_local7, _local8);
};
};
};
};
_local19++;
};
_local7 = 0;
_local8 = 0;
_local5 = xPos;
_local6 = yPos;
_local20 = app.stageH;
_local21 = app.stageW;
if (xPos < _local4){
_local5 = _local4;
_local7 = (_local5 - xPos);
} else {
if (xPos > (_local21 - _local4)){
_local5 = (_local21 - _local4);
_local7 = (_local5 - xPos);
};
};
if (_local20 < (2 * _local4)){
_local6 = (_local20 / 2);
_local8 = (_local6 - yPos);
} else {
if (yPos < _local4){
_local6 = _local4;
_local8 = (_local6 - yPos);
} else {
if (yPos > (_local20 - _local4)){
_local6 = (_local20 - _local4);
_local8 = (_local6 - yPos);
};
};
};
if (((!((_local7 == 0))) || (!((_local8 == 0))))){
xPos = _local5;
yPos = _local6;
if ((((state == WALK)) || ((state == WALK_SWIM)))){
flegs[0].shiftFoot(_local7, _local8);
rlegs[0].shiftFoot(_local7, _local8);
flegs[1].shiftFoot(_local7, _local8);
rlegs[1].shiftFoot(_local7, _local8);
};
};
}
public function pickedUp(){
var _local1:Number;
var _local2:Number;
_local1 = 0;
_local2 = angleTo(xPos, yPos, mouseX, mouseY);
angle = (bangle = (_local2 + angDiffM));
xPos = (mouseX + (Math.cos((_local2 + Math.PI)) * distToM));
yPos = (mouseY + (Math.sin((_local2 + Math.PI)) * distToM));
swimRotVel = getAngleDiff(prevAng, bangle);
swimVelX = (mouseVelX = ((mouseX - prevMouseX) / 3));
swimVelY = (mouseVelY = ((mouseY - prevMouseY) / 3));
setHips();
shell.x = xPos;
shell.y = yPos;
shell.rotation = ((bangle * 180) / Math.PI);
_local1 = 0.02;
flegs[0].swimMoveLegs(_local1, bangle);
rlegs[0].swimMoveLegs(_local1, bangle);
flegs[1].swimMoveLegs(_local1, bangle);
rlegs[1].swimMoveLegs(_local1, bangle);
prevAng = bangle;
}
private function drawShell(_arg1:Shape, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Number){
var _local6:Matrix;
var _local7:Array;
var _local8:Array;
var _local9:Array;
_local6 = new Matrix();
_local6.createGradientBox((_arg3 * 4), (_arg2 * 4), 0, (-(_arg3) * 2), (-(_arg2) * 2));
_local7 = [_arg5, 0];
_local8 = [_arg3, _arg2];
_local9 = [0, 0xFF];
_arg1.graphics.clear();
_arg1.graphics.beginGradientFill(GradientType.RADIAL, _local7, _local8, _local9, _local6);
_arg1.graphics.lineStyle(1, _arg4);
_arg1.graphics.moveTo(0, _arg2);
_arg1.graphics.curveTo((_arg3 * 0.9), (_arg2 * 0.9), _arg3, (_arg2 * 0.3));
_arg1.graphics.curveTo((_arg3 * 0.95), 0, _arg3, (-(_arg2) * 0.3));
_arg1.graphics.curveTo((_arg3 * 0.9), (-(_arg2) * 0.9), 0, -(_arg2));
_arg1.graphics.curveTo(-(_arg3), (-(_arg2) * 1.1), (-(_arg3) * 1.2), 0);
_arg1.graphics.curveTo(-(_arg3), (_arg2 * 1.1), 0, _arg2);
_arg1.graphics.endFill();
_arg1.graphics.lineStyle(3, _arg4);
_arg4 = 0x333333;
drawFrontPattern(_arg1, 1, (_arg3 * 0.9), (_arg2 * 0.9), _arg4);
drawFrontPattern(_arg1, -1, (_arg3 * 0.9), (_arg2 * 0.9), _arg4);
drawRearPattern(_arg1, 1, (_arg3 * 1.05), (_arg2 * 0.9), _arg4);
drawRearPattern(_arg1, -1, (_arg3 * 1.05), (_arg2 * 0.9), _arg4);
}
private function shellOnPress(_arg1:Event){
state = PICKED_UP;
move = pickedUp;
angDiffM = getAngleDiff(angleTo(xPos, yPos, mouseX, mouseY), bangle);
distToM = distTo(xPos, yPos, mouseX, mouseY);
prevAng = bangle;
}
private function setCenter(){
var _local1:Number;
var _local2:Number;
var _local3:Number;
_local1 = 0;
_local2 = 0;
_local3 = 0;
while (_local3 < legs.length) {
_local1 = (_local1 + legs[_local3].ftX);
_local2 = (_local2 + legs[_local3].ftY);
_local3++;
};
xPos = (_local1 / legs.length);
yPos = (_local2 / legs.length);
}
function draw(_arg1:Object=null){
if (_arg1 != null){
if (_arg1.shellColor != null){
shellColor = _arg1.shellColor;
};
if (_arg1.headColor != null){
headColor = _arg1.headColor;
};
};
drawHead(head, 12, headWidth, 0, headColor);
drawShell(shellShape, shW, shH, 0, shellColor);
drawTail(shellColor);
}
private function drawRearPattern(_arg1:Shape, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Number){
var _local6:Number;
var _local7:Number;
_local6 = -(_arg3);
_local7 = (_arg2 * _arg4);
_arg1.graphics.lineStyle(1, _arg5);
_arg1.graphics.moveTo(0, (_local7 * 0.5));
_arg1.graphics.lineTo((_local6 * 0.28), (_local7 * 0.32));
_arg1.graphics.lineTo((_local6 * 0.5), (_local7 * 0.5));
_arg1.graphics.lineTo((_local6 * 0.7), (_local7 * 0.32));
_arg1.graphics.lineTo((_local6 * 0.85), (_local7 * 0.6));
_arg1.graphics.moveTo((_local6 * 0.28), (_local7 * 0.32));
_arg1.graphics.lineTo((_local6 * 0.28), 0);
_arg1.graphics.moveTo((_local6 * 0.5), (_local7 * 0.5));
_arg1.graphics.lineTo((_local6 * 0.5), (_local7 * 0.95));
_arg1.graphics.moveTo((_local6 * 0.7), (_local7 * 0.32));
_arg1.graphics.lineTo((_local6 * 0.7), 0);
_arg1.graphics.moveTo(0, _local7);
_arg1.graphics.lineTo((_local6 * 0.5), (_local7 * 0.95));
_arg1.graphics.lineTo((_local6 * 0.85), (_local7 * 0.6));
_arg1.graphics.lineTo(_local6, (_local7 * 0.16));
_arg1.graphics.lineTo(_local6, 0);
}
private function setHead(){
neckX = (xPos + ((hips[0].x - hips[1].x) / 2));
neckY = (yPos + ((hips[0].y - hips[1].y) / 2));
angDiffT = getAngleDiff(bangle, angToTarg);
angDiffT = Math.max(angDiffT, -0.4);
angDiffT = Math.min(angDiffT, 0.4);
neckAng = (neckAng - ((neckAng - angDiffT) * 0.1));
headX = (neckX + (Math.cos((neckAng + bangle)) * neckLen));
headY = (neckY + (Math.sin((neckAng + bangle)) * neckLen));
head.x = headX;
head.y = headY;
}
private function drawHead(_arg1:Shape, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Number){
var _local6:Matrix;
var _local7:Array;
var _local8:Array;
var _local9:Array;
_local6 = new Matrix();
_local6.createGradientBox((_arg2 * 2), (_arg3 * 2), 0, -(_arg2), -(_arg3));
_local7 = [_arg5, 0];
_local8 = [_arg2, _arg3];
_local9 = [0, 0xFF];
_arg1.graphics.clear();
_arg1.graphics.beginGradientFill(GradientType.RADIAL, _local7, _local8, _local9, _local6);
_arg1.graphics.lineStyle(1, _arg4);
_arg1.graphics.moveTo(-(_arg2), (-(_arg3) / 4));
_arg1.graphics.lineTo((-(_arg2) / 2), (-(_arg3) / 4));
_arg1.graphics.curveTo((_arg2 * 0.2), (-(_arg3) * 0.7), (_arg2 / 2), 0);
_arg1.graphics.curveTo((_arg2 * 0.2), (_arg3 * 0.7), (-(_arg2) / 2), (_arg3 / 4));
_arg1.graphics.lineTo(-(_arg2), (_arg3 / 4));
_arg1.graphics.lineTo(-(_arg2), (-(_arg3) / 4));
_arg1.graphics.endFill();
}
private function render(){
var _local1:Number;
_local1 = 0;
while (_local1 < 4) {
legs[_local1].render();
_local1++;
};
}
public function changeMove(_arg1:Number){
if ((((_arg1 == WALK)) && ((this.state == SWIM)))){
move = swimToWalk;
this.state = WALK_SWIM;
numSteps = 0;
} else {
if ((((((_arg1 == SWIM)) && ((this.state == WALK)))) && ((numSteps > 3)))){
move = walkToSwim;
timeToSwim = (counter + 20);
flegs[0].setTarget(bangle, stride, framesPerStep);
rlegs[0].setTarget(bangle, stride, framesPerStep);
flegs[1].setTarget(bangle, stride, framesPerStep);
rlegs[1].setTarget(bangle, stride, framesPerStep);
this.state = SWIM_WALK;
};
};
}
function findFood():Food{
var _local1:Number;
var _local2:Number;
var _local3:Number;
var _local4:Number;
var _local5:Array;
var _local6:Number;
var _local7:Object;
var _local8:Number;
var _local9:Number;
var _local10:*;
_local2 = 400;
_local5 = this.food;
_local8 = _local5.length;
_local9 = bangle;
_local10 = 0;
while (_local10 < _local8) {
_local7 = _local5[_local10].pos;
_local4 = angleTo(xPos, yPos, _local7.x, _local7.y);
_local6 = getAngleDiff(_local9, _local4);
if (Math.abs(_local6) < maxSightAng){
_local1 = (Math.abs((yPos - _local7.y)) + Math.abs((xPos - _local7.x)));
if ((((_local1 < maxSightDist)) && ((_local1 < _local2)))){
_local2 = _local1;
_local3 = _local10;
};
};
_local10++;
};
return (_local5[_local3]);
}
function drawTail(_arg1:Number){
tail.graphics.clear();
tail.graphics.lineStyle(1);
tail.graphics.beginFill(_arg1);
tail.graphics.moveTo(0, -3);
tail.graphics.lineTo(tailLen, 0);
tail.graphics.lineTo(0, 3);
tail.graphics.lineTo(0, -3);
tail.graphics.endFill();
}
private function swimToWalk(){
var _local1:Number;
var _local2:Number;
flegs[0].swimMoveLegs(0, bangle);
rlegs[0].swimMoveLegs(0, bangle);
flegs[1].swimMoveLegs(0, bangle);
rlegs[1].swimMoveLegs(0, bangle);
_local1 = 0;
_local2 = 0;
while (_local2 < 4) {
if (legs[_local2].stVel > _local1){
_local1 = legs[_local2].stVel;
};
_local2++;
};
if (_local1 < 0.01){
swimRotVel = 0;
move = walk;
state = WALK;
_local2 = 0;
while (_local2 < 4) {
legs[_local2].resetFoot();
_local2++;
};
};
}
public function walk(){
midX = ((legs[0].ftX + legs[2].ftX) / 2);
midY = ((legs[0].ftY + legs[2].ftY) / 2);
if (target == FOOD){
angle = (angle + (getRotDir(bangle, angToTarg, 10) * angSpeedToM));
} else {
angle = (angle + (getRotDir(bangle, angToTarg, 20) * angSpeedToM));
};
bangle = angleTo(xPos, yPos, midX, midY);
checkCollision();
setCenter();
setHips();
shell.x = xPos;
shell.y = yPos;
shell.rotation = ((bangle * 180) / Math.PI);
framesPerStep = 15;
if (target == FOOD){
closeDistOuter = 30;
} else {
closeDistOuter = 50;
};
if (distToTarg > closeDistOuter){
stride = 10;
} else {
if (distToTarg < closeDistInner){
stride = -5;
} else {
stride = 0;
};
};
if ((counter % wait) == 0){
currLeg = legs[legNum];
if (legNum < (legs.length - 1)){
legNum++;
} else {
legNum = 0;
};
if ((((legNum == 1)) || ((legNum == 3)))){
wait = 7;
} else {
wait = 20;
};
currLeg.setTarget(angle, stride, framesPerStep);
numSteps++;
};
flegs[0].step();
rlegs[0].step();
flegs[1].step();
rlegs[1].step();
}
private function fixAngle(_arg1:Number):Number{
_arg1 = (_arg1 % (2 * Math.PI));
return (((_arg1)<0) ? (_arg1 + (2 * Math.PI)) : _arg1);
}
private function setTail(){
var _local1:Number;
tailBaseX = (xPos + ((hips[2].x - hips[3].x) / 2));
tailBaseY = (yPos + ((hips[2].y - hips[3].y) / 2));
tailAng = angleTo(tailBaseX, tailBaseY, tailTipX, tailTipY);
_local1 = getAngleDiff((bangle + Math.PI), tailAng);
if (_local1 > 0.3){
tailAng = ((bangle + Math.PI) + 0.3);
} else {
if (_local1 < -0.3){
tailAng = ((bangle + Math.PI) - 0.3);
};
};
tailTipX = (tailBaseX + (Math.cos(tailAng) * tailLen));
tailTipY = (tailBaseY + (Math.sin(tailAng) * tailLen));
tail.x = tailBaseX;
tail.y = tailBaseY;
tail.rotation = ((tailAng * 180) / Math.PI);
}
}
}//package