Section 1
//Bounce (com.robertpenner.easing.Bounce)
package com.robertpenner.easing {
public class Bounce {
public static function easeOut(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number):Number{
_arg1 = (_arg1 / _arg4);
if (_arg1 < (1 / 2.75)){
return (((_arg3 * ((7.5625 * _arg1) * _arg1)) + _arg2));
};
if (_arg1 < (2 / 2.75)){
_arg1 = (_arg1 - (1.5 / 2.75));
return (((_arg3 * (((7.5625 * _arg1) * _arg1) + 0.75)) + _arg2));
};
if (_arg1 < (2.5 / 2.75)){
_arg1 = (_arg1 - (2.25 / 2.75));
return (((_arg3 * (((7.5625 * _arg1) * _arg1) + 0.9375)) + _arg2));
};
_arg1 = (_arg1 - (2.625 / 2.75));
return (((_arg3 * (((7.5625 * _arg1) * _arg1) + 0.984375)) + _arg2));
}
public static function easeIn(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number):Number{
return (((_arg3 - Bounce.easeOut((_arg4 - _arg1), 0, _arg3, _arg4)) + _arg2));
}
public static function easeInOut(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number):Number{
if (_arg1 < (_arg4 / 2)){
return (((Bounce.easeIn((_arg1 * 2), 0, _arg3, _arg4) * 0.5) + _arg2));
};
return ((((Bounce.easeOut(((_arg1 * 2) - _arg4), 0, _arg3, _arg4) * 0.5) + (_arg3 * 0.5)) + _arg2));
}
}
}//package com.robertpenner.easing
Section 2
//Elastic (com.robertpenner.easing.Elastic)
package com.robertpenner.easing {
public class Elastic {
public static function easeOut(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Number=0, _arg6:Number=0):Number{
var _local7:*;
if (_arg1 == 0){
return (_arg2);
};
_arg1 = (_arg1 / _arg4);
if (_arg1 == 1){
return ((_arg2 + _arg3));
};
if (!_arg6){
_arg6 = (_arg4 * 0.3);
};
if (((!(_arg5)) || ((_arg5 < Math.abs(_arg3))))){
_arg5 = _arg3;
_local7 = (_arg6 / 4);
} else {
_local7 = ((_arg6 / (2 * Math.PI)) * Math.asin((_arg3 / _arg5)));
};
return (((((_arg5 * Math.pow(2, (-10 * _arg1))) * Math.sin(((((_arg1 * _arg4) - _local7) * (2 * Math.PI)) / _arg6))) + _arg3) + _arg2));
}
public static function easeIn(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Number=0, _arg6:Number=0):Number{
var _local7:*;
if (_arg1 == 0){
return (_arg2);
};
_arg1 = (_arg1 / _arg4);
if (_arg1 == 1){
return ((_arg2 + _arg3));
};
if (!_arg6){
_arg6 = (_arg4 * 0.3);
};
if (((!(_arg5)) || ((_arg5 < Math.abs(_arg3))))){
_arg5 = _arg3;
_local7 = (_arg6 / 4);
} else {
_local7 = ((_arg6 / (2 * Math.PI)) * Math.asin((_arg3 / _arg5)));
};
--_arg1;
return ((-(((_arg5 * Math.pow(2, (10 * _arg1))) * Math.sin(((((_arg1 * _arg4) - _local7) * (2 * Math.PI)) / _arg6)))) + _arg2));
}
public static function easeInOut(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Number=0, _arg6:Number=0):Number{
var _local7:*;
if (_arg1 == 0){
return (_arg2);
};
_arg1 = (_arg1 / (_arg4 / 2));
if (_arg1 == 2){
return ((_arg2 + _arg3));
};
if (!_arg6){
_arg6 = (_arg4 * (0.3 * 1.5));
};
if (((!(_arg5)) || ((_arg5 < Math.abs(_arg3))))){
_arg5 = _arg3;
_local7 = (_arg6 / 4);
} else {
_local7 = ((_arg6 / (2 * Math.PI)) * Math.asin((_arg3 / _arg5)));
};
if (_arg1 < 1){
--_arg1;
return (((-0.5 * ((_arg5 * Math.pow(2, (10 * _arg1))) * Math.sin(((((_arg1 * _arg4) - _local7) * (2 * Math.PI)) / _arg6)))) + _arg2));
};
--_arg1;
return ((((((_arg5 * Math.pow(2, (-10 * _arg1))) * Math.sin(((((_arg1 * _arg4) - _local7) * (2 * Math.PI)) / _arg6))) * 0.5) + _arg3) + _arg2));
}
}
}//package com.robertpenner.easing
Section 3
//Expo (com.robertpenner.easing.Expo)
package com.robertpenner.easing {
public class Expo {
public static function easeOut(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number):Number{
return (((_arg1)==_arg4) ? (_arg2 + _arg3) : ((_arg3 * (-(Math.pow(2, ((-10 * _arg1) / _arg4))) + 1)) + _arg2));
}
public static function easeIn(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number):Number{
return (((_arg1)==0) ? _arg2 : ((_arg3 * Math.pow(2, (10 * ((_arg1 / _arg4) - 1)))) + _arg2));
}
public static function easeInOut(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number):Number{
if (_arg1 == 0){
return (_arg2);
};
if (_arg1 == _arg4){
return ((_arg2 + _arg3));
};
_arg1 = (_arg1 / (_arg4 / 2));
if (_arg1 < 1){
return ((((_arg3 / 2) * Math.pow(2, (10 * (_arg1 - 1)))) + _arg2));
};
--_arg1;
return ((((_arg3 / 2) * (-(Math.pow(2, (-10 * _arg1))) + 2)) + _arg2));
}
}
}//package com.robertpenner.easing
Section 4
//Linear (com.robertpenner.easing.Linear)
package com.robertpenner.easing {
public class Linear {
public static function easeOut(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number):Number{
return ((((_arg3 * _arg1) / _arg4) + _arg2));
}
public static function easeIn(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number):Number{
return ((((_arg3 * _arg1) / _arg4) + _arg2));
}
public static function easeInOut(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number):Number{
return ((((_arg3 * _arg1) / _arg4) + _arg2));
}
public static function easeNone(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number):Number{
return ((((_arg3 * _arg1) / _arg4) + _arg2));
}
}
}//package com.robertpenner.easing
Section 5
//Array2 (de.polygonal.ds.Array2)
package de.polygonal.ds {
public class Array2 implements Collection {
private var _a:Array;
private var _h:int;
private var _w:int;
public function Array2(_arg1:int, _arg2:int){
if ((((_arg1 < 2)) || ((_arg2 < 2)))){
throw (new Error("illegal size"));
};
_a = new Array((_w = _arg1), (_h = _arg2));
fill(null);
}
public function get size():int{
return ((_w * _h));
}
public function fill(_arg1):void{
var _local3:int;
var _local4:Class;
var _local2:int = (_w * _h);
if ((_arg1 is Class)){
_local4 = (_arg1 as Class);
_local3 = 0;
while (_local3 < _local2) {
_a[_local3] = new (_local4);
_local3++;
};
} else {
_local3 = 0;
while (_local3 < _local2) {
_a[_local3] = _arg1;
_local3++;
};
};
}
public function get width():int{
return (_w);
}
public function getCol(_arg1:int):Array{
var _local2:Array = [];
var _local3:int;
while (_local3 < _h) {
_local2[_local3] = _a[int(((_local3 * _w) + _arg1))];
_local3++;
};
return (_local2);
}
public function shiftDown():void{
if (_h == 1){
return;
};
var _local1:int = ((_h - 1) * _w);
_a = _a.slice(_local1, (_local1 + _w)).concat(_a);
_a.splice((_h * _w), _w);
}
public function set width(_arg1:int):void{
resize(_arg1, _h);
}
public function appendCol(_arg1:Array):void{
_arg1.length = _h;
var _local2:int;
while (_local2 < _h) {
_a.splice((((_local2 * _w) + _w) + _local2), 0, _arg1[_local2]);
_local2++;
};
_w++;
}
public function set height(_arg1:int):void{
resize(_w, _arg1);
}
public function clear():void{
_a = new Array(size);
}
public function get(_arg1:int, _arg2:int){
return (_a[int(((_arg2 * _w) + _arg1))]);
}
public function setRow(_arg1:uint, _arg2:Array):void{
if ((((_arg1 < 0)) || ((_arg1 > _h)))){
throw (new Error("row index out of bounds"));
};
var _local3:int = (_arg1 * _w);
var _local4:int;
while (_local4 < _w) {
_a[int((_local3 + _local4))] = _arg2[_local4];
_local4++;
};
}
public function prependCol(_arg1:Array):void{
_arg1.length = _h;
var _local2:int;
while (_local2 < _h) {
_a.splice(((_local2 * _w) + _local2), 0, _arg1[_local2]);
_local2++;
};
_w++;
}
public function isEmpty():Boolean{
return (false);
}
public function toArray():Array{
var _local1:Array = _a.concat();
var _local2:int = size;
if (_local1.length > _local2){
_local1.length = _local2;
};
return (_local1);
}
public function contains(_arg1):Boolean{
var _local2:int = size;
var _local3:int;
while (_local3 < _local2) {
if (_a[_local3] === _arg1){
return (true);
};
_local3++;
};
return (false);
}
public function appendRow(_arg1:Array):void{
_arg1.length = _w;
_a = _a.concat(_arg1);
_h++;
}
public function dump():String{
var _local2:int;
var _local3:*;
var _local5:int;
var _local1 = "Array2\n{";
var _local4:int;
while (_local4 < _h) {
_local1 = (_local1 + ("\n" + "\t"));
_local2 = (_local4 * _w);
_local5 = 0;
while (_local5 < _w) {
_local3 = _a[int((_local2 + _local5))];
_local1 = (_local1 + (("[" + ((_local3)!=undefined) ? _local3 : "?") + "]"));
_local5++;
};
_local4++;
};
_local1 = (_local1 + "\n}");
return (_local1);
}
public function getArray():Array{
return (_a);
}
public function getRow(_arg1:int):Array{
var _local2:int = (_arg1 * _w);
return (_a.slice(_local2, (_local2 + _w)));
}
public function get height():int{
return (_h);
}
public function shiftLeft():void{
var _local2:int;
if (_w == 1){
return;
};
var _local1:int = (_w - 1);
var _local3:int;
while (_local3 < _h) {
_local2 = ((_local3 * _w) + _local1);
_a.splice(_local2, 0, _a.splice((_local2 - _local1), 1));
_local3++;
};
}
public function getIterator():Iterator{
return (new Array2Iterator(this));
}
public function prependRow(_arg1:Array):void{
_arg1.length = _w;
_a = _arg1.concat(_a);
_h++;
}
public function set(_arg1:int, _arg2:int, _arg3):void{
_a[int(((_arg2 * _w) + _arg1))] = _arg3;
}
public function resize(_arg1:int, _arg2:int):void{
var _local6:int;
var _local7:int;
var _local8:int;
var _local9:int;
if ((((_arg1 < 2)) || ((_arg2 < 2)))){
throw (new Error("illegal size"));
};
var _local3:Array = _a.concat();
_a.length = 0;
_a.length = (_arg1 * _arg2);
var _local4:int = ((_arg1 < _w)) ? _arg1 : _w;
var _local5:int = ((_arg2 < _h)) ? _arg2 : _h;
_local7 = 0;
while (_local7 < _local5) {
_local8 = (_local7 * _arg1);
_local9 = (_local7 * _w);
_local6 = 0;
while (_local6 < _local4) {
_a[int((_local8 + _local6))] = _local3[int((_local9 + _local6))];
_local6++;
};
_local7++;
};
_w = _arg1;
_h = _arg2;
}
public function transpose():void{
var _local3:int;
var _local1:Array = _a.concat();
var _local2:int;
while (_local2 < _h) {
_local3 = 0;
while (_local3 < _w) {
_a[int(((_local3 * _w) + _local2))] = _local1[int(((_local2 * _w) + _local3))];
_local3++;
};
_local2++;
};
}
public function shiftRight():void{
var _local2:int;
if (_w == 1){
return;
};
var _local1:int = (_w - 1);
var _local3:int;
while (_local3 < _h) {
_local2 = ((_local3 * _w) + _local1);
_a.splice((_local2 - _local1), 0, _a.splice(_local2, 1));
_local3++;
};
}
public function toString():String{
return ((((("[Array2, width=" + width) + ", height=") + height) + "]"));
}
public function shiftUp():void{
if (_h == 1){
return;
};
_a = _a.concat(_a.slice(0, _w));
_a.splice(0, _w);
}
public function setCol(_arg1:int, _arg2:Array):void{
if ((((_arg1 < 0)) || ((_arg1 > _w)))){
throw (new Error("column index out of bounds"));
};
var _local3:int;
while (_local3 < _h) {
_a[int(((_local3 * _w) + _arg1))] = _arg2[_local3];
_local3++;
};
}
}
}//package de.polygonal.ds
class Array2Iterator implements Iterator {
private var _xCursor:int;
private var _a2:Array2;
private var _yCursor:int;
private function Array2Iterator(_arg1:Array2){
_a2 = _arg1;
_xCursor = (_yCursor = 0);
}
public function start():void{
_xCursor = (_yCursor = 0);
}
public function hasNext():Boolean{
return ((((_yCursor * _a2.width) + _xCursor) < _a2.size));
}
public function get data(){
return (_a2.get(_xCursor, _yCursor));
}
public function set data(_arg1):void{
_a2.set(_xCursor, _yCursor, _arg1);
}
public function next(){
var _local1:* = data;
if (++_xCursor == _a2.width){
_yCursor++;
_xCursor = 0;
};
return (_local1);
}
}
Section 6
//ArrayedQueue (de.polygonal.ds.ArrayedQueue)
package de.polygonal.ds {
public class ArrayedQueue implements Collection {
private var _que:Array;
private var _count:int;
private var _size:int;
private var _front:int;
private var _divisor:int;
public function ArrayedQueue(_arg1:int){
init(_arg1);
}
public function get size():int{
return (_count);
}
public function isEmpty():Boolean{
return ((_count == 0));
}
public function get maxSize():int{
return (_size);
}
public function enqueue(_arg1):Boolean{
if (_size != _count){
_que[int(((_count++ + _front) & _divisor))] = _arg1;
return (true);
};
return (false);
}
public function clear():void{
_que = new Array(_size);
_front = (_count = 0);
var _local1:int;
while (_local1 < _size) {
_que[_local1] = null;
_local1++;
};
}
private function init(_arg1:int):void{
if (!(((_arg1 > 0)) && (((_arg1 & (_arg1 - 1)) == 0)))){
_arg1 = (_arg1 | (_arg1 >> 1));
_arg1 = (_arg1 | (_arg1 >> 2));
_arg1 = (_arg1 | (_arg1 >> 4));
_arg1 = (_arg1 | (_arg1 >> 8));
_arg1 = (_arg1 | (_arg1 >> 16));
_arg1++;
};
_size = _arg1;
_divisor = (_arg1 - 1);
clear();
}
public function peek(){
return (_que[_front]);
}
public function toArray():Array{
var _local1:Array = new Array(_count);
var _local2:int;
while (_local2 < _count) {
_local1[_local2] = _que[int(((_local2 + _front) & _divisor))];
_local2++;
};
return (_local1);
}
public function contains(_arg1):Boolean{
var _local2:int;
while (_local2 < _count) {
if (_que[int(((_local2 + _front) & _divisor))] === _arg1){
return (true);
};
_local2++;
};
return (false);
}
public function getIterator():Iterator{
return (new ArrayedQueueIterator(this));
}
public function dispose():void{
if (!_front){
_que[int((_size - 1))] = null;
} else {
_que[int((_front - 1))] = null;
};
}
public function back(){
return (_que[int((((_count - 1) + _front) & _divisor))]);
}
public function getAt(_arg1:int){
if (_arg1 >= _count){
return (null);
};
return (_que[int(((_arg1 + _front) & _divisor))]);
}
public function toString():String{
return ((("[ArrayedQueue, size=" + size) + "]"));
}
public function dequeue(){
var _local1:*;
if (_count > 0){
_local1 = _que[int(_front++)];
if (_front == _size){
_front = 0;
};
_count--;
return (_local1);
};
return (null);
}
public function dump():String{
var _local2:int;
var _local1 = "[ArrayedQueue]\n";
_local1 = (_local1 + (("\t" + getAt(_local2)) + " -> front\n"));
_local2 = 1;
while (_local2 < _count) {
_local1 = (_local1 + (("\t" + getAt(_local2)) + "\n"));
_local2++;
};
return (_local1);
}
public function setAt(_arg1:int, _arg2):void{
if (_arg1 >= _count){
return;
};
_que[int(((_arg1 + _front) & _divisor))] = _arg2;
}
}
}//package de.polygonal.ds
class ArrayedQueueIterator implements Iterator {
private var _que:ArrayedQueue;
private var _cursor:int;
private function ArrayedQueueIterator(_arg1:ArrayedQueue){
_que = _arg1;
_cursor = 0;
}
public function get data(){
return (_que.getAt(_cursor));
}
public function next(){
if (_cursor < _que.size){
return (_que.getAt(_cursor++));
};
return (null);
}
public function hasNext():Boolean{
return ((_cursor < _que.size));
}
public function set data(_arg1):void{
_que.setAt(_cursor, _arg1);
}
public function start():void{
_cursor = 0;
}
}
Section 7
//BinaryTreeNode (de.polygonal.ds.BinaryTreeNode)
package de.polygonal.ds {
public class BinaryTreeNode {
public var left:BinaryTreeNode;
public var data;
public var parent:BinaryTreeNode;
public var right:BinaryTreeNode;
public function BinaryTreeNode(_arg1){
this.data = _arg1;
parent = (left = (right = null));
}
public function destroy():void{
if (left){
left.destroy();
};
left = null;
if (right){
right.destroy();
};
right = null;
}
public function setLeft(_arg1):void{
if (!left){
left = new BinaryTreeNode(_arg1);
left.parent = this;
} else {
left.data = data;
};
}
public function toString():String{
return ((("[BinaryTreeNode, data= " + data) + "]"));
}
public function getDepth(_arg1:BinaryTreeNode=null):int{
var _local2 = -1;
var _local3 = -1;
if (_arg1 == null){
_arg1 = this;
};
if (_arg1.left){
_local2 = getDepth(_arg1.left);
};
if (_arg1.right){
_local3 = getDepth(_arg1.right);
};
return ((((_local2 > _local3)) ? _local2 : _local3 + 1));
}
public function count():int{
var _local1 = 1;
if (left){
_local1 = (_local1 + left.count());
};
if (right){
_local1 = (_local1 + right.count());
};
return (_local1);
}
public function isLeft():Boolean{
return ((this == parent.left));
}
public function isRight():Boolean{
return ((this == parent.right));
}
public function setRight(_arg1):void{
if (!right){
right = new BinaryTreeNode(_arg1);
right.parent = this;
} else {
right.data = data;
};
}
public static function inorder(_arg1:BinaryTreeNode, _arg2:Function):void{
if (_arg1){
if (_arg1.left){
BinaryTreeNode.inorder(_arg1.left, _arg2);
};
_arg2(_arg1);
if (_arg1.right){
BinaryTreeNode.inorder(_arg1.right, _arg2);
};
};
}
public static function preorder(_arg1:BinaryTreeNode, _arg2:Function):void{
if (_arg1){
_arg2(_arg1);
if (_arg1.left){
BinaryTreeNode.preorder(_arg1.left, _arg2);
};
if (_arg1.right){
BinaryTreeNode.preorder(_arg1.right, _arg2);
};
};
}
public static function postorder(_arg1:BinaryTreeNode, _arg2:Function):void{
if (_arg1){
if (_arg1.left){
BinaryTreeNode.postorder(_arg1.left, _arg2);
};
if (_arg1.right){
BinaryTreeNode.postorder(_arg1.right, _arg2);
};
_arg2(_arg1);
};
}
}
}//package de.polygonal.ds
Section 8
//Collection (de.polygonal.ds.Collection)
package de.polygonal.ds {
public interface Collection {
function get size():int;
function isEmpty():Boolean;
function getIterator():Iterator;
function clear():void;
function toArray():Array;
function contains(_arg1):Boolean;
}
}//package de.polygonal.ds
Section 9
//Iterator (de.polygonal.ds.Iterator)
package de.polygonal.ds {
public interface Iterator {
function start():void;
function set data(_arg1):void;
function get data();
function next();
function hasNext():Boolean;
}
}//package de.polygonal.ds
Section 10
//BroadPhase (de.polygonal.motor2.collision.nbody.BroadPhase)
package de.polygonal.motor2.collision.nbody {
import de.polygonal.motor2.*;
import flash.geom.*;
import de.polygonal.motor2.math.*;
import de.polygonal.motor2.collision.shapes.*;
import de.polygonal.ds.*;
public class BroadPhase implements IBroadPhase {
public var proxyLookup:Array;
public var world:World;
protected var _ymin:Number;
protected var _ymax:Number;
protected var _xmin:Number;
public var pairBuffer:Array;
public var proxyList:ShapeProxy;
protected var _xmax:Number;
protected var _pairHandler:IPairCallback;
public var freeProxy:int;
public var proxyIdQueue:ArrayedQueue;
public var proxyQue:ArrayedQueue;
public var pairBufferCount:int;
public var worldAABB:AABB2;
public function BroadPhase(){
init();
}
protected function removeBufferedPair(_arg1:int, _arg2:int):void{
var _local3:Pair;
if (_local3 == null){
return;
};
if (_local3.isBuffered() == false){
if (pairBufferCount < Constants.k_maxPairs){
_local3.setBuffered();
pairBuffer[pairBufferCount].proxyId1 = _local3.proxyId1;
pairBuffer[pairBufferCount].proxyId2 = _local3.proxyId2;
pairBufferCount++;
};
};
_local3.setRemoved();
}
public function init():void{
var _local1:ShapeProxy;
var _local3:int;
var _local2:int = Constants.k_maxProxies;
proxyLookup = new Array(_local2);
proxyQue = new ArrayedQueue(_local2);
_local3 = 0;
while (_local3 < _local2) {
_local1 = new ShapeProxy();
_local1.id = (_local3 + 1);
proxyQue.enqueue(_local1);
proxyLookup[_local1.id] = _local1;
_local3++;
};
proxyList = null;
pairBuffer = new Array(Constants.k_maxPairs);
pairBufferCount = 0;
_local2 = Constants.k_maxPairs;
}
public function inRange2(_arg1:Number):Boolean{
return (false);
}
public function moveProxy(_arg1:int):void{
}
protected function addBufferedPair(_arg1:int, _arg2:int):void{
var _local5:Pair;
var _local3:ShapeProxy = proxyLookup[_arg1];
var _local4:ShapeProxy = proxyLookup[_arg2];
if (_local3.groupIndex == _local4.groupIndex){
if (_local3.groupIndex != 0){
if (_local3.groupIndex <= 0){
return;
};
};
};
if ((_local3.maskBits & _local4.categoryBits) == 0){
return;
};
if ((_local3.categoryBits & _local4.maskBits) == 0){
return;
};
if (_local5 == null){
return;
};
if (_local5.isBuffered() == false){
if (pairBufferCount < Constants.k_maxPairs){
_local5.setBuffered();
pairBufferCount++;
};
};
_local5.clearRemoved();
}
public function inRange(_arg1:AABB2):Boolean{
return (false);
}
public function search():void{
}
public function setWorldBounds(_arg1:AABB2):void{
this.worldAABB = _arg1;
_xmin = worldAABB.xmin;
_ymin = worldAABB.ymin;
_xmax = worldAABB.xmax;
_ymax = worldAABB.ymax;
}
public function query(_arg1:Point, _arg2:Number, _arg3:Array, _arg4:int):int{
return (0);
}
public function setPairHandler(_arg1:IPairCallback):void{
_pairHandler = _arg1;
}
public function removeProxy(_arg1:int):void{
var _local2:ShapeProxy = proxyLookup[_arg1];
if (_local2.prev){
_local2.prev.next = _local2.next;
};
if (_local2.next){
_local2.next.prev = _local2.prev;
};
if (_local2 == proxyList){
proxyList = _local2.next;
};
_local2.init();
proxyQue.enqueue(_local2);
}
public function createProxy(_arg1:int, _arg2:int, _arg3:int, _arg4:ShapeSkeleton):int{
var _local5:ShapeProxy;
_local5 = proxyQue.dequeue();
_local5.shape = _arg4;
_local5.groupIndex = _arg1;
_local5.categoryBits = _arg2;
_local5.maskBits = _arg3;
proxyLookup[_local5.id] = _local5;
_local5.next = proxyList;
if (proxyList){
proxyList.prev = _local5;
};
proxyList = _local5;
return (_local5.id);
}
public function insideBounds(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number):Boolean{
return (false);
}
public function Flush():void{
}
public function setWorld(_arg1:World):void{
this.world = _arg1;
}
}
}//package de.polygonal.motor2.collision.nbody
Section 11
//ExhaustiveSearch (de.polygonal.motor2.collision.nbody.ExhaustiveSearch)
package de.polygonal.motor2.collision.nbody {
import flash.geom.*;
import de.polygonal.motor2.collision.shapes.*;
import de.polygonal.motor2.dynamics.contact.*;
import flash.utils.*;
public class ExhaustiveSearch extends BroadPhase {
public var _pairs:Dictionary;
public function ExhaustiveSearch(){
_pairs = new Dictionary(true);
}
override public function search():void{
var _local1:ShapeProxy;
var _local2:ShapeSkeleton;
var _local3:int;
var _local4:ShapeProxy;
var _local5:ShapeSkeleton;
var _local6:int;
var _local7:Contact;
var _local8:int;
var _local9:Pair;
_local1 = proxyList;
while (_local1) {
_local3 = _local1.id;
_local2 = _local1.shape;
_local4 = _local1.next;
while (_local4) {
_local6 = _local4.id;
_local5 = _local4.shape;
if (_local1.groupIndex == _local4.groupIndex){
//unresolved if
//unresolved if
} else {
if ((_local1.maskBits & _local4.categoryBits) == 0){
} else {
if ((_local1.categoryBits & _local4.maskBits) == 0){
} else {
if ((((((((_local2.xmin > _local5.xmax)) || ((_local2.xmax < _local5.xmin)))) || ((_local2.ymin > _local5.ymax)))) || ((_local2.ymax < _local5.ymin)))){
if ((((_local1.overlapCount > 0)) && ((_local4.overlapCount > 0)))){
if (_local3 < _local6){
_local8 = ((_local3 << 16) | (_local6 << 8));
} else {
_local8 = ((_local6 << 16) | (_local3 << 8));
};
_local9 = _pairs[_local8];
if (_local9){
_local1.overlapCount--;
_local4.overlapCount--;
_pairHandler.pairRemoved(_local3, _local6, (_local9.userData as Contact));
_pairs[_local8] = undefined;
};
};
} else {
if (_local3 < _local6){
_local8 = ((_local3 << 16) | (_local6 << 8));
} else {
_local8 = ((_local6 << 16) | (_local3 << 8));
};
if (_pairs[_local8] == undefined){
_local1.overlapCount++;
_local4.overlapCount++;
_local7 = _pairHandler.pairAdded(_local2, _local5);
_pairs[_local8] = new Pair(_local3, _local6, _local7);
};
};
};
};
};
_local4 = _local4.next;
};
_local1 = _local1.next;
};
}
override public function insideBounds(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number):Boolean{
return (true);
}
override public function query(_arg1:Point, _arg2:Number, _arg3:Array, _arg4:int):int{
var _local6:Number;
var _local8:Number;
var _local10:int;
var _local11:ShapeSkeleton;
var _local5:Number = _arg1.x;
var _local7:Number = _arg1.y;
var _local9:Number = (_arg2 * _arg2);
var _local12:ShapeProxy = proxyList;
while (_local12) {
_local11 = _local12.shape;
_local6 = (_local11.x - _local5);
_local8 = (_local11.y - _local7);
if (((_local6 * _local6) + (_local8 * _local8)) < _local9){
var _temp1 = _local10;
_local10 = (_local10 + 1);
var _local13 = _temp1;
_arg3[_local13] = _local11;
if (_local10 == _arg4){
break;
};
};
_local12 = _local12.next;
};
return (_local10);
}
}
}//package de.polygonal.motor2.collision.nbody
Section 12
//IBroadPhase (de.polygonal.motor2.collision.nbody.IBroadPhase)
package de.polygonal.motor2.collision.nbody {
import de.polygonal.motor2.*;
import flash.geom.*;
import de.polygonal.motor2.math.*;
import de.polygonal.motor2.collision.shapes.*;
public interface IBroadPhase {
function setWorld(_arg1:World):void;
function insideBounds(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number):Boolean;
function createProxy(_arg1:int, _arg2:int, _arg3:int, _arg4:ShapeSkeleton):int;
function setWorldBounds(_arg1:AABB2):void;
function query(_arg1:Point, _arg2:Number, _arg3:Array, _arg4:int):int;
function inRange(_arg1:AABB2):Boolean;
function removeProxy(_arg1:int):void;
function moveProxy(_arg1:int):void;
function setPairHandler(_arg1:IPairCallback):void;
function search():void;
}
}//package de.polygonal.motor2.collision.nbody
Section 13
//IPairCallback (de.polygonal.motor2.collision.nbody.IPairCallback)
package de.polygonal.motor2.collision.nbody {
import de.polygonal.motor2.dynamics.contact.*;
public interface IPairCallback {
function pairRemoved(_arg1, _arg2, _arg3):void;
function pairAdded(_arg1, _arg2):Contact;
}
}//package de.polygonal.motor2.collision.nbody
Section 14
//Pair (de.polygonal.motor2.collision.nbody.Pair)
package de.polygonal.motor2.collision.nbody {
public class Pair {
public var proxyId1:int;
public var proxyId2:int;
public var userData;
public var status:int;
public static const PAIR_BUFFERED:int = (1 << 1);
public static const PAIR_RECEIVED:int = (1 << 2);
public static const MAX_PROXIES:int = (1 << 10);
public static const NULL_PAIR:int = (1 << 16);
public static const TABLE_MASK:int = (TABLE_CAPACITY - 1);
public static const TABLE_CAPACITY:int = MAX_PAIRS;
public static const PAIR_REMOVED:int = (1 << 3);
public static const NULL_PROXY:int = (1 << 16);
public static const MAX_PAIRS:int = (MAX_PROXIES << 3);
public function Pair(_arg1:int=0, _arg2:int=0, _arg3=null):void{
if (_arg1 > _arg2){
this.proxyId1 = _arg2;
this.proxyId2 = _arg1;
} else {
this.proxyId1 = _arg1;
this.proxyId2 = _arg2;
};
this.userData = _arg3;
}
public function setBuffered():void{
status = (status | PAIR_BUFFERED);
}
public function setReceived():void{
status = (status | PAIR_RECEIVED);
}
public function isReceived():Boolean{
return (((status & PAIR_RECEIVED) == PAIR_RECEIVED));
}
public function clearBuffered():void{
status = (status & ~(PAIR_BUFFERED));
}
public function isRemoved():Boolean{
return (((status & PAIR_REMOVED) == PAIR_REMOVED));
}
public function init(_arg1:int, _arg2:int, _arg3):void{
if (_arg1 > _arg2){
this.proxyId1 = _arg2;
this.proxyId2 = _arg1;
} else {
this.proxyId1 = _arg1;
this.proxyId2 = _arg2;
};
this.userData = _arg3;
}
public function isBuffered():Boolean{
return (((status & PAIR_BUFFERED) == PAIR_BUFFERED));
}
public function clearRemoved():void{
status = (status & ~(PAIR_REMOVED));
}
public function setRemoved():void{
status = (status | PAIR_REMOVED);
}
}
}//package de.polygonal.motor2.collision.nbody
Section 15
//ShapeProxy (de.polygonal.motor2.collision.nbody.ShapeProxy)
package de.polygonal.motor2.collision.nbody {
import de.polygonal.motor2.collision.shapes.*;
public class ShapeProxy {
public var shape:ShapeSkeleton;
public var categoryBits:int;
public var overlapCount:int;
public var maskBits:int;
public var prev:ShapeProxy;
public var groupIndex:int;
public var next:ShapeProxy;
public var id:int;
public var userData;
public static const NULL_PROXY:int = 2147483647;
public function ShapeProxy(){
init();
}
public function updateIntervals():void{
}
public function init():void{
next = (prev = null);
shape = null;
id = (categoryBits = (maskBits = (groupIndex = -1)));
overlapCount = 0;
}
}
}//package de.polygonal.motor2.collision.nbody
Section 16
//CollideBox (de.polygonal.motor2.collision.pairwise.CollideBox)
package de.polygonal.motor2.collision.pairwise {
import de.polygonal.motor2.collision.shapes.*;
import de.polygonal.motor2.dynamics.contact.*;
import de.polygonal.motor2.dynamics.contact.generator.*;
public class CollideBox implements Collider {
public function collide(_arg1:Manifold, _arg2:ShapeSkeleton, _arg3:ShapeSkeleton, _arg4:Contact):void{
var _local6:Number;
var _local7:Number;
var _local8:Number;
var _local9:Number;
var _local10:Number;
var _local11:int;
var _local14:Number;
var _local15:Number;
var _local16:Number;
var _local17:Number;
var _local18:int;
var _local19:int;
var _local20:int;
var _local21:ShapeSkeleton;
var _local22:Number;
var _local23:Number;
var _local24:Number;
var _local25:Number;
var _local26:Number;
var _local27:Number;
var _local28:int;
var _local29:int;
var _local30:int;
var _local31:Number;
var _local32:Number;
var _local33:Number;
var _local34:Number;
var _local39:Number;
var _local40:Number;
var _local41:Number;
var _local42:Number;
var _local43:Number;
var _local44:Number;
var _local45:Number;
var _local46:ContactPoint;
var _local5:BoxContact = BoxContact(_arg4);
var _local12:Number = (_arg3.x - _arg2.x);
var _local13:Number = (_arg3.y - _arg2.y);
_local11 = _local5.sepAxisId;
if (_local11 == 0){
_local14 = ((_arg2.r11 * _arg3.r11) + (_arg2.r21 * _arg3.r21));
if (_local14 < 0){
_local14 = -(_local14);
};
_local16 = ((_arg2.r11 * _arg3.r12) + (_arg2.r21 * _arg3.r22));
if (_local16 < 0){
_local16 = -(_local16);
};
_local8 = ((_arg2.r11 * _local12) + (_arg2.r21 * _local13));
if (_local8 > 0){
_local9 = ((_local8 - _arg2.ex) - ((_local14 * _arg3.ex) + (_local16 * _arg3.ey)));
if (_local9 > 0){
_arg1.pointCount = 0;
return;
};
_local6 = _arg2.r11;
_local7 = _arg2.r21;
_local18 = 3;
} else {
_local9 = ((-(_local8) - _arg2.ex) - ((_local14 * _arg3.ex) + (_local16 * _arg3.ey)));
if (_local9 > 0){
_arg1.pointCount = 0;
return;
};
_local6 = -(_arg2.r11);
_local7 = -(_arg2.r21);
_local18 = 1;
};
_local10 = _local9;
_local17 = ((_arg2.r12 * _arg3.r12) + (_arg2.r22 * _arg3.r22));
if (_local17 < 0){
_local17 = -(_local17);
};
_local15 = ((_arg2.r12 * _arg3.r11) + (_arg2.r22 * _arg3.r21));
if (_local15 < 0){
_local15 = -(_local15);
};
_local8 = ((_arg2.r12 * _local12) + (_arg2.r22 * _local13));
if (_local8 > 0){
_local9 = ((_local8 - _arg2.ey) - ((_local15 * _arg3.ex) + (_local17 * _arg3.ey)));
if (_local9 > 0){
_local5.sepAxisId = 1;
_arg1.pointCount = 0;
return;
};
if (_local9 > ((0.95 * _local10) + (0.01 * _arg2.ey))){
_local11 = 1;
_local10 = _local9;
_local6 = _arg2.r12;
_local7 = _arg2.r22;
_local18 = 0;
};
} else {
_local9 = ((-(_local8) - _arg2.ey) - ((_local15 * _arg3.ex) + (_local17 * _arg3.ey)));
if (_local9 > 0){
_local5.sepAxisId = 1;
_arg1.pointCount = 0;
return;
};
if (_local9 > ((0.95 * _local10) + (0.01 * _arg2.ey))){
_local11 = 1;
_local10 = _local9;
_local6 = -(_arg2.r12);
_local7 = -(_arg2.r22);
_local18 = 2;
};
};
_local8 = ((_arg3.r11 * _local12) + (_arg3.r21 * _local13));
if (_local8 > 0){
_local9 = ((_local8 - ((_local14 * _arg2.ex) + (_local15 * _arg2.ey))) - _arg3.ex);
if (_local9 > 0){
_local5.sepAxisId = 2;
_arg1.pointCount = 0;
return;
};
if (_local9 > ((0.95 * _local10) + (0.01 * _arg3.ex))){
_local11 = 2;
_local10 = _local9;
_local6 = _arg3.r11;
_local7 = _arg3.r21;
_local18 = 1;
};
} else {
_local9 = ((-(_local8) - ((_local14 * _arg2.ex) + (_local15 * _arg2.ey))) - _arg3.ex);
if (_local9 > 0){
_local5.sepAxisId = 2;
_arg1.pointCount = 0;
return;
};
if (_local9 > ((0.95 * _local10) + (0.01 * _arg3.ex))){
_local11 = 2;
_local10 = _local9;
_local6 = -(_arg3.r11);
_local7 = -(_arg3.r21);
_local18 = 3;
};
};
_local8 = ((_arg3.r12 * _local12) + (_arg3.r22 * _local13));
if (_local8 > 0){
_local9 = ((_local8 - ((_local16 * _arg2.ex) + (_local17 * _arg2.ey))) - _arg3.ey);
if (_local9 > 0){
_local5.sepAxisId = 3;
_arg1.pointCount = 0;
return;
};
if (_local9 > ((0.95 * _local10) + (0.01 * _arg3.ey))){
_local11 = 3;
_local10 = _local9;
_local6 = _arg3.r12;
_local7 = _arg3.r22;
_local18 = 2;
};
} else {
_local9 = ((-(_local8) - ((_local16 * _arg2.ex) + (_local17 * _arg2.ey))) - _arg3.ey);
if (_local9 > 0){
_local5.sepAxisId = 3;
_arg1.pointCount = 0;
return;
};
if (_local9 > ((0.95 * _local10) + (0.01 * _arg3.ey))){
_local11 = 3;
_local10 = _local9;
_local6 = -(_arg3.r12);
_local7 = -(_arg3.r22);
_local18 = 0;
};
};
} else {
if (_local11 == 1){
_local17 = ((_arg2.r12 * _arg3.r12) + (_arg2.r22 * _arg3.r22));
if (_local17 < 0){
_local17 = -(_local17);
};
_local15 = ((_arg2.r12 * _arg3.r11) + (_arg2.r22 * _arg3.r21));
if (_local15 < 0){
_local15 = -(_local15);
};
_local8 = ((_arg2.r12 * _local12) + (_arg2.r22 * _local13));
if (_local8 > 0){
_local9 = ((_local8 - _arg2.ey) - ((_local15 * _arg3.ex) + (_local17 * _arg3.ey)));
if (_local9 > 0){
_arg1.pointCount = 0;
return;
};
_local6 = _arg2.r12;
_local7 = _arg2.r22;
_local18 = 0;
} else {
_local9 = ((-(_local8) - _arg2.ey) - ((_local15 * _arg3.ex) + (_local17 * _arg3.ey)));
if (_local9 > 0){
_arg1.pointCount = 0;
return;
};
_local6 = -(_arg2.r12);
_local7 = -(_arg2.r22);
_local18 = 2;
};
_local10 = _local9;
_local14 = ((_arg2.r11 * _arg3.r11) + (_arg2.r21 * _arg3.r21));
if (_local14 < 0){
_local14 = -(_local14);
};
_local16 = ((_arg2.r11 * _arg3.r12) + (_arg2.r21 * _arg3.r22));
if (_local16 < 0){
_local16 = -(_local16);
};
_local8 = ((_arg2.r11 * _local12) + (_arg2.r21 * _local13));
if (_local8 > 0){
_local9 = ((_local8 - _arg2.ex) - ((_local14 * _arg3.ex) + (_local16 * _arg3.ey)));
if (_local9 > 0){
_local5.sepAxisId = 0;
_arg1.pointCount = 0;
return;
};
if (_local9 > ((0.95 * _local10) + (0.01 * _arg2.ex))){
_local11 = 0;
_local10 = _local9;
_local6 = _arg2.r11;
_local7 = _arg2.r21;
_local18 = 3;
};
} else {
_local9 = ((-(_local8) - _arg2.ex) - ((_local14 * _arg3.ex) + (_local16 * _arg3.ey)));
if (_local9 > 0){
_local5.sepAxisId = 0;
_arg1.pointCount = 0;
return;
};
if (_local9 > ((0.95 * _local10) + (0.01 * _arg2.ex))){
_local11 = 0;
_local10 = _local9;
_local6 = -(_arg2.r11);
_local7 = -(_arg2.r21);
_local18 = 1;
};
};
_local8 = ((_arg3.r11 * _local12) + (_arg3.r21 * _local13));
if (_local8 > 0){
_local9 = ((_local8 - ((_local14 * _arg2.ex) + (_local15 * _arg2.ey))) - _arg3.ex);
if (_local9 > 0){
_local5.sepAxisId = 2;
_arg1.pointCount = 0;
return;
};
if (_local9 > ((0.95 * _local10) + (0.01 * _arg3.ex))){
_local11 = 2;
_local10 = _local9;
_local6 = _arg3.r11;
_local7 = _arg3.r21;
_local18 = 1;
};
} else {
_local9 = ((-(_local8) - ((_local14 * _arg2.ex) + (_local15 * _arg2.ey))) - _arg3.ex);
if (_local9 > 0){
_local5.sepAxisId = 2;
_arg1.pointCount = 0;
return;
};
if (_local9 > ((0.95 * _local10) + (0.01 * _arg3.ex))){
_local11 = 2;
_local10 = _local9;
_local6 = -(_arg3.r11);
_local7 = -(_arg3.r21);
_local18 = 3;
};
};
_local8 = ((_arg3.r12 * _local12) + (_arg3.r22 * _local13));
if (_local8 > 0){
_local9 = ((_local8 - ((_local16 * _arg2.ex) + (_local17 * _arg2.ey))) - _arg3.ey);
if (_local9 > 0){
_local5.sepAxisId = 3;
_arg1.pointCount = 0;
return;
};
if (_local9 > ((0.95 * _local10) + (0.01 * _arg3.ey))){
_local11 = 3;
_local10 = _local9;
_local6 = _arg3.r12;
_local7 = _arg3.r22;
_local18 = 2;
};
} else {
_local9 = ((-(_local8) - ((_local16 * _arg2.ex) + (_local17 * _arg2.ey))) - _arg3.ey);
if (_local9 > 0){
_local5.sepAxisId = 3;
_arg1.pointCount = 0;
return;
};
if (_local9 > ((0.95 * _local10) + (0.01 * _arg3.ey))){
_local11 = 3;
_local10 = _local9;
_local6 = -(_arg3.r12);
_local7 = -(_arg3.r22);
_local18 = 0;
};
};
} else {
if (_local11 == 2){
_local14 = ((_arg2.r11 * _arg3.r11) + (_arg2.r21 * _arg3.r21));
if (_local14 < 0){
_local14 = -(_local14);
};
_local15 = ((_arg2.r12 * _arg3.r11) + (_arg2.r22 * _arg3.r21));
if (_local15 < 0){
_local15 = -(_local15);
};
_local8 = ((_arg3.r11 * _local12) + (_arg3.r21 * _local13));
if (_local8 > 0){
_local9 = ((_local8 - ((_local14 * _arg2.ex) + (_local15 * _arg2.ey))) - _arg3.ex);
if (_local9 > 0){
_arg1.pointCount = 0;
return;
};
_local6 = _arg3.r11;
_local7 = _arg3.r21;
_local18 = 1;
} else {
_local9 = ((-(_local8) - ((_local14 * _arg2.ex) + (_local15 * _arg2.ey))) - _arg3.ex);
if (_local9 > 0){
_arg1.pointCount = 0;
return;
};
_local6 = -(_arg3.r11);
_local7 = -(_arg3.r21);
_local18 = 3;
};
_local10 = _local9;
_local16 = ((_arg2.r11 * _arg3.r12) + (_arg2.r21 * _arg3.r22));
if (_local16 < 0){
_local16 = -(_local16);
};
_local17 = ((_arg2.r12 * _arg3.r12) + (_arg2.r22 * _arg3.r22));
if (_local17 < 0){
_local17 = -(_local17);
};
_local8 = ((_arg2.r11 * _local12) + (_arg2.r21 * _local13));
if (_local8 > 0){
_local9 = ((_local8 - _arg2.ex) - ((_local14 * _arg3.ex) + (_local16 * _arg3.ey)));
if (_local9 > 0){
_local5.sepAxisId = 0;
_arg1.pointCount = 0;
return;
};
if (_local9 > ((0.95 * _local10) + (0.01 * _arg2.ex))){
_local11 = 0;
_local10 = _local9;
_local6 = _arg2.r11;
_local7 = _arg2.r21;
_local18 = 3;
};
} else {
_local9 = ((-(_local8) - _arg2.ex) - ((_local14 * _arg3.ex) + (_local16 * _arg3.ey)));
if (_local9 > 0){
_local5.sepAxisId = 0;
_arg1.pointCount = 0;
return;
};
if (_local9 > ((0.95 * _local10) + (0.01 * _arg2.ex))){
_local11 = 0;
_local10 = _local9;
_local6 = -(_arg2.r11);
_local7 = -(_arg2.r21);
_local18 = 1;
};
};
_local8 = ((_arg2.r12 * _local12) + (_arg2.r22 * _local13));
if (_local8 > 0){
_local9 = ((_local8 - _arg2.ey) - ((_local15 * _arg3.ex) + (_local17 * _arg3.ey)));
if (_local9 > 0){
_local5.sepAxisId = 1;
_arg1.pointCount = 0;
return;
};
if (_local9 > ((0.95 * _local10) + (0.01 * _arg2.ey))){
_local11 = 1;
_local10 = _local9;
_local6 = _arg2.r12;
_local7 = _arg2.r22;
_local18 = 0;
};
} else {
_local9 = ((-(_local8) - _arg2.ey) - ((_local15 * _arg3.ex) + (_local17 * _arg3.ey)));
if (_local9 > 0){
_local5.sepAxisId = 1;
_arg1.pointCount = 0;
return;
};
if (_local9 > ((0.95 * _local10) + (0.01 * _arg2.ey))){
_local11 = 1;
_local10 = _local9;
_local6 = -(_arg2.r12);
_local7 = -(_arg2.r22);
_local18 = 2;
};
};
_local8 = ((_arg3.r12 * _local12) + (_arg3.r22 * _local13));
if (_local8 > 0){
_local9 = ((_local8 - ((_local16 * _arg2.ex) + (_local17 * _arg2.ey))) - _arg3.ey);
if (_local9 > 0){
_local5.sepAxisId = 3;
_arg1.pointCount = 0;
return;
};
if (_local9 > ((0.95 * _local10) + (0.01 * _arg3.ey))){
_local11 = 3;
_local10 = _local9;
_local6 = _arg3.r12;
_local7 = _arg3.r22;
_local18 = 2;
};
} else {
_local9 = ((-(_local8) - ((_local16 * _arg2.ex) + (_local17 * _arg2.ey))) - _arg3.ey);
if (_local9 > 0){
_local5.sepAxisId = 3;
_arg1.pointCount = 0;
return;
};
if (_local9 > ((0.95 * _local10) + (0.01 * _arg3.ey))){
_local11 = 3;
_local10 = _local9;
_local6 = -(_arg3.r12);
_local7 = -(_arg3.r22);
_local18 = 0;
};
};
} else {
if (_local11 == 3){
_local16 = ((_arg2.r11 * _arg3.r12) + (_arg2.r21 * _arg3.r22));
if (_local16 < 0){
_local16 = -(_local16);
};
_local17 = ((_arg2.r12 * _arg3.r12) + (_arg2.r22 * _arg3.r22));
if (_local17 < 0){
_local17 = -(_local17);
};
_local8 = ((_arg3.r12 * _local12) + (_arg3.r22 * _local13));
if (_local8 > 0){
_local9 = ((_local8 - ((_local16 * _arg2.ex) + (_local17 * _arg2.ey))) - _arg3.ey);
if (_local9 > 0){
_arg1.pointCount = 0;
return;
};
_local6 = _arg3.r12;
_local7 = _arg3.r22;
_local18 = 2;
} else {
_local9 = ((-(_local8) - ((_local16 * _arg2.ex) + (_local17 * _arg2.ey))) - _arg3.ey);
if (_local9 > 0){
_arg1.pointCount = 0;
return;
};
_local6 = -(_arg3.r12);
_local7 = -(_arg3.r22);
_local18 = 0;
};
_local10 = _local9;
_local14 = ((_arg2.r11 * _arg3.r11) + (_arg2.r21 * _arg3.r21));
if (_local14 < 0){
_local14 = -(_local14);
};
_local15 = ((_arg2.r12 * _arg3.r11) + (_arg2.r22 * _arg3.r21));
if (_local15 < 0){
_local15 = -(_local15);
};
_local8 = ((_arg2.r11 * _local12) + (_arg2.r21 * _local13));
if (_local8 > 0){
_local9 = ((_local8 - _arg2.ex) - ((_local14 * _arg3.ex) + (_local16 * _arg3.ey)));
if (_local9 > 0){
_local5.sepAxisId = 0;
_arg1.pointCount = 0;
return;
};
if (_local9 > ((0.95 * _local10) + (0.01 * _arg2.ex))){
_local11 = 0;
_local10 = _local9;
_local6 = _arg2.r11;
_local7 = _arg2.r21;
_local18 = 3;
};
} else {
_local9 = ((-(_local8) - _arg2.ex) - ((_local14 * _arg3.ex) + (_local16 * _arg3.ey)));
if (_local9 > 0){
_local5.sepAxisId = 0;
_arg1.pointCount = 0;
return;
};
if (_local9 > ((0.95 * _local10) + (0.01 * _arg2.ex))){
_local11 = 0;
_local10 = _local9;
_local6 = -(_arg2.r11);
_local7 = -(_arg2.r21);
_local18 = 1;
};
};
_local8 = ((_arg2.r12 * _local12) + (_arg2.r22 * _local13));
if (_local8 > 0){
_local9 = ((_local8 - _arg2.ey) - ((_local15 * _arg3.ex) + (_local17 * _arg3.ey)));
if (_local9 > 0){
_local5.sepAxisId = 1;
_arg1.pointCount = 0;
return;
};
if (_local9 > ((0.95 * _local10) + (0.01 * _arg2.ey))){
_local11 = 1;
_local10 = _local9;
_local6 = _arg2.r12;
_local7 = _arg2.r22;
_local18 = 0;
};
} else {
_local9 = ((-(_local8) - _arg2.ey) - ((_local15 * _arg3.ex) + (_local17 * _arg3.ey)));
if (_local9 > 0){
_local5.sepAxisId = 1;
_arg1.pointCount = 0;
return;
};
if (_local9 > ((0.95 * _local10) + (0.01 * _arg2.ey))){
_local11 = 1;
_local10 = _local9;
_local6 = -(_arg2.r12);
_local7 = -(_arg2.r22);
_local18 = 2;
};
};
_local8 = ((_arg3.r11 * _local12) + (_arg3.r21 * _local13));
if (_local8 > 0){
_local9 = ((_local8 - ((_local14 * _arg2.ex) + (_local15 * _arg2.ey))) - _arg3.ex);
if (_local9 > 0){
_local5.sepAxisId = 2;
_arg1.pointCount = 0;
return;
};
if (_local9 > ((0.95 * _local10) + (0.01 * _arg3.ex))){
_local11 = 2;
_local10 = _local9;
_local6 = _arg3.r11;
_local7 = _arg3.r21;
_local18 = 1;
};
} else {
_local9 = ((-(_local8) - ((_local14 * _arg2.ex) + (_local15 * _arg2.ey))) - _arg3.ex);
if (_local9 > 0){
_local5.sepAxisId = 2;
_arg1.pointCount = 0;
return;
};
if (_local9 > ((0.95 * _local10) + (0.01 * _arg3.ex))){
_local11 = 2;
_local10 = _local9;
_local6 = -(_arg3.r11);
_local7 = -(_arg3.r21);
_local18 = 3;
};
};
};
};
};
};
if (_local11 == 0){
_local21 = _arg3;
_local22 = (((_arg2.x * _local6) + (_arg2.y * _local7)) + _arg2.ex);
_local26 = _arg2.r12;
_local27 = _arg2.r22;
_local23 = ((_arg2.x * _local26) + (_arg2.y * _local27));
_local24 = (-(_local23) + _arg2.ey);
_local28 = 1;
_local25 = (_local23 + _arg2.ey);
_local29 = 3;
} else {
if (_local11 == 1){
_local21 = _arg3;
_local22 = (((_arg2.x * _local6) + (_arg2.y * _local7)) + _arg2.ey);
_local26 = _arg2.r11;
_local27 = _arg2.r21;
_local23 = ((_arg2.x * _local26) + (_arg2.y * _local27));
_local24 = (-(_local23) + _arg2.ex);
_local28 = 2;
_local25 = (_local23 + _arg2.ex);
_local29 = 4;
} else {
if (_local11 == 2){
_local21 = _arg2;
_local30 = 1;
_local6 = -(_local6);
_local7 = -(_local7);
_local22 = (((_arg3.x * _local6) + (_arg3.y * _local7)) + _arg3.ex);
_local26 = _arg3.r12;
_local27 = _arg3.r22;
_local23 = ((_arg3.x * _local26) + (_arg3.y * _local27));
_local24 = (-(_local23) + _arg3.ey);
_local28 = 1;
_local25 = (_local23 + _arg3.ey);
_local29 = 3;
} else {
if (_local11 == 3){
_local21 = _arg2;
_local30 = 1;
_local6 = -(_local6);
_local7 = -(_local7);
_local22 = (((_arg3.x * _local6) + (_arg3.y * _local7)) + _arg3.ey);
_local26 = _arg3.r11;
_local27 = _arg3.r21;
_local23 = ((_arg3.x * _local26) + (_arg3.y * _local27));
_local24 = (-(_local23) + _arg3.ex);
_local28 = 2;
_local25 = (_local23 + _arg3.ex);
_local29 = 4;
};
};
};
};
var _local35:Number = ((-(_local21.r11) * _local6) - (_local21.r21 * _local7));
var _local36:Number = ((-(_local21.r12) * _local6) - (_local21.r22 * _local7));
if (((_local35 < 0)) ? -(_local35) : _local35 > ((_local36 < 0)) ? -(_local36) : _local36){
if (_local35 > 0){
_local31 = _local21.ex;
_local33 = -(_local21.ey);
_local32 = _local21.ex;
_local34 = _local21.ey;
if (_local36 > 0){
_local19 = 0;
_local20 = 3;
} else {
_local19 = 3;
_local20 = 0;
};
} else {
_local31 = -(_local21.ex);
_local33 = _local21.ey;
_local32 = -(_local21.ex);
_local34 = -(_local21.ey);
if (_local36 > 0){
_local19 = 1;
_local20 = 2;
} else {
_local19 = 2;
_local20 = 1;
};
};
} else {
if (_local36 > 0){
_local31 = _local21.ex;
_local33 = _local21.ey;
_local32 = -(_local21.ex);
_local34 = _local21.ey;
if (_local35 > 0){
_local19 = 0;
_local20 = 1;
} else {
_local19 = 1;
_local20 = 0;
};
} else {
_local31 = -(_local21.ex);
_local33 = -(_local21.ey);
_local32 = _local21.ex;
_local34 = -(_local21.ey);
if (_local35 > 0){
_local19 = 3;
_local20 = 2;
} else {
_local19 = 2;
_local20 = 3;
};
};
};
var _local37:Number = _local31;
var _local38:Number = _local33;
_local31 = ((_local21.x + (_local21.r11 * _local37)) + (_local21.r12 * _local38));
_local33 = ((_local21.y + (_local21.r21 * _local37)) + (_local21.r22 * _local38));
_local37 = _local32;
_local38 = _local34;
_local32 = ((_local21.x + (_local21.r11 * _local37)) + (_local21.r12 * _local38));
_local34 = ((_local21.y + (_local21.r21 * _local37)) + (_local21.r22 * _local38));
_local43 = (((_local31 * -(_local26)) + (_local33 * -(_local27))) - _local24);
_local44 = (((_local32 * -(_local26)) + (_local34 * -(_local27))) - _local24);
if ((_local43 * _local44) < 0){
_local45 = (_local43 / (_local43 - _local44));
if (_local43 < 0){
_local39 = _local31;
_local41 = _local33;
_local40 = (_local39 + (_local45 * (_local32 - _local39)));
_local42 = (_local41 + (_local45 * (_local34 - _local41)));
} else {
_local39 = _local32;
_local41 = _local34;
_local40 = (_local31 + (_local45 * (_local39 - _local31)));
_local42 = (_local33 + (_local45 * (_local41 - _local33)));
};
} else {
if (_local43 > 0){
_arg1.pointCount = 0;
return;
};
if (_local43 < _local44){
_local39 = _local31;
_local41 = _local33;
_local40 = _local32;
_local42 = _local34;
} else {
_local40 = _local31;
_local42 = _local33;
_local39 = _local32;
_local41 = _local34;
};
};
_local43 = (((_local39 * _local26) + (_local41 * _local27)) - _local25);
_local44 = (((_local40 * _local26) + (_local42 * _local27)) - _local25);
if ((_local43 * _local44) < 0){
_local45 = (_local43 / (_local43 - _local44));
_local39 = (_local39 + (_local45 * (_local40 - _local39)));
_local41 = (_local41 + (_local45 * (_local42 - _local41)));
} else {
if (_local43 > 0){
_arg1.pointCount = 0;
return;
};
};
_local9 = (((_local6 * _local39) + (_local7 * _local41)) - _local22);
if (_local9 <= 0){
_arg1.pointCount = 1;
if (_local30){
_arg1.nx = -(_local6);
_arg1.ny = -(_local7);
} else {
_arg1.nx = _local6;
_arg1.ny = _local7;
};
_local46 = _arg1.c0;
_local46.sep = _local9;
_local46.x = _local39;
_local46.y = _local41;
_local46.id.flip = _local30;
_local46.id.incEdge = _local20;
_local46.id.incVert = _local19;
_local46.id.refFace = _local18;
_local46.id.bake();
_local9 = (((_local6 * _local40) + (_local7 * _local42)) - _local22);
if (_local9 <= 0){
_arg1.pointCount = 2;
_local46 = _arg1.c1;
_local46.sep = _local9;
_local46.x = _local40;
_local46.y = _local42;
_local46.id.flip = _local30;
_local46.id.incEdge = _local20;
_local46.id.incVert = _local19;
_local46.id.refFace = _local18;
_local46.id.bake();
};
} else {
_local9 = (((_local6 * _local40) + (_local7 * _local42)) - _local22);
if (_local9 <= 0){
_arg1.pointCount = 1;
if (_local30){
_arg1.nx = -(_local6);
_arg1.ny = -(_local7);
} else {
_arg1.nx = _local6;
_arg1.ny = _local7;
};
_local46 = _arg1.c0;
_local46.sep = _local9;
_local46.x = _local40;
_local46.y = _local42;
_local46.id.flip = _local30;
_local46.id.incEdge = _local20;
_local46.id.incVert = _local19;
_local46.id.refFace = _local18;
_local46.id.bake();
};
};
}
}
}//package de.polygonal.motor2.collision.pairwise
Section 17
//CollideBoxCircle (de.polygonal.motor2.collision.pairwise.CollideBoxCircle)
package de.polygonal.motor2.collision.pairwise {
import de.polygonal.motor2.math.*;
import de.polygonal.motor2.collision.shapes.*;
import de.polygonal.motor2.dynamics.contact.*;
import de.polygonal.motor2.dynamics.contact.generator.*;
public class CollideBoxCircle implements Collider {
public function collide(_arg1:Manifold, _arg2:ShapeSkeleton, _arg3:ShapeSkeleton, _arg4:Contact):void{
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:Number;
var _local9:ContactPoint;
var _local11:int;
var _local12:int;
var _local13:Number;
var _local14:Number;
var _local15:Number;
var _local16:Number;
var _local17:Number;
var _local18:Number;
var _local19:Number;
var _local20:V2;
var _local21:V2;
var _local22:V2;
var _local23:V2;
var _local24:Number;
var _local25:Number;
var _local26:Number;
var _local27:Number;
var _local28:BoxCircleContact;
var _local29:Number;
var _local30:Number;
var _local31:int;
var _local32:Number;
var _local33:Number;
var _local34:Number;
var _local35:Number;
var _local10:int = ContactID.NULL_FEATURE;
if (_arg1.pointCount == 1){
_local11 = _local10;
_local12 = _local10;
_local13 = _arg2.x;
_local14 = _arg2.y;
_local15 = (_arg3.x - _arg2.x);
_local16 = (_arg3.y - _arg2.y);
_local17 = 0;
_local18 = 0;
_local19 = ((_local15 * _arg2.r11) + (_local16 * _arg2.r21));
if (_local19 < -(_arg2.ex)){
_local18 = (_local19 + _arg2.ex);
_local19 = -(_arg2.ex);
_local12 = (1 + 1);
_local11 = _local12;
} else {
if (_local19 > _arg2.ex){
_local18 = (_local19 - _arg2.ex);
_local19 = _arg2.ex;
_local12 = (3 + 1);
_local11 = _local12;
};
};
_local13 = (_local13 + (_arg2.r11 * _local19));
_local14 = (_local14 + (_arg2.r21 * _local19));
_local17 = (_local17 + (_local18 * _local18));
_local18 = 0;
_local19 = ((_local15 * _arg2.r12) + (_local16 * _arg2.r22));
if (_local19 < -(_arg2.ey)){
_local18 = (_local19 + _arg2.ey);
_local19 = -(_arg2.ey);
_local12 = _local10;
if (_local11 == (1 + 1)){
_local11 = (2 + 1);
} else {
if (_local11 == _local10){
_local12 = (2 + 1);
};
};
} else {
if (_local19 > _arg2.ey){
_local18 = (_local19 - _arg2.ey);
_local19 = _arg2.ey;
_local12 = _local10;
if (_local11 == (3 + 1)){
_local11 = (0 + 1);
} else {
if (_local11 == _local10){
_local12 = (0 + 1);
};
};
} else {
_local11 = _local10;
};
};
_local13 = (_local13 + (_arg2.r12 * _local19));
_local14 = (_local14 + (_arg2.r22 * _local19));
_local5 = (_local17 + (_local18 * _local18));
if (_local5 >= _arg3.radiusSq){
_arg1.pointCount = 0;
return;
};
_arg1.pointCount = 1;
_local9 = _arg1.c0;
_local9.id.refFace = _local10;
_local9.id.flip = 0;
if (_local5 == 0){
_local9.id.incVert = _local10;
_local7 = ((_local15 * _arg2.r11) + (_local16 * _arg2.r21));
_local8 = ((_local15 * _arg2.r12) + (_local16 * _arg2.r22));
if (_local7 > 0){
if (_local8 > 0){
if ((_arg2.ex - _local7) < (_arg2.ey - _local8)){
_arg1.nx = _arg2.r11;
_arg1.ny = _arg2.r21;
_local9.sep = ((_arg3.radius + _arg2.ex) - _local7);
_local9.id.incEdge = 3;
} else {
_arg1.nx = _arg2.r12;
_arg1.ny = _arg2.r22;
_local9.sep = ((_arg3.radius + _arg2.ey) - _local8);
_local9.id.incEdge = 0;
};
} else {
if ((_arg2.ex - _local7) < (_arg2.ey + _local8)){
_arg1.nx = _arg2.r11;
_arg1.ny = _arg2.r21;
_local9.sep = ((_arg3.radius + _arg2.ex) - _local7);
_local9.id.incEdge = 3;
} else {
_arg1.nx = -(_arg2.r12);
_arg1.ny = -(_arg2.r22);
_local9.sep = ((_arg3.radius + _arg2.ey) + _local8);
_local9.id.incEdge = 2;
};
};
} else {
if (_local8 > 0){
if ((_arg2.ex + _local7) < (_arg2.ey - _local8)){
_arg1.nx = -(_arg2.r11);
_arg1.ny = -(_arg2.r21);
_local9.sep = ((_arg3.radius + _arg2.ex) + _local7);
_local9.id.incEdge = 1;
} else {
_arg1.nx = _arg2.r12;
_arg1.ny = _arg2.r22;
_local9.sep = ((_arg3.radius + _arg2.ey) - _local8);
_local9.id.incEdge = 0;
};
} else {
if ((_arg2.ex + _local7) < (_arg2.ey + _local8)){
_arg1.nx = -(_arg2.r11);
_arg1.ny = -(_arg2.r21);
_local9.sep = ((_arg3.radius + _arg2.ex) + _local7);
_local9.id.incEdge = 1;
} else {
_arg1.nx = -(_arg2.r12);
_arg1.ny = -(_arg2.r22);
_local9.sep = ((_arg3.radius + _arg2.ey) + _local8);
_local9.id.incEdge = 2;
};
};
};
_local9.sep = -(_local9.sep);
} else {
_local7 = (_arg3.x - _local13);
_local8 = (_arg3.y - _local14);
_local6 = Math.sqrt(((_local7 * _local7) + (_local8 * _local8)));
_arg1.nx = (_local7 / _local6);
_arg1.ny = (_local8 / _local6);
_local9.id.incVert = _local11;
_local9.id.incEdge = _local12;
_local9.sep = -((_arg3.radius - Math.sqrt(_local5)));
};
_local9.x = (_arg3.x - (_arg3.radius * _arg1.nx));
_local9.y = (_arg3.y - (_arg3.radius * _arg1.ny));
_local9.id.bake();
} else {
_local24 = _arg3.x;
_local25 = _arg3.y;
_local27 = _arg3.radius;
_local5 = -2147483648;
_local28 = BoxCircleContact(_arg4);
_local20 = _local28.p;
_local21 = _local28.d;
_local26 = ((_local21.x * (_local24 - _local20.x)) + (_local21.y * (_local25 - _local20.y)));
if (_local26 > _local27){
_arg1.pointCount = 0;
_local28.p = _local20;
_local28.d = _local21;
return;
};
if (_local26 > _local5){
_local5 = _local26;
_local22 = _local21;
_local23 = _local20;
};
_local20 = _local20.next;
_local21 = _local21.next;
_local26 = ((_local21.x * (_local24 - _local20.x)) + (_local21.y * (_local25 - _local20.y)));
if (_local26 > _local27){
_local28.p = _local20;
_local28.d = _local21;
_arg1.pointCount = 0;
return;
};
if (_local26 > _local5){
_local5 = _local26;
_local22 = _local21;
_local23 = _local20;
};
_local20 = _local20.next;
_local21 = _local21.next;
_local26 = ((_local21.x * (_local24 - _local20.x)) + (_local21.y * (_local25 - _local20.y)));
if (_local26 > _local27){
_local28.p = _local20;
_local28.d = _local21;
_arg1.pointCount = 0;
return;
};
if (_local26 > _local5){
_local5 = _local26;
_local22 = _local21;
_local23 = _local20;
};
_local20 = _local20.next;
_local21 = _local21.next;
_local26 = ((_local21.x * (_local24 - _local20.x)) + (_local21.y * (_local25 - _local20.y)));
if (_local26 > _local27){
_local28.p = _local20;
_local28.d = _local21;
_arg1.pointCount = 0;
return;
};
if (_local26 > _local5){
_local5 = _local26;
_local22 = _local21;
_local23 = _local20;
};
if (_local5 < 1E-6){
_arg1.pointCount = 1;
_arg1.nx = _local22.x;
_arg1.ny = _local22.y;
_local9 = _arg1.c0;
_local9.id.incEdge = _local22.I;
_local9.id.incVert = _local10;
_local9.id.refFace = _local10;
_local9.id.flip = 0;
_local9.id.bake();
_local9.x = (_local24 - (_local27 * _arg1.nx));
_local9.y = (_local25 - (_local27 * _arg1.ny));
_local9.sep = (_local5 - _local27);
return;
};
_local31 = _local23.I;
if (_local31 == 0){
_local6 = (_arg2.ex * 2);
_local29 = -(_arg2.r11);
_local30 = -(_arg2.r21);
} else {
if (_local31 == 1){
_local29 = -(_arg2.r12);
_local30 = -(_arg2.r22);
_local6 = (_arg2.ey * 2);
} else {
if (_local31 == 2){
_local29 = _arg2.r11;
_local30 = _arg2.r21;
_local6 = (_arg2.ex * 2);
} else {
if (_local31 == 3){
_local29 = _arg2.r12;
_local30 = _arg2.r22;
_local6 = (_arg2.ey * 2);
};
};
};
};
if (_local6 < 1E-6){
_local7 = (_local24 - _local23.x);
_local8 = (_local25 - _local23.y);
_local32 = ((_local7 * _local7) + (_local8 * _local8));
if (_local32 > _arg3.radiusSq){
_arg1.pointCount = 0;
return;
};
_local32 = Math.sqrt(_local32);
_local7 = (_local7 / _local32);
_local8 = (_local8 / _local32);
_arg1.pointCount = 1;
_arg1.nx = _local7;
_arg1.ny = _local8;
_local9 = _arg1.c0;
_local9.id.incVert = (_local31 + 1);
_local9.id.incEdge = _local10;
_local9.id.refFace = _local10;
_local9.id.flip = 0;
_local9.id.bake();
_local9.x = (_local24 - (_arg3.radius * _local7));
_local9.y = (_local25 - (_arg3.radius * _local8));
_local9.sep = (_local32 - _local27);
return;
};
_local9 = _arg1.c0;
_local9.id.flip = 0;
_local9.id.refFace = _local10;
_local35 = (((_local24 - _local23.x) * _local29) + ((_local25 - _local23.y) * _local30));
if (_local35 <= 0){
_local33 = _local23.x;
_local34 = _local23.y;
_local9.id.incVert = _local23.I;
_local9.id.incEdge = _local10;
} else {
if (_local35 >= _local6){
_local33 = _local23.next.x;
_local34 = _local23.next.y;
_local9.id.incVert = _local23.next.I;
_local9.id.incEdge = _local10;
} else {
_local33 = ((_local29 * _local35) + _local23.x);
_local34 = ((_local30 * _local35) + _local23.y);
_local9.id.incVert = _local10;
_local9.id.incEdge = _local23.I;
};
};
_local7 = (_local24 - _local33);
_local8 = (_local25 - _local34);
_local32 = ((_local7 * _local7) + (_local8 * _local8));
if (_local32 > _arg3.radiusSq){
_arg1.pointCount = 0;
return;
};
_local32 = Math.sqrt(_local32);
_local7 = (_local7 / _local32);
_local8 = (_local8 / _local32);
_arg1.pointCount = 1;
_arg1.nx = _local7;
_arg1.ny = _local8;
_local9.x = (_local24 - (_local27 * _local7));
_local9.y = (_local25 - (_local27 * _local8));
_local9.sep = (_local32 - _local27);
_local9.id.bake();
};
}
}
}//package de.polygonal.motor2.collision.pairwise
Section 18
//CollideBoxLineDS (de.polygonal.motor2.collision.pairwise.CollideBoxLineDS)
package de.polygonal.motor2.collision.pairwise {
import de.polygonal.motor2.math.*;
import de.polygonal.motor2.collision.shapes.*;
import de.polygonal.motor2.dynamics.contact.*;
public class CollideBoxLineDS implements Collider {
public function collide(_arg1:Manifold, _arg2:ShapeSkeleton, _arg3:ShapeSkeleton, _arg4:Contact):void{
var _local5:ConvexBSPNode;
var _local6:V2;
var _local7:V2;
var _local8:V2;
var _local9:V2;
var _local10:V2;
var _local11:V2;
var _local12:Number;
var _local26:int;
var _local30:Number;
var _local32:Number;
var _local33:Number;
var _local34:Number;
var _local35:Number;
var _local36:Number;
var _local37:Number;
var _local38:Number;
var _local39:ContactPoint;
var _local40:V2;
var _local13:Number = -2147483648;
var _local14:int;
_local9 = _arg3.worldVertexChain;
_local8 = _arg3.worldNormalChain;
_local5 = _arg2.BSPNode;
while (_local5.R) {
_local5 = ((((-(_local5.N.y) * _local8.x) + (_local5.N.x * _local8.y)))<=0) ? _local5.R : _local5.L;
};
_local6 = _local5.V;
_local12 = ((_local8.x * (_local6.x - _local9.x)) + (_local8.y * (_local6.y - _local9.y)));
if (_local12 > 0){
_arg1.pointCount = 0;
return;
};
if (((_local12 * 0.95) + 0.01) > _local13){
_local13 = _local12;
_local7 = _local8;
_local10 = _local9;
_local11 = _local6;
_local14 = 1;
};
_local9 = _local9.next;
_local8 = _local8.next;
_local6 = _local6.next.next;
_local12 = ((_local8.x * (_local6.x - _local9.x)) + (_local8.y * (_local6.y - _local9.y)));
if (_local12 > 0){
_arg1.pointCount = 0;
return;
};
if (((_local12 * 0.95) + 0.01) > _local13){
_local13 = _local12;
_local7 = _local8;
_local10 = _local9;
_local11 = _local6;
_local14 = 1;
};
var _local15:V2 = _arg3.worldVertexChain;
var _local16:V2 = _local15.next;
var _local17:Number = _local15.x;
var _local18:Number = _local16.x;
var _local19:Number = _local15.y;
var _local20:Number = _local16.y;
_local9 = _arg2.worldVertexChain.next;
_local8 = _arg2.worldNormalChain.next;
if (((_local17 * _local8.x) + (_local19 * _local8.y)) < ((_local18 * _local8.x) + (_local20 * _local8.y))){
_local12 = ((_local8.x * (_local17 - _local9.x)) + (_local8.y * (_local19 - _local9.y)));
if (_local12 > 0){
_arg1.pointCount = 0;
return;
};
if (((_local12 * 0.95) + 0.01) > _local13){
_local13 = _local12;
_local7 = _local8;
_local10 = _local9;
_local11 = _local15;
_local14 = 0;
};
_local9 = _local9.next.next;
_local8 = _local8.next.next;
_local12 = ((_local8.x * (_local18 - _local9.x)) + (_local8.y * (_local20 - _local9.y)));
if (_local12 > 0){
_arg1.pointCount = 0;
return;
};
if (((_local12 * 0.95) + 0.01) > _local13){
_local13 = _local12;
_local7 = _local8;
_local10 = _local9;
_local11 = _local16;
_local14 = 0;
};
} else {
_local12 = ((_local8.x * (_local18 - _local9.x)) + (_local8.y * (_local20 - _local9.y)));
if (_local12 > 0){
_arg1.pointCount = 0;
return;
};
if (((_local12 * 0.95) + 0.01) > _local13){
_local13 = _local12;
_local7 = _local8;
_local10 = _local9;
_local11 = _local16;
_local14 = 0;
};
_local9 = _local9.next.next;
_local8 = _local8.next.next;
_local12 = ((_local8.x * (_local17 - _local9.x)) + (_local8.y * (_local19 - _local9.y)));
if (_local12 > 0){
_arg1.pointCount = 0;
return;
};
if (((_local12 * 0.95) + 0.01) > _local13){
_local13 = _local12;
_local7 = _local8;
_local10 = _local9;
_local11 = _local15;
_local14 = 0;
};
};
_local9 = _arg2.worldVertexChain;
_local8 = _arg2.worldNormalChain;
if (((_local17 * _local8.x) + (_local19 * _local8.y)) < ((_local18 * _local8.x) + (_local20 * _local8.y))){
_local12 = ((_local8.x * (_local17 - _local9.x)) + (_local8.y * (_local19 - _local9.y)));
if (_local12 > 0){
_arg1.pointCount = 0;
return;
};
if (((_local12 * 0.95) + 0.01) > _local13){
_local13 = _local12;
_local7 = _local8;
_local10 = _local9;
_local11 = _local15;
_local14 = 0;
};
_local9 = _local9.next.next;
_local8 = _local8.next.next;
_local12 = ((_local8.x * (_local18 - _local9.x)) + (_local8.y * (_local20 - _local9.y)));
if (_local12 > 0){
_arg1.pointCount = 0;
return;
};
if (((_local12 * 0.95) + 0.01) > _local13){
_local13 = _local12;
_local7 = _local8;
_local10 = _local9;
_local11 = _local16;
_local14 = 0;
};
} else {
_local12 = ((_local8.x * (_local18 - _local9.x)) + (_local8.y * (_local20 - _local9.y)));
if (_local12 > 0){
_arg1.pointCount = 0;
return;
};
if (((_local12 * 0.95) + 0.01) > _local13){
_local13 = _local12;
_local7 = _local8;
_local10 = _local9;
_local11 = _local16;
_local14 = 0;
};
_local9 = _local9.next.next;
_local8 = _local8.next.next;
_local12 = ((_local8.x * (_local17 - _local9.x)) + (_local8.y * (_local19 - _local9.y)));
if (_local12 > 0){
_arg1.pointCount = 0;
return;
};
if (((_local12 * 0.95) + 0.01) > _local13){
_local13 = _local12;
_local7 = _local8;
_local10 = _local9;
_local11 = _local15;
_local14 = 0;
};
};
var _local21:ShapeSkeleton = _arg2;
var _local22:Number = _local7.x;
var _local23:Number = _local7.y;
var _local24:int = _local10.I;
var _local25:int = _local11.I;
var _local27:V2 = _local11.userData.n;
var _local28:Number = ((_local27.x * _local22) + (_local27.y * _local23));
if (((_local27.prev.x * _local22) + (_local27.prev.y * _local23)) < _local28){
_local11 = _local11.prev;
_local26 = _local27.prev.I;
} else {
if (((_local27.next.x * _local22) + (_local27.next.y * _local23)) < _local28){
_local11 = _local11.next;
_local26 = _local27.next.I;
};
};
var _local29:Number = (((_local21.x * _local22) + (_local21.y * _local23)) + (((_local10.x - _local21.x) * _local22) + ((_local10.y - _local21.y) * _local23)));
if (_local21.regularShape){
_local30 = ((_local21.y * _local22) - (_local21.x * _local23));
} else {
_local40 = _local21.offsets[_local10.I];
_local30 = ((((_local21.y + (_local21.r21 * _local40.x)) + (_local21.r22 * _local40.y)) * _local22) - (((_local21.x + (_local21.r11 * _local40.x)) + (_local21.r12 * _local40.y)) * _local23));
};
var _local31:Number = (_local10.userData.mag / 2);
_local36 = ((((_local11.x * _local23) - (_local11.y * _local22)) + _local30) - _local31);
_local37 = ((((_local11.next.x * _local23) - (_local11.next.y * _local22)) + _local30) - _local31);
if ((_local36 * _local37) < 0){
_local38 = (_local36 / (_local36 - _local37));
if (_local36 < 0){
_local32 = _local11.x;
_local34 = _local11.y;
_local33 = (_local32 + (_local38 * (_local11.next.x - _local32)));
_local35 = (_local34 + (_local38 * (_local11.next.y - _local34)));
} else {
_local32 = _local11.next.x;
_local34 = _local11.next.y;
_local33 = (_local11.x + (_local38 * (_local32 - _local11.x)));
_local35 = (_local11.y + (_local38 * (_local34 - _local11.y)));
};
} else {
if (_local36 > 0){
_arg1.pointCount = 0;
return;
};
if (_local36 < _local37){
_local32 = _local11.x;
_local34 = _local11.y;
_local33 = _local11.next.x;
_local35 = _local11.next.y;
} else {
_local33 = _local11.x;
_local35 = _local11.y;
_local32 = _local11.next.x;
_local34 = _local11.next.y;
};
};
_local36 = ((((_local34 * _local22) - _local30) - _local31) - (_local32 * _local23));
_local37 = ((((_local35 * _local22) - _local30) - _local31) - (_local33 * _local23));
if ((_local36 * _local37) < 0){
_local38 = (_local36 / (_local36 - _local37));
_local32 = (_local32 + (_local38 * (_local33 - _local32)));
_local34 = (_local34 + (_local38 * (_local35 - _local34)));
} else {
if (_local36 > 0){
_arg1.pointCount = 0;
return;
};
};
_local13 = (((_local22 * _local32) + (_local23 * _local34)) - _local29);
if (_local13 <= 0){
_arg1.pointCount = 1;
if (_local14){
_arg1.nx = -(_local22);
_arg1.ny = -(_local23);
} else {
_arg1.nx = _local22;
_arg1.ny = _local23;
};
_local39 = _arg1.c0;
_local39.sep = _local13;
_local39.x = _local32;
_local39.y = _local34;
_local39.id.flip = _local14;
_local39.id.incEdge = _local26;
_local39.id.incVert = _local25;
_local39.id.refFace = _local24;
_local39.id.bake();
_local13 = (((_local22 * _local33) + (_local23 * _local35)) - _local29);
if (_local13 <= 0){
_arg1.pointCount = 2;
_local39 = _arg1.c1;
_local39.sep = _local13;
_local39.x = _local33;
_local39.y = _local35;
_local39.id.flip = _local14;
_local39.id.incEdge = _local26;
_local39.id.incVert = _local25;
_local39.id.refFace = _local24;
_local39.id.bake();
};
} else {
_local13 = (((_local22 * _local33) + (_local23 * _local35)) - _local29);
if (_local13 <= 0){
_arg1.pointCount = 1;
if (_local14){
_arg1.nx = -(_local22);
_arg1.ny = -(_local23);
} else {
_arg1.nx = _local22;
_arg1.ny = _local23;
};
_local39 = _arg1.c0;
_local39.sep = _local13;
_local39.x = _local33;
_local39.y = _local35;
_local39.id.flip = _local14;
_local39.id.incEdge = _local26;
_local39.id.incVert = _local25;
_local39.id.refFace = _local24;
_local39.id.bake();
};
};
}
}
}//package de.polygonal.motor2.collision.pairwise
Section 19
//CollideBoxLineSS (de.polygonal.motor2.collision.pairwise.CollideBoxLineSS)
package de.polygonal.motor2.collision.pairwise {
import de.polygonal.motor2.math.*;
import de.polygonal.motor2.collision.shapes.*;
import de.polygonal.motor2.dynamics.contact.*;
public class CollideBoxLineSS implements Collider {
public function collide(_arg1:Manifold, _arg2:ShapeSkeleton, _arg3:ShapeSkeleton, _arg4:Contact):void{
var _local6:ConvexBSPNode;
var _local7:V2;
var _local8:V2;
var _local9:V2;
var _local10:V2;
var _local11:V2;
var _local12:Number;
var _local26:int;
var _local30:Number;
var _local32:Number;
var _local33:Number;
var _local34:Number;
var _local35:Number;
var _local36:Number;
var _local37:Number;
var _local38:Number;
var _local39:ContactPoint;
var _local40:V2;
var _local5:V2 = _arg3.worldNormalChain;
if ((((_arg2.x * _local5.x) + (_arg2.y * _local5.y)) - _arg3.d) < 0){
_arg4.disabled = true;
_arg1.pointCount = 0;
return;
};
var _local13:Number = -2147483648;
var _local14:int;
_local9 = _arg3.worldVertexChain;
_local8 = _arg3.worldNormalChain;
_local6 = _arg2.BSPNode;
while (_local6.R) {
_local6 = ((((-(_local6.N.y) * _local8.x) + (_local6.N.x * _local8.y)))<=0) ? _local6.R : _local6.L;
};
_local7 = _local6.V;
_local12 = ((_local8.x * (_local7.x - _local9.x)) + (_local8.y * (_local7.y - _local9.y)));
if (_local12 > 0){
_arg4.disabled = false;
_arg1.pointCount = 0;
return;
};
if (((_local12 * 0.95) + 0.01) > _local13){
_local13 = _local12;
_local5 = _local8;
_local10 = _local9;
_local11 = _local7;
_local14 = 1;
};
_local9 = _local9.next;
_local8 = _local8.next;
_local7 = _local7.next.next;
_local12 = ((_local8.x * (_local7.x - _local9.x)) + (_local8.y * (_local7.y - _local9.y)));
if (_local12 > 0){
_arg4.disabled = false;
_arg1.pointCount = 0;
return;
};
if (((_local12 * 0.95) + 0.01) > _local13){
_local13 = _local12;
_local5 = _local8;
_local10 = _local9;
_local11 = _local7;
_local14 = 1;
};
var _local15:V2 = _arg3.worldVertexChain;
var _local16:V2 = _local15.next;
var _local17:Number = _local15.x;
var _local18:Number = _local16.x;
var _local19:Number = _local15.y;
var _local20:Number = _local16.y;
_local9 = _arg2.worldVertexChain.next;
_local8 = _arg2.worldNormalChain.next;
if (((_local17 * _local8.x) + (_local19 * _local8.y)) < ((_local18 * _local8.x) + (_local20 * _local8.y))){
_local12 = ((_local8.x * (_local17 - _local9.x)) + (_local8.y * (_local19 - _local9.y)));
if (_local12 > 0){
_arg4.disabled = false;
_arg1.pointCount = 0;
return;
};
if (((_local12 * 0.95) + 0.01) > _local13){
_local13 = _local12;
_local5 = _local8;
_local10 = _local9;
_local11 = _local15;
_local14 = 0;
};
_local9 = _local9.next.next;
_local8 = _local8.next.next;
_local12 = ((_local8.x * (_local18 - _local9.x)) + (_local8.y * (_local20 - _local9.y)));
if (_local12 > 0){
_arg4.disabled = false;
_arg1.pointCount = 0;
return;
};
if (((_local12 * 0.95) + 0.01) > _local13){
_local13 = _local12;
_local5 = _local8;
_local10 = _local9;
_local11 = _local16;
_local14 = 0;
};
} else {
_local12 = ((_local8.x * (_local18 - _local9.x)) + (_local8.y * (_local20 - _local9.y)));
if (_local12 > 0){
_arg4.disabled = false;
_arg1.pointCount = 0;
return;
};
if (((_local12 * 0.95) + 0.01) > _local13){
_local13 = _local12;
_local5 = _local8;
_local10 = _local9;
_local11 = _local16;
_local14 = 0;
};
_local9 = _local9.next.next;
_local8 = _local8.next.next;
_local12 = ((_local8.x * (_local17 - _local9.x)) + (_local8.y * (_local19 - _local9.y)));
if (_local12 > 0){
_arg4.disabled = false;
_arg1.pointCount = 0;
return;
};
if (((_local12 * 0.95) + 0.01) > _local13){
_local13 = _local12;
_local5 = _local8;
_local10 = _local9;
_local11 = _local15;
_local14 = 0;
};
};
_local9 = _arg2.worldVertexChain;
_local8 = _arg2.worldNormalChain;
if (((_local17 * _local8.x) + (_local19 * _local8.y)) < ((_local18 * _local8.x) + (_local20 * _local8.y))){
_local12 = ((_local8.x * (_local17 - _local9.x)) + (_local8.y * (_local19 - _local9.y)));
if (_local12 > 0){
_arg4.disabled = false;
_arg1.pointCount = 0;
return;
};
if (((_local12 * 0.95) + 0.01) > _local13){
_local13 = _local12;
_local5 = _local8;
_local10 = _local9;
_local11 = _local15;
_local14 = 0;
};
_local9 = _local9.next.next;
_local8 = _local8.next.next;
_local12 = ((_local8.x * (_local18 - _local9.x)) + (_local8.y * (_local20 - _local9.y)));
if (_local12 > 0){
_arg4.disabled = false;
_arg1.pointCount = 0;
return;
};
if (((_local12 * 0.95) + 0.01) > _local13){
_local13 = _local12;
_local5 = _local8;
_local10 = _local9;
_local11 = _local16;
_local14 = 0;
};
} else {
_local12 = ((_local8.x * (_local18 - _local9.x)) + (_local8.y * (_local20 - _local9.y)));
if (_local12 > 0){
_arg4.disabled = false;
_arg1.pointCount = 0;
return;
};
if (((_local12 * 0.95) + 0.01) > _local13){
_local13 = _local12;
_local5 = _local8;
_local10 = _local9;
_local11 = _local16;
_local14 = 0;
};
_local9 = _local9.next.next;
_local8 = _local8.next.next;
_local12 = ((_local8.x * (_local17 - _local9.x)) + (_local8.y * (_local19 - _local9.y)));
if (_local12 > 0){
_arg4.disabled = false;
_arg1.pointCount = 0;
return;
};
if (((_local12 * 0.95) + 0.01) > _local13){
_local13 = _local12;
_local5 = _local8;
_local10 = _local9;
_local11 = _local15;
_local14 = 0;
};
};
if (_arg4.disabled){
_arg1.pointCount = 0;
return;
};
var _local21:ShapeSkeleton = _arg2;
var _local22:Number = _local5.x;
var _local23:Number = _local5.y;
var _local24:int = _local10.I;
var _local25:int = _local11.I;
var _local27:V2 = _local11.userData.n;
var _local28:Number = ((_local27.x * _local22) + (_local27.y * _local23));
if (((_local27.prev.x * _local22) + (_local27.prev.y * _local23)) < _local28){
_local11 = _local11.prev;
_local26 = _local27.prev.I;
} else {
if (((_local27.next.x * _local22) + (_local27.next.y * _local23)) < _local28){
_local11 = _local11.next;
_local26 = _local27.next.I;
};
};
var _local29:Number = (((_local21.x * _local22) + (_local21.y * _local23)) + (((_local10.x - _local21.x) * _local22) + ((_local10.y - _local21.y) * _local23)));
if (_local21.regularShape){
_local30 = ((_local21.y * _local22) - (_local21.x * _local23));
} else {
_local40 = _local21.offsets[_local10.I];
_local30 = ((((_local21.y + (_local21.r21 * _local40.x)) + (_local21.r22 * _local40.y)) * _local22) - (((_local21.x + (_local21.r11 * _local40.x)) + (_local21.r12 * _local40.y)) * _local23));
};
var _local31:Number = (_local10.userData.mag / 2);
_local36 = ((((_local11.x * _local23) - (_local11.y * _local22)) + _local30) - _local31);
_local37 = ((((_local11.next.x * _local23) - (_local11.next.y * _local22)) + _local30) - _local31);
if ((_local36 * _local37) < 0){
_local38 = (_local36 / (_local36 - _local37));
if (_local36 < 0){
_local32 = _local11.x;
_local34 = _local11.y;
_local33 = (_local32 + (_local38 * (_local11.next.x - _local32)));
_local35 = (_local34 + (_local38 * (_local11.next.y - _local34)));
} else {
_local32 = _local11.next.x;
_local34 = _local11.next.y;
_local33 = (_local11.x + (_local38 * (_local32 - _local11.x)));
_local35 = (_local11.y + (_local38 * (_local34 - _local11.y)));
};
} else {
if (_local36 > 0){
_arg1.pointCount = 0;
return;
};
if (_local36 < _local37){
_local32 = _local11.x;
_local34 = _local11.y;
_local33 = _local11.next.x;
_local35 = _local11.next.y;
} else {
_local33 = _local11.x;
_local35 = _local11.y;
_local32 = _local11.next.x;
_local34 = _local11.next.y;
};
};
_local36 = ((((_local34 * _local22) - _local30) - _local31) - (_local32 * _local23));
_local37 = ((((_local35 * _local22) - _local30) - _local31) - (_local33 * _local23));
if ((_local36 * _local37) < 0){
_local38 = (_local36 / (_local36 - _local37));
_local32 = (_local32 + (_local38 * (_local33 - _local32)));
_local34 = (_local34 + (_local38 * (_local35 - _local34)));
} else {
if (_local36 > 0){
_arg1.pointCount = 0;
return;
};
};
_local13 = (((_local22 * _local32) + (_local23 * _local34)) - _local29);
if (_local13 <= 0){
_arg1.pointCount = 1;
if (_local14){
_arg1.nx = -(_local22);
_arg1.ny = -(_local23);
} else {
_arg1.nx = _local22;
_arg1.ny = _local23;
};
_local39 = _arg1.c0;
_local39.sep = _local13;
_local39.x = _local32;
_local39.y = _local34;
_local39.id.flip = _local14;
_local39.id.incEdge = _local26;
_local39.id.incVert = _local25;
_local39.id.refFace = _local24;
_local39.id.bake();
_local13 = (((_local22 * _local33) + (_local23 * _local35)) - _local29);
if (_local13 <= 0){
_arg1.pointCount = 2;
_local39 = _arg1.c1;
_local39.sep = _local13;
_local39.x = _local33;
_local39.y = _local35;
_local39.id.flip = _local14;
_local39.id.incEdge = _local26;
_local39.id.incVert = _local25;
_local39.id.refFace = _local24;
_local39.id.bake();
};
} else {
_local13 = (((_local22 * _local33) + (_local23 * _local35)) - _local29);
if (_local13 <= 0){
_arg1.pointCount = 1;
if (_local14){
_arg1.nx = -(_local22);
_arg1.ny = -(_local23);
} else {
_arg1.nx = _local22;
_arg1.ny = _local23;
};
_local39 = _arg1.c0;
_local39.sep = _local13;
_local39.x = _local33;
_local39.y = _local35;
_local39.id.flip = _local14;
_local39.id.incEdge = _local26;
_local39.id.incVert = _local25;
_local39.id.refFace = _local24;
_local39.id.bake();
};
};
}
}
}//package de.polygonal.motor2.collision.pairwise
Section 20
//CollideBoxPlaneDS (de.polygonal.motor2.collision.pairwise.CollideBoxPlaneDS)
package de.polygonal.motor2.collision.pairwise {
import de.polygonal.motor2.math.*;
import de.polygonal.motor2.collision.shapes.*;
import de.polygonal.motor2.dynamics.contact.*;
public class CollideBoxPlaneDS implements Collider {
public function collide(_arg1:Manifold, _arg2:ShapeSkeleton, _arg3:ShapeSkeleton, _arg4:Contact):void{
var _local5:ConvexBSPNode;
var _local16:int;
var _local17:int;
var _local6:Number = _arg3.worldNormalChain.x;
var _local7:Number = _arg3.worldNormalChain.y;
var _local8:Number = ((_local6 * _arg2.r11) + (_local7 * _arg2.r21));
var _local9:Number = ((_local6 * _arg2.r12) + (_local7 * _arg2.r22));
var _local10:Number = ((_arg2.ex * ((_local8 < 0)) ? -(_local8) : _local8) + (_arg2.ey * ((_local9 < 0)) ? -(_local9) : _local9));
var _local11:Number = _arg3.d;
var _local12:Number = (((_local6 * _arg2.x) + (_local7 * _arg2.y)) - _local11);
if (_local12 > 0){
if (_local12 > _local10){
_arg1.pointCount = 0;
return;
};
} else {
if (_local12 < -(_local10)){
_arg1.pointCount = 0;
return;
};
_local6 = -(_local6);
_local7 = -(_local7);
_local11 = -(_local11);
};
_local5 = _arg2.BSPNode;
while (_local5.R) {
_local5 = ((((_local5.N.x * _local7) - (_local5.N.y * _local6)))<=0) ? _local5.R : _local5.L;
};
var _local13:V2 = _local5.V;
_arg1.nx = -(_local6);
_arg1.ny = -(_local7);
_arg1.pointCount = 1;
var _local14:ContactPoint = _arg1.c0;
_local14.sep = (((_local13.x * _local6) + (_local13.y * _local7)) - _local11);
_local14.x = _local13.x;
_local14.y = _local13.y;
var _local15:V2 = _local13.userData.n;
var _local18:Number = ((_local15.x * _local6) + (_local15.y * _local7));
if (((_local15.prev.x * _local6) + (_local15.prev.y * _local7)) < _local18){
_local16 = _local15.prev.I;
_local14.id.flip = 0;
_local14.id.incEdge = _local16;
_local14.id.incVert = _local17;
_local14.id.refFace = 0;
_local14.id.bake();
_local13 = _local13.prev;
_local12 = (((_local13.x * _local6) + (_local13.y * _local7)) - _local11);
if (_local12 < 0){
_local14 = _arg1.c1;
_local14.sep = _local12;
_local14.x = _local13.x;
_local14.y = _local13.y;
_local14.id.flip = 0;
_local14.id.incEdge = _local16;
_local14.id.incVert = _local17;
_local14.id.refFace = 0;
_local14.id.bake();
_arg1.pointCount++;
};
} else {
_local16 = _local15.next.I;
_local14.id.flip = 0;
_local14.id.incEdge = _local16;
_local14.id.incVert = _local17;
_local14.id.refFace = 0;
_local14.id.bake();
_local13 = _local13.next;
_local12 = (((_local13.x * _local6) + (_local13.y * _local7)) - _local11);
if (_local12 < 0){
_local14 = _arg1.c1;
_local14.sep = _local12;
_local14.x = _local13.x;
_local14.y = _local13.y;
_local14.id.flip = 0;
_local14.id.incEdge = _local16;
_local14.id.incVert = _local17;
_local14.id.refFace = 0;
_local14.id.bake();
_arg1.pointCount++;
};
};
}
}
}//package de.polygonal.motor2.collision.pairwise
Section 21
//CollideBoxPlaneSS (de.polygonal.motor2.collision.pairwise.CollideBoxPlaneSS)
package de.polygonal.motor2.collision.pairwise {
import de.polygonal.motor2.math.*;
import de.polygonal.motor2.collision.shapes.*;
import de.polygonal.motor2.dynamics.contact.*;
public class CollideBoxPlaneSS implements Collider {
public function collide(_arg1:Manifold, _arg2:ShapeSkeleton, _arg3:ShapeSkeleton, _arg4:Contact):void{
var _local5:ConvexBSPNode;
var _local7:Number;
var _local8:Number;
var _local9:V2;
var _local10:Number;
var _local11:ContactPoint;
var _local12:Number;
var _local13:Number;
var _local14:Number;
var _local6:Number = _arg3.worldNormalChain.x;
_local7 = _arg3.worldNormalChain.y;
if (_arg1.pointCount > 0){
_local5 = _arg2.BSPNode;
while (_local5.R) {
_local5 = ((((_local5.N.x * _local7) - (_local5.N.y * _local6)))<=0) ? _local5.R : _local5.L;
};
_local8 = _arg3.d;
_local9 = _local5.V;
_local10 = (((_local9.x * _local6) + (_local9.y * _local7)) - _local8);
if (_local10 > 0){
_arg1.pointCount = 0;
return;
};
_arg1.pointCount = 1;
_arg1.nx = -(_local6);
_arg1.ny = -(_local7);
_local11 = _arg1.c0;
_local11.sep = _local10;
_local11.x = _local9.x;
_local11.y = _local9.y;
_local11.id.key = 0;
_local10 = (((_local9.prev.x * _local6) + (_local9.prev.y * _local7)) - _local8);
if (_local10 < 0){
_local11.id.key = 1;
_local11 = _arg1.c1;
_local11.sep = _local10;
_local11.x = _local9.prev.x;
_local11.y = _local9.prev.y;
_local11.id.key = 1;
_arg1.pointCount++;
} else {
_local10 = (((_local9.next.x * _local6) + (_local9.next.y * _local7)) - _local8);
if (_local10 < 0){
_local11.id.key = 1;
_local11 = _arg1.c1;
_local11.sep = _local10;
_local11.x = _local9.next.x;
_local11.y = _local9.next.y;
_local11.id.key = 1;
_arg1.pointCount++;
};
};
} else {
_local12 = ((_local6 * _arg2.r11) + (_local7 * _arg2.r21));
_local13 = ((_local6 * _arg2.r12) + (_local7 * _arg2.r22));
_local14 = ((_arg2.ex * ((_local12 < 0)) ? -(_local12) : _local12) + (_arg2.ey * ((_local13 < 0)) ? -(_local13) : _local13));
if ((((_local6 * _arg2.x) + (_local7 * _arg2.y)) - _arg3.d) > _local14){
_arg1.pointCount = 0;
return;
};
_local8 = _arg3.d;
_local5 = _arg2.BSPNode;
while (_local5.R) {
_local5 = ((((_local5.N.x * _local7) - (_local5.N.y * _local6)))<=0) ? _local5.R : _local5.L;
};
_local9 = _local5.V;
_local10 = (((_local9.x * _local6) + (_local9.y * _local7)) - _local8);
_arg1.pointCount = 1;
_arg1.nx = -(_local6);
_arg1.ny = -(_local7);
_local11 = _arg1.c0;
_local11.sep = _local10;
_local11.x = _local9.x;
_local11.y = _local9.y;
_local11.id.key = 0;
_local10 = (((_local9.prev.x * _local6) + (_local9.prev.y * _local7)) - _local8);
if (_local10 < 0){
_local11.id.key = 1;
_local11 = _arg1.c1;
_local11.sep = _local10;
_local11.x = _local9.prev.x;
_local11.y = _local9.prev.y;
_local11.id.key = 1;
_arg1.pointCount++;
} else {
_local10 = (((_local9.next.x * _local6) + (_local9.next.y * _local7)) - _local8);
if (_local10 < 0){
_local11.id.key = 1;
_local11 = _arg1.c1;
_local11.sep = _local10;
_local11.x = _local9.next.x;
_local11.y = _local9.next.y;
_local11.id.key = 1;
_arg1.pointCount++;
};
};
};
}
}
}//package de.polygonal.motor2.collision.pairwise
Section 22
//CollideCircle (de.polygonal.motor2.collision.pairwise.CollideCircle)
package de.polygonal.motor2.collision.pairwise {
import de.polygonal.motor2.collision.shapes.*;
import de.polygonal.motor2.dynamics.contact.*;
public class CollideCircle implements Collider {
public function collide(_arg1:Manifold, _arg2:ShapeSkeleton, _arg3:ShapeSkeleton, _arg4:Contact):void{
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:Number;
var _local9:Number;
_local5 = (_arg3.x - _arg2.x);
_local6 = (_arg3.y - _arg2.y);
_local7 = ((_local5 * _local5) + (_local6 * _local6));
_local8 = (_arg2.radius + _arg3.radius);
if (_local7 > (_local8 * _local8)){
_arg1.pointCount = 0;
return;
};
if (_local7 < 1E-8){
_arg1.c0.sep = -(_local8);
_arg1.nx = 0;
_arg1.ny = 1;
_arg1.c0.x = _arg3.x;
_arg1.c0.y = (_arg3.y - _arg3.radius);
} else {
_local9 = Math.sqrt(_local7);
_arg1.c0.sep = (_local9 - _local8);
_arg1.c0.x = (_arg3.x - (_arg3.radius * (_arg1.nx = ((1 / _local9) * _local5))));
_arg1.c0.y = (_arg3.y - (_arg3.radius * (_arg1.ny = ((1 / _local9) * _local6))));
};
_arg1.pointCount = 1;
_arg1.c0.id.key = 0;
}
}
}//package de.polygonal.motor2.collision.pairwise
Section 23
//CollideCircleLineDS (de.polygonal.motor2.collision.pairwise.CollideCircleLineDS)
package de.polygonal.motor2.collision.pairwise {
import de.polygonal.motor2.math.*;
import de.polygonal.motor2.collision.shapes.*;
import de.polygonal.motor2.dynamics.contact.*;
public class CollideCircleLineDS implements Collider {
public function collide(_arg1:Manifold, _arg2:ShapeSkeleton, _arg3:ShapeSkeleton, _arg4:Contact):void{
var _local5:ContactPoint;
var _local19:Number;
var _local20:Number;
var _local21:Number;
var _local22:Number;
var _local25:Number;
var _local26:Number;
var _local27:Number;
var _local28:Number;
var _local6:V2 = _arg3.worldVertexChain;
var _local7:V2 = _local6.next;
var _local8:Number = _arg2.radiusSq;
var _local9:Number = _local6.x;
var _local10:Number = _local7.x;
var _local11:Number = _arg2.x;
var _local12:Number = _local6.y;
var _local13:Number = _local7.y;
var _local14:Number = _arg2.y;
var _local15:Number = (_local10 - _local9);
var _local16:Number = (_local13 - _local12);
var _local17:Number = (_local11 - _local9);
var _local18:Number = (_local14 - _local12);
var _local23:Number = ((_local17 * _local15) + (_local18 * _local16));
if (_local23 < 0){
_local19 = ((_local17 * _local17) + (_local18 * _local18));
if (_local19 > _local8){
_arg1.pointCount = 0;
return;
};
_local20 = Math.sqrt(_local19);
_local21 = (_local17 / _local20);
_local22 = (_local18 / _local20);
_local5 = _arg1.c0;
_local5.id.incEdge = _local6.I;
_local5.id.incVert = _local6.I;
} else {
_local25 = (_local10 - _local11);
_local26 = (_local13 - _local14);
_local23 = ((_local25 * _local15) + (_local26 * _local16));
if (_local23 < 0){
_local19 = ((_local25 * _local25) + (_local26 * _local26));
if (_local19 > _local8){
_arg1.pointCount = 0;
return;
};
_local20 = Math.sqrt(_local19);
_local21 = (-(_local25) / _local20);
_local22 = (-(_local26) / _local20);
_local5 = _arg1.c0;
_local5.id.incEdge = _local7.I;
_local5.id.incVert = _local7.I;
} else {
_local27 = ((_local18 * _local15) - (_local17 * _local16));
_local19 = ((((_local18 * _local15) - (_local17 * _local16)) * _local27) / ((_local15 * _local15) + (_local16 * _local16)));
if (_local19 > _local8){
_arg1.pointCount = 0;
return;
};
_local20 = Math.sqrt(_local19);
_local21 = (-(_local13) + _local12);
_local22 = (_local10 - _local9);
_local28 = (Math.sqrt(((_local21 * _local21) + (_local22 * _local22))) * ((((_local21 * _local17) + (_local22 * _local18)) < 0)) ? -1 : 1);
_local21 = (_local21 / _local28);
_local22 = (_local22 / _local28);
_local5 = _arg1.c0;
_local5.id.incEdge = _local6.I;
_local5.id.incVert = _local7.I;
};
};
_arg1.pointCount = 1;
_arg1.nx = -(_local21);
_arg1.ny = -(_local22);
_local5.id.refFace = ContactID.NULL_FEATURE;
_local5.id.flip = 0;
_local5.id.bake();
var _local24:Number = _arg2.radius;
_local5.x = (_local11 - (_local24 * _local21));
_local5.y = (_local14 - (_local24 * _local22));
_local5.sep = (_local20 - _local24);
}
}
}//package de.polygonal.motor2.collision.pairwise
Section 24
//CollideCircleLineSS (de.polygonal.motor2.collision.pairwise.CollideCircleLineSS)
package de.polygonal.motor2.collision.pairwise {
import de.polygonal.motor2.math.*;
import de.polygonal.motor2.collision.shapes.*;
import de.polygonal.motor2.dynamics.contact.*;
public class CollideCircleLineSS implements Collider {
public function collide(_arg1:Manifold, _arg2:ShapeSkeleton, _arg3:ShapeSkeleton, _arg4:Contact):void{
var _local5:ContactPoint;
var _local20:Number;
var _local21:Number;
var _local22:Number;
var _local23:Number;
var _local26:Number;
var _local27:Number;
var _local28:Number;
var _local29:Number;
var _local6:V2 = _arg3.worldNormalChain;
if ((((_arg2.x * _local6.x) + (_arg2.y * _local6.y)) - _arg3.d) < 0){
_arg4.disabled = true;
_arg1.pointCount = 0;
return;
};
var _local7:V2 = _arg3.worldVertexChain;
var _local8:V2 = _local7.next;
var _local9:Number = _arg2.radiusSq;
var _local10:Number = _local7.x;
var _local11:Number = _local8.x;
var _local12:Number = _arg2.x;
var _local13:Number = _local7.y;
var _local14:Number = _local8.y;
var _local15:Number = _arg2.y;
var _local16:Number = (_local11 - _local10);
var _local17:Number = (_local14 - _local13);
var _local18:Number = (_local12 - _local10);
var _local19:Number = (_local15 - _local13);
var _local24:Number = ((_local18 * _local16) + (_local19 * _local17));
if (_local24 < 0){
_local22 = _arg3.worldNormalChain.x;
_local23 = _arg3.worldNormalChain.y;
if (((_local22 * _local18) + (_local23 * _local19)) < 0){
_arg1.pointCount = 0;
return;
};
_local20 = ((_local18 * _local18) + (_local19 * _local19));
if (_local20 > _local9){
_arg4.disabled = false;
_arg1.pointCount = 0;
return;
};
if (_arg4.disabled){
_arg1.pointCount = 0;
return;
};
_local21 = Math.sqrt(_local20);
_local22 = (_local18 / _local21);
_local23 = (_local19 / _local21);
_local5 = _arg1.c0;
_local5.id.incEdge = _local7.I;
_local5.id.incVert = _local7.I;
} else {
_local26 = (_local11 - _local12);
_local27 = (_local14 - _local15);
_local24 = ((_local26 * _local16) + (_local27 * _local17));
_local22 = _arg3.worldNormalChain.x;
_local23 = _arg3.worldNormalChain.y;
if (((_local22 * _local26) + (_local23 * _local27)) > 0){
_arg1.pointCount = 0;
return;
};
if (_local24 < 0){
_local20 = ((_local26 * _local26) + (_local27 * _local27));
if (_local20 > _local9){
_arg4.disabled = false;
_arg1.pointCount = 0;
return;
};
if (_arg4.disabled){
_arg1.pointCount = 0;
return;
};
_local21 = Math.sqrt(_local20);
_local22 = (-(_local26) / _local21);
_local23 = (-(_local27) / _local21);
_local5 = _arg1.c0;
_local5.id.incEdge = _local8.I;
_local5.id.incVert = _local8.I;
} else {
_local28 = ((_local19 * _local16) - (_local18 * _local17));
if (_local28 > 0){
_arg1.pointCount = 0;
return;
};
_local20 = ((_local28 * _local28) / ((_local16 * _local16) + (_local17 * _local17)));
if (_local20 > _local9){
_arg4.disabled = false;
_arg1.pointCount = 0;
return;
};
if (_arg4.disabled){
_arg1.pointCount = 0;
return;
};
_local21 = Math.sqrt(_local20);
_local22 = (-(_local14) + _local13);
_local23 = (_local11 - _local10);
_local29 = (Math.sqrt(((_local22 * _local22) + (_local23 * _local23))) * ((((_local22 * _local18) + (_local23 * _local19)) < 0)) ? -1 : 1);
_local22 = (_local22 / _local29);
_local23 = (_local23 / _local29);
_local5 = _arg1.c0;
_local5.id.incEdge = _local7.I;
_local5.id.incVert = _local8.I;
};
};
_arg1.pointCount = 1;
_arg1.nx = -(_local22);
_arg1.ny = -(_local23);
_local5.id.refFace = ContactID.NULL_FEATURE;
_local5.id.flip = 0;
_local5.id.bake();
var _local25:Number = _arg2.radius;
_local5.x = (_local12 - (_local25 * _local22));
_local5.y = (_local15 - (_local25 * _local23));
_local5.sep = (_local21 - _local25);
}
}
}//package de.polygonal.motor2.collision.pairwise
Section 25
//CollideCirclePlaneDS (de.polygonal.motor2.collision.pairwise.CollideCirclePlaneDS)
package de.polygonal.motor2.collision.pairwise {
import de.polygonal.motor2.math.*;
import de.polygonal.motor2.collision.shapes.*;
import de.polygonal.motor2.dynamics.contact.*;
public class CollideCirclePlaneDS implements Collider {
public function collide(_arg1:Manifold, _arg2:ShapeSkeleton, _arg3:ShapeSkeleton, _arg4:Contact):void{
var _local5:ContactPoint;
var _local7:Number;
var _local6:V2 = _arg3.worldNormalChain;
_local7 = _arg2.radius;
var _local8:Number = (((_arg2.x * _local6.x) + (_arg2.y * _local6.y)) - _arg3.d);
if (_local8 > 0){
if (_local8 <= _local7){
_arg1.pointCount = 1;
_arg1.nx = -(_local6.x);
_arg1.ny = -(_local6.y);
_local5 = _arg1.c0;
_local5.id.key = 0;
_local5.sep = (_local8 - _local7);
_local5.x = (_arg2.x - (_local7 * _local6.x));
_local5.y = (_arg2.y - (_local7 * _local6.y));
return;
};
} else {
if (-(_local8) <= _local7){
_arg1.pointCount = 1;
_arg1.nx = _local6.x;
_arg1.ny = _local6.y;
_local5 = _arg1.c0;
_local5.id.key = 1;
_local5.sep = (-(_local7) - _local8);
_local5.x = (_arg2.x + (_local7 * _local6.x));
_local5.y = (_arg2.y + (_local7 * _local6.y));
return;
};
};
_arg1.pointCount = 0;
}
}
}//package de.polygonal.motor2.collision.pairwise
Section 26
//CollideCirclePlaneSS (de.polygonal.motor2.collision.pairwise.CollideCirclePlaneSS)
package de.polygonal.motor2.collision.pairwise {
import de.polygonal.motor2.math.*;
import de.polygonal.motor2.collision.shapes.*;
import de.polygonal.motor2.dynamics.contact.*;
public class CollideCirclePlaneSS implements Collider {
public function collide(_arg1:Manifold, _arg2:ShapeSkeleton, _arg3:ShapeSkeleton, _arg4:Contact):void{
var _local7:Number;
var _local8:ContactPoint;
var _local5:V2 = _arg3.worldNormalChain;
var _local6:Number = _arg2.radius;
_local7 = (((_arg2.x * _local5.x) + (_arg2.y * _local5.y)) - _arg3.d);
if (_local7 <= _local6){
_arg1.pointCount = 1;
_arg1.nx = -(_local5.x);
_arg1.ny = -(_local5.y);
_local8 = _arg1.c0;
_local8.x = (_arg2.x - (_local6 * _local5.x));
_local8.y = (_arg2.y - (_local6 * _local5.y));
_local8.sep = (_local7 - _local6);
return;
};
_arg1.pointCount = 0;
}
}
}//package de.polygonal.motor2.collision.pairwise
Section 27
//CollidePoly (de.polygonal.motor2.collision.pairwise.CollidePoly)
package de.polygonal.motor2.collision.pairwise {
import de.polygonal.motor2.math.*;
import de.polygonal.motor2.collision.shapes.*;
import de.polygonal.motor2.dynamics.contact.*;
import de.polygonal.motor2.dynamics.contact.generator.*;
public class CollidePoly implements Collider {
public function collide(_arg1:Manifold, _arg2:ShapeSkeleton, _arg3:ShapeSkeleton, _arg4:Contact):void{
var _local6:V2;
var _local7:V2;
var _local8:V2;
var _local9:V2;
var _local10:V2;
var _local11:V2;
var _local13:Number;
var _local14:int;
var _local15:ConvexBSPNode;
var _local21:int;
var _local25:Number;
var _local27:Number;
var _local28:Number;
var _local29:Number;
var _local30:Number;
var _local31:Number;
var _local32:Number;
var _local33:Number;
var _local34:ContactPoint;
var _local35:V2;
var _local5:PolyContact = PolyContact(_arg4);
var _local12:Number = -2147483648;
_local6 = _local5.p;
_local7 = _local5.d;
if (_local5.firstOut){
while (true) {
_local15 = _arg3.BSPNode;
while (_local15.R) {
_local15 = ((((-(_local15.N.y) * _local7.x) + (_local15.N.x * _local7.y)))<=0) ? _local15.R : _local15.L;
};
_local8 = _local15.V;
_local13 = ((_local7.x * (_local8.x - _local6.x)) + (_local7.y * (_local8.y - _local6.y)));
if (_local13 > 0){
_local5.p = _local6;
_local5.d = _local7;
_arg1.pointCount = 0;
return;
};
if (((_local13 * 0.95) + 0.01) > _local12){
_local12 = _local13;
_local9 = _local7;
_local11 = _local6;
_local10 = _local8;
};
if (_local6.last){
break;
};
_local6 = _local6.next;
_local7 = _local7.next;
};
_local6 = _arg3.worldVertexChain;
_local7 = _arg3.worldNormalChain;
while (true) {
_local15 = _arg2.BSPNode;
while (_local15.R) {
_local15 = ((((-(_local15.N.y) * _local7.x) + (_local15.N.x * _local7.y)))<=0) ? _local15.R : _local15.L;
};
_local8 = _local15.V;
_local13 = ((_local7.x * (_local8.x - _local6.x)) + (_local7.y * (_local8.y - _local6.y)));
if (_local13 > 0){
_local5.p = _local6;
_local5.d = _local7;
_local5.firstOut = false;
_arg1.pointCount = 0;
return;
};
if (((_local13 * 0.95) + 0.01) > _local12){
_local12 = _local13;
_local9 = _local7;
_local11 = _local6;
_local10 = _local8;
_local14 = 1;
};
if (_local6.last){
break;
};
_local6 = _local6.next;
_local7 = _local7.next;
};
} else {
while (true) {
_local15 = _arg2.BSPNode;
while (_local15.R) {
_local15 = ((((-(_local15.N.y) * _local7.x) + (_local15.N.x * _local7.y)))<=0) ? _local15.R : _local15.L;
};
_local8 = _local15.V;
_local13 = ((_local7.x * (_local8.x - _local6.x)) + (_local7.y * (_local8.y - _local6.y)));
if (_local13 > 0){
_local5.p = _local6;
_local5.d = _local7;
_arg1.pointCount = 0;
return;
};
if (((_local13 * 0.95) + 0.01) > _local12){
_local12 = _local13;
_local9 = _local7;
_local11 = _local6;
_local10 = _local8;
_local14 = 1;
};
if (_local6.last){
break;
};
_local6 = _local6.next;
_local7 = _local7.next;
};
_local6 = _arg2.worldVertexChain;
_local7 = _arg2.worldNormalChain;
while (true) {
_local15 = _arg3.BSPNode;
while (_local15.R) {
_local15 = ((((-(_local15.N.y) * _local7.x) + (_local15.N.x * _local7.y)))<=0) ? _local15.R : _local15.L;
};
_local8 = _local15.V;
_local13 = ((_local7.x * (_local8.x - _local6.x)) + (_local7.y * (_local8.y - _local6.y)));
if (_local13 > 0){
_local5.p = _local6;
_local5.d = _local7;
_local5.firstOut = true;
_arg1.pointCount = 0;
return;
};
if (((_local13 * 0.95) + 0.01) > _local12){
_local12 = _local13;
_local9 = _local7;
_local11 = _local6;
_local10 = _local8;
_local14 = 0;
};
if (_local6.last){
break;
};
_local6 = _local6.next;
_local7 = _local7.next;
};
};
var _local16:ShapeSkeleton = (_local14) ? _arg3 : _arg2;
var _local17:Number = _local9.x;
var _local18:Number = _local9.y;
var _local19:int = _local11.I;
var _local20:int = _local10.I;
var _local22:V2 = _local10.userData.n;
var _local23:Number = ((_local22.x * _local17) + (_local22.y * _local18));
if (((_local22.prev.x * _local17) + (_local22.prev.y * _local18)) < _local23){
_local10 = _local10.prev;
_local21 = _local22.prev.I;
} else {
if (((_local22.next.x * _local17) + (_local22.next.y * _local18)) < _local23){
_local10 = _local10.next;
_local21 = _local22.next.I;
};
};
var _local24:Number = (((_local16.x * _local17) + (_local16.y * _local18)) + (((_local11.x - _local16.x) * _local17) + ((_local11.y - _local16.y) * _local18)));
if (_local16.regularShape){
_local25 = ((_local16.y * _local17) - (_local16.x * _local18));
} else {
_local35 = _local16.offsets[_local11.I];
_local25 = ((((_local16.y + (_local16.r21 * _local35.x)) + (_local16.r22 * _local35.y)) * _local17) - (((_local16.x + (_local16.r11 * _local35.x)) + (_local16.r12 * _local35.y)) * _local18));
};
var _local26:Number = (_local11.userData.mag / 2);
_local31 = ((((_local10.x * _local18) - (_local10.y * _local17)) + _local25) - _local26);
_local32 = ((((_local10.next.x * _local18) - (_local10.next.y * _local17)) + _local25) - _local26);
if ((_local31 * _local32) < 0){
_local33 = (_local31 / (_local31 - _local32));
if (_local31 < 0){
_local27 = _local10.x;
_local29 = _local10.y;
_local28 = (_local27 + (_local33 * (_local10.next.x - _local27)));
_local30 = (_local29 + (_local33 * (_local10.next.y - _local29)));
} else {
_local27 = _local10.next.x;
_local29 = _local10.next.y;
_local28 = (_local10.x + (_local33 * (_local27 - _local10.x)));
_local30 = (_local10.y + (_local33 * (_local29 - _local10.y)));
};
} else {
if (_local31 > 0){
_arg1.pointCount = 0;
return;
};
if (_local31 < _local32){
_local27 = _local10.x;
_local29 = _local10.y;
_local28 = _local10.next.x;
_local30 = _local10.next.y;
} else {
_local28 = _local10.x;
_local30 = _local10.y;
_local27 = _local10.next.x;
_local29 = _local10.next.y;
};
};
_local31 = ((((_local29 * _local17) - _local25) - _local26) - (_local27 * _local18));
_local32 = ((((_local30 * _local17) - _local25) - _local26) - (_local28 * _local18));
if ((_local31 * _local32) < 0){
_local33 = (_local31 / (_local31 - _local32));
_local27 = (_local27 + (_local33 * (_local28 - _local27)));
_local29 = (_local29 + (_local33 * (_local30 - _local29)));
} else {
if (_local31 > 0){
_arg1.pointCount = 0;
return;
};
};
_local12 = (((_local17 * _local27) + (_local18 * _local29)) - _local24);
if (_local12 <= 0){
_arg1.pointCount = 1;
if (_local14){
_arg1.nx = -(_local17);
_arg1.ny = -(_local18);
} else {
_arg1.nx = _local17;
_arg1.ny = _local18;
};
_local34 = _arg1.c0;
_local34.sep = _local12;
_local34.x = _local27;
_local34.y = _local29;
_local34.id.flip = _local14;
_local34.id.incEdge = _local21;
_local34.id.incVert = _local20;
_local34.id.refFace = _local19;
_local34.id.bake();
_local12 = (((_local17 * _local28) + (_local18 * _local30)) - _local24);
if (_local12 <= 0){
_arg1.pointCount = 2;
_local34 = _arg1.c1;
_local34.sep = _local12;
_local34.x = _local28;
_local34.y = _local30;
_local34.id.flip = _local14;
_local34.id.incEdge = _local21;
_local34.id.incVert = _local20;
_local34.id.refFace = _local19;
_local34.id.bake();
};
} else {
_local12 = (((_local17 * _local28) + (_local18 * _local30)) - _local24);
if (_local12 <= 0){
_arg1.pointCount = 1;
if (_local14){
_arg1.nx = -(_local17);
_arg1.ny = -(_local18);
} else {
_arg1.nx = _local17;
_arg1.ny = _local18;
};
_local34 = _arg1.c0;
_local34.sep = _local12;
_local34.x = _local28;
_local34.y = _local30;
_local34.id.flip = _local14;
_local34.id.incEdge = _local21;
_local34.id.incVert = _local20;
_local34.id.refFace = _local19;
_local34.id.bake();
};
};
}
}
}//package de.polygonal.motor2.collision.pairwise
Section 28
//CollidePolyCircle (de.polygonal.motor2.collision.pairwise.CollidePolyCircle)
package de.polygonal.motor2.collision.pairwise {
import de.polygonal.motor2.math.*;
import de.polygonal.motor2.collision.shapes.*;
import de.polygonal.motor2.dynamics.contact.*;
import de.polygonal.motor2.dynamics.contact.generator.*;
public class CollidePolyCircle implements Collider {
public function collide(_arg1:Manifold, _arg2:ShapeSkeleton, _arg3:ShapeSkeleton, _arg4:Contact):void{
var _local5:V2;
var _local6:V2;
var _local7:V2;
var _local8:V2;
var _local11:Number;
var _local12:Number;
var _local17:Number;
var _local19:Number;
var _local21:Number;
var _local22:ContactPoint;
var _local24:Number;
var _local25:Number;
var _local9:Number = _arg3.x;
var _local10:Number = _arg3.y;
_local12 = _arg3.radius;
var _local13:Number = -2147483648;
var _local14:ConvexCircleContact = ConvexCircleContact(_arg4);
_local5 = _local14.p;
_local6 = _local14.d;
var _local15:int = _local5.prev.I;
while (true) {
_local11 = ((_local6.x * (_local9 - _local5.x)) + (_local6.y * (_local10 - _local5.y)));
if (_local11 > _local12){
_arg1.pointCount = 0;
_local14.p = _local5;
_local14.d = _local6;
return;
};
if (_local11 > _local13){
_local13 = _local11;
_local7 = _local6;
_local8 = _local5;
};
if (_local5.I == _local15){
break;
};
_local5 = _local5.next;
_local6 = _local6.next;
};
if (_local13 < 1E-6){
_arg1.pointCount = 1;
_arg1.nx = _local7.x;
_arg1.ny = _local7.y;
_local22 = _arg1.c0;
_local22.id.incEdge = (_local7.I + 1);
_local22.id.incVert = 254;
_local22.id.refFace = 254;
_local22.id.flip = 0;
_local22.id.bake();
_local22.x = (_local9 - (_local12 * _arg1.nx));
_local22.y = (_local10 - (_local12 * _arg1.ny));
_local22.sep = (_local13 - _local12);
return;
};
var _local16:E2 = _local8.userData;
var _local18:Number = ((_arg2.r11 * _local16.d.x) + (_arg2.r12 * _local16.d.y));
var _local20:Number = ((_arg2.r21 * _local16.d.x) + (_arg2.r22 * _local16.d.y));
if (_local16.mag < 1E-6){
_local17 = (_local9 - _local8.x);
_local19 = (_local10 - _local8.y);
_local21 = ((_local17 * _local17) + (_local19 * _local19));
if (_local21 > _arg3.radiusSq){
};
_arg1.pointCount = 0;
return;
};
var _local23:Number = (((_local9 - _local8.x) * _local18) + ((_local10 - _local8.y) * _local20));
_local22 = _arg1.c0;
_local22.id.refFace = 254;
_local22.id.flip = 0;
if (_local23 <= 0){
_local24 = _local8.x;
_local25 = _local8.y;
_local22.id.incVert = (_local8.I + 1);
_local22.id.incEdge = 254;
} else {
if (_local23 >= _local16.mag){
_local24 = _local8.next.x;
_local25 = _local8.next.y;
_local22.id.incVert = (_local8.next.I + 1);
_local22.id.incEdge = 254;
} else {
_local24 = ((_local18 * _local23) + _local8.x);
_local25 = ((_local20 * _local23) + _local8.y);
_local22.id.incVert = 254;
_local22.id.incEdge = (_local8.I + 1);
};
};
_local17 = (_local9 - _local24);
_local19 = (_local10 - _local25);
_local21 = ((_local17 * _local17) + (_local19 * _local19));
if (_local21 > _arg3.radiusSq){
_arg1.pointCount = 0;
return;
};
_local21 = Math.sqrt(_local21);
_local17 = (_local17 / _local21);
_local19 = (_local19 / _local21);
_arg1.pointCount = 1;
_arg1.nx = _local17;
_arg1.ny = _local19;
_local22.x = (_local9 - (_arg3.radius * _local17));
_local22.y = (_local10 - (_arg3.radius * _local19));
_local22.sep = (_local21 - _local12);
_local22.id.bake();
}
}
}//package de.polygonal.motor2.collision.pairwise
Section 29
//CollidePolyLineDS (de.polygonal.motor2.collision.pairwise.CollidePolyLineDS)
package de.polygonal.motor2.collision.pairwise {
import de.polygonal.motor2.math.*;
import de.polygonal.motor2.collision.shapes.*;
import de.polygonal.motor2.dynamics.contact.*;
public class CollidePolyLineDS implements Collider {
public function collide(_arg1:Manifold, _arg2:ShapeSkeleton, _arg3:ShapeSkeleton, _arg4:Contact):void{
var _local5:ConvexBSPNode;
var _local6:V2;
var _local7:V2;
var _local8:V2;
var _local9:V2;
var _local10:V2;
var _local11:V2;
var _local12:V2;
var _local13:Number;
var _local22:ShapeSkeleton;
var _local23:ShapeSkeleton;
var _local28:int;
var _local32:Number;
var _local34:Number;
var _local35:Number;
var _local36:Number;
var _local37:Number;
var _local38:Number;
var _local39:Number;
var _local40:Number;
var _local41:ContactPoint;
var _local42:V2;
var _local14:Number = -2147483648;
var _local15:int;
_local10 = _arg3.worldVertexChain;
_local9 = _arg3.worldNormalChain;
_local5 = _arg2.BSPNode;
while (_local5.R) {
_local6 = _local5.N;
_local5 = ((((-(_local6.y) * _local9.x) + (_local6.x * _local9.y)))<=0) ? _local5.R : _local5.L;
};
_local7 = _local5.V;
_local13 = ((_local9.x * (_local7.x - _local10.x)) + (_local9.y * (_local7.y - _local10.y)));
if (_local13 > 0){
_arg1.pointCount = 0;
return;
};
if (((_local13 * 0.95) + 0.01) > _local14){
_local14 = _local13;
_local8 = _local9;
_local11 = _local10;
_local12 = _local7;
_local15 = 1;
};
_local10 = _local10.next;
_local9 = _local9.next;
_local5 = _arg2.BSPNode;
while (_local5.R) {
_local6 = _local5.N;
_local5 = ((((-(_local6.y) * _local9.x) + (_local6.x * _local9.y)))<=0) ? _local5.R : _local5.L;
};
_local7 = _local5.V;
_local13 = ((_local9.x * (_local7.x - _local10.x)) + (_local9.y * (_local7.y - _local10.y)));
if (_local13 > 0){
_arg1.pointCount = 0;
return;
};
if (((_local13 * 0.95) + 0.01) > _local14){
_local14 = _local13;
_local8 = _local9;
_local11 = _local10;
_local12 = _local7;
_local15 = 1;
};
var _local16:V2 = _arg3.worldVertexChain;
var _local17:V2 = _local16.next;
var _local18:Number = _local16.x;
var _local19:Number = _local17.x;
var _local20:Number = _local16.y;
var _local21:Number = _local17.y;
_local10 = _arg2.worldVertexChain;
_local9 = _arg2.worldNormalChain;
while (true) {
if (((_local18 * _local9.x) + (_local20 * _local9.y)) < ((_local19 * _local9.x) + (_local21 * _local9.y))){
_local13 = ((_local9.x * (_local18 - _local10.x)) + (_local9.y * (_local20 - _local10.y)));
if (_local13 > 0){
_arg1.pointCount = 0;
return;
};
if (((_local13 * 0.95) + 0.01) > _local14){
_local14 = _local13;
_local8 = _local9;
_local11 = _local10;
_local12 = _local16;
_local15 = 0;
};
} else {
_local13 = ((_local9.x * (_local19 - _local10.x)) + (_local9.y * (_local21 - _local10.y)));
if (_local13 > 0){
_arg1.pointCount = 0;
return;
};
if (((_local13 * 0.95) + 0.01) > _local14){
_local14 = _local13;
_local8 = _local9;
_local11 = _local10;
_local12 = _local17;
_local15 = 0;
};
};
if (_local10.last){
break;
};
_local10 = _local10.next;
_local9 = _local9.next;
};
if (_local15){
_local22 = _arg3;
_local23 = _arg2;
} else {
_local22 = _arg2;
_local23 = _arg3;
};
var _local24:Number = _local8.x;
var _local25:Number = _local8.y;
var _local26:int = _local11.I;
var _local27:int = _local12.I;
var _local29:V2 = _local12.userData.n;
var _local30:Number = ((_local29.x * _local24) + (_local29.y * _local25));
if (((_local29.prev.x * _local24) + (_local29.prev.y * _local25)) < _local30){
_local12 = _local12.prev;
_local28 = _local29.prev.I;
} else {
if (((_local29.next.x * _local24) + (_local29.next.y * _local25)) < _local30){
_local12 = _local12.next;
_local28 = _local29.next.I;
};
};
var _local31:Number = (((_local22.x * _local24) + (_local22.y * _local25)) + (((_local11.x - _local22.x) * _local24) + ((_local11.y - _local22.y) * _local25)));
if (_local22.regularShape){
_local32 = ((_local22.y * _local24) - (_local22.x * _local25));
} else {
_local42 = _local22.offsets[_local11.I];
_local32 = ((((_local22.y + (_local22.r21 * _local42.x)) + (_local22.r22 * _local42.y)) * _local24) - (((_local22.x + (_local22.r11 * _local42.x)) + (_local22.r12 * _local42.y)) * _local25));
};
var _local33:Number = (_local11.userData.mag / 2);
_local38 = ((((_local12.x * _local25) - (_local12.y * _local24)) + _local32) - _local33);
_local39 = ((((_local12.next.x * _local25) - (_local12.next.y * _local24)) + _local32) - _local33);
if ((_local38 * _local39) < 0){
_local40 = (_local38 / (_local38 - _local39));
if (_local38 < 0){
_local34 = _local12.x;
_local36 = _local12.y;
_local35 = (_local34 + (_local40 * (_local12.next.x - _local34)));
_local37 = (_local36 + (_local40 * (_local12.next.y - _local36)));
} else {
_local34 = _local12.next.x;
_local36 = _local12.next.y;
_local35 = (_local12.x + (_local40 * (_local34 - _local12.x)));
_local37 = (_local12.y + (_local40 * (_local36 - _local12.y)));
};
} else {
if (_local38 > 0){
_arg1.pointCount = 0;
return;
};
if (_local38 < _local39){
_local34 = _local12.x;
_local36 = _local12.y;
_local35 = _local12.next.x;
_local37 = _local12.next.y;
} else {
_local35 = _local12.x;
_local37 = _local12.y;
_local34 = _local12.next.x;
_local36 = _local12.next.y;
};
};
_local38 = ((((_local36 * _local24) - _local32) - _local33) - (_local34 * _local25));
_local39 = ((((_local37 * _local24) - _local32) - _local33) - (_local35 * _local25));
if ((_local38 * _local39) < 0){
_local40 = (_local38 / (_local38 - _local39));
_local34 = (_local34 + (_local40 * (_local35 - _local34)));
_local36 = (_local36 + (_local40 * (_local37 - _local36)));
} else {
if (_local38 > 0){
_arg1.pointCount = 0;
return;
};
};
_local14 = (((_local24 * _local34) + (_local25 * _local36)) - _local31);
if (_local14 <= 0){
_arg1.pointCount = 1;
if (_local15){
_arg1.nx = -(_local24);
_arg1.ny = -(_local25);
} else {
_arg1.nx = _local24;
_arg1.ny = _local25;
};
_local41 = _arg1.c0;
_local41.sep = _local14;
_local41.x = _local34;
_local41.y = _local36;
_local41.id.flip = _local15;
_local41.id.incEdge = _local28;
_local41.id.incVert = _local27;
_local41.id.refFace = _local26;
_local41.id.bake();
_local14 = (((_local24 * _local35) + (_local25 * _local37)) - _local31);
if (_local14 <= 0){
_arg1.pointCount = 2;
_local41 = _arg1.c1;
_local41.sep = _local14;
_local41.x = _local35;
_local41.y = _local37;
_local41.id.flip = _local15;
_local41.id.incEdge = _local28;
_local41.id.incVert = _local27;
_local41.id.refFace = _local26;
_local41.id.bake();
};
} else {
_local14 = (((_local24 * _local35) + (_local25 * _local37)) - _local31);
if (_local14 <= 0){
_arg1.pointCount = 1;
if (_local15){
_arg1.nx = -(_local24);
_arg1.ny = -(_local25);
} else {
_arg1.nx = _local24;
_arg1.ny = _local25;
};
_local41 = _arg1.c0;
_local41.sep = _local14;
_local41.x = _local35;
_local41.y = _local37;
_local41.id.flip = _local15;
_local41.id.incEdge = _local28;
_local41.id.incVert = _local27;
_local41.id.refFace = _local26;
_local41.id.bake();
};
};
}
}
}//package de.polygonal.motor2.collision.pairwise
Section 30
//CollidePolyLineSS (de.polygonal.motor2.collision.pairwise.CollidePolyLineSS)
package de.polygonal.motor2.collision.pairwise {
import de.polygonal.motor2.math.*;
import de.polygonal.motor2.collision.shapes.*;
import de.polygonal.motor2.dynamics.contact.*;
public class CollidePolyLineSS implements Collider {
public function collide(_arg1:Manifold, _arg2:ShapeSkeleton, _arg3:ShapeSkeleton, _arg4:Contact):void{
var _local6:ConvexBSPNode;
var _local7:V2;
var _local8:V2;
var _local9:V2;
var _local10:V2;
var _local11:V2;
var _local12:Number;
var _local21:ShapeSkeleton;
var _local22:ShapeSkeleton;
var _local27:int;
var _local31:Number;
var _local33:Number;
var _local34:Number;
var _local35:Number;
var _local36:Number;
var _local37:Number;
var _local38:Number;
var _local39:Number;
var _local40:ContactPoint;
var _local41:V2;
var _local5:V2 = _arg3.worldNormalChain;
if ((((_arg2.x * _local5.x) + (_arg2.y * _local5.y)) - _arg3.d) < 0){
_arg4.disabled = true;
_arg1.pointCount = 0;
return;
};
var _local13:Number = -2147483648;
var _local14:int;
_local9 = _arg3.worldVertexChain;
_local8 = _arg3.worldNormalChain;
_local6 = _arg2.BSPNode;
while (_local6.R) {
_local6 = ((((-(_local6.N.y) * _local8.x) + (_local6.N.x * _local8.y)))<=0) ? _local6.R : _local6.L;
};
_local7 = _local6.V;
_local12 = ((_local8.x * (_local7.x - _local9.x)) + (_local8.y * (_local7.y - _local9.y)));
if (_local12 > 0){
_arg4.disabled = false;
_arg1.pointCount = 0;
return;
};
if (((_local12 * 0.95) + 0.01) > _local13){
_local13 = _local12;
_local5 = _local8;
_local10 = _local9;
_local11 = _local7;
_local14 = 1;
};
_local9 = _local9.next;
_local8 = _local8.next;
_local6 = _arg2.BSPNode;
while (_local6.R) {
_local6 = ((((-(_local6.N.y) * _local8.x) + (_local6.N.x * _local8.y)))<=0) ? _local6.R : _local6.L;
};
_local7 = _local6.V;
_local12 = ((_local8.x * (_local7.x - _local9.x)) + (_local8.y * (_local7.y - _local9.y)));
if (_local12 > 0){
_arg4.disabled = false;
_arg1.pointCount = 0;
return;
};
if (((_local12 * 0.95) + 0.01) > _local13){
_local13 = _local12;
_local5 = _local8;
_local10 = _local9;
_local11 = _local7;
_local14 = 1;
};
var _local15:V2 = _arg3.worldVertexChain;
var _local16:V2 = _local15.next;
var _local17:Number = _local15.x;
var _local18:Number = _local16.x;
var _local19:Number = _local15.y;
var _local20:Number = _local16.y;
_local9 = _arg2.worldVertexChain;
_local8 = _arg2.worldNormalChain;
while (true) {
if (((_local17 * _local8.x) + (_local19 * _local8.y)) < ((_local18 * _local8.x) + (_local20 * _local8.y))){
_local12 = ((_local8.x * (_local17 - _local9.x)) + (_local8.y * (_local19 - _local9.y)));
if (_local12 > 0){
_arg4.disabled = false;
_arg1.pointCount = 0;
return;
};
if (((_local12 * 0.95) + 0.01) > _local13){
_local13 = _local12;
_local5 = _local8;
_local10 = _local9;
_local11 = _local15;
_local14 = 0;
};
} else {
_local12 = ((_local8.x * (_local18 - _local9.x)) + (_local8.y * (_local20 - _local9.y)));
if (_local12 > 0){
_arg4.disabled = false;
_arg1.pointCount = 0;
return;
};
if (((_local12 * 0.95) + 0.01) > _local13){
_local13 = _local12;
_local5 = _local8;
_local10 = _local9;
_local11 = _local16;
_local14 = 0;
};
};
if (_local9.last){
break;
};
_local9 = _local9.next;
_local8 = _local8.next;
};
if (_arg4.disabled){
_arg1.pointCount = 0;
return;
};
if (_local14){
_local21 = _arg3;
_local22 = _arg2;
} else {
_local21 = _arg2;
_local22 = _arg3;
};
var _local23:Number = _local5.x;
var _local24:Number = _local5.y;
var _local25:int = _local10.I;
var _local26:int = _local11.I;
var _local28:V2 = _local11.userData.n;
var _local29:Number = ((_local28.x * _local23) + (_local28.y * _local24));
if (((_local28.prev.x * _local23) + (_local28.prev.y * _local24)) < _local29){
_local11 = _local11.prev;
_local27 = _local28.prev.I;
} else {
if (((_local28.next.x * _local23) + (_local28.next.y * _local24)) < _local29){
_local11 = _local11.next;
_local27 = _local28.next.I;
};
};
var _local30:Number = (((_local21.x * _local23) + (_local21.y * _local24)) + (((_local10.x - _local21.x) * _local23) + ((_local10.y - _local21.y) * _local24)));
if (_local21.regularShape){
_local31 = ((_local21.y * _local23) - (_local21.x * _local24));
} else {
_local41 = _local21.offsets[_local10.I];
_local31 = ((((_local21.y + (_local21.r21 * _local41.x)) + (_local21.r22 * _local41.y)) * _local23) - (((_local21.x + (_local21.r11 * _local41.x)) + (_local21.r12 * _local41.y)) * _local24));
};
var _local32:Number = (_local10.userData.mag / 2);
_local37 = ((((_local11.x * _local24) - (_local11.y * _local23)) + _local31) - _local32);
_local38 = ((((_local11.next.x * _local24) - (_local11.next.y * _local23)) + _local31) - _local32);
if ((_local37 * _local38) < 0){
_local39 = (_local37 / (_local37 - _local38));
if (_local37 < 0){
_local33 = _local11.x;
_local35 = _local11.y;
_local34 = (_local33 + (_local39 * (_local11.next.x - _local33)));
_local36 = (_local35 + (_local39 * (_local11.next.y - _local35)));
} else {
_local33 = _local11.next.x;
_local35 = _local11.next.y;
_local34 = (_local11.x + (_local39 * (_local33 - _local11.x)));
_local36 = (_local11.y + (_local39 * (_local35 - _local11.y)));
};
} else {
if (_local37 > 0){
_arg1.pointCount = 0;
return;
};
if (_local37 < _local38){
_local33 = _local11.x;
_local35 = _local11.y;
_local34 = _local11.next.x;
_local36 = _local11.next.y;
} else {
_local34 = _local11.x;
_local36 = _local11.y;
_local33 = _local11.next.x;
_local35 = _local11.next.y;
};
};
_local37 = ((((_local35 * _local23) - _local31) - _local32) - (_local33 * _local24));
_local38 = ((((_local36 * _local23) - _local31) - _local32) - (_local34 * _local24));
if ((_local37 * _local38) < 0){
_local39 = (_local37 / (_local37 - _local38));
_local33 = (_local33 + (_local39 * (_local34 - _local33)));
_local35 = (_local35 + (_local39 * (_local36 - _local35)));
} else {
if (_local37 > 0){
_arg1.pointCount = 0;
return;
};
};
_local13 = (((_local23 * _local33) + (_local24 * _local35)) - _local30);
if (_local13 <= 0){
_arg1.pointCount = 1;
if (_local14){
_arg1.nx = -(_local23);
_arg1.ny = -(_local24);
} else {
_arg1.nx = _local23;
_arg1.ny = _local24;
};
_local40 = _arg1.c0;
_local40.sep = _local13;
_local40.x = _local33;
_local40.y = _local35;
_local40.id.flip = _local14;
_local40.id.incEdge = _local27;
_local40.id.incVert = _local26;
_local40.id.refFace = _local25;
_local40.id.bake();
_local13 = (((_local23 * _local34) + (_local24 * _local36)) - _local30);
if (_local13 <= 0){
_arg1.pointCount = 2;
_local40 = _arg1.c1;
_local40.sep = _local13;
_local40.x = _local34;
_local40.y = _local36;
_local40.id.flip = _local14;
_local40.id.incEdge = _local27;
_local40.id.incVert = _local26;
_local40.id.refFace = _local25;
_local40.id.bake();
};
} else {
_local13 = (((_local23 * _local34) + (_local24 * _local36)) - _local30);
if (_local13 <= 0){
_arg1.pointCount = 1;
if (_local14){
_arg1.nx = -(_local23);
_arg1.ny = -(_local24);
} else {
_arg1.nx = _local23;
_arg1.ny = _local24;
};
_local40 = _arg1.c0;
_local40.sep = _local13;
_local40.x = _local34;
_local40.y = _local36;
_local40.id.flip = _local14;
_local40.id.incEdge = _local27;
_local40.id.incVert = _local26;
_local40.id.refFace = _local25;
_local40.id.bake();
};
};
}
}
}//package de.polygonal.motor2.collision.pairwise
Section 31
//CollidePolyPlaneDS (de.polygonal.motor2.collision.pairwise.CollidePolyPlaneDS)
package de.polygonal.motor2.collision.pairwise {
import de.polygonal.motor2.math.*;
import de.polygonal.motor2.collision.shapes.*;
import de.polygonal.motor2.dynamics.contact.*;
public class CollidePolyPlaneDS implements Collider {
public function collide(_arg1:Manifold, _arg2:ShapeSkeleton, _arg3:ShapeSkeleton, _arg4:Contact):void{
var _local5:ConvexBSPNode;
var _local9:V2;
var _local10:int;
var _local11:ContactPoint;
var _local12:Number;
var _local6:Number = _arg3.worldNormalChain.x;
var _local7:Number = _arg3.worldNormalChain.y;
var _local8:Number = _arg3.d;
if ((((_arg2.x * _local6) + (_arg2.y * _local7)) - _local8) > 0){
_local5 = _arg2.BSPNode;
while (_local5.R) {
_local5 = ((((_local5.N.x * _local7) - (_local5.N.y * _local6)))<=0) ? _local5.R : _local5.L;
};
_local9 = _local5.V;
_local12 = (((_local9.x * _local6) + (_local9.y * _local7)) - _local8);
if (_local12 > 0){
_arg1.pointCount = 0;
return;
};
} else {
_local6 = -(_local6);
_local7 = -(_local7);
_local8 = -(_local8);
_local10 = 1;
_local5 = _arg2.BSPNode;
while (_local5.R) {
_local5 = ((((_local5.N.x * _local7) - (_local5.N.y * _local6)))<=0) ? _local5.R : _local5.L;
};
_local9 = _local5.V;
_local12 = (((_local9.x * _local6) + (_local9.y * _local7)) - _local8);
if (_local12 > 0){
_arg1.pointCount = 0;
return;
};
};
_arg1.pointCount = 1;
_arg1.nx = -(_local6);
_arg1.ny = -(_local7);
_local11 = _arg1.c0;
_local11.sep = _local12;
_local11.x = _local9.x;
_local11.y = _local9.y;
_local11.id.key = _local10;
_local12 = (((_local9.prev.x * _local6) + (_local9.prev.y * _local7)) - _local8);
if (_local12 < 0){
_local11.id.key = -(~(_local10));
_local11 = _arg1.c1;
_local11.sep = _local12;
_local11.x = _local9.prev.x;
_local11.y = _local9.prev.y;
_local11.id.key = -(~(_local10));
_arg1.pointCount++;
} else {
_local12 = (((_local9.next.x * _local6) + (_local9.next.y * _local7)) - _local8);
if (_local12 < 0){
_local11.id.key = -(~(_local10));
_local11 = _arg1.c1;
_local11.sep = _local12;
_local11.x = _local9.next.x;
_local11.y = _local9.next.y;
_local11.id.key = -(~(_local10));
_arg1.pointCount++;
};
};
}
}
}//package de.polygonal.motor2.collision.pairwise
Section 32
//CollidePolyPlaneSS (de.polygonal.motor2.collision.pairwise.CollidePolyPlaneSS)
package de.polygonal.motor2.collision.pairwise {
import de.polygonal.motor2.math.*;
import de.polygonal.motor2.collision.shapes.*;
import de.polygonal.motor2.dynamics.contact.*;
public class CollidePolyPlaneSS implements Collider {
public function collide(_arg1:Manifold, _arg2:ShapeSkeleton, _arg3:ShapeSkeleton, _arg4:Contact):void{
var _local5:ConvexBSPNode;
var _local7:Number;
var _local8:Number;
var _local6:Number = _arg3.worldNormalChain.x;
_local7 = _arg3.worldNormalChain.y;
_local8 = _arg3.d;
_local5 = _arg2.BSPNode;
while (_local5.R) {
_local5 = ((((_local5.N.x * _local7) - (_local5.N.y * _local6)))<=0) ? _local5.R : _local5.L;
};
var _local9:V2 = _local5.V;
var _local10:Number = (((_local9.x * _local6) + (_local9.y * _local7)) - _local8);
if (_local10 > 0){
_arg1.pointCount = 0;
return;
};
_arg1.nx = -(_local6);
_arg1.ny = -(_local7);
_arg1.pointCount = 1;
var _local11:ContactPoint = _arg1.c0;
_local11.sep = _local10;
_local11.x = _local9.x;
_local11.y = _local9.y;
_local11.id.key = 0;
_local10 = (((_local9.prev.x * _local6) + (_local9.prev.y * _local7)) - _local8);
if (_local10 < 0){
_local11.id.key = 1;
_local11 = _arg1.c1;
_local11.sep = _local10;
_local11.x = _local9.prev.x;
_local11.y = _local9.prev.y;
_local11.id.key = 1;
_arg1.pointCount++;
} else {
_local10 = (((_local9.next.x * _local6) + (_local9.next.y * _local7)) - _local8);
if (_local10 < 0){
_local11.id.key = 1;
_local11 = _arg1.c1;
_local11.sep = _local10;
_local11.x = _local9.next.x;
_local11.y = _local9.next.y;
_local11.id.key = 1;
_arg1.pointCount++;
};
};
}
}
}//package de.polygonal.motor2.collision.pairwise
Section 33
//Collider (de.polygonal.motor2.collision.pairwise.Collider)
package de.polygonal.motor2.collision.pairwise {
import de.polygonal.motor2.collision.shapes.*;
import de.polygonal.motor2.dynamics.contact.*;
public interface Collider {
function collide(_arg1:Manifold, _arg2:ShapeSkeleton, _arg3:ShapeSkeleton, _arg4:Contact):void;
}
}//package de.polygonal.motor2.collision.pairwise
Section 34
//BoxData (de.polygonal.motor2.collision.shapes.data.BoxData)
package de.polygonal.motor2.collision.shapes.data {
import de.polygonal.motor2.math.*;
import de.polygonal.motor2.collision.shapes.*;
public class BoxData extends ShapeData {
private var _h:Number;
private var _w:Number;
public function BoxData(_arg1:Number, _arg2:Number, _arg3:Number){
super(_arg1);
this.width = _arg2;
this.height = _arg3;
}
public function get width():Number{
return (_w);
}
public function get height():Number{
return (_h);
}
override protected function computeMass():void{
_mass = ((_density * _w) * _h);
_I = ((_mass / 12) * ((_w * _w) + (_h * _h)));
_cm = new V2();
}
public function set width(_arg1:Number):void{
_w = _arg1;
invalidate();
}
override public function getShapeClass():Class{
return (BoxShape);
}
public function set height(_arg1:Number):void{
_h = _arg1;
invalidate();
}
override public function get area():Number{
return ((_w * _h));
}
override protected function setType():void{
type = ShapeTypes.BOX;
}
}
}//package de.polygonal.motor2.collision.shapes.data
Section 35
//CircleData (de.polygonal.motor2.collision.shapes.data.CircleData)
package de.polygonal.motor2.collision.shapes.data {
import de.polygonal.motor2.math.*;
import de.polygonal.motor2.collision.shapes.*;
public class CircleData extends ShapeData {
private var _radius:Number;
public function CircleData(_arg1:Number, _arg2:Number){
super(_arg1);
this.radius = Math.abs(_arg2);
}
public function set radius(_arg1:Number):void{
_radius = _arg1;
invalidate();
}
public function get radius():Number{
return (_radius);
}
override protected function computeMass():void{
_mass = (((_density * Math.PI) * radius) * radius);
_I = (((0.5 * _mass) * radius) * radius);
_cm = new V2();
}
override public function getShapeClass():Class{
return (CircleShape);
}
override public function get area():Number{
return (((Math.PI * _radius) * _radius));
}
override protected function setType():void{
type = ShapeTypes.CIRCLE;
}
}
}//package de.polygonal.motor2.collision.shapes.data
Section 36
//LineData (de.polygonal.motor2.collision.shapes.data.LineData)
package de.polygonal.motor2.collision.shapes.data {
import flash.geom.*;
import de.polygonal.motor2.math.*;
import de.polygonal.motor2.collision.shapes.*;
public class LineData extends ShapeData {
public const a:Point;
public const b:Point;
public var infinite:Boolean;
public var doubleSided:Boolean;
public function LineData(_arg1:Point, _arg2:Point, _arg3:Boolean=false, _arg4:Boolean=true){
a = new Point();
b = new Point();
super(0);
var _local5:Number = (_arg2.x - _arg1.x);
var _local6:Number = (_arg2.y - _arg1.y);
if (Math.sqrt((((_local5 * _local5) + _local6) + _local6)) <= 1E-6){
throw (new Error("overlapping vertices detected"));
};
var _local7:Number = (_arg1.x + ((_arg2.x - _arg1.x) * 0.5));
var _local8:Number = (_arg1.y + ((_arg2.y - _arg1.y) * 0.5));
this.a.x = (_arg1.x - _local7);
this.b.x = (_arg2.x - _local7);
this.a.y = (_arg1.y - _local8);
this.b.y = (_arg2.y - _local8);
this.infinite = _arg3;
this.doubleSided = _arg4;
}
override protected function setType():void{
type = ShapeTypes.LINE;
}
override public function getShapeClass():Class{
return (LineShape);
}
override public function get density():Number{
return (0);
}
override protected function computeMass():void{
_mass = 0;
_I = 0;
_cm = new V2((a.x + (0.5 * (b.x - a.x))), (a.y + (0.5 * (b.y - a.y))));
}
override public function get area():Number{
return (0);
}
override public function set density(_arg1:Number):void{
super.density = 0;
}
}
}//package de.polygonal.motor2.collision.shapes.data
Section 37
//PolyData (de.polygonal.motor2.collision.shapes.data.PolyData)
package de.polygonal.motor2.collision.shapes.data {
import de.polygonal.motor2.math.*;
import de.polygonal.motor2.collision.shapes.*;
public class PolyData extends ShapeData {
private var _vertices:Array;
private var _area:Number;
private var _radius:Number;
private var _vertexCount:int;
private var _regular:Boolean;
public function PolyData(_arg1:Number, _arg2:Array){
super(_arg1);
setVertices(_arg2);
}
private function setVertices(_arg1:Array):void{
var _local2:int;
var _local3:int;
var _local4:int;
var _local5:Number;
var _local6:V2;
var _local7:V2;
var _local8:V2;
var _local9:V2;
var _local10:V2;
var _local12:Number;
var _local13:Number;
var _local14:Number;
var _local15:Number;
var _local16:Number;
var _local17:Number;
var _local18:Number;
if ((_local4 % 2) != 0){
throw (new Error("invalid source data"));
};
_local4 = (_arg1.length / 2);
_vertices = null;
if (_local4 < 3){
throw (new Error("invalid source data"));
};
_local6 = new V2(parseFloat(_arg1[0]), parseFloat(_arg1[1]));
_local10 = _local6;
if (((isNaN(_local6.x)) || (isNaN(_local6.y)))){
throw (new Error("invalid source data"));
};
_local2 = 1;
_local3 = 2;
while (_local2 < _local4) {
_local7 = new V2(parseFloat(_arg1[_local3]), parseFloat(_arg1[int((_local3 + 1))]));
_local3 = (_local3 + 2);
if (((isNaN(_local7.x)) || (isNaN(_local7.y)))){
throw (new Error("invalid source data"));
};
_local6.next = _local7;
_local6 = _local7;
_local2++;
};
_local6.next = _local10;
_local6 = _local10;
_local2 = 0;
while (_local2 < (_local4 - 1)) {
_local7 = _local6.next;
_local3 = (_local2 + 1);
while (_local3 < _local4) {
if ((((_local7.x - _local6.x) * (_local7.x - _local6.x)) + ((_local7.y - _local6.y) * (_local7.y - _local6.y))) < 0.1){
throw (new Error("overlapping vertices detected"));
};
_local7 = _local7.next;
_local3++;
};
_local6 = _local6.next;
_local2++;
};
_local6 = _local10;
var _local11:Number = 0;
_local2 = 0;
while (_local2 < _local4) {
_local7 = _local6.next;
_local11 = (_local11 + ((_local6.x * _local7.y) - (_local6.y * _local7.x)));
_local6 = _local7;
_local2++;
};
if (_local11 < 0){
throw (new Error("vertices are not clockwise ordered"));
};
_local6 = _local10;
_local7 = _local6.next;
_local2 = 0;
while (_local2 < _local4) {
_local12 = (_local7.x - _local6.x);
_local13 = (_local7.y - _local6.y);
_local9 = _local7.next;
_local3 = 0;
while (_local3 < (_local4 - 2)) {
if (((_local12 * (_local9.y - _local6.y)) - ((_local9.x - _local6.x) * _local13)) < 0){
throw (new Error("shape is not convex"));
};
_local9 = _local9.next;
_local3++;
};
_local6 = _local7;
_local7 = _local6.next;
_local2++;
};
_vertexCount = _local4;
_vertices = new Array(_local4);
_local2 = 0;
_local6 = _local10;
while (_local2 < _local4) {
_vertices[_local2] = _local6;
_local6 = _local6.next;
_local2++;
};
_regular = true;
_local6 = _local10;
_local7 = _local6.next;
_local8 = _local7.next;
_local14 = (_local8.x - _local7.x);
_local15 = (_local8.y - _local7.y);
_local16 = (_local7.x - _local6.x);
_local17 = (_local7.y - _local6.y);
_local11 = Math.atan2(((_local14 * _local17) - (_local15 * _local16)), ((_local14 * _local16) + (_local15 * _local17)));
_local2 = 1;
while (_local2 < _local4) {
_local6 = _local7;
_local7 = _local8;
_local8 = _local8.next;
_local14 = (_local8.x - _local7.x);
_local15 = (_local8.y - _local7.y);
_local16 = (_local7.x - _local6.x);
_local17 = (_local7.y - _local6.y);
_local18 = Math.atan2(((_local14 * _local17) - (_local15 * _local16)), ((_local14 * _local16) + (_local15 * _local17)));
if (Math.abs((_local11 - _local18)) > 1E-6){
_regular = false;
break;
};
_local2++;
};
_local5 = Number.MIN_VALUE;
_local6 = _local10;
_local2 = 0;
_local6 = _local10;
while (_local2 < _local4) {
_local5 = Math.max(_local5, ((_local6.x * _local6.x) + (_local6.y * _local6.y)));
_local6 = _local6.next;
_local2++;
};
_radius = Math.sqrt(_local5);
invalidate();
}
override protected function computeMass():void{
var _local6:Number;
var _local7: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 _local20:V2;
var _local1:Number = 0;
var _local2:Number = 0;
var _local3:Number = 0;
var _local4:Number = 0;
var _local5:Number = 0;
var _local8:Number = 0;
var _local19:Number = (1 / 3);
var _local21:int;
while (_local21 < _vertexCount) {
_local20 = _vertices[_local21];
_local6 = _local20.x;
_local7 = _local20.y;
_local20 = _vertices[int(((_local21 + 1) % _vertexCount))];
_local9 = _local20.x;
_local10 = _local20.y;
_local11 = (_local6 - _local5);
_local12 = (_local7 - _local8);
_local13 = (_local9 - _local5);
_local14 = (_local10 - _local8);
_local15 = ((_local11 * _local14) - (_local12 * _local13));
_local16 = (0.5 * _local15);
_local3 = (_local3 + _local16);
_local1 = (_local1 + ((_local16 * _local19) * ((_local5 + _local6) + _local9)));
_local2 = (_local2 + ((_local16 * _local19) * ((_local8 + _local7) + _local10)));
_local17 = ((_local19 * ((0.25 * (((_local11 * _local11) + (_local13 * _local11)) + (_local13 * _local13))) + ((_local5 * _local11) + (_local5 * _local13)))) + ((0.5 * _local5) * _local5));
_local18 = ((_local19 * ((0.25 * (((_local12 * _local12) + (_local14 * _local12)) + (_local14 * _local14))) + ((_local8 * _local12) + (_local8 * _local14)))) + ((0.5 * _local8) * _local8));
_local4 = (_local4 + (_local15 * (_local17 + _local18)));
_local21++;
};
_mass = (_density * _local3);
_local1 = (_local1 / _local3);
_local2 = (_local2 / _local3);
_cm = new V2(_local1, _local2);
_I = (_density * (_local4 - (_local3 * ((_local1 * _local1) + (_local2 * _local2)))));
_area = _local3;
}
override public function get area():Number{
return (_area);
}
public function getVertices():Array{
var _local1:int;
var _local2:Array;
_local2 = new Array(_vertexCount);
_local1 = 0;
while (_local1 < _vertexCount) {
_local2[_local1] = new V2(_vertices[_local1].x, _vertices[_local1].y);
_local1++;
};
return (_local2);
}
public function isRegular():Boolean{
return (_regular);
}
override public function getShapeClass():Class{
return (PolyShape);
}
public function getVertexCount():int{
return (_vertexCount);
}
public function get radius():Number{
return (_radius);
}
override protected function setType():void{
type = ShapeTypes.POLY;
}
}
}//package de.polygonal.motor2.collision.shapes.data
Section 38
//ShapeData (de.polygonal.motor2.collision.shapes.data.ShapeData)
package de.polygonal.motor2.collision.shapes.data {
import de.polygonal.motor2.math.*;
import de.polygonal.motor2.collision.shapes.*;
public class ShapeData {
public var next:ShapeData;
protected var _cm:V2;
protected var _I:Number;
public var maskBits:int;
public var groupIndex:int;
private var _friction:Number;
protected var _mass:Number;
public var categoryBits:int;
public var mr:Number;
protected var _density:Number;
private var _restitution:Number;
public var my:Number;
public var mx:Number;
public var type:int;
public function ShapeData(_arg1:Number){
this.density = _arg1;
init();
}
public function getCM():V2{
if (_cm == null){
computeMass();
};
return (_cm);
}
public function get friction():Number{
return (_friction);
}
public function getInertia():Number{
if (_density == 0){
return (0);
};
if (isNaN(_I)){
computeMass();
};
return (_I);
}
public function get area():Number{
return (NaN);
}
public function invalidate():void{
_mass = Number.NaN;
_I = Number.NaN;
_cm = null;
}
public function set density(_arg1:Number):void{
_density = _arg1;
invalidate();
}
public function set restitution(_arg1:Number):void{
_restitution = ((_arg1)<0) ? 0 : ((_arg1)>1) ? 1 : _arg1;
}
private function init():void{
setType();
mx = (my = (mr = 0));
friction = 0.2;
restitution = 0;
categoryBits = 1;
maskBits = 0xFFFF;
groupIndex = 0;
}
public function getShapeClass():Class{
return (null);
}
protected function computeMass():void{
}
public function get density():Number{
return (_density);
}
public function get restitution():Number{
return (_restitution);
}
public function getMass():Number{
if (_density == 0){
return (0);
};
if (isNaN(_mass)){
computeMass();
};
return (_mass);
}
public function set friction(_arg1:Number):void{
_friction = ((_arg1)<0) ? 0 : ((_arg1)>1) ? 1 : _arg1;
}
protected function setType():void{
type = ShapeTypes.UNKNOWN;
}
}
}//package de.polygonal.motor2.collision.shapes.data
Section 39
//BoxShape (de.polygonal.motor2.collision.shapes.BoxShape)
package de.polygonal.motor2.collision.shapes {
import flash.geom.*;
import de.polygonal.motor2.math.*;
import de.polygonal.motor2.dynamics.*;
import de.polygonal.motor2.collision.shapes.data.*;
import de.polygonal.ds.*;
public class BoxShape extends ShapeSkeleton {
private var _mr:Number;
private var _r11:Number;
private var _r12:Number;
private var _v0:V2;
private var _v1:V2;
private var _v2:V2;
private var _v3:V2;
private var _n0:V2;
private var _n1:V2;
private var _n2:V2;
private var _n3:V2;
private var _r22:Number;
private var _r21:Number;
public function BoxShape(_arg1:BoxData, _arg2:RigidBody){
super(_arg1, _arg2);
setup(_arg1, _arg2);
}
override public function update():void{
synced = false;
if (_mr == 0){
r11 = body.r11;
r12 = body.r12;
r21 = body.r21;
r22 = body.r22;
} else {
r11 = ((_r11 * body.r11) + (_r12 * body.r21));
r21 = ((_r21 * body.r11) + (_r22 * body.r21));
r12 = ((_r11 * body.r12) + (_r12 * body.r22));
r22 = ((_r21 * body.r12) + (_r22 * body.r22));
};
x = ((body.x + (body.r11 * mx)) + (body.r12 * my));
y = ((body.y + (body.r21 * mx)) + (body.r22 * my));
xmin = (xmax = x);
ymin = (ymax = y);
if (r11 > 0){
xmin = (xmin + (r11 * -(ex)));
xmax = (xmax + (r11 * ex));
} else {
xmin = (xmin + (r11 * ex));
xmax = (xmax + (r11 * -(ex)));
};
if (r12 > 0){
xmin = (xmin + (r12 * -(ey)));
xmax = (xmax + (r12 * ey));
} else {
xmin = (xmin + (r12 * ey));
xmax = (xmax + (r12 * -(ey)));
};
if (r21 > 0){
ymin = (ymin + (r21 * -(ex)));
ymax = (ymax + (r21 * ex));
} else {
ymin = (ymin + (r21 * ex));
ymax = (ymax + (r21 * -(ex)));
};
if (r22 > 0){
ymin = (ymin + (r22 * -(ey)));
ymax = (ymax + (r22 * ey));
} else {
ymin = (ymin + (r22 * ey));
ymax = (ymax + (r22 * -(ey)));
};
super.update();
}
override public function getShapeOffset(_arg1:Point):void{
_arg1.x = ((mx * _r11) + (my * _r12));
_arg1.y = ((mx * _r21) + (my * _r22));
}
override public function pointInside(_arg1:Point):Boolean{
var _local2:Number;
var _local3:Number;
var _local4:Number;
_local2 = (_arg1.x - x);
_local3 = (_arg1.y - y);
_local4 = ((_local2 * r11) + (_local3 * r21));
if (_local4 > ex){
return (false);
};
if (_local4 < -(ex)){
return (false);
};
_local4 = ((_local2 * r12) + (_local3 * r22));
if (_local4 > ey){
return (false);
};
if (_local4 < -(ey)){
return (false);
};
return (true);
}
override public function toWorldSpace():void{
if (synced){
return;
};
synced = true;
var _local1:Number = (r11 * ex);
var _local2:Number = (r12 * ey);
var _local3:Number = (r21 * ex);
var _local4:Number = (r22 * ey);
_v0.x = ((x + _local1) + _local2);
_n0.x = r12;
_v0.y = ((y + _local3) + _local4);
_n0.y = r22;
_v1.x = ((x - _local1) + _local2);
_n1.x = -(r11);
_v1.y = ((y - _local3) + _local4);
_n1.y = -(r21);
_v2.x = ((x - _local1) - _local2);
_n2.x = -(r12);
_v2.y = ((y - _local3) - _local4);
_n2.y = -(r22);
_v3.x = ((x + _local1) - _local2);
_n3.x = r11;
_v3.y = ((y + _local3) - _local4);
_n3.y = r21;
}
override public function closestPoint(_arg1:Point, _arg2:Point=null):void{
var _local3:Number;
var _local4:Number;
var _local5:Number;
if (_arg2){
_local3 = (x - (_arg2.x = x));
_local4 = (y - (_arg2.y = y));
_local5 = ((_local3 * r11) + (_local4 * r21));
if (_local5 > ex){
_local5 = ex;
} else {
if (_local5 < -(ex)){
_local5 = -(ex);
};
};
_arg2.x = (_arg2.x + (r11 * _local5));
_arg2.y = (_arg2.y + (r21 * _local5));
_local5 = ((_local3 * r12) + (_local4 * r22));
if (_local5 > ey){
_local5 = ey;
} else {
if (_local5 < -(ey)){
_local5 = -(ey);
};
};
_arg2.x = (_arg2.x + (r12 * _local5));
_arg2.y = (_arg2.y + (r22 * _local5));
} else {
_local3 = (x - (_arg1.x = x));
_local4 = (y - (_arg1.y = y));
_local5 = ((_local3 * r11) + (_local4 * r21));
if (_local5 > ex){
_local5 = ex;
} else {
if (_local5 < -(ex)){
_local5 = -(ex);
};
};
x = (x + (r11 * _local5));
y = (y + (r21 * _local5));
_local5 = ((_local3 * r12) + (_local4 * r22));
if (_local5 > ey){
_local5 = ey;
} else {
if (_local5 < -(ey)){
_local5 = -(ey);
};
};
x = (x + (r12 * _local5));
y = (y + (r22 * _local5));
};
}
override public function triangulate():void{
triangleList = new Tri2(_v0, _v1, _v3);
triangleList.next = new Tri2(_v3, _v1, _v2);
}
override protected function setType():void{
type = ShapeTypes.BOX;
}
private function setup(_arg1:BoxData, _arg2:RigidBody):void{
var xLocalCenter:Number;
var sin:Number;
var yLocalCenter:Number;
var cos:Number;
var modelVertexList:Array;
var v:V2;
var sd = _arg1;
var rb = _arg2;
xLocalCenter = rb.cx;
yLocalCenter = rb.cy;
mx = (sd.mx - xLocalCenter);
my = (sd.my - yLocalCenter);
sin = Math.sin(sd.mr);
cos = Math.cos(sd.mr);
_r11 = cos;
_r12 = -(sin);
_r21 = sin;
_r22 = cos;
_mr = sd.mr;
ex = (sd.width * 0.5);
ey = (sd.height * 0.5);
xmin = -(ex);
xmax = ex;
xmin = -(ey);
ymax = ey;
radiusSq = ((ex * ex) + (ey * ey));
radius = Math.sqrt(radiusSq);
vertexCount = 4;
modelVertexList = new Array(vertexCount);
v = (modelVertexList[0] = new V2());
v.x = ((mx + (_r11 * ex)) + (_r12 * ey));
v.y = ((my + (_r21 * ex)) + (_r22 * ey));
v = (modelVertexList[1] = new V2());
v.x = ((mx + (_r11 * -(ex))) + (_r12 * ey));
v.y = ((my + (_r21 * -(ex))) + (_r22 * ey));
v = (modelVertexList[2] = new V2());
v.x = ((mx + (_r11 * -(ex))) + (_r12 * -(ey)));
v.y = ((my + (_r21 * -(ex))) + (_r22 * -(ey)));
v = (modelVertexList[3] = new V2());
v.x = ((mx + (_r11 * ex)) + (_r12 * -(ey)));
v.y = ((my + (_r21 * ex)) + (_r22 * -(ey)));
initPoly(modelVertexList, vertexCount, true, mx, my);
v = worldVertexChain;
_v0 = v;
v = v.next;
_v1 = v;
v = v.next;
_v2 = v;
v = v.next;
_v3 = v;
v = worldNormalChain;
_n0 = v;
v = v.next;
_n1 = v;
v = v.next;
_n2 = v;
v = v.next;
_n3 = v;
BSPNode = ConvexBSP.createBSP(vertexCount, modelNormalChain.toArray(), _edges);
BinaryTreeNode.inorder(BSPNode, function (_arg1:ConvexBSPNode):void{
_arg1.N = worldNormalChain.getAt(_arg1.I);
_arg1.V = worldVertexChain.getAt(_arg1.I);
});
createProxy(sd.groupIndex, sd.categoryBits, sd.maskBits);
}
}
}//package de.polygonal.motor2.collision.shapes
Section 40
//CircleShape (de.polygonal.motor2.collision.shapes.CircleShape)
package de.polygonal.motor2.collision.shapes {
import flash.geom.*;
import de.polygonal.motor2.dynamics.*;
import de.polygonal.motor2.collision.shapes.data.*;
public class CircleShape extends ShapeSkeleton {
public function CircleShape(_arg1:CircleData, _arg2:RigidBody){
super(_arg1, _arg2);
setup(_arg1, _arg2);
}
override public function update():void{
synced = false;
x = (body.x + (((r11 = body.r11) * mx) + ((r12 = body.r12) * my)));
y = (body.y + (((r21 = body.r21) * mx) + ((r22 = body.r22) * my)));
xmin = (x - radius);
ymin = (y - radius);
xmax = (x + radius);
ymax = (y + radius);
super.update();
}
override public function pointInside(_arg1:Point):Boolean{
return (((((_arg1.x - x) * (_arg1.x - x)) + ((_arg1.y - y) * (_arg1.y - y))) <= radiusSq));
}
private function setup(_arg1:CircleData, _arg2:RigidBody):void{
var _local3:Number = _arg2.cx;
var _local4:Number = _arg2.cy;
mx = (_arg1.mx - _local3);
my = (_arg1.my - _local4);
x = (body.x + (((r11 = body.r11) * mx) + ((r12 = body.r12) * my)));
y = (body.y + (((r21 = body.r21) * mx) + ((r22 = body.r22) * my)));
radius = _arg1.radius;
radiusSq = (radius * radius);
ex = radius;
ey = radius;
xmin = -(ex);
xmax = ex;
xmin = -(ey);
ymax = ey;
vertexCount = 0;
createProxy(_arg1.groupIndex, _arg1.categoryBits, _arg1.maskBits);
}
override protected function setType():void{
type = ShapeTypes.CIRCLE;
}
override public function closestPoint(_arg1:Point, _arg2:Point=null):void{
var _local3:Number = (_arg1.x - x);
var _local4:Number = (_arg1.y - y);
var _local5:Number = Math.sqrt(((_local3 * _local3) + (_local4 * _local4)));
if (_local5 > 1E-6){
if (_arg2){
_arg2.x = (x + ((_local3 / _local5) * radius));
_arg2.y = (y + ((_local4 / _local5) * radius));
} else {
_arg1.x = (x + ((_local3 / _local5) * radius));
_arg1.y = (y + ((_local4 / _local5) * radius));
};
} else {
if (_arg2){
_arg2.x = x;
_arg2.y = y;
} else {
_arg1.x = x;
_arg1.y = y;
};
};
}
}
}//package de.polygonal.motor2.collision.shapes
Section 41
//LineShape (de.polygonal.motor2.collision.shapes.LineShape)
package de.polygonal.motor2.collision.shapes {
import de.polygonal.motor2.math.*;
import de.polygonal.motor2.dynamics.*;
import de.polygonal.motor2.collision.shapes.data.*;
public class LineShape extends ShapeSkeleton {
public var infinite:Boolean;
public var doubleSided:Boolean;
public function LineShape(_arg1:LineData, _arg2:RigidBody){
super(_arg1, _arg2);
setup(_arg1, _arg2);
}
override public function toWorldSpace():void{
var _local1:V2 = worldVertexChain;
var _local2:V2 = modelVertexChain;
var _local3:V2 = worldNormalChain;
var _local4:V2 = modelNormalChain;
var _local5:Number = body.x;
var _local6:Number = body.y;
_local1.x = (((r11 * _local2.x) + (r12 * _local2.y)) + _local5);
_local1.y = (((r21 * _local2.x) + (r22 * _local2.y)) + _local6);
_local3.x = ((r11 * _local4.x) + (r12 * _local4.y));
_local3.y = ((r21 * _local4.x) + (r22 * _local4.y));
_local1 = _local1.next;
_local3 = _local3.next;
_local2 = _local2.next;
_local4 = _local4.next;
_local1.x = (((r11 * _local2.x) + (r12 * _local2.y)) + _local5);
_local1.y = (((r21 * _local2.x) + (r22 * _local2.y)) + _local6);
_local3.x = ((r11 * _local4.x) + (r12 * _local4.y));
_local3.y = ((r21 * _local4.x) + (r22 * _local4.y));
}
override public function update():void{
synced = false;
x = (body.x + (((r11 = body.r11) * mx) + ((r12 = body.r12) * my)));
y = (body.y + (((r21 = body.r21) * mx) + ((r22 = body.r22) * my)));
xmin = (x - ex);
ymin = (y - ey);
xmax = (x + ex);
ymax = (y + ey);
super.update();
}
override protected function setType():void{
type = ShapeTypes.LINE;
}
private function setup(_arg1:LineData, _arg2:RigidBody):void{
var _local3:Number;
var _local4:Number;
var _local5:Number;
var _local6:Number;
var _local7:Array;
var _local8:V2;
var _local10:AABB2;
infinite = _arg1.infinite;
doubleSided = _arg1.doubleSided;
_local3 = _arg2.cx;
_local5 = _arg2.cy;
mx = (_arg1.mx - _local3);
my = (_arg1.my - _local5);
x = (body.x + (((r11 = body.r11) * mx) + ((r12 = body.r12) * my)));
y = (body.y + (((r21 = body.r21) * mx) + ((r22 = body.r22) * my)));
_local4 = (_arg1.b.x - _arg1.a.x);
_local6 = (_arg1.b.y - _arg1.a.y);
var _local9:Number = Math.sqrt(((_local4 * _local4) + (_local6 * _local6)));
vertexCount = 2;
_local7 = new Array(vertexCount);
_local8 = (_local7[0] = new V2());
_local8.x = ((mx + (r11 * _arg1.a.x)) + (r12 * _arg1.a.y));
_local8.y = ((my + (r21 * _arg1.a.x)) + (r22 * _arg1.a.y));
_local8 = (_local7[1] = new V2());
_local8.x = ((mx + (r11 * _arg1.b.x)) + (r12 * _arg1.b.y));
_local8.y = ((my + (r21 * _arg1.b.x)) + (r22 * _arg1.b.y));
initPoly(_local7, vertexCount, true);
radius = (_local9 / 2);
radiusSq = (radius * radius);
toWorldSpace();
if (infinite){
_local10 = body.world.worldAABB;
xmin = _local10.xmin;
ymin = _local10.ymin;
xmax = _local10.xmax;
ymax = _local10.ymax;
} else {
if ((((Math.abs(_local4) < 0.001)) || ((Math.abs(_local6) < 0.001)))){
xmin = (x - radius);
ymin = (y - radius);
xmax = (x + radius);
ymax = (y + radius);
} else {
_local8 = worldVertexChain;
xmin = Math.min(_local8.x, _local8.next.x);
xmax = Math.max(_local8.x, _local8.next.x);
ymin = Math.min(_local8.y, _local8.next.y);
ymax = Math.max(_local8.y, _local8.next.y);
};
};
ex = ((xmax - xmin) / 2);
ey = ((ymax - ymin) / 2);
createProxy(_arg1.groupIndex, _arg1.categoryBits, _arg1.maskBits);
update();
_local4 = (worldVertexChain.next.x - worldVertexChain.x);
_local6 = (worldVertexChain.next.y - worldVertexChain.y);
_local9 = Math.sqrt(((_local4 * _local4) + (_local6 * _local6)));
_local4 = (_local4 / _local9);
_local6 = (_local6 / _local9);
d = ((worldNormalChain.x * worldVertexChain.x) + (worldNormalChain.y * worldVertexChain.y));
}
}
}//package de.polygonal.motor2.collision.shapes
Section 42
//PolyShape (de.polygonal.motor2.collision.shapes.PolyShape)
package de.polygonal.motor2.collision.shapes {
import flash.geom.*;
import de.polygonal.motor2.math.*;
import de.polygonal.motor2.dynamics.*;
import de.polygonal.motor2.collision.shapes.data.*;
import de.polygonal.ds.*;
public class PolyShape extends ShapeSkeleton {
private var _x:Number;
private var _y:Number;
private var _triCenter:V2;
private var _r21:Number;
private var _r11:Number;
private var _r12:Number;
private var _r22:Number;
public function PolyShape(_arg1:PolyData, _arg2:RigidBody){
super(_arg1, _arg2);
setup(_arg1, _arg2);
}
override public function update():void{
synced = false;
x = ((body.x + ((r11 = body.r11) * mx)) + ((r12 = body.r12) * my));
y = ((body.y + ((r21 = body.r21) * mx)) + ((r22 = body.r22) * my));
xmin = (xmax = ((x + (r11 * _x)) + (r12 * _y)));
ymin = (ymax = ((y + (r21 * _x)) + (r22 * _y)));
var _local1:Number = ((_r11 * r11) + (_r12 * r21));
if (_local1 > 0){
xmin = (xmin + (_local1 * -(ex)));
xmax = (xmax + (_local1 * ex));
} else {
xmin = (xmin + (_local1 * ex));
xmax = (xmax + (_local1 * -(ex)));
};
_local1 = ((_r11 * r12) + (_r12 * r22));
if (_local1 > 0){
xmin = (xmin + (_local1 * -(ey)));
xmax = (xmax + (_local1 * ey));
} else {
xmin = (xmin + (_local1 * ey));
xmax = (xmax + (_local1 * -(ey)));
};
_local1 = ((_r21 * r11) + (_r22 * r21));
if (_local1 > 0){
ymin = (ymin + (_local1 * -(ex)));
ymax = (ymax + (_local1 * ex));
} else {
ymin = (ymin + (_local1 * ex));
ymax = (ymax + (_local1 * -(ex)));
};
_local1 = ((_r21 * r12) + (_r22 * r22));
if (_local1 > 0){
ymin = (ymin + (_local1 * -(ey)));
ymax = (ymax + (_local1 * ey));
} else {
ymin = (ymin + (_local1 * ey));
ymax = (ymax + (_local1 * -(ey)));
};
if (_triCenter){
_triCenter.x = x;
_triCenter.y = y;
};
super.update();
}
override public function pointInside(_arg1:Point):Boolean{
var _local2:Number = _arg1.x;
var _local3:Number = _arg1.y;
var _local4:Number = ((r11 * (_local2 - this.x)) + (r21 * (_local3 - this.y)));
var _local5:Number = ((r12 * (_local2 - this.x)) + (r22 * (_local3 - this.y)));
var _local6:V2 = modelVertexChain;
var _local7:V2 = modelNormalChain;
while (_local6) {
if ((((_local4 - _local6.x) * _local7.x) + ((_local5 - _local6.y) * _local7.y)) > 0){
return (false);
};
if (_local6.last){
break;
};
_local7 = _local7.next;
_local6 = _local6.next;
};
return (true);
}
override public function triangulate():void{
var _local2:Tri2;
_triCenter = new V2(x, y);
var _local1:V2 = worldVertexChain;
while (true) {
_local2 = new Tri2(_local1, _local1.next, _triCenter);
_local2.next = triangleList;
triangleList = _local2;
if (_local1.last){
break;
};
_local1 = _local1.next;
};
}
override public function toWorldSpace():void{
var _local1:V2 = worldVertexChain;
var _local2:V2 = modelVertexChain;
var _local3:V2 = worldNormalChain;
var _local4:V2 = modelNormalChain;
var _local5:Number = body.x;
var _local6:Number = body.y;
while (true) {
_local1.x = (((r11 * _local2.x) + (r12 * _local2.y)) + _local5);
_local1.y = (((r21 * _local2.x) + (r22 * _local2.y)) + _local6);
_local3.x = ((r11 * _local4.x) + (r12 * _local4.y));
_local3.y = ((r21 * _local4.x) + (r22 * _local4.y));
if (_local1.last){
break;
};
_local1 = _local1.next;
_local2 = _local2.next;
_local3 = _local3.next;
_local4 = _local4.next;
};
}
public function getWorldOBB():V2{
var _local1:Number = (_r11 * ex);
var _local2:Number = (_r21 * ex);
var _local3:Number = (_r12 * ey);
var _local4:Number = (_r22 * ey);
var _local5:V2 = new V2((((_x + mx) + _local1) - _local3), (((_y + my) + _local2) - _local4));
var _local6:V2 = new V2((((_x + mx) - _local1) - _local3), (((_y + my) - _local2) - _local4));
var _local7:V2 = new V2((((_x + mx) - _local1) + _local3), (((_y + my) - _local2) + _local4));
var _local8:V2 = new V2((((_x + mx) + _local1) + _local3), (((_y + my) + _local2) + _local4));
_local5.next = _local6;
_local6.next = _local7;
_local7.next = _local8;
return (_local5);
}
override public function closestPoint(_arg1:Point, _arg2:Point=null):void{
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;
var _local14:Number;
var _local15:Number;
var _local16:V2;
var _local17:V2;
var _local13:Number = -1;
_local6 = ((r11 * (x - this.x)) + (r21 * (y - this.y)));
_local11 = ((r12 * (x - this.x)) + (r22 * (y - this.y)));
_local16 = modelVertexChain;
_local17 = _local16.next;
while (true) {
_local3 = (_local17.x - _local16.x);
_local8 = (_local17.y - _local16.y);
_local4 = (_local6 - _local16.x);
_local9 = (_local11 - _local16.y);
if (((_local4 * _local3) + (_local9 * _local8)) > 0){
_local15 = (((_local4 * _local3) + (_local9 * _local8)) / ((_local3 * _local3) + (_local8 * _local8)));
_local15 = ((_local15)<0) ? 0 : ((_local15)>1) ? 1 : _local15;
_local5 = (_local16.x + (_local3 * _local15));
_local10 = (_local16.y + (_local8 * _local15));
_local14 = (((_local6 - _local5) * (_local6 - _local5)) + ((_local11 - _local10) * (_local11 - _local10)));
if ((((_local14 < _local13)) || ((_local13 < 0)))){
_local13 = _local14;
_local7 = ((this.x + (r11 * _local5)) + (r12 * _local10));
_local12 = ((this.y + (r21 * _local5)) + (r22 * _local10));
};
};
if (_local16.last){
break;
};
_local16 = _local17;
_local17 = _local17.next;
};
if (_arg2){
_arg2.x = _local7;
_arg2.y = _local12;
} else {
_arg1.x = _local7;
_arg1.y = _local12;
};
}
override protected function setType():void{
type = ShapeTypes.POLY;
}
private function setup(_arg1:PolyData, _arg2:RigidBody):void{
var xLocalCenter:Number;
var xt:Number;
var s:Number;
var yLocalCenter:Number;
var yt:Number;
var c:Number;
var verts:Array;
var modelVertexList:Array;
var i:int;
var r:Number;
var v:V2;
var pos:V2;
var ext:V2;
var sd = _arg1;
var rb = _arg2;
xLocalCenter = rb.cx;
yLocalCenter = rb.cy;
mx = (sd.mx - xLocalCenter);
my = (sd.my - yLocalCenter);
s = Math.sin(sd.mr);
c = Math.cos(sd.mr);
r11 = c;
r12 = -(s);
r21 = s;
r22 = c;
radius = sd.radius;
radiusSq = (radius * radius);
vertexCount = sd.getVertexCount();
modelVertexList = new Array(vertexCount);
verts = sd.getVertices();
i = 0;
while (i < vertexCount) {
v = verts[i];
xt = ((mx + (r11 * v.x)) + (r12 * v.y));
yt = ((my + (r21 * v.x)) + (r22 * v.y));
modelVertexList[i] = new V2(xt, yt);
i = (i + 1);
};
initPoly(modelVertexList, vertexCount, sd.isRegular(), mx, my);
pos = new V2();
ext = new V2();
r = computeMinAreaRect(pos, ext);
_x = (pos.x - mx);
ex = ext.x;
_y = (pos.y - my);
ey = ext.y;
s = Math.sin(r);
c = Math.cos(r);
_r11 = c;
_r12 = -(s);
_r21 = s;
_r22 = c;
BSPNode = ConvexBSP.createBSP(vertexCount, modelNormalChain.toArray(), _edges);
BinaryTreeNode.inorder(BSPNode, function (_arg1:ConvexBSPNode):void{
_arg1.N = worldNormalChain.getAt(_arg1.I);
_arg1.V = worldVertexChain.getAt(_arg1.I);
});
createProxy(sd.groupIndex, sd.categoryBits, sd.maskBits);
}
}
}//package de.polygonal.motor2.collision.shapes
Section 43
//ShapeSkeleton (de.polygonal.motor2.collision.shapes.ShapeSkeleton)
package de.polygonal.motor2.collision.shapes {
import flash.geom.*;
import de.polygonal.motor2.math.*;
import de.polygonal.motor2.dynamics.*;
import de.polygonal.motor2.collision.shapes.data.*;
import de.polygonal.motor2.collision.nbody.*;
public class ShapeSkeleton {
public var y:Number;
public var friction:Number;
public var worldVertexChain:V2;
public var area:Number;
public var radiusSq:Number;
public var radius:Number;
public var r12:Number;
public var modelVertexChain:V2;
public var r11:Number;
public var body:RigidBody;
public var proxyId:int;
public var mx:Number;
public var my:Number;
public var worldNormalChain:V2;
public var modelNormalChain:V2;
public var r22:Number;
public var ex:Number;
public var ey:Number;
public var r21:Number;
public var ymin:Number;
public var type:int;
protected var _broadPhase:IBroadPhase;
public var offsets:Array;
public var BSPNode:ConvexBSPNode;
public var triangleList:Tri2;
public var ymax:Number;
protected var _edges:Array;
public var xmin:Number;
public var vertexCount:int;
public var regularShape:Boolean;
public var restitution:Number;
public var d:Number;
public var xmax:Number;
public var next:ShapeSkeleton;
public var x:Number;
public var synced:Boolean;// = false
public function ShapeSkeleton(_arg1:ShapeData, _arg2:RigidBody){
friction = _arg1.friction;
restitution = _arg1.restitution;
area = _arg1.area;
body = _arg2;
setType();
_broadPhase = body.world.getBroadPhase();
proxyId = ShapeProxy.NULL_PROXY;
}
public function triangulate():void{
}
public function closestPoint(_arg1:Point, _arg2:Point=null):void{
}
protected function setType():void{
type = ShapeTypes.UNKNOWN;
}
public function update():void{
if (proxyId == ShapeProxy.NULL_PROXY){
return;
};
if (_broadPhase.insideBounds(xmin, ymin, xmax, ymax)){
_broadPhase.moveProxy(proxyId);
} else {
_broadPhase.removeProxy(proxyId);
proxyId = ShapeProxy.NULL_PROXY;
body.freeze();
};
}
protected function computeMinAreaRect(_arg1:V2, _arg2:V2):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;
var _local13:Number;
var _local14:Number;
var _local15:Number;
var _local16:Number;
var _local17:Number;
var _local18:Number;
var _local19:Number;
var _local20:Number;
var _local21:Number;
var _local22:Number;
var _local23:Number;
var _local24:Number;
var _local25:Number;
var _local26:Number;
var _local27:Number;
var _local28:Number;
var _local29:V2;
var _local30:V2;
var _local31:V2;
var _local32:V2;
var _local33:int;
var _local34:Number;
var _local3:Number = Number.MAX_VALUE;
_local29 = modelVertexChain;
_local30 = modelVertexChain.next;
_local31 = modelVertexChain;
_local33 = 0;
while (_local33 < vertexCount) {
_local17 = (_local30.x - _local29.x);
_local20 = (_local30.y - _local29.y);
_local28 = Math.sqrt(((_local17 * _local17) + (_local20 * _local20)));
_local17 = (_local17 / _local28);
_local20 = (_local20 / _local28);
_local18 = -(_local20);
_local21 = _local17;
_local15 = ((_local31.x * _local17) + (_local31.y * _local20));
_local13 = _local15;
_local16 = ((_local31.x * _local18) + (_local31.y * _local21));
_local14 = _local16;
_local32 = modelVertexChain.next;
while (true) {
_local27 = ((_local32.x * _local17) + (_local32.y * _local20));
if (_local27 < _local13){
_local13 = _local27;
} else {
if (_local27 > _local15){
_local15 = _local27;
};
};
_local27 = ((_local32.x * _local18) + (_local32.y * _local21));
if (_local27 < _local14){
_local14 = _local27;
} else {
if (_local27 > _local16){
_local16 = _local27;
};
};
if (_local32.last){
break;
};
_local32 = _local32.next;
};
_local4 = ((_local15 - _local13) * (_local16 - _local14));
if (_local4 < _local3){
_local3 = _local4;
_local5 = (_local17 * _local13);
_local6 = (_local20 * _local13);
_local7 = (_local17 * _local15);
_local8 = (_local20 * _local15);
_local9 = (_local18 * _local14);
_local10 = (_local21 * _local14);
_local11 = (_local18 * _local16);
_local12 = (_local21 * _local16);
};
_local29 = _local30;
_local30 = _local30.next;
_local33++;
};
_local19 = (_local7 - _local5);
_local22 = (_local8 - _local6);
_local25 = Math.sqrt(((_local19 * _local19) + (_local22 * _local22)));
_local23 = Math.atan2(_local22, _local19);
_local19 = (_local11 - _local9);
_local22 = (_local12 - _local10);
_local26 = Math.sqrt(((_local19 * _local19) + (_local22 * _local22)));
_local24 = Math.atan2(_local22, _local19);
if (((_local24 < 0)) ? -(_local24) : _local24 < ((_local23 < 0)) ? -(_local23) : _local23){
_local34 = _local24;
_arg2.x = (_local26 / 2);
_arg2.y = (_local25 / 2);
} else {
_local34 = _local23;
_arg2.x = (_local25 / 2);
_arg2.y = (_local26 / 2);
};
_arg1.x = ((_local5 + _local9) + (((_local7 + _local11) - (_local5 + _local9)) / 2));
_arg1.y = ((_local6 + _local10) + (((_local8 + _local12) - (_local6 + _local10)) / 2));
return (_local34);
}
public function pointInside(_arg1:Point):Boolean{
return (false);
}
protected function createProxy(_arg1:int, _arg2:int, _arg3:int):void{
update();
if (_broadPhase.insideBounds(xmin, ymin, xmax, ymax)){
proxyId = _broadPhase.createProxy(_arg1, _arg2, _arg3, this);
} else {
proxyId = ShapeProxy.NULL_PROXY;
body.freeze();
};
}
public function getShapeOffset(_arg1:Point):void{
_arg1.x = mx;
_arg1.y = my;
}
public function toWorldSpace():void{
}
public function deconstruct():void{
BSPNode = null;
modelVertexChain = (modelNormalChain = (worldVertexChain = (worldNormalChain = null)));
_edges = (offsets = null);
triangleList = null;
if (proxyId != ShapeProxy.NULL_PROXY){
_broadPhase.removeProxy(proxyId);
};
_broadPhase = null;
}
protected function initPoly(_arg1:Array, _arg2:int, _arg3:Boolean, _arg4:Number=0, _arg5:Number=0):void{
var _local6:int;
var _local7:Number;
var _local8:Number;
var _local9:Number;
var _local10:Number;
var _local11:Number;
var _local12:V2;
var _local13:V2;
var _local14:V2;
var _local15:V2;
var _local16:V2;
var _local17:V2;
var _local18:V2;
var _local19:E2;
var _local20:Number;
var _local21:Number;
var _local22:Number;
regularShape = _arg3;
_local15 = _arg1[0];
modelVertexChain = _local15;
_local16 = new V2();
worldVertexChain = _local16;
_local15.I = 0;
_local16.I = 0;
_local17 = new V2();
modelNormalChain = _local17;
_local18 = new V2();
worldNormalChain = _local18;
_local17.I = 0;
_local18.I = 0;
_local6 = 1;
while (_local6 < _arg2) {
_local12 = _arg1[_local6];
_local13 = _local15;
_local14 = _local12;
_local14.I = _local6;
_local13.next = _local14;
_local14.prev = _local13;
_local15 = _local15.next;
_local13 = _local16;
_local14 = new V2();
_local14.I = _local6;
_local13.next = _local14;
_local14.prev = _local13;
_local16 = _local16.next;
_local13 = _local17;
_local14 = new V2();
_local14.I = _local6;
_local13.next = _local14;
_local14.prev = _local13;
_local17 = _local17.next;
_local13 = _local18;
_local14 = new V2();
_local14.I = _local6;
_local13.next = _local14;
_local14.prev = _local13;
_local18 = _local18.next;
_local6++;
};
_local15.last = true;
_local15.next = modelVertexChain;
modelVertexChain.prev = _local15;
_local16.last = true;
_local16.next = worldVertexChain;
worldVertexChain.prev = _local16;
_local17.last = true;
_local17.next = modelNormalChain;
modelNormalChain.prev = _local17;
_local18.last = true;
_local18.next = worldNormalChain;
worldNormalChain.prev = _local18;
_edges = [];
offsets = [];
_local18 = worldNormalChain;
_local16 = worldVertexChain;
_local17 = modelNormalChain;
_local13 = modelVertexChain;
_local14 = _local13.next;
_local6 = 0;
while (_local6 < _arg2) {
_local7 = (_local14.x - _local13.x);
_local8 = (_local14.y - _local13.y);
_local11 = Math.sqrt(((_local7 * _local7) + (_local8 * _local8)));
_local7 = (_local7 / _local11);
_local8 = (_local8 / _local11);
_edges[_local6] = new V2(_local7, _local8);
_local9 = _local8;
_local10 = -(_local7);
_local17.x = _local9;
_local17.y = _local10;
_local17 = _local17.next;
_local20 = ((body.cx + _local13.x) + ((_local14.x - _local13.x) * 0.5));
_local21 = ((body.cy + _local13.y) + ((_local14.y - _local13.y) * 0.5));
_local22 = (((_local20 - _arg4) * _local9) + ((_local21 - _arg5) * _local10));
if (!_arg3){
offsets[_local6] = new V2((_local20 + (-(_local9) * _local22)), (_local21 + (-(_local10) * _local22)));
};
_local19 = new E2();
_local19.v = _local13;
_local19.w = _local13.next;
_local19.n = _local17;
_local19.d = _edges[_local6];
_local19.mag = _local11;
_local13.userData = _local19;
_local13 = _local14;
_local14 = _local13.next;
_local19 = new E2();
_local19.v = _local16;
_local19.w = _local16.next;
_local19.n = _local18;
_local19.d = _edges[_local6];
_local19.mag = _local11;
_local16.userData = _local19;
_local16 = _local16.next;
_local18 = _local18.next;
_local6++;
};
}
}
}//package de.polygonal.motor2.collision.shapes
Section 44
//ShapeTypes (de.polygonal.motor2.collision.shapes.ShapeTypes)
package de.polygonal.motor2.collision.shapes {
public class ShapeTypes {
public static const UNKNOWN:int = 0;
public static const BOX:int = 2;
public static const POLY:int = 3;
public static const CIRCLE:int = 1;
public static const SHAPE_COUNT:int = 5;
public static const LINE:int = 4;
public static function getName(_arg1:int):String{
switch (_arg1){
case 1:
return ("CIRCLE");
case 2:
return ("BOX");
case 3:
return ("POLY");
case 4:
return ("LINE");
};
return ("UNKNOWN");
}
}
}//package de.polygonal.motor2.collision.shapes
Section 45
//BoxCircleContact (de.polygonal.motor2.dynamics.contact.generator.BoxCircleContact)
package de.polygonal.motor2.dynamics.contact.generator {
import de.polygonal.motor2.collision.shapes.*;
import de.polygonal.motor2.collision.pairwise.*;
public class BoxCircleContact extends ConvexCircleContact {
public function BoxCircleContact(_arg1:ShapeSkeleton, _arg2:ShapeSkeleton){
super(_arg1, _arg2);
}
override protected function getCollider():Collider{
return (new CollideBoxCircle());
}
}
}//package de.polygonal.motor2.dynamics.contact.generator
Section 46
//BoxContact (de.polygonal.motor2.dynamics.contact.generator.BoxContact)
package de.polygonal.motor2.dynamics.contact.generator {
import de.polygonal.motor2.collision.shapes.*;
import de.polygonal.motor2.collision.pairwise.*;
public class BoxContact extends ConvexContact {
public var sepAxisId:int;
public function BoxContact(_arg1:ShapeSkeleton, _arg2:ShapeSkeleton){
super(_arg1, _arg2);
}
override protected function getCollider():Collider{
return (new CollideBox());
}
}
}//package de.polygonal.motor2.dynamics.contact.generator
Section 47
//BoxLineContact (de.polygonal.motor2.dynamics.contact.generator.BoxLineContact)
package de.polygonal.motor2.dynamics.contact.generator {
import de.polygonal.motor2.collision.shapes.*;
import de.polygonal.motor2.collision.pairwise.*;
public class BoxLineContact extends ConvexContact {
public var sid:int;// = -1
public function BoxLineContact(_arg1:ShapeSkeleton, _arg2:ShapeSkeleton){
super(_arg1, _arg2);
}
override protected function getCollider():Collider{
var _local1:LineShape = LineShape(shape2);
if (_local1.infinite){
if (_local1.doubleSided){
return (new CollideBoxPlaneDS());
};
return (new CollideBoxPlaneSS());
};
if (_local1.doubleSided){
return (new CollideBoxLineDS());
};
return (new CollideBoxLineSS());
}
}
}//package de.polygonal.motor2.dynamics.contact.generator
Section 48
//CircleContact (de.polygonal.motor2.dynamics.contact.generator.CircleContact)
package de.polygonal.motor2.dynamics.contact.generator {
import de.polygonal.motor2.collision.shapes.*;
import de.polygonal.motor2.dynamics.contact.*;
import de.polygonal.motor2.collision.pairwise.*;
public class CircleContact extends Contact {
public var manifold:Manifold;
public function CircleContact(_arg1:ShapeSkeleton, _arg2:ShapeSkeleton){
super(_arg1, _arg2);
manifold = (manifolds[0] = new Manifold());
manifold.c0.Pn = 0;
manifold.c0.Pt = 0;
}
override public function evaluate():void{
_collider.collide(manifold, shape1, shape2, null);
manifoldCount = ((manifold.pointCount > 0)) ? 1 : 0;
}
override protected function getCollider():Collider{
return (new CollideCircle());
}
}
}//package de.polygonal.motor2.dynamics.contact.generator
Section 49
//CircleLineContact (de.polygonal.motor2.dynamics.contact.generator.CircleLineContact)
package de.polygonal.motor2.dynamics.contact.generator {
import de.polygonal.motor2.*;
import de.polygonal.motor2.collision.shapes.*;
import de.polygonal.motor2.dynamics.contact.*;
import de.polygonal.motor2.collision.pairwise.*;
public class CircleLineContact extends Contact {
private var _m1Cp1:ContactPoint;
private var _Pt0:Number;
public var manifold:Manifold;
private var _Pn0:Number;
private var _id0:uint;
public function CircleLineContact(_arg1:ShapeSkeleton, _arg2:ShapeSkeleton){
super(_arg1, _arg2);
manifold = (manifolds[0] = new Manifold());
_m1Cp1 = manifold.c0;
manifold.c0.Pn = 0;
manifold.c0.Pt = 0;
}
override protected function getCollider():Collider{
var _local1:LineShape = LineShape(shape2);
if (_local1.infinite){
if (_local1.doubleSided){
return (new CollideCirclePlaneDS());
};
return (new CollideCirclePlaneSS());
};
if (_local1.doubleSided){
return (new CollideCircleLineDS());
};
return (new CollideCircleLineSS());
}
override public function evaluate():void{
var _local1:int;
var _local2:int;
if (World.doWarmStarting){
_m1Cp1.matched = false;
_local1 = manifold.pointCount;
if (_local1 > 0){
_id0 = _m1Cp1.id.key;
_Pn0 = _m1Cp1.Pn;
_Pt0 = _m1Cp1.Pt;
};
_collider.collide(manifold, shape1, shape2, this);
_local2 = manifold.pointCount;
if (_local2 > 0){
manifoldCount = 1;
} else {
manifoldCount = 0;
return;
};
_m1Cp1.Pn = 0;
_m1Cp1.Pt = 0;
if ((((_local1 == 1)) && ((_local2 == 1)))){
if (_m1Cp1.id.key == _id0){
_m1Cp1.Pn = _Pn0;
_m1Cp1.Pt = _Pt0;
_m1Cp1.matched = true;
};
};
} else {
_collider.collide(manifold, shape1, shape2, this);
manifoldCount = ((manifold.pointCount > 0)) ? 1 : 0;
};
}
}
}//package de.polygonal.motor2.dynamics.contact.generator
Section 50
//ConvexCircleContact (de.polygonal.motor2.dynamics.contact.generator.ConvexCircleContact)
package de.polygonal.motor2.dynamics.contact.generator {
import de.polygonal.motor2.*;
import de.polygonal.motor2.math.*;
import de.polygonal.motor2.collision.shapes.*;
import de.polygonal.motor2.dynamics.contact.*;
public class ConvexCircleContact extends Contact {
private var _m1Cp1:ContactPoint;
public var d:V2;
private var _Pt0:Number;
public var manifold:Manifold;
private var _Pn0:Number;
private var _id0:uint;
public var p:V2;
public function ConvexCircleContact(_arg1:ShapeSkeleton, _arg2:ShapeSkeleton){
super(_arg1, _arg2);
manifold = (manifolds[0] = new Manifold());
_m1Cp1 = manifold.c0;
p = _arg1.worldVertexChain;
d = _arg1.worldNormalChain;
}
override public function evaluate():void{
var _local1:int;
var _local2:int;
if (!shape1.synced){
shape1.toWorldSpace();
};
if (World.doWarmStarting){
_m1Cp1.matched = false;
_local1 = manifold.pointCount;
if (_local1 > 0){
_id0 = _m1Cp1.id.key;
_Pn0 = _m1Cp1.Pn;
_Pt0 = _m1Cp1.Pt;
};
_collider.collide(manifold, shape1, shape2, this);
_local2 = manifold.pointCount;
if (_local2 > 0){
manifoldCount = 1;
} else {
manifoldCount = 0;
return;
};
_m1Cp1.Pn = 0;
_m1Cp1.Pt = 0;
if ((((_local1 == 1)) && ((_local2 == 1)))){
if (_m1Cp1.id.key == _id0){
_m1Cp1.Pn = _Pn0;
_m1Cp1.Pt = _Pt0;
_m1Cp1.matched = true;
};
};
} else {
_collider.collide(manifold, shape1, shape2, this);
if (manifold.pointCount > 0){
manifoldCount = 1;
} else {
manifoldCount = 0;
return;
};
};
}
}
}//package de.polygonal.motor2.dynamics.contact.generator
Section 51
//ConvexContact (de.polygonal.motor2.dynamics.contact.generator.ConvexContact)
package de.polygonal.motor2.dynamics.contact.generator {
import de.polygonal.motor2.*;
import de.polygonal.motor2.collision.shapes.*;
import de.polygonal.motor2.dynamics.contact.*;
public class ConvexContact extends Contact {
private var _m1Cp1:ContactPoint;
private var _Pn0_1:Number;
private var _Pn0_2:Number;
private var _Pt0_2:Number;
private var _id0_1:uint;
private var _m1Cp2:ContactPoint;
public var manifold:Manifold;
private var _id0_2:uint;
private var _Pt0_1:Number;
public function ConvexContact(_arg1:ShapeSkeleton, _arg2:ShapeSkeleton){
super(_arg1, _arg2);
manifold = (manifolds[0] = new Manifold());
_m1Cp1 = manifold.c0;
_m1Cp2 = manifold.c1;
}
override public function evaluate():void{
var _local1:int;
var _local2:int;
var _local3:int;
if (!shape1.synced){
shape1.toWorldSpace();
};
if (!shape2.synced){
shape2.toWorldSpace();
};
if (World.doWarmStarting){
_m1Cp1.matched = false;
_m1Cp2.matched = false;
_local1 = manifold.pointCount;
if (_local1 > 0){
_id0_1 = _m1Cp1.id.key;
_Pn0_1 = _m1Cp1.Pn;
_Pt0_1 = _m1Cp1.Pt;
if (_local1 > 1){
_id0_2 = _m1Cp2.id.key;
_Pn0_2 = _m1Cp2.Pn;
_Pt0_2 = _m1Cp2.Pt;
};
};
_collider.collide(manifold, shape1, shape2, this);
_local2 = manifold.pointCount;
if (_local2 > 0){
manifoldCount = 1;
} else {
manifoldCount = 0;
return;
};
_m1Cp1.Pn = 0;
_m1Cp1.Pt = 0;
_m1Cp2.Pn = 0;
_m1Cp2.Pt = 0;
if (_local2 == 1){
if (_local1 == 1){
if (_m1Cp1.id.key == _id0_1){
_m1Cp1.Pn = _Pn0_1;
_m1Cp1.Pt = _Pt0_1;
_m1Cp1.matched = true;
};
} else {
if (_local1 == 2){
_local3 = _m1Cp1.id.key;
if (_local3 == _id0_1){
_m1Cp1.Pn = _Pn0_1;
_m1Cp1.Pt = _Pt0_1;
_m1Cp1.matched = true;
} else {
if (_local3 == _id0_2){
};
};
_m1Cp1.Pn = _Pn0_2;
_m1Cp1.Pt = _Pn0_2;
_m1Cp1.matched = true;
};
};
} else {
if (_local2 == 2){
if (_local1 == 1){
if (_m1Cp1.id.key == _id0_1){
_m1Cp1.Pn = _Pn0_1;
_m1Cp1.Pt = _Pt0_1;
_m1Cp1.matched = true;
} else {
if (_m1Cp2.id.key == _id0_1){
_m1Cp2.Pn = _Pn0_1;
_m1Cp2.Pt = _Pt0_1;
_m1Cp2.matched = true;
};
};
} else {
if (_local1 == 2){
if (_m1Cp1.id.key == _id0_1){
_m1Cp1.Pn = _Pn0_1;
_m1Cp1.Pt = _Pt0_1;
_m1Cp1.matched = true;
if (_m1Cp2.id.key == _id0_2){
_m1Cp2.Pn = _Pn0_2;
_m1Cp2.Pt = _Pt0_2;
_m1Cp2.matched = true;
return;
};
} else {
if (_m1Cp1.id.key == _id0_2){
_m1Cp1.Pn = _Pn0_2;
_m1Cp1.Pt = _Pt0_2;
_m1Cp1.matched = true;
if (_m1Cp2.id.key == _id0_1){
_m1Cp2.Pn = _Pn0_1;
_m1Cp2.Pt = _Pt0_1;
_m1Cp2.matched = true;
return;
};
};
};
if (_m1Cp2.id.key == _id0_1){
_m1Cp2.Pn = _Pn0_1;
_m1Cp2.Pt = _Pt0_1;
_m1Cp2.matched = true;
} else {
if (_m1Cp2.id.key == _id0_2){
_m1Cp2.Pn = _Pn0_2;
_m1Cp2.Pt = _Pt0_2;
_m1Cp2.matched = true;
};
};
};
};
};
};
} else {
_collider.collide(manifold, shape1, shape2, this);
manifoldCount = ((manifold.pointCount > 0)) ? 1 : 0;
};
}
}
}//package de.polygonal.motor2.dynamics.contact.generator
Section 52
//PolyCircleContact (de.polygonal.motor2.dynamics.contact.generator.PolyCircleContact)
package de.polygonal.motor2.dynamics.contact.generator {
import de.polygonal.motor2.collision.shapes.*;
import de.polygonal.motor2.collision.pairwise.*;
public class PolyCircleContact extends ConvexCircleContact {
public function PolyCircleContact(_arg1:ShapeSkeleton, _arg2:ShapeSkeleton){
super(_arg1, _arg2);
}
override protected function getCollider():Collider{
return (new CollidePolyCircle());
}
}
}//package de.polygonal.motor2.dynamics.contact.generator
Section 53
//PolyContact (de.polygonal.motor2.dynamics.contact.generator.PolyContact)
package de.polygonal.motor2.dynamics.contact.generator {
import de.polygonal.motor2.math.*;
import de.polygonal.motor2.collision.shapes.*;
import de.polygonal.motor2.collision.pairwise.*;
public class PolyContact extends ConvexContact {
public var p:V2;
public var d:V2;
public var firstOut:Boolean;
public function PolyContact(_arg1:ShapeSkeleton, _arg2:ShapeSkeleton){
super(_arg1, _arg2);
firstOut = true;
p = _arg1.worldVertexChain;
d = _arg1.worldNormalChain;
}
override protected function getCollider():Collider{
return (new CollidePoly());
}
}
}//package de.polygonal.motor2.dynamics.contact.generator
Section 54
//PolyLineContact (de.polygonal.motor2.dynamics.contact.generator.PolyLineContact)
package de.polygonal.motor2.dynamics.contact.generator {
import de.polygonal.motor2.collision.shapes.*;
import de.polygonal.motor2.collision.pairwise.*;
public class PolyLineContact extends ConvexContact {
public function PolyLineContact(_arg1:ShapeSkeleton, _arg2:ShapeSkeleton){
super(_arg1, _arg2);
}
override protected function getCollider():Collider{
var _local1:LineShape = LineShape(shape2);
if (_local1.infinite){
if (_local1.doubleSided){
return (new CollidePolyPlaneDS());
};
return (new CollidePolyPlaneSS());
};
if (_local1.doubleSided){
return (new CollidePolyLineDS());
};
return (new CollidePolyLineSS());
}
}
}//package de.polygonal.motor2.dynamics.contact.generator
Section 55
//IContactSolver (de.polygonal.motor2.dynamics.contact.solver.IContactSolver)
package de.polygonal.motor2.dynamics.contact.solver {
public interface IContactSolver {
}
}//package de.polygonal.motor2.dynamics.contact.solver
Section 56
//SIContactSolver (de.polygonal.motor2.dynamics.contact.solver.SIContactSolver)
package de.polygonal.motor2.dynamics.contact.solver {
import de.polygonal.motor2.*;
import de.polygonal.motor2.dynamics.*;
import de.polygonal.motor2.dynamics.contact.*;
public class SIContactSolver implements IContactSolver {
private var _maxLinCorrection:Number;
private var _linSlop:Number;
private var _velThreshold:Number;
public var contactCount:int;
public var contacts:Array;
public function SIContactSolver():void{
_linSlop = Constants.k_linSlop;
_velThreshold = Constants.k_velocityThreshold;
_maxLinCorrection = Constants.k_maxLinCorrection;
}
public function solveVelConstraints():void{
var _local1:int;
var _local2:int;
var _local3:int;
var _local4:Contact;
var _local5:Manifold;
var _local6:ContactPoint;
var _local7:RigidBody;
var _local8:Number;
var _local9:Number;
var _local10:Number;
var _local11:Number;
var _local12:Number;
var _local13:RigidBody;
var _local14:Number;
var _local15:Number;
var _local16:Number;
var _local17:Number;
var _local18:Number;
var _local19:Number;
var _local20:Number;
var _local21:Number;
var _local22:Number;
var _local23:Number;
var _local24:Number;
var _local25:Number;
var _local26:Number;
var _local27:Number;
var _local28:Number;
var _local29:Number;
var _local30:Number;
var _local31:Number;
_local1 = 0;
while (_local1 < contactCount) {
_local4 = contacts[_local1];
_local7 = _local4.body1;
_local13 = _local4.body2;
_local8 = _local7.invMass;
_local9 = _local7.invI;
_local14 = _local13.invMass;
_local15 = _local13.invI;
_local10 = _local7.vx;
_local11 = _local7.vy;
_local12 = _local7.w;
_local16 = _local13.vx;
_local17 = _local13.vy;
_local18 = _local13.w;
_local2 = 0;
while (_local2 < _local4.manifoldCount) {
_local5 = _local4.manifolds[_local2];
_local19 = _local5.nx;
_local22 = _local5.ny;
_local3 = 0;
while (_local3 < _local5.pointCount) {
_local6 = _local5.points[_local3];
_local25 = _local6.w_r1x;
_local26 = _local6.w_r1y;
_local27 = _local6.w_r2x;
_local28 = _local6.w_r2y;
_local21 = (((_local16 - (_local18 * _local28)) - _local10) + (_local12 * _local26));
_local24 = (((_local17 + (_local18 * _local27)) - _local11) - (_local12 * _local25));
_local30 = (-(_local6.nMass) * (((_local21 * _local19) + (_local24 * _local22)) - _local6.velBias));
_local29 = (_local6.Pn + _local30);
if (_local29 < 0){
_local29 = 0;
};
_local30 = (_local29 - _local6.Pn);
_local20 = (_local30 * _local19);
_local23 = (_local30 * _local22);
_local10 = (_local10 - (_local8 * _local20));
_local11 = (_local11 - (_local8 * _local23));
_local12 = (_local12 - (_local9 * ((_local25 * _local23) - (_local26 * _local20))));
_local16 = (_local16 + (_local14 * _local20));
_local17 = (_local17 + (_local14 * _local23));
_local18 = (_local18 + (_local15 * ((_local27 * _local23) - (_local28 * _local20))));
_local6.Pn = _local29;
_local21 = (((_local16 - (_local18 * _local28)) - _local10) + (_local12 * _local26));
_local24 = (((_local17 + (_local18 * _local27)) - _local11) - (_local12 * _local25));
_local30 = (((_local6.tMass * -(_local22)) * _local21) + (_local19 * _local24));
_local31 = (_local4.friction * _local6.Pn);
_local29 = (_local6.Pt + _local30);
_local29 = ((_local29)<-(_local31)) ? -(_local31) : ((_local29)>_local31) ? _local31 : _local29;
_local30 = (_local29 - _local6.Pt);
_local20 = (_local30 * _local22);
_local23 = (_local30 * -(_local19));
_local10 = (_local10 - (_local8 * _local20));
_local11 = (_local11 - (_local8 * _local23));
_local12 = (_local12 - (_local9 * ((_local25 * _local23) - (_local26 * _local20))));
_local16 = (_local16 + (_local14 * _local20));
_local17 = (_local17 + (_local14 * _local23));
_local18 = (_local18 + (_local15 * ((_local27 * _local23) - (_local28 * _local20))));
_local6.Pt = _local29;
_local3++;
};
_local2++;
};
_local7.vx = _local10;
_local7.vy = _local11;
_local7.w = _local12;
_local13.vx = _local16;
_local13.vy = _local17;
_local13.w = _local18;
_local1++;
};
}
public function solvePosConstraints(_arg1:Number):Boolean{
var _local2:int;
var _local3:int;
var _local4:int;
var _local5:Contact;
var _local6:Manifold;
var _local7:ContactPoint;
var _local8:RigidBody;
var _local9:RigidBody;
var _local10: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:Number;
var _local21:Number;
var _local22:Number;
var _local23:Number;
var _local24:Number;
var _local25:Number;
var _local26:Number;
var _local27:Number;
var _local28:Number;
var _local29:Number;
var _local11:Number = 0;
_local2 = 0;
while (_local2 < contactCount) {
_local5 = contacts[_local2];
_local8 = _local5.body1;
_local9 = _local5.body2;
_local3 = 0;
while (_local3 < _local5.manifoldCount) {
_local6 = _local5.manifolds[_local3];
_local12 = _local6.nx;
_local17 = _local6.ny;
_local4 = 0;
while (_local4 < _local6.pointCount) {
_local7 = _local6.points[_local4];
_local15 = ((_local8.r11 * _local7.l_r1x) + (_local8.r12 * _local7.l_r1y));
_local20 = ((_local8.r21 * _local7.l_r1x) + (_local8.r22 * _local7.l_r1y));
_local16 = ((_local9.r11 * _local7.l_r2x) + (_local9.r12 * _local7.l_r2y));
_local21 = ((_local9.r21 * _local7.l_r2x) + (_local9.r22 * _local7.l_r2y));
_local14 = ((_local9.x + _local16) - (_local8.x + _local15));
_local19 = ((_local9.y + _local21) - (_local8.y + _local20));
_local10 = (((_local14 * _local12) + (_local19 * _local17)) + _local7.sep);
_local11 = ((_local11 < _local10)) ? _local11 : _local10;
_local24 = (_local10 + _linSlop);
_local25 = -(_maxLinCorrection);
_local26 = 0;
_local27 = (_arg1 * ((_local24)<_local25) ? _local25 : ((_local24)>_local26) ? _local26 : _local24);
_local28 = (-(_local7.nMass) * _local27);
_local29 = _local7.Pp;
_local7.Pp = (_local29 + _local28);
if (_local7.Pp < 0){
_local7.Pp = 0;
};
_local28 = (_local7.Pp - _local29);
_local13 = (_local28 * _local12);
_local18 = (_local28 * _local17);
_local8.x = (_local8.x - (_local8.invMass * _local13));
_local8.y = (_local8.y - (_local8.invMass * _local18));
_local8.r = (_local8.r - (_local8.invI * ((_local15 * _local18) - (_local20 * _local13))));
_local22 = Math.cos(_local8.r);
_local23 = Math.sin(_local8.r);
_local8.r11 = _local22;
_local8.r12 = -(_local23);
_local8.r21 = _local23;
_local8.r22 = _local22;
_local9.x = (_local9.x + (_local9.invMass * _local13));
_local9.y = (_local9.y + (_local9.invMass * _local18));
_local9.r = (_local9.r + (_local9.invI * ((_local16 * _local18) - (_local21 * _local13))));
_local22 = Math.cos(_local9.r);
_local23 = Math.sin(_local9.r);
_local9.r11 = _local22;
_local9.r12 = -(_local23);
_local9.r21 = _local23;
_local9.r22 = _local22;
_local4++;
};
_local3++;
};
_local2++;
};
return ((_local11 >= -(_linSlop)));
}
public function postSolve():void{
}
public function setContacts(_arg1:Array, _arg2:int):void{
this.contacts = _arg1;
this.contactCount = _arg2;
}
public function preStep():void{
var _local1:int;
var _local2:int;
var _local3:int;
var _local4:RigidBody;
var _local5:RigidBody;
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:Contact;
var _local18:Manifold;
var _local19:ContactPoint;
_local1 = 0;
while (_local1 < contactCount) {
_local17 = contacts[_local1];
_local4 = (contacts[_local1].body1 = _local17.shape1.body);
_local5 = (_local17.body2 = _local17.shape2.body);
_local2 = 0;
while (_local2 < _local17.manifoldCount) {
_local18 = _local17.manifolds[_local2];
_local6 = _local18.nx;
_local10 = _local18.ny;
_local3 = 0;
while (_local3 < _local18.pointCount) {
_local19 = _local18.points[_local3];
_local8 = (_local19.x - _local4.x);
_local12 = (_local19.y - _local4.y);
_local9 = (_local19.x - _local5.x);
_local13 = (_local19.y - _local5.y);
if (World.doPositionCorrection){
_local19.l_r1x = ((_local4.r11 * _local8) + (_local4.r21 * _local12));
_local19.l_r1y = ((_local4.r12 * _local8) + (_local4.r22 * _local12));
_local19.l_r2x = ((_local5.r11 * _local9) + (_local5.r21 * _local13));
_local19.l_r2y = ((_local5.r12 * _local9) + (_local5.r22 * _local13));
};
_local19.w_r1x = _local8;
_local19.w_r1y = _local12;
_local19.w_r2x = _local9;
_local19.w_r2y = _local13;
_local14 = ((_local8 * _local10) - (_local12 * _local6));
_local15 = ((_local9 * _local10) - (_local13 * _local6));
_local19.nMass = (1 / (((_local4.invMass + _local5.invMass) + ((_local4.invI * _local14) * _local14)) + ((_local5.invI * _local15) * _local15)));
_local14 = ((_local8 * -(_local6)) - (_local12 * _local10));
_local15 = ((_local9 * -(_local6)) - (_local13 * _local10));
_local19.tMass = (1 / (((_local4.invMass + _local5.invMass) + ((_local4.invI * _local14) * _local14)) + ((_local5.invI * _local15) * _local15)));
_local16 = ((_local6 * (((_local5.vx - (_local5.w * _local13)) - _local4.vx) + (_local4.vx * _local12))) + (_local10 * (((_local5.vy + (_local5.w * _local9)) - _local4.vy) - (_local4.vy * _local8))));
_local19.velBias = ((_local16 < -(_velThreshold))) ? (-(_local17.restitution) * _local16) : 0;
if (World.doWarmStarting){
_local7 = ((_local19.Pn * _local6) + (_local19.Pt * _local10));
_local11 = ((_local19.Pn * _local10) + (_local19.Pt * -(_local6)));
_local4.vx = (_local4.vx - (_local4.invMass * _local7));
_local4.vy = (_local4.vy - (_local4.invMass * _local11));
_local4.w = (_local4.w - (_local4.invI * ((_local8 * _local11) - (_local12 * _local7))));
_local5.vx = (_local5.vx + (_local5.invMass * _local7));
_local5.vy = (_local5.vy + (_local5.invMass * _local11));
_local5.w = (_local5.w + (_local5.invI * ((_local9 * _local11) - (_local13 * _local7))));
} else {
_local19.Pn = (_local19.Pt = 0);
};
_local19.Pp = 0;
_local3++;
};
_local2++;
};
_local1++;
};
}
public function preSolve():void{
}
public function solve():void{
}
}
}//package de.polygonal.motor2.dynamics.contact.solver
Section 57
//Contact (de.polygonal.motor2.dynamics.contact.Contact)
package de.polygonal.motor2.dynamics.contact {
import de.polygonal.motor2.dynamics.*;
import de.polygonal.motor2.collision.shapes.*;
import de.polygonal.motor2.collision.pairwise.*;
public class Contact {
public var next:Contact;
public var body1:RigidBody;
public var body2:RigidBody;
protected var _collider:Collider;
public var stateBits:int;
public var manifoldCount:int;
public var manifolds:Array;
public var restitution:Number;
public var node1:ContactNode;
public var node2:ContactNode;
public var shape2:ShapeSkeleton;
public var prev:Contact;
public var shape1:ShapeSkeleton;
public var friction:Number;
public var secondary:Boolean;
public var disabled:Boolean;
public static const k_bitDestroy:int = 1;
public static const k_bitIsland:int = 32;
public function Contact(_arg1:ShapeSkeleton, _arg2:ShapeSkeleton){
init(_arg1, _arg2);
}
public function evaluate():void{
}
protected function init(_arg1:ShapeSkeleton, _arg2:ShapeSkeleton):void{
shape1 = _arg1;
shape2 = _arg2;
manifoldCount = 0;
manifolds = [];
friction = Math.sqrt((_arg1.friction * _arg2.friction));
restitution = ((_arg1.restitution > _arg2.restitution)) ? _arg1.restitution : _arg2.restitution;
_collider = getCollider();
node1 = new ContactNode();
node2 = new ContactNode();
}
protected function getCollider():Collider{
return (null);
}
}
}//package de.polygonal.motor2.dynamics.contact
Section 58
//ContactFactory (de.polygonal.motor2.dynamics.contact.ContactFactory)
package de.polygonal.motor2.dynamics.contact {
import de.polygonal.motor2.collision.shapes.*;
import de.polygonal.ds.*;
import de.polygonal.motor2.dynamics.contact.generator.*;
public class ContactFactory {
private static var _contactMatrix:Array2;
public function ContactFactory(){
initializeContactMatrix();
}
private function initializeContactMatrix():void{
_contactMatrix = new Array2(ShapeTypes.SHAPE_COUNT, ShapeTypes.SHAPE_COUNT);
_contactMatrix.fill(ContactRegister);
registerContactHandler(BoxContact, ShapeTypes.BOX, ShapeTypes.BOX);
registerContactHandler(PolyContact, ShapeTypes.BOX, ShapeTypes.POLY);
registerContactHandler(BoxCircleContact, ShapeTypes.BOX, ShapeTypes.CIRCLE);
registerContactHandler(BoxLineContact, ShapeTypes.BOX, ShapeTypes.LINE);
registerContactHandler(PolyContact, ShapeTypes.POLY, ShapeTypes.POLY);
registerContactHandler(PolyCircleContact, ShapeTypes.POLY, ShapeTypes.CIRCLE);
registerContactHandler(PolyLineContact, ShapeTypes.POLY, ShapeTypes.LINE);
registerContactHandler(CircleContact, ShapeTypes.CIRCLE, ShapeTypes.CIRCLE);
registerContactHandler(CircleLineContact, ShapeTypes.CIRCLE, ShapeTypes.LINE);
}
public function destroy(_arg1:Contact):void{
if (_arg1.manifoldCount > 0){
_arg1.shape1.body.wakeUp();
_arg1.shape2.body.wakeUp();
};
_contactMatrix.get(_arg1.shape1.type, _arg1.shape2.type).deconstruct(_arg1);
}
public function create(_arg1:ShapeSkeleton, _arg2:ShapeSkeleton):Contact{
var _local5:Contact;
var _local6:int;
var _local7:Manifold;
var _local3:ContactRegister = _contactMatrix.get(_arg1.type, _arg2.type);
var _local4:Class = _local3.constructor;
if (_local4){
if (_local3.primary){
return (new _local4(_arg1, _arg2));
};
_local5 = new _local4(_arg2, _arg1);
_local5.secondary = true;
_local6 = 0;
while (_local6 < _local5.manifoldCount) {
_local7 = _local5.manifolds[_local6];
_local5.manifolds[_local6].nx = -(_local7.nx);
_local7.ny = -(_local7.ny);
_local6++;
};
return (_local5);
};
return (null);
}
private function registerContactHandler(_arg1:Class, _arg2:int, _arg3:int):void{
ContactRegister(_contactMatrix.get(_arg2, _arg3)).constructor = _arg1;
ContactRegister(_contactMatrix.get(_arg2, _arg3)).primary = true;
if (_arg2 != _arg3){
ContactRegister(_contactMatrix.get(_arg3, _arg2)).constructor = _arg1;
ContactRegister(_contactMatrix.get(_arg3, _arg2)).primary = false;
};
}
}
}//package de.polygonal.motor2.dynamics.contact
class ContactRegister {
public var primary:Boolean;
public var deconstruct:Function;
public var constructor:Class;
private function ContactRegister(){
}
}
Section 59
//ContactID (de.polygonal.motor2.dynamics.contact.ContactID)
package de.polygonal.motor2.dynamics.contact {
public class ContactID {
public var flip:int;
public var incVert:int;
public var refFace:int;
public var incEdge:int;
public var key:uint;
public static const NULL_FEATURE:int = 254;
public function toString():String{
return (((((((((refFace + "|") + incEdge) + "|") + incVert) + "|") + flip) + " -> ") + key));
}
public function bake():void{
key = ((((-(~(refFace)) << 24) | (-(~(incEdge)) << 16)) | (-(~(incVert)) << 8)) | -(~(flip)));
}
}
}//package de.polygonal.motor2.dynamics.contact
Section 60
//ContactManager (de.polygonal.motor2.dynamics.contact.ContactManager)
package de.polygonal.motor2.dynamics.contact {
import de.polygonal.motor2.*;
import de.polygonal.motor2.dynamics.*;
import de.polygonal.motor2.collision.nbody.*;
import de.polygonal.motor2.collision.shapes.*;
public class ContactManager implements IPairCallback {
private var _contactFactory:ContactFactory;
public var statsContactCount:int;
private var _world:World;
public var destroyImmediate:Boolean;
private static const NULL_CONTACT:NullContact = new NullContact();
public function ContactManager(_arg1:World){
this._world = _arg1;
_contactFactory = new ContactFactory();
}
public function cleanContactList():void{
var _local2:Contact;
var _local1:Contact = _world.contactList;
while (_local1) {
_local2 = _local1;
_local1 = _local1.next;
if ((_local2.stateBits & Contact.k_bitDestroy)){
destroyContact(_local2);
};
_local2 = null;
};
}
public function collide():void{
var _local2:RigidBody;
var _local3:RigidBody;
var _local4:int;
var _local5:int;
var _local6:ContactNode;
var _local1:Contact = _world.contactList;
while (_local1) {
_local2 = _local1.shape1.body;
_local3 = _local1.shape2.body;
if (((_local2.stateBits & _local3.stateBits) & RigidBody.k_bitSleep)){
_local1 = _local1.next;
} else {
_local4 = _local1.manifoldCount;
_local1.evaluate();
_local5 = _local1.manifoldCount;
if ((((_local4 == 0)) && ((_local5 > 0)))){
_local6 = _local1.node1;
_local6.contact = _local1;
_local6.other = _local3;
_local6.prev = null;
_local6.next = _local2.contactList;
if (_local6.next){
_local6.next.prev = _local6;
};
_local2.contactList = _local6;
_local6 = _local1.node2;
_local6.contact = _local1;
_local6.other = _local2;
_local6.prev = null;
_local6.next = _local3.contactList;
if (_local6.next){
_local6.next.prev = _local6;
};
_local3.contactList = _local6;
} else {
if ((((_local4 > 0)) && ((_local5 == 0)))){
_local6 = _local1.node1;
if (_local6.next){
_local6.next.prev = _local6.prev;
};
if (_local6.prev){
_local6.prev.next = _local6.next;
};
if (_local6 == _local2.contactList){
_local2.contactList = _local6.next;
};
_local6.next = (_local6.prev = null);
_local6 = _local1.node2;
if (_local6.next){
_local6.next.prev = _local6.prev;
};
if (_local6.prev){
_local6.prev.next = _local6.next;
};
if (_local6 == _local3.contactList){
_local3.contactList = _local6.next;
};
_local6.next = (_local6.prev = null);
};
};
_local1 = _local1.next;
};
};
}
public function pairAdded(_arg1, _arg2):Contact{
var _local8:ShapeSkeleton;
var _local9:RigidBody;
statsContactCount++;
var _local3:ShapeSkeleton = (_arg1 as ShapeSkeleton);
var _local4:ShapeSkeleton = (_arg2 as ShapeSkeleton);
var _local5:RigidBody = _local3.body;
var _local6:RigidBody = _local4.body;
if (_local5 == _local6){
return (NULL_CONTACT);
};
if (((_local5.stateBits & _local6.stateBits) & RigidBody.k_bitStatic)){
return (NULL_CONTACT);
};
if (_local6.invMass == 0){
_local8 = _local3;
_local3 = _local4;
_local4 = _local8;
_local9 = _local5;
_local5 = _local6;
_local6 = _local9;
};
if (_local6.isConnected(_local5)){
return (NULL_CONTACT);
};
var _local7:Contact = _contactFactory.create(_local3, _local4);
if (_local7 == null){
return (NULL_CONTACT);
};
_local7.prev = null;
_local7.next = _world.contactList;
if (_world.contactList){
_world.contactList.prev = _local7;
};
_world.contactList = _local7;
_world.contactCount++;
return (_local7);
}
public function pairRemoved(_arg1, _arg2, _arg3):void{
statsContactCount--;
if (_arg3 == null){
return;
};
var _local4:Contact = (_arg3 as Contact);
if (_local4 != NULL_CONTACT){
if (destroyImmediate == true){
destroyContact(_local4);
_local4 = null;
} else {
_local4.stateBits = (_local4.stateBits | Contact.k_bitDestroy);
};
};
}
private function destroyContact(_arg1:Contact):void{
var _local2:RigidBody;
var _local3:RigidBody;
var _local4:ContactNode;
if (_world.contactCount == 0){
return;
};
if (_arg1.prev){
_arg1.prev.next = _arg1.next;
};
if (_arg1.next){
_arg1.next.prev = _arg1.prev;
};
if (_arg1 == _world.contactList){
_world.contactList = _arg1.next;
};
if (_arg1.manifoldCount > 0){
_local2 = _arg1.shape1.body;
_local2.stateBits = (_local2.stateBits & ~(RigidBody.k_bitSleep));
_local2.sleepTime = 0;
_local3 = _arg1.shape2.body;
_local3.stateBits = (_local3.stateBits & ~(RigidBody.k_bitSleep));
_local3.sleepTime = 0;
_local4 = _arg1.node1;
if (_local4.next){
_local4.next.prev = _local4.prev;
};
if (_local4.prev){
_local4.prev.next = _local4.next;
};
if (_local4 == _local2.contactList){
_local2.contactList = _local4.next;
};
_local4.next = (_local4.prev = null);
_local4 = _arg1.node2;
if (_local4.next){
_local4.next.prev = _local4.prev;
};
if (_local4.prev){
_local4.prev.next = _local4.next;
};
if (_local4 == _local3.contactList){
_local3.contactList = _local4.next;
};
_local4.next = (_local4.prev = null);
};
_world.contactCount--;
}
}
}//package de.polygonal.motor2.dynamics.contact
Section 61
//ContactNode (de.polygonal.motor2.dynamics.contact.ContactNode)
package de.polygonal.motor2.dynamics.contact {
import de.polygonal.motor2.dynamics.*;
public class ContactNode {
public var other:RigidBody;
public var prev:ContactNode;
public var contact:Contact;
public var next:ContactNode;
public function ContactNode(){
init();
}
private function init():void{
prev = (next = null);
other = null;
contact = null;
}
}
}//package de.polygonal.motor2.dynamics.contact
Section 62
//ContactPoint (de.polygonal.motor2.dynamics.contact.ContactPoint)
package de.polygonal.motor2.dynamics.contact {
public class ContactPoint {
public var nMass:Number;
public var l_r1x:Number;
public var l_r1y:Number;
public var w_r1x:Number;
public var w_r1y:Number;
public var tMass:Number;
public var id:ContactID;
public var Pn:Number;
public var Pp:Number;
public var matched:Boolean;// = false
public var sep:Number;
public var l_r2y:Number;
public var Pt:Number;
public var w_r2y:Number;
public var l_r2x:Number;
public var w_r2x:Number;
public var x:Number;
public var y:Number;
public var velBias:Number;
public function ContactPoint():void{
init();
}
public function init():void{
id = new ContactID();
x = (y = (sep = (velBias = (Pn = (Pt = (Pp = (nMass = (tMass = 0))))))));
}
}
}//package de.polygonal.motor2.dynamics.contact
Section 63
//Manifold (de.polygonal.motor2.dynamics.contact.Manifold)
package de.polygonal.motor2.dynamics.contact {
public class Manifold {
public var points:Array;
public var nx:Number;
public var ny:Number;
public var c0:ContactPoint;
public var c1:ContactPoint;
public var pointCount:int;
public function Manifold(){
init();
}
public function init():void{
c0 = new ContactPoint();
c1 = new ContactPoint();
points = [c0, c1];
pointCount = 0;
}
}
}//package de.polygonal.motor2.dynamics.contact
Section 64
//NullContact (de.polygonal.motor2.dynamics.contact.NullContact)
package de.polygonal.motor2.dynamics.contact {
import de.polygonal.motor2.collision.shapes.*;
public class NullContact extends Contact {
public function NullContact(){
super(null, null);
}
override protected function init(_arg1:ShapeSkeleton, _arg2:ShapeSkeleton):void{
}
override public function evaluate():void{
}
}
}//package de.polygonal.motor2.dynamics.contact
Section 65
//Buoyancy (de.polygonal.motor2.dynamics.forces.Buoyancy)
package de.polygonal.motor2.dynamics.forces {
import de.polygonal.motor2.math.*;
import de.polygonal.motor2.dynamics.*;
import de.polygonal.motor2.collision.shapes.*;
public class Buoyancy extends ForceGenerator {
public var planeNormal:V2;
private var _cp0:V2;
public var linDrag:Number;
public var density:Number;
private var _cp1:V2;
public var angDrag:Number;
public var planeOffset:Number;
private var _clipTri0:ClipTriangle;
private var _clipTri1:ClipTriangle;
public var velocity:V2;
public function Buoyancy(_arg1:Number, _arg2:V2, _arg3:Number, _arg4:Number=5, _arg5:Number=0.5, _arg6:V2=null){
_clipTri0 = new ClipTriangle();
_clipTri1 = new ClipTriangle();
_cp0 = new V2();
_cp1 = new V2();
super();
this.planeOffset = _arg1;
this.planeNormal = _arg2;
this.density = _arg3;
this.linDrag = _arg4;
this.angDrag = _arg5;
this.velocity = (_arg6) ? _arg6 : new V2();
}
private function clipTriangle(_arg1:Tri2, _arg2:Number, _arg3:ClipTriangle, _arg4:ClipTriangle):int{
var _local11:V2;
var _local12:V2;
var _local13:V2;
var _local14:Number;
var _local15:Number;
var _local16:Number;
var _local17:Number;
var _local5:int;
var _local6:int;
var _local7:V2;
var _local8:V2;
var _local9:V2;
var _local10:V2;
if (_arg1.a.y > _arg2){
_local6++;
_local8 = _arg1.a;
} else {
_local5++;
_local7 = _arg1.a;
};
if (_arg1.b.y > _arg2){
_local6++;
if (_local8){
_local10 = _arg1.b;
} else {
_local8 = _arg1.b;
};
} else {
_local5++;
if (_local7){
_local9 = _arg1.b;
} else {
_local7 = _arg1.b;
};
};
if (_arg1.c.y > _arg2){
_local6++;
if (_local8){
_local10 = _arg1.c;
} else {
_local8 = _arg1.c;
};
} else {
_local5++;
if (_local7){
_local9 = _arg1.c;
} else {
_local7 = _arg1.c;
};
};
if (_local5 == 0){
_arg3.a = _arg1.a;
_arg3.b = _arg1.b;
_arg3.c = _arg1.c;
return (1);
};
if (_local6 == 0){
return (-1);
};
if (_local5 == 1){
_local11 = _local7;
_local12 = _local8;
_local14 = (_local11.y - _arg2);
_local15 = (_local12.y - _arg2);
_local16 = (_local14 / (_local14 - _local15));
_cp0.x = (_local11.x + (_local16 * (_local12.x - _local11.x)));
_cp0.y = (_local11.y + (_local16 * (_local12.y - _local11.y)));
_local12 = _local10;
_local15 = (_local12.y - _arg2);
_local16 = (_local14 / (_local14 - _local15));
_cp1.x = (_local11.x + (_local16 * (_local12.x - _local11.x)));
_cp1.y = (_local11.y + (_local16 * (_local12.y - _local11.y)));
if (_cp0.x > _cp1.x){
_local13 = _cp0;
_cp0 = _cp1;
_cp1 = _local13;
};
_local17 = (((_local8.x - _local11.x) * (_local10.y - _local11.y)) - ((_local8.y - _local11.y) * (_local10.x - _local11.x)));
if (_local8.x > _cp1.x){
_arg3.a = _local10;
_arg3.b = _cp1;
_arg3.c = _local8;
if (_local17 > 0){
_arg4.a = _local10;
_arg4.b = _cp1;
_arg4.c = _cp0;
} else {
_arg4.a = _local8;
_arg4.b = _cp1;
_arg4.c = _cp0;
};
return (2);
} else {
if (_local10.x < _cp0.x){
_arg3.a = _local10;
_arg3.b = _cp0;
_arg3.c = _local8;
if (_local17 > 0){
_arg4.a = _local8;
_arg4.b = _cp1;
_arg4.c = _cp0;
} else {
_arg4.a = _local10;
_arg4.b = _cp1;
_arg4.c = _cp0;
};
return (2);
} else {
_arg3.a = _local8;
_arg3.b = _local10;
_arg3.c = _cp0;
_arg4.a = _cp0;
_arg4.b = _local10;
_arg4.c = _cp1;
return (2);
};
};
} else {
if (_local5 == 2){
_local11 = _local8;
_local12 = _local7;
_local14 = (_local11.y - _arg2);
_local15 = (_local12.y - _arg2);
_local16 = (_local14 / (_local14 - _local15));
_cp0.x = (_local11.x + (_local16 * (_local12.x - _local11.x)));
_cp0.y = (_local11.y + (_local16 * (_local12.y - _local11.y)));
_local12 = _local9;
_local15 = (_local12.y - _arg2);
_local16 = (_local14 / (_local14 - _local15));
_cp1.x = (_local11.x + (_local16 * (_local12.x - _local11.x)));
_cp1.y = (_local11.y + (_local16 * (_local12.y - _local11.y)));
if (_cp0.x > _cp1.x){
_local13 = _cp0;
_cp0 = _cp1;
_cp1 = _local13;
};
_arg3.a = _cp1;
_arg3.b = _cp0;
_arg3.c = _local8;
return (1);
};
};
return (-1);
}
override public function evaluate(_arg1:RigidBody):void{
var _local8:int;
var _local9:V2;
var _local10:V2;
var _local11:V2;
var _local12:Number;
var _local13:ShapeSkeleton;
var _local14:Tri2;
var _local21:Number;
var _local22:Number;
var _local23:Number;
var _local24:Number;
var _local2:Number = 0;
var _local3:Number = 0;
var _local4:Number = 2147483648;
var _local5:Number = -2147483648;
var _local6:Number = 0;
var _local7:Number = 0;
_local13 = _arg1.shapeList;
while (_local13) {
_local2 = (_local2 + _local13.area);
if (_local13.ymax < planeOffset){
} else {
if (_local13.ymin >= planeOffset){
_local12 = _local13.area;
_local6 = (_local6 + (_local12 * _local13.x));
_local7 = (_local7 + (_local12 * _local13.y));
_local3 = (_local3 + _local12);
if (_local13.xmin < _local4){
_local4 = _local13.xmin;
};
if (_local13.xmax > _local5){
_local5 = _local13.xmax;
};
} else {
if (_local13.type == ShapeTypes.CIRCLE){
_local21 = _local13.radius;
_local22 = (_local13.ymax - planeOffset);
_local12 = (((_local21 * _local21) * Math.acos(((_local21 - _local22) / _local21))) - ((_local21 - _local22) * Math.sqrt((((2 * _local21) * _local22) - (_local22 * _local22)))));
_local23 = ((2 * _local21) - _local22);
_local24 = ((3 * (_local23 * _local23)) / (4 * ((3 * _local21) - _local22)));
_local6 = (_local6 + (_local13.x * _local12));
_local7 = (_local7 + ((_local13.y + _local24) * _local12));
_local3 = (_local3 + _local12);
if (_local13.xmin < _local4){
_local4 = _local13.xmin;
};
if (_local13.xmax > _local5){
_local5 = _local13.xmax;
};
} else {
if (!_local13.synced){
_local13.toWorldSpace();
};
_local14 = _local13.triangleList;
while (_local14) {
_local8 = clipTriangle(_local14, planeOffset, _clipTri0, _clipTri1);
if (_local8 > 0){
_local9 = _clipTri0.a;
_local10 = _clipTri0.b;
_local11 = _clipTri0.c;
_local12 = ((((_local10.x - _local9.x) * (_local11.y - _local9.y)) - ((_local10.y - _local9.y) * (_local11.x - _local9.x))) / 2);
if (_local12 < 0){
_local12 = -(_local12);
};
if (_local12 > 1E-5){
_local6 = (_local6 + ((_local12 * ((_local9.x + _local10.x) + _local11.x)) / 3));
_local7 = (_local7 + ((_local12 * ((_local9.y + _local10.y) + _local11.y)) / 3));
_local3 = (_local3 + _local12);
};
};
if (_local8 > 1){
_local9 = _clipTri1.a;
_local10 = _clipTri1.b;
_local11 = _clipTri1.c;
_local12 = ((((_local10.x - _local9.x) * (_local11.y - _local9.y)) - ((_local10.y - _local9.y) * (_local11.x - _local9.x))) / 2);
if (_local12 < 0){
_local12 = -(_local12);
};
if (_local12 > 1E-5){
_local6 = (_local6 + ((_local12 * ((_local9.x + _local10.x) + _local11.x)) / 3));
_local7 = (_local7 + ((_local12 * ((_local9.y + _local10.y) + _local11.y)) / 3));
_local3 = (_local3 + _local12);
};
};
if (_local13.xmin < _local4){
_local4 = _local13.xmin;
};
if (_local13.xmax > _local5){
_local5 = _local13.xmax;
};
_local14 = _local14.next;
};
};
};
};
_local13 = _local13.next;
};
_local6 = (_local6 / _local3);
_local7 = (_local7 / _local3);
if (_local3 <= 1E-5){
return;
};
var _local15:Number = ((density * _local3) * _arg1.world.gravity.y);
var _local16:Number = ((_arg1.mass * _local3) / _local2);
var _local17:Number = (_local6 - _arg1.x);
var _local18:Number = (_local7 - _arg1.y);
var _local19:Number = ((planeNormal.x * _local15) + ((_local16 * linDrag) * (velocity.x - (_arg1.vx - (_arg1.w * _local18)))));
var _local20:Number = ((planeNormal.y * _local15) + ((_local16 * linDrag) * (velocity.y - (_arg1.vy + (_arg1.w * _local17)))));
_arg1.fx = (_arg1.fx + _local19);
_arg1.fy = (_arg1.fy + _local20);
_arg1.t = (_arg1.t + (((_local17 * _local20) - (_local18 * _local19)) + (((-(_local16) * angDrag) * ((_local5 - _local4) * (_local5 - _local4))) * _arg1.w)));
}
}
}//package de.polygonal.motor2.dynamics.forces
import de.polygonal.motor2.math.*;
class Plane2 {
public var d:Number;// = 0
public var n:V2;
private function Plane2(){
n = new V2();
super();
}
}
class ClipTriangle {
public var a:V2;
public var c:V2;
public var b:V2;
private function ClipTriangle(){
a = new V2();
b = new V2();
c = new V2();
super();
}
}
Section 66
//Drag (de.polygonal.motor2.dynamics.forces.Drag)
package de.polygonal.motor2.dynamics.forces {
import de.polygonal.motor2.dynamics.*;
public class Drag extends ForceGenerator {
public var k1:Number;
public var k2:Number;
public function Drag(_arg1:Number, _arg2:Number=0){
this.k1 = _arg1;
this.k2 = _arg2;
}
override public function evaluate(_arg1:RigidBody):void{
var _local2:Number = Math.sqrt(((_arg1.vx * _arg1.vx) + (_arg1.vy * _arg1.vy)));
var _local3:Number = -(((k1 * _local2) + ((k2 * _local2) * _local2)));
if (_local2 > 0){
_arg1.fx = (_arg1.fx + ((_arg1.vx / _local2) * _local3));
_arg1.fy = (_arg1.fy + ((_arg1.vy / _local2) * _local3));
};
}
}
}//package de.polygonal.motor2.dynamics.forces
Section 67
//ForceGenerator (de.polygonal.motor2.dynamics.forces.ForceGenerator)
package de.polygonal.motor2.dynamics.forces {
import de.polygonal.motor2.dynamics.*;
public class ForceGenerator {
public var isActive:Boolean;
public function ForceGenerator(){
init();
}
public function evaluate(_arg1:RigidBody):void{
}
public function init():void{
isActive = true;
}
}
}//package de.polygonal.motor2.dynamics.forces
Section 68
//ForceRegistry (de.polygonal.motor2.dynamics.forces.ForceRegistry)
package de.polygonal.motor2.dynamics.forces {
import de.polygonal.motor2.*;
import de.polygonal.motor2.dynamics.*;
import de.polygonal.ds.*;
public class ForceRegistry {
private var _idQue:ArrayedQueue;
private var _registration:ForceNode;
public function ForceRegistry(){
init();
}
public function init():void{
_registration = null;
var _local1:int = Constants.k_maxForceGenerators;
_idQue = new ArrayedQueue(_local1);
var _local2:int;
while (_local2 < _local1) {
_idQue.enqueue(_local2);
_local2++;
};
}
public function add(_arg1:RigidBody, _arg2:ForceGenerator):int{
var _local3:int = _idQue.dequeue();
var _local4:ForceNode = new ForceNode(_arg1, _arg2);
_local4.next = _registration;
if (_registration){
_registration.prev = _local4;
};
_registration = _local4;
return (_local3);
}
public function remove(_arg1:RigidBody, _arg2:ForceGenerator):Boolean{
var _local3:ForceNode = _registration;
while (_local3) {
if ((((_local3.force == _arg2)) && ((_local3.body == _arg1)))){
if (_local3.prev){
_local3.prev.next = _local3.next;
};
if (_local3.next){
_local3.next.prev = _local3.prev;
};
if (_local3 == _registration){
_registration = _local3.next;
};
return (true);
};
_local3 = _local3.next;
};
return (false);
}
public function evaluate():void{
var _local2:ForceGenerator;
var _local1:ForceNode = _registration;
while (_local1) {
_local2 = _local1.force;
if (_local2.isActive){
_local2.evaluate(_local1.body);
};
_local1 = _local1.next;
};
}
public function clear():void{
var _local2:ForceNode;
var _local1:ForceNode = _registration;
_registration = null;
while (_local1) {
_local2 = _local1.next;
_local1.next = (_local1.prev = null);
_local1 = _local2;
};
}
}
}//package de.polygonal.motor2.dynamics.forces
import de.polygonal.motor2.dynamics.*;
class ForceNode {
public var body:RigidBody;
public var prev:ForceNode;
public var next:ForceNode;
public var force:ForceGenerator;
private function ForceNode(_arg1:RigidBody, _arg2:ForceGenerator){
this.body = _arg1;
this.force = _arg2;
init();
}
public function init():void{
prev = (next = null);
}
}
Section 69
//Spring2 (de.polygonal.motor2.dynamics.forces.Spring2)
package de.polygonal.motor2.dynamics.forces {
import de.polygonal.motor2.math.*;
import de.polygonal.motor2.dynamics.*;
public class Spring2 extends ForceGenerator {
public var damping:Number;
public var otherBody:RigidBody;
public var offset:V2;
public var restLength:Number;
public var offsetOther:V2;
public var stiffness:Number;
public function Spring2(_arg1:RigidBody, _arg2:Number, _arg3:Number=0, _arg4:Number=0, _arg5:V2=null, _arg6:V2=null){
this.otherBody = _arg1;
this.stiffness = _arg2;
this.restLength = ((_arg3 < 0)) ? -(_arg3) : _arg3;
this.damping = ((_arg4 < 0)) ? -(_arg4) : _arg4;
this.offset = (_arg5) ? _arg5.copy() : null;
this.offsetOther = (_arg6) ? _arg6.copy() : null;
}
override public function evaluate(_arg1:RigidBody):void{
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;
var _local13:Number;
var _local14:Number;
var _local15:Number;
var _local16:Number;
var _local17:Number;
var _local19:Number;
var _local18:int;
if (offset){
_local5 = ((_arg1.r11 * offset.x) + (_arg1.r12 * offset.y));
_local12 = ((_arg1.r21 * offset.x) + (_arg1.r22 * offset.y));
_local7 = (_arg1.x + _local5);
_local14 = (_arg1.y + _local12);
_local18 = (_local18 ^ 1);
} else {
_local7 = _arg1.x;
_local14 = _arg1.y;
_local5 = 0;
_local12 = 0;
};
if (offsetOther){
_local6 = ((otherBody.r11 * offsetOther.x) + (otherBody.r12 * offsetOther.y));
_local13 = ((otherBody.r21 * offsetOther.x) + (otherBody.r22 * offsetOther.y));
_local8 = (otherBody.x + _local6);
_local15 = (otherBody.y + _local13);
_local18 = (_local18 ^ 1);
} else {
_local8 = otherBody.x;
_local15 = otherBody.y;
_local6 = 0;
_local13 = 0;
};
_local4 = (_local7 - _local8);
_local11 = (_local14 - _local15);
if (restLength > 0){
_local19 = (Math.sqrt(((_local4 * _local4) + (_local11 * _local11))) + 1E-6);
_local16 = (-(stiffness) * (_local19 - restLength));
_local3 = (_local16 * (_local4 / _local19));
_local10 = (_local16 * (_local11 / _local19));
} else {
_local16 = -(stiffness);
_local3 = (_local16 * _local4);
_local10 = (_local16 * _local11);
};
if (_local18 != 0){
if (offset){
if (damping > 0){
_local2 = ((_arg1.vx - (_arg1.w * _local12)) - otherBody.vx);
_local9 = ((_arg1.vy + (_arg1.w * _local5)) - otherBody.vy);
_local17 = ((-(damping) * ((_local2 * _local3) + (_local9 * _local10))) / ((_local3 * _local3) + (_local10 * _local10)));
_local3 = (_local3 + (_local3 * _local17));
_local10 = (_local10 + (_local10 * _local17));
};
_arg1.fx = (_arg1.fx + _local3);
_arg1.fy = (_arg1.fy + _local10);
_arg1.t = (_arg1.t + ((_local5 * _local10) - (_local12 * _local3)));
otherBody.fx = (otherBody.fx - _local3);
otherBody.fy = (otherBody.fy - _local10);
} else {
if (damping > 0){
_local2 = (_arg1.vx - (otherBody.vx - (otherBody.w * _local13)));
_local9 = (_arg1.vy - (otherBody.vy + (otherBody.w * _local6)));
_local17 = ((-(damping) * ((_local2 * _local3) + (_local9 * _local10))) / ((_local3 * _local3) + (_local10 * _local10)));
_local3 = (_local3 + (_local3 * _local17));
_local10 = (_local10 + (_local10 * _local17));
};
_arg1.fx = (_arg1.fx + _local3);
_arg1.fy = (_arg1.fy + _local10);
otherBody.fx = (otherBody.fx - _local3);
otherBody.fy = (otherBody.fy - _local10);
otherBody.t = (otherBody.t - ((_local6 * _local10) - (_local13 * _local3)));
};
} else {
if (offset){
if (damping > 0){
_local2 = ((_arg1.vx - (_arg1.w * _local12)) - (otherBody.vx - (otherBody.w * _local13)));
_local9 = ((_arg1.vy + (_arg1.w * _local5)) - (otherBody.vy + (otherBody.w * _local6)));
_local17 = ((-(damping) * ((_local2 * _local3) + (_local9 * _local10))) / ((_local3 * _local3) + (_local10 * _local10)));
_local3 = (_local3 + (_local3 * _local17));
_local10 = (_local10 + (_local10 * _local17));
};
_arg1.fx = (_arg1.fx + _local3);
_arg1.fy = (_arg1.fy + _local10);
_arg1.t = (_arg1.t + ((_local5 * _local10) - (_local12 * _local3)));
otherBody.fx = (otherBody.fx - _local3);
otherBody.fy = (otherBody.fy - _local10);
otherBody.t = (otherBody.t - ((_local6 * _local10) - (_local13 * _local3)));
} else {
if (damping > 0){
_local2 = (_arg1.vx - otherBody.vx);
_local9 = (_arg1.vy - otherBody.vy);
_local17 = ((-(damping) * ((_local2 * _local3) + (_local9 * _local10))) / ((_local3 * _local3) + (_local10 * _local10)));
_local3 = (_local3 + (_local3 * _local17));
_local10 = (_local10 + (_local10 * _local17));
};
_arg1.fx = (_arg1.fx + _local3);
_arg1.fy = (_arg1.fy + _local10);
otherBody.fx = (otherBody.fx - _local3);
otherBody.fy = (otherBody.fy - _local10);
};
};
}
}
}//package de.polygonal.motor2.dynamics.forces
Section 70
//JointData (de.polygonal.motor2.dynamics.joints.data.JointData)
package de.polygonal.motor2.dynamics.joints.data {
import de.polygonal.motor2.dynamics.*;
import de.polygonal.motor2.dynamics.joints.*;
public class JointData {
public var collideConnected:Boolean;
public var body1:RigidBody;
public var body2:RigidBody;
public var userData;
public var type:int;
public function JointData(_arg1:RigidBody, _arg2:RigidBody){
this.body1 = _arg1;
this.body2 = _arg2;
setType();
userData = null;
}
public function getJointClass():Class{
return (null);
}
protected function setType():void{
type = JointTypes.UNKNOWN;
}
}
}//package de.polygonal.motor2.dynamics.joints.data
Section 71
//RevoluteJointData (de.polygonal.motor2.dynamics.joints.data.RevoluteJointData)
package de.polygonal.motor2.dynamics.joints.data {
import flash.geom.*;
import de.polygonal.motor2.dynamics.*;
import de.polygonal.motor2.dynamics.joints.*;
public class RevoluteJointData extends JointData {
public const anchor1:Point;
public const anchor2:Point;
public var lowerAngle:Number;
public var referenceAngle:Number;
public var upperAngle:Number;
public var enableMotor:Boolean;
public var motorSpeed:Number;
public var maxMotorTorque:Number;
public var enableLimit:Boolean;
public function RevoluteJointData(_arg1:RigidBody, _arg2:RigidBody, _arg3:Point){
anchor1 = new Point();
anchor2 = new Point();
super(_arg1, _arg2);
referenceAngle = (_arg2.r - _arg1.r);
lowerAngle = (upperAngle = 0);
enableLimit = false;
motorSpeed = (maxMotorTorque = 0);
enableMotor = false;
var _local4:Point = new Point();
_arg1.getModelPoint(_arg3, _local4);
anchor1.x = _local4.x;
anchor1.y = _local4.y;
_arg2.getModelPoint(_arg3, _local4);
anchor2.x = _local4.x;
anchor2.y = _local4.y;
}
override protected function setType():void{
type = JointTypes.REVOLUTE;
}
override public function getJointClass():Class{
return (RevoluteJoint);
}
}
}//package de.polygonal.motor2.dynamics.joints.data
Section 72
//Joint (de.polygonal.motor2.dynamics.joints.Joint)
package de.polygonal.motor2.dynamics.joints {
import flash.geom.*;
import de.polygonal.motor2.dynamics.*;
import de.polygonal.motor2.dynamics.joints.data.*;
public class Joint {
protected const _anchor2:Point;
protected const _reactionForce:Point;
protected const _anchor1:Point;
public var next:Joint;
public var body1:RigidBody;
public var body2:RigidBody;
protected var _invdt:Number;
public var userData;
public var la1x:Number;
public var la1y:Number;
public var collideConnected:Boolean;
public var node1:JointNode;
public var node2:JointNode;
public var prev:Joint;
public var stateBits:int;
public var type:int;
public var la2x:Number;
public var la2y:Number;
protected var _dt:Number;
public static const k_bitIsland:int = 32;
public function Joint(_arg1:JointData){
_reactionForce = new Point();
_anchor1 = new Point();
_anchor2 = new Point();
super();
type = _arg1.type;
body1 = _arg1.body1;
body2 = _arg1.body2;
collideConnected = _arg1.collideConnected;
userData = _arg1.userData;
node1 = new JointNode();
node2 = new JointNode();
}
public function preparePosSolver():void{
}
public function getReactionForce():Point{
return (null);
}
public function getAnchor2():Point{
_anchor2.x = ((body2.x + (body2.r11 * la2x)) + (body2.r12 * la2y));
_anchor2.y = ((body2.y + (body2.r21 * la2x)) + (body2.r22 * la2y));
return (_anchor2);
}
public function getReactionTorque():Number{
return (0);
}
public function solveVelConstraints(_arg1:Number, _arg2:int):void{
}
public function solvePosConstraints():Boolean{
return (true);
}
protected function setType(_arg1:int):void{
this.type = _arg1;
}
public function preStep(_arg1:Number):void{
_dt = _arg1;
_invdt = (1 / _arg1);
}
public function getAnchor1():Point{
_anchor1.x = ((body1.x + (body1.r11 * la1x)) + (body1.r12 * la1y));
_anchor1.y = ((body1.y + (body1.r21 * la1x)) + (body1.r22 * la1y));
return (_anchor1);
}
}
}//package de.polygonal.motor2.dynamics.joints
Section 73
//JointNode (de.polygonal.motor2.dynamics.joints.JointNode)
package de.polygonal.motor2.dynamics.joints {
import de.polygonal.motor2.dynamics.*;
public class JointNode {
public var other:RigidBody;
public var next:JointNode;
public var prev:JointNode;
public var joint:Joint;
}
}//package de.polygonal.motor2.dynamics.joints
Section 74
//JointTypes (de.polygonal.motor2.dynamics.joints.JointTypes)
package de.polygonal.motor2.dynamics.joints {
public class JointTypes {
public static const MOUSE:int = 2;
public static const REVOLUTE:int = 3;
public static const PRISMATIC:int = 6;
public static const GEAR:int = 5;
public static const DISTANCE:int = 1;
public static const UNKNOWN:int = 0;
public static const PULLEY:int = 4;
}
}//package de.polygonal.motor2.dynamics.joints
Section 75
//LimitState (de.polygonal.motor2.dynamics.joints.LimitState)
package de.polygonal.motor2.dynamics.joints {
public class LimitState {
public static const LOWER:int = 1;
public static const EQUAL:int = 3;
public static const UPPER:int = 2;
public static const INACTIVE:int = 0;
}
}//package de.polygonal.motor2.dynamics.joints
Section 76
//RevoluteJoint (de.polygonal.motor2.dynamics.joints.RevoluteJoint)
package de.polygonal.motor2.dynamics.joints {
import de.polygonal.motor2.*;
import flash.geom.*;
import de.polygonal.motor2.dynamics.*;
import de.polygonal.motor2.dynamics.joints.data.*;
public class RevoluteJoint extends Joint {
private var _motorMass:Number;
private var _k11:Number;
private var _k12:Number;
private var _k13:Number;
private var _r1x:Number;
private var _motorImpulse:Number;
private var _r1y:Number;
private var _k21:Number;
private var _k22:Number;
private var _k23:Number;
public var enableMotor:Boolean;
private var _limitState:int;
private var _r2x:Number;
private var _r2y:Number;
private var _k31:Number;
private var _k32:Number;
private var _k33:Number;
public var upperAngle:Number;
public var lowerAngle:Number;
public var motorSpeed:Number;
public var maxMotorTorque:Number;
private var _impulseX:Number;
private var _impulseY:Number;
private var _referenceAngle:Number;
private var _impulseZ:Number;
public var enableLimit:Boolean;
public function RevoluteJoint(_arg1:RevoluteJointData){
super(_arg1);
var _local2:RevoluteJointData = (_arg1 as RevoluteJointData);
la1x = _local2.anchor1.x;
la1y = _local2.anchor1.y;
la2x = _local2.anchor2.x;
la2y = _local2.anchor2.y;
_referenceAngle = _local2.referenceAngle;
lowerAngle = _local2.lowerAngle;
upperAngle = _local2.upperAngle;
maxMotorTorque = _local2.maxMotorTorque;
motorSpeed = _local2.motorSpeed;
enableLimit = _local2.enableLimit;
enableMotor = _local2.enableMotor;
_impulseX = (_impulseY = (_impulseZ = 0));
_motorImpulse = 0;
}
override public function getReactionTorque():Number{
return ((_invdt * _impulseZ));
}
override public function preStep(_arg1:Number):void{
var _local8:Number;
var _local9:Number;
super.preStep(_arg1);
var _local2:RigidBody = body1;
var _local3:RigidBody = body2;
_r1x = ((_local2.r11 * la1x) + (_local2.r12 * la1y));
_r1y = ((_local2.r21 * la1x) + (_local2.r22 * la1y));
_r2x = ((_local3.r11 * la2x) + (_local3.r12 * la2y));
_r2y = ((_local3.r21 * la2x) + (_local3.r22 * la2y));
var _local4:Number = _local2.invMass;
var _local5:Number = _local2.invI;
var _local6:Number = _local3.invMass;
var _local7:Number = _local3.invI;
_k11 = (((_local4 + _local6) + ((_r1y * _r1y) * _local5)) + ((_r2y * _r2y) * _local7));
_k12 = (_k21 = (((-(_r1y) * _r1x) * _local5) - ((_r2y * _r2x) * _local7)));
_k31 = (_k13 = ((-(_r1y) * _local5) - (_r2y * _local7)));
_k22 = (((_local4 + _local6) + ((_r1x * _r1x) * _local5)) + ((_r2x * _r2x) * _local7));
_k32 = (_k23 = ((_r1x * _local5) + (_r2x * _local7)));
_k33 = (_local5 + _local7);
_motorMass = (1 / (_local5 + _local7));
if (!enableMotor){
_motorImpulse = 0;
};
if (enableLimit){
_local8 = ((_local3.r - _local2.r) - _referenceAngle);
_local9 = (upperAngle - lowerAngle);
if (((_local9 < 0)) ? -(_local9) : _local9 < (2 * Constants.k_angSlop)){
_limitState = LimitState.EQUAL;
} else {
if (_local8 <= lowerAngle){
if (_limitState != LimitState.LOWER){
_impulseZ = 0;
};
_limitState = LimitState.LOWER;
} else {
if (_local8 >= upperAngle){
if (_limitState != LimitState.UPPER){
_impulseZ = 0;
};
_limitState = LimitState.UPPER;
} else {
_limitState = LimitState.INACTIVE;
_impulseZ = 0;
};
};
};
};
if (World.doWarmStarting){
_local2.vx = (_local2.vx - (_local4 * _impulseX));
_local2.vy = (_local2.vy - (_local4 * _impulseY));
_local2.w = (_local2.w - (_local5 * (((_r1x * _impulseY) - (_r1y * _impulseX)) + (_motorImpulse + _impulseZ))));
_local3.vx = (_local3.vx + (_local6 * _impulseX));
_local3.vy = (_local3.vy + (_local6 * _impulseY));
_local3.w = (_local3.w + (_local7 * (((_r2x * _impulseY) - (_r2y * _impulseX)) + (_motorImpulse + _impulseZ))));
} else {
_impulseX = 0;
_impulseY = 0;
_impulseZ = 0;
_motorImpulse = 0;
};
}
override public function getReactionForce():Point{
_reactionForce.x = (_impulseX * _invdt);
_reactionForce.y = (_impulseY * _invdt);
return (_reactionForce);
}
public function getMotorTorque():Number{
return (_motorImpulse);
}
public function setLimits(_arg1:Number, _arg2:Number):void{
if (_arg1 < _arg2){
lowerAngle = _arg1;
upperAngle = _arg2;
};
}
public function getJointSpeed():Number{
return ((body2.w - body1.w));
}
public function getJointAngle():Number{
return (((body2.r - body1.r) - _referenceAngle));
}
override public function solvePosConstraints():Boolean{
var _local18:Number;
var _local19:Number;
var _local20:Number;
var _local21:Number;
var _local1:RigidBody = body1;
var _local2:RigidBody = body2;
var _local3:Number = ((_local1.r11 * la1x) + (_local1.r12 * la1y));
var _local4:Number = ((_local1.r21 * la1x) + (_local1.r22 * la1y));
var _local5:Number = ((_local2.r11 * la2x) + (_local2.r12 * la2y));
var _local6:Number = ((_local2.r21 * la2x) + (_local2.r22 * la2y));
var _local7:Number = 0;
var _local8:Number = 0;
var _local9:Number = 0;
var _local10:Number = 0;
var _local11:Number = 0;
var _local12:Number = 0;
var _local13:Number = 0;
var _local14:Number = 0;
if (((enableLimit) && (!((_limitState == LimitState.INACTIVE))))){
_local18 = ((body2.r - body1.r) - _referenceAngle);
_local19 = 0;
if (_limitState == LimitState.EQUAL){
_local9 = ((_local18)<-(Constants.k_maxAngCorrection)) ? -(Constants.k_maxAngCorrection) : ((_local18)>Constants.k_maxAngCorrection) ? Constants.k_maxAngCorrection : _local18;
_local19 = (-(_motorMass) * _local9);
_local8 = ((_local9 > 0)) ? _local9 : -(_local9);
} else {
if (_limitState == LimitState.LOWER){
_local9 = (_local18 - lowerAngle);
_local8 = -(_local9);
_local12 = (_local9 + Constants.k_angSlop);
_local9 = ((_local12)<-(Constants.k_maxAngCorrection)) ? -(Constants.k_maxAngCorrection) : ((_local12)>0) ? 0 : _local12;
_local19 = (-(_motorMass) * _local9);
} else {
if (_limitState == LimitState.UPPER){
_local9 = (_local18 - upperAngle);
_local8 = _local9;
_local12 = (_local9 - Constants.k_angSlop);
_local9 = ((_local12)<0) ? 0 : ((_local12)>Constants.k_maxAngCorrection) ? Constants.k_maxAngCorrection : _local12;
_local19 = (-(_motorMass) * _local9);
};
};
};
body1.r = (body1.r - (body1.invI * _local19));
body2.r = (body2.r + (body2.invI * _local19));
};
_local3 = ((_local1.r11 * la1x) + (_local1.r12 * la1y));
_local4 = ((_local1.r21 * la1x) + (_local1.r22 * la1y));
_local5 = ((_local2.r11 * la2x) + (_local2.r12 * la2y));
_local6 = ((_local2.r21 * la2x) + (_local2.r22 * la2y));
_local10 = (((body2.x + _local5) - body1.x) - _local3);
_local11 = (((body2.y + _local6) - body1.y) - _local4);
_local7 = Math.sqrt(((_local10 * _local10) + (_local11 * _local11)));
var _local15:Number = (10 * Constants.k_linSlop);
var _local16:Number = ((_local10 * _local10) + (_local11 * _local11));
if (_local16 > (_local15 * _local15)){
_local16 = (1 / Math.sqrt(_local16));
_local20 = (body1.invMass + body2.invMass);
if (_local20 > 1E-8){
_local21 = (1 / _local20);
} else {
throw (new Error("division by zero"));
};
_local13 = (-(_local21) * _local10);
_local14 = (-(_local21) * _local11);
body1.x = (body1.x - ((0.5 * body1.invMass) * _local13));
body1.y = (body1.y - ((0.5 * body1.invMass) * _local14));
body2.x = (body2.x + ((0.5 * body2.invMass) * _local13));
body2.y = (body2.y + ((0.5 * body2.invMass) * _local14));
_local10 = (((body2.x + _local5) - body1.x) - _local3);
_local11 = (((body2.y + _local6) - body1.y) - _local4);
};
_k11 = (((body1.invMass + body2.invMass) + ((body1.invI * _local4) * _local4)) + ((body2.invI * _local6) * _local6));
_k22 = (((body1.invMass + body2.invMass) + ((body1.invI * _local3) * _local3)) + ((body2.invI * _local5) * _local5));
_k21 = (_k12 = (((-(body1.invI) * _local3) * _local4) - ((body2.invI * _local5) * _local6)));
var _local17:Number = ((_k11 * _k22) - (_k12 * _k21));
if (_local17 != 0){
_local17 = (1 / _local17);
} else {
throw (new Error("division by zero"));
};
_local13 = (_local17 * ((-(_k22) * _local10) + (_k12 * _local11)));
_local14 = (_local17 * ((-(_k11) * _local11) + (_k21 * _local10)));
body1.x = (body1.x - (body1.invMass * _local13));
body1.y = (body1.y - (body1.invMass * _local14));
body1.r = (body1.r - (body1.invI * ((_local3 * _local14) - (_local4 * _local13))));
body2.x = (body2.x + (body2.invMass * _local13));
body2.y = (body2.y + (body2.invMass * _local14));
body2.r = (body2.r + (body2.invI * ((_local5 * _local14) - (_local6 * _local13))));
return ((((_local7 <= Constants.k_linSlop)) && ((_local8 <= Constants.k_angSlop))));
}
override public function solveVelConstraints(_arg1:Number, _arg2:int):void{
var _local16:Number;
var _local17:Number;
var _local18:Number;
var _local19:Number;
var _local20:Number;
var _local21:Number;
var _local3:Number = body1.vx;
var _local4:Number = body1.vy;
var _local5:Number = body2.vx;
var _local6:Number = body2.vy;
var _local7:Number = body1.w;
var _local8:Number = body2.w;
var _local9:RigidBody = body1;
var _local10:RigidBody = body2;
_r1x = ((_local9.r11 * la1x) + (_local9.r12 * la1y));
_r1y = ((_local9.r21 * la1x) + (_local9.r22 * la1y));
_r2x = ((_local10.r11 * la2x) + (_local10.r12 * la2y));
_r2y = ((_local10.r21 * la2x) + (_local10.r22 * la2y));
var _local11:Number = 0;
var _local12:Number = 0;
var _local13:Number = 0;
var _local14:Number = 0;
var _local15:Number = 0;
if (((enableMotor) && (!((_limitState == LimitState.EQUAL))))){
_local16 = ((_local8 - _local7) - motorSpeed);
_local11 = (-(_motorMass) * _local16);
_local17 = _motorImpulse;
_local18 = (_arg1 * maxMotorTorque);
_motorImpulse = (((_motorImpulse + _local11))<-(_local18)) ? -(_local18) : (((_motorImpulse + _local11))>_local18) ? _local18 : (_motorImpulse + _local11);
_local11 = (_motorImpulse - _local17);
_local7 = (_local7 - (body1.invI * _local11));
_local8 = (_local8 + (body2.invI * _local11));
};
if (((enableLimit) && (!((_limitState == LimitState.INACTIVE))))){
_local13 = (((_local5 - (_local8 * _r2y)) - _local3) + (_local7 * _r1y));
_local14 = (((_local6 + (_local8 * _r2x)) - _local4) - (_local7 * _r1x));
_local15 = (_local8 - _local7);
_local12 = (((((_k22 * _k33) - (_k32 * _k23)) * _k11) + (((_k32 * _k13) - (_k12 * _k33)) * _k21)) + (((_k12 * _k23) - (_k22 * _k13)) * _k31));
if (_local12 != 0){
_local12 = (1 / _local12);
} else {
throw (new Error("division by zero"));
};
_local19 = (_local12 * (((-(((_k22 * _k33) - (_k32 * _k23))) * _local13) - (((_k32 * _k13) - (_k12 * _k33)) * _local14)) - (((_k12 * _k23) - (_k22 * _k13)) * _local15)));
_local20 = (_local12 * (((((-(_local14) * _k33) + (_local15 * _k23)) * _k11) + (((-(_local15) * _k13) + (_local13 * _k33)) * _k21)) + (((-(_local13) * _k23) + (_local14 * _k13)) * _k31)));
_local21 = (_local12 * (((((-(_k22) * _local15) + (_k32 * _local14)) * _k11) + (((-(_k32) * _local13) + (_k12 * _local15)) * _k21)) + (((-(_k12) * _local14) + (_k22 * _local13)) * _k31)));
if (_limitState == LimitState.EQUAL){
_impulseX = (_impulseX + _local19);
_impulseY = (_impulseY + _local20);
_impulseZ = (_impulseZ + _local21);
} else {
if (_limitState == LimitState.LOWER){
_local11 = (_impulseZ + _local21);
if (_local11 < 0){
_local12 = ((_k11 * _k22) - (_k12 * _k21));
if (_local12 != 0){
_local12 = (1 / _local12);
} else {
throw (new Error("division by zero"));
};
_local19 = (_local12 * ((-(_k22) * _local13) + (_k12 * _local14)));
_local20 = (_local12 * ((-(_k11) * _local14) + (_k21 * _local13)));
_local21 = -(_impulseZ);
_impulseX = (_impulseX + _local19);
_impulseY = (_impulseY + _local20);
_impulseZ = 0;
};
} else {
if (_limitState == LimitState.UPPER){
_local11 = (_impulseZ + _local21);
if (_local11 > 0){
_local12 = ((_k11 * _k22) - (_k12 * _k21));
if (_local12 != 0){
_local12 = (1 / _local12);
} else {
throw (new Error("division by zero"));
};
_local19 = (_local12 * ((-(_k22) * _local13) + (_k12 * _local14)));
_local20 = (_local12 * ((-(_k11) * _local14) + (_k21 * _local13)));
_local21 = -(_impulseZ);
_impulseX = (_impulseX + _local19);
_impulseY = (_impulseY + _local20);
_impulseZ = 0;
};
};
};
};
_local3 = (_local3 - (body1.invMass * _local19));
_local4 = (_local4 - (body1.invMass * _local20));
_local7 = (_local7 - (body1.invI * (((_r1x * _local20) - (_r1y * _local19)) + _local21)));
_local5 = (_local5 + (body2.invMass * _local19));
_local6 = (_local6 + (body2.invMass * _local20));
_local8 = (_local8 + (body2.invI * (((_r2x * _local20) - (_r2y * _local19)) + _local21)));
} else {
_local13 = (((_local5 - (_local8 * _r2y)) - _local3) + (_local7 * _r1y));
_local14 = (((_local6 + (_local8 * _r2x)) - _local4) - (_local7 * _r1x));
_local12 = ((_k11 * _k22) - (_k12 * _k21));
if (_local12 != 0){
_local12 = (1 / _local12);
} else {
throw (new Error("division by zero"));
};
_local19 = (_local12 * ((-(_k22) * _local13) + (_k12 * _local14)));
_local20 = (_local12 * ((-(_k11) * _local14) + (_k21 * _local13)));
_impulseX = (_impulseX + _local19);
_impulseY = (_impulseY + _local20);
_local3 = (_local3 - (body1.invMass * _local19));
_local4 = (_local4 - (body1.invMass * _local20));
_local7 = (_local7 - (body1.invI * ((_r1x * _local20) - (_r1y * _local19))));
_local5 = (_local5 + (body2.invMass * _local19));
_local6 = (_local6 + (body2.invMass * _local20));
_local8 = (_local8 + (body2.invI * ((_r2x * _local20) - (_r2y * _local19))));
};
body1.vx = _local3;
body1.vy = _local4;
body1.w = _local7;
body2.vx = _local5;
body2.vy = _local6;
body2.w = _local8;
}
}
}//package de.polygonal.motor2.dynamics.joints
Section 77
//Island (de.polygonal.motor2.dynamics.Island)
package de.polygonal.motor2.dynamics {
import de.polygonal.motor2.*;
import de.polygonal.motor2.dynamics.contact.solver.*;
public class Island {
public var bodies:Array;
public var contactSolver:IContactSolver;
public var jointCount:int;
public var joints:Array;
public var bodyCount:int;
public var positionError:Number;
public var contacts:Array;
public var contactCount:int;
public var bodyList:RigidBody;
public var positionIterations:int;
public static var numIslands:int = 0;
public static var bodiesPerIsland:Array = [];
public function Island(){
bodyCount = 0;
contactCount = 0;
jointCount = 0;
bodyList = null;
bodies = [];
contacts = [];
joints = [];
contactSolver = new SIContactSolver();
}
public function solve(_arg1:Number, _arg2:Number, _arg3:int, _arg4:Number):void{
var _local5:int;
var _local6:int;
var _local7:RigidBody;
var _local9:Number;
var _local10:Number;
var _local11:Boolean;
var _local12:Boolean;
_local5 = 0;
while (_local5 < bodyCount) {
_local7 = bodies[_local5];
if (_local7.invMass == 0){
} else {
_local7.vx = ((_local7.vx + (_arg4 * (_arg1 + (_local7.invMass * _local7.fx)))) * _local7.linDamping);
_local7.vy = ((_local7.vy + (_arg4 * (_arg2 + (_local7.invMass * _local7.fy)))) * _local7.linDamping);
_local7.w = ((_local7.w + (_arg4 * (_local7.invI * _local7.t))) * _local7.angDamping);
};
_local5++;
};
var _local8:SIContactSolver = SIContactSolver(contactSolver);
_local8.setContacts(contacts, contactCount);
_local8.preStep();
_local6 = 0;
while (_local6 < jointCount) {
joints[_local6].preStep(_arg4);
_local6++;
};
_local5 = 0;
while (_local5 < _arg3) {
_local8.solveVelConstraints();
_local6 = 0;
while (_local6 < jointCount) {
joints[_local6].solveVelConstraints(_arg4, _arg3);
_local6++;
};
_local5++;
};
_local5 = 0;
while (_local5 < bodyCount) {
_local7 = bodies[_local5];
if (_local7.invMass == 0){
} else {
_local7.x = (_local7.x + (_arg4 * _local7.vx));
_local7.y = (_local7.y + (_arg4 * _local7.vy));
_local7.r = (_local7.r + (_arg4 * _local7.w));
_local10 = Math.cos(_local7.r);
_local9 = Math.sin(_local7.r);
_local7.r11 = _local10;
_local7.r12 = -(_local9);
_local7.r21 = _local9;
_local7.r22 = _local10;
};
_local5++;
};
if (World.doPositionCorrection){
_local5 = 0;
while (_local5 < _arg3) {
_local11 = _local8.solvePosConstraints(Constants.k_contactBaumgarte);
_local12 = true;
_local6 = 0;
while (_local6 < jointCount) {
_local12 = joints[_local6].solvePosConstraints();
_local12 = ((_local12) && (_local12));
_local6++;
};
if (((_local11) && (_local12))){
break;
};
_local5++;
};
};
_local5 = 0;
while (_local5 < bodyCount) {
_local7 = bodies[_local5];
if (_local7.invMass == 0){
} else {
_local7.updateShapes();
_local7.fx = (_local7.fy = (_local7.t = 0));
};
_local5++;
};
}
public function init():void{
bodies.length = 0;
contacts.length = 0;
joints.length = 0;
}
public function setContactSolver(_arg1:IContactSolver):void{
contactSolver = _arg1;
}
public function updateSleep(_arg1:Number):void{
var _local5:RigidBody;
var _local6:int;
var _local2:Number = 2147483648;
var _local3:Number = Constants.k_linSleepToleranceSq;
var _local4:Number = Constants.k_angSleepToleranceSq;
_local6 = 0;
while (_local6 < bodyCount) {
_local5 = bodies[_local6];
if (_local5.invMass == 0){
} else {
if ((_local5.stateBits & RigidBody.k_bitAllowSleep) == 0){
_local5.sleepTime = 0;
_local2 = 0;
};
if (((((((_local5.stateBits & RigidBody.k_bitAllowSleep) == 0)) || (((_local5.w * _local5.w) > _local4)))) || ((((_local5.vx * _local5.vx) + (_local5.vy * _local5.vy)) > _local3)))){
_local5.sleepTime = 0;
_local2 = 0;
} else {
_local5.sleepTime = (_local5.sleepTime + _arg1);
_local2 = ((_local2 < _local5.sleepTime)) ? _local2 : _local5.sleepTime;
};
};
_local6++;
};
if (_local2 >= Constants.k_timeToSleep){
_local6 = 0;
while (_local6 < bodyCount) {
_local5 = bodies[_local6];
bodies[_local6].stateBits = (_local5.stateBits | RigidBody.k_bitSleep);
_local6++;
};
};
}
}
}//package de.polygonal.motor2.dynamics
class RBNode {
public var body:RigidBody;
public var next:RBNode;
private function RBNode(){
}
}
Section 78
//RigidBody (de.polygonal.motor2.dynamics.RigidBody)
package de.polygonal.motor2.dynamics {
import de.polygonal.motor2.*;
import flash.geom.*;
import de.polygonal.motor2.math.*;
import de.polygonal.motor2.collision.shapes.data.*;
import de.polygonal.motor2.dynamics.joints.*;
import de.polygonal.motor2.collision.shapes.*;
import de.polygonal.motor2.dynamics.contact.*;
public class RigidBody {
public var r:Number;
public var invMass:Number;
public var world:World;
public var r12:Number;
public var id:int;
public var r11:Number;
public var linDamping:Number;
public var r22:Number;
public var prev:RigidBody;
public var stateBits:int;
public var r21:Number;
public var vx:Number;
public var vy:Number;
public var sleepTime:Number;
public var angDamping:Number;
public var I:Number;
public var jointList:JointNode;
public var fx:Number;
public var fy:Number;
public var contactList:ContactNode;
public var shapeList:ShapeSkeleton;
public var shapeCount:int;
public var next:RigidBody;
public var mass:Number;
public var cx:Number;
public var cy:Number;
public var x:Number;
public var y:Number;
public var t:Number;
public var w:Number;
public var invI:Number;
public static const k_bitDestroy:int = 16;
public static const k_bitAllowSleep:int = 8;
public static const k_bitExclude:int = (((k_bitStatic | k_bitIsland) | k_bitSleep) | k_bitFrozen);
public static const k_bitIsland:int = 32;
public static const k_bitStatic:int = 1;
public static const k_bitFrozen:int = 2;
public static const k_bitSleep:int = 4;
public function RigidBody(_arg1:World, _arg2:RigidBodyData){
init(_arg1, _arg2);
}
public function getWorldDirection(_arg1:Point, _arg2:Point=null):void{
var _local3:Number;
if (_arg2){
_arg2.x = ((r11 * _arg1.x) + (r12 * _arg1.y));
_arg2.y = ((r21 * _arg1.x) + (r22 * _arg1.y));
} else {
_local3 = _arg1.x;
_arg1.x = ((r11 * _local3) + (r12 * _arg1.y));
_arg1.y = ((r21 * _local3) + (r22 * _arg1.y));
};
}
public function wakeUp():void{
stateBits = (stateBits & ~(k_bitSleep));
sleepTime = 0;
}
public function putToSleep():void{
stateBits = (stateBits | k_bitSleep);
sleepTime = 0;
vx = (vy = (w = (fx = (fy = (t = 0)))));
}
public function deconstruct():void{
var _local2:ShapeSkeleton;
prev = (next = null);
var _local1:ShapeSkeleton = shapeList;
while (_local1) {
_local2 = _local1;
_local1 = _local1.next;
_local2.deconstruct();
};
}
public function getWorldPoint(_arg1:Point, _arg2:Point=null):void{
var _local3:Number;
if (_arg2){
_arg2.x = (x + ((r11 * _arg1.x) + (r12 * _arg1.y)));
_arg2.y = (y + ((r21 * _arg1.x) + (r22 * _arg1.y)));
} else {
_local3 = _arg1.x;
_arg1.x = (x + ((r11 * _local3) + (r12 * _arg1.y)));
_arg1.y = (y + ((r21 * _local3) + (r22 * _arg1.y)));
};
}
public function applyTorque(_arg1:Number):void{
if ((stateBits & k_bitSleep) == 0){
t = (t + _arg1);
};
}
public function getOrigin(_arg1:V2):void{
_arg1.x = (x - ((r11 * cx) + (r12 * cy)));
_arg1.y = (y - ((r21 * cx) + (r22 * cy)));
}
public function applyForce(_arg1:Number, _arg2:Number):void{
if ((stateBits & k_bitSleep) == 0){
this.fx = (this.fx + _arg1);
this.fy = (this.fy + _arg2);
};
}
public function freeze():void{
stateBits = (stateBits | k_bitFrozen);
vx = (vy = (w = 0));
}
private function init(_arg1:World, _arg2:RigidBodyData):void{
var _local3:Number;
var _local4:Number;
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:ShapeData;
var _local9:ShapeSkeleton;
var _local10:Class;
this.world = _arg1;
x = _arg2.x;
y = _arg2.y;
r = _arg2.r;
_local3 = Math.cos(r);
_local4 = Math.sin(r);
r11 = _local3;
r12 = -(_local4);
r21 = _local4;
r22 = _local3;
vx = (vy = (w = 0));
fx = (fy = (t = 0));
mass = (invMass = (I = (invI = 0)));
cx = (cy = 0);
linDamping = (1 - _arg2.linDamping);
linDamping = ((linDamping)<0) ? 0 : ((linDamping)>1) ? 1 : linDamping;
angDamping = (1 - _arg2.angDamping);
angDamping = ((angDamping)<0) ? 0 : ((angDamping)>1) ? 1 : angDamping;
shapeCount = 0;
stateBits = 0;
sleepTime = 0;
if (_arg2.allowSleep){
stateBits = (stateBits | k_bitAllowSleep);
};
if (_arg2.isSleeping){
stateBits = (stateBits | k_bitSleep);
};
jointList = null;
contactList = null;
next = (prev = null);
_local8 = _arg2.shapeDataList;
while (_local8) {
_local5 = _local8.getMass();
mass = (mass + _local5);
cx = (cx + (_local5 * (_local8.mx + _local8.getCM().x)));
cy = (cy + (_local5 * (_local8.my + _local8.getCM().y)));
shapeCount++;
_local8 = _local8.next;
};
if (mass > 0){
cx = (cx / mass);
cy = (cy / mass);
x = (x + ((r11 * cx) + (r12 * cy)));
y = (y + ((r21 * cx) + (r22 * cy)));
} else {
stateBits = (stateBits | k_bitStatic);
};
if (!_arg2.preventRotation){
_local8 = _arg2.shapeDataList;
while (_local8) {
I = (I + _local8.getInertia());
_local6 = ((_local8.mx + _local8.getCM().x) - cx);
_local7 = ((_local8.my + _local8.getCM().y) - cy);
I = (I + (_local8.getMass() * ((_local6 * _local6) + (_local7 * _local7))));
_local8 = _local8.next;
};
if (I > 0){
invI = (1 / I);
};
};
invMass = ((mass)>0) ? (1 / mass) : 0;
if (((!(_arg2.isSleeping)) && ((invMass > 0)))){
vx = (_arg2.vx + (-(_arg2.w) * cy));
vy = (_arg2.vy + (_arg2.w * cy));
w = _arg2.w;
};
_local8 = _arg2.shapeDataList;
while (_local8) {
_local10 = _local8.getShapeClass();
_local9 = new _local10(_local8, this);
_local9.next = shapeList;
shapeList = _local9;
_local8 = _local8.next;
};
}
public function updateShapes():void{
var _local1:Number;
var _local2:Number;
_local1 = Math.cos(r);
_local2 = Math.sin(r);
r11 = _local1;
r12 = -(_local2);
r21 = _local2;
r22 = _local1;
var _local3:ShapeSkeleton = shapeList;
while (_local3) {
_local3.update();
_local3 = _local3.next;
};
}
public function allowSleeping(_arg1:Boolean):void{
if (_arg1){
stateBits = (stateBits | k_bitAllowSleep);
} else {
stateBits = (stateBits & ~(k_bitAllowSleep));
wakeUp();
};
}
public function setOrigin(_arg1:Number, _arg2:Number, _arg3:Number):void{
var _local4:Number;
var _local5:Number;
var _local6:ShapeSkeleton;
if ((stateBits & k_bitFrozen) == 0){
r = _arg3;
_local4 = Math.cos(r);
_local5 = Math.sin(r);
r11 = _local4;
r12 = -(_local5);
r21 = _local5;
r22 = _local4;
this.x = (_arg1 + ((r11 * cx) + (r12 * cy)));
this.y = (_arg2 + ((r21 * cx) + (r22 * cy)));
_local6 = shapeList;
while (_local6) {
_local6.update();
_local6 = _local6.next;
};
};
}
public function isConnected(_arg1:RigidBody):Boolean{
return (false);
}
public function applyImpulse(_arg1:Number, _arg2:Number):void{
if ((stateBits & k_bitSleep) == 0){
vx = (vx + (invMass * _arg1));
vy = (vy + (invMass * _arg2));
};
}
public function applyForceAt(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number):void{
if ((stateBits & k_bitSleep) == 0){
this.fx = (this.fx + _arg1);
this.fy = (this.fy + _arg2);
t = (t + (((_arg3 - x) * _arg2) - ((_arg4 - y) * _arg1)));
};
}
public function isStatic():Boolean{
return (((stateBits & k_bitStatic) == k_bitStatic));
}
public function applyImpulseAt(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number):void{
if ((stateBits & k_bitSleep) == 0){
vx = (vx + (invMass * _arg1));
vy = (vy + (invMass * _arg2));
w = (w + (((invI * (_arg3 - x)) * _arg2) - ((_arg4 - y) * _arg1)));
};
}
public function getModelDirection(_arg1:Point, _arg2:Point=null):void{
var _local3:Number;
if (_arg2){
_arg2.x = ((r11 * _arg1.x) + (r21 * _arg1.y));
_arg2.y = ((r12 * _arg1.x) + (r22 * _arg1.y));
} else {
_local3 = _arg1.x;
_arg1.x = ((r11 * _local3) + (r21 * _arg1.y));
_arg1.y = ((r12 * _local3) + (r22 * _arg1.y));
};
}
public function setCenter(_arg1:Number, _arg2:Number, _arg3:Number):void{
var _local4:Number;
var _local5:Number;
var _local6:ShapeSkeleton;
if ((stateBits & k_bitFrozen) == 0){
r = _arg3;
_local4 = Math.cos(r);
_local5 = Math.sin(r);
r11 = _local4;
r12 = -(_local5);
r21 = _local5;
r22 = _local4;
this.x = _arg1;
this.y = _arg2;
_local6 = shapeList;
while (_local6) {
_local6.update();
_local6 = _local6.next;
};
};
}
public function getCenter(_arg1:V2):void{
_arg1.x = x;
_arg1.y = y;
}
public function rotate(_arg1:Number):void{
if (_arg1 < 0){
_arg1 = (_arg1 + 360);
} else {
if (_arg1 > 360){
_arg1 = (_arg1 - 360);
};
};
r = (_arg1 * (Math.PI / 180));
updateShapes();
}
public function getModelPoint(_arg1:Point, _arg2:Point=null):void{
var _local3:Number;
if (_arg2){
_arg2.x = ((r11 * (_arg1.x - x)) + (r21 * (_arg1.y - y)));
_arg2.y = ((r12 * (_arg1.x - x)) + (r22 * (_arg1.y - y)));
} else {
_local3 = _arg1.x;
_arg1.x = ((r11 * (_local3 - x)) + (r21 * (_arg1.y - y)));
_arg1.y = ((r12 * (_local3 - x)) + (r22 * (_arg1.y - y)));
};
}
public function isFrozen():Boolean{
return (((stateBits & k_bitFrozen) == k_bitFrozen));
}
public function isSleeping():Boolean{
return (((stateBits & k_bitSleep) == k_bitSleep));
}
}
}//package de.polygonal.motor2.dynamics
Section 79
//RigidBodyData (de.polygonal.motor2.dynamics.RigidBodyData)
package de.polygonal.motor2.dynamics {
import de.polygonal.motor2.collision.shapes.data.*;
public class RigidBodyData {
public var y:Number;
public var vx:Number;
public var vy:Number;
public var angDamping:Number;
public var allowSleep:Boolean;
public var shapeDataList:ShapeData;
public var linDamping:Number;
public var r:Number;
public var isSleeping:Boolean;
public var preventRotation:Boolean;
public var w:Number;
public var x:Number;
public function RigidBodyData(_arg1:Number=0, _arg2:Number=0, _arg3:Number=0){
init();
this.x = _arg1;
this.y = _arg2;
this.r = _arg3;
}
public function addShapeData(_arg1:ShapeData):void{
if (_arg1 == null){
return;
};
_arg1.next = shapeDataList;
shapeDataList = _arg1;
}
public function move(_arg1:Number, _arg2:Number):void{
this.x = _arg1;
this.y = _arg2;
}
public function init():void{
x = (y = (r = (vx = (vy = (w = 0)))));
allowSleep = true;
isSleeping = false;
linDamping = 0;
angDamping = 0;
preventRotation = false;
shapeDataList = null;
}
public function rotate(_arg1:Number):void{
if (_arg1 < 0){
_arg1 = (_arg1 + 360);
} else {
if (_arg1 > 360){
_arg1 = (_arg1 - 360);
};
};
r = (_arg1 * (Math.PI / 180));
}
}
}//package de.polygonal.motor2.dynamics
Section 80
//AABB2 (de.polygonal.motor2.math.AABB2)
package de.polygonal.motor2.math {
public class AABB2 {
public var ymax:Number;
public var xmax:Number;
public var ymin:Number;
public var xmin:Number;
public function AABB2(_arg1:Number=1.79769313486232E308, _arg2:Number=1.79769313486232E308, _arg3:Number=4.94065645841247E-324, _arg4:Number=4.94065645841247E-324){
this.xmin = _arg1;
this.ymin = _arg2;
this.xmax = _arg3;
this.ymax = _arg4;
}
public function isEmpty():Boolean{
return ((((xmin > xmax)) || ((ymin > ymax))));
}
public function empty():void{
xmin = (ymin = 2147483647);
xmax = (ymax = -2147483648);
}
public function addPoint(_arg1:Number, _arg2:Number):void{
if (_arg1 < xmin){
xmin = _arg1;
};
if (_arg1 > xmax){
xmax = _arg1;
};
if (_arg2 < ymin){
ymin = _arg2;
};
if (_arg2 > ymax){
ymax = _arg2;
};
}
public function copy():AABB2{
return (new AABB2(xmin, ymin, xmax, ymax));
}
}
}//package de.polygonal.motor2.math
Section 81
//ConvexBSP (de.polygonal.motor2.math.ConvexBSP)
package de.polygonal.motor2.math {
public class ConvexBSP {
public static var VERTEX_ORDER:Number = 1;
public static function createInternalNode(_arg1:int, _arg2:Array, _arg3:Array, _arg4:Array, _arg5:Array):ConvexBSPNode{
var _local6:ConvexBSPNode;
var _local7:ConvexBSPNode;
var _local8:Array;
var _local9:Array;
var _local10:Array;
var _local11:Array;
var _local12:Array;
var _local13:V2;
var _local14:V2;
var _local15:Number;
var _local16:Number;
var _local17:int;
var _local18:int;
var _local19:int;
var _local20:Number;
var _local21:int;
_local8 = [];
_local9 = [];
_local10 = [];
_local11 = [];
_local18 = _arg4.length;
_local12 = new Array();
_local21 = int(((_arg4[0] + _arg4[int((_local18 - 1))]) / 2));
_local13 = _arg3[_local21];
_local15 = (_local13.x * VERTEX_ORDER);
_local16 = (_local13.y * VERTEX_ORDER);
_local19 = (_arg4[0] - 1);
if (_local19 < 0){
_local19 = (_local18 - 1);
};
_local14 = _arg2[_local19];
_local12[0] = ((_local15 * _local14.x) + (_local16 * _local14.y));
_local17 = 0;
while (_local17 < _local18) {
_local19 = _arg4[_local17];
if (_local19 == _local21){
_local12[int((_local17 + 1))] = 1;
} else {
_local14 = _arg2[_local19];
_local20 = (_local12[int((_local17 + 1))] = ((_local15 * _local14.x) + (_local16 * _local14.y)));
if ((_local20 >= 0)){
_local8[_local8.length] = _local19;
} else {
_local9[_local9.length] = _local19;
};
};
_local17++;
};
_local19 = (_arg4[int((_local18 - 1))] + 1);
if (_local19 == _arg1){
_local19 = 0;
};
_local14 = _arg2[_local19];
_local12[_local12.length] = ((_local15 * _local14.x) + (_local16 * _local14.y));
_local18 = _arg5.length;
_local17 = 0;
while (_local17 < _local18) {
if ((((_local12[_local17] >= 0)) && ((_local12[int((_local17 + 1))] >= 0)))){
_local10[_local10.length] = _arg5[_local17];
} else {
_local11[_local11.length] = _arg5[_local17];
};
_local17++;
};
_local7 = null;
if (_local8.length > 0){
_local7 = createInternalNode(_arg1, _arg2, _arg3, _local8, _local10);
} else {
if (_local10.length > 0){
_local7 = createNode(_local10[0][1]);
};
};
_local6 = null;
if (_local9.length > 0){
_local6 = createInternalNode(_arg1, _arg2, _arg3, _local9, _local11);
} else {
_local6 = createNode(_local11[0][1]);
};
var _local22:ConvexBSPNode = createNode(_local21, _local7, _local6);
return (_local22);
}
public static function createBSP(_arg1:int, _arg2:Array, _arg3:Array):ConvexBSPNode{
var _local4:Array;
var _local5:Array;
var _local6:Array;
var _local7:Array;
var _local8:V2;
var _local9:V2;
var _local10:Number;
var _local11:Number;
var _local12:int;
var _local13:Number;
var _local14:Number;
var _local15:ConvexBSPNode;
var _local16:ConvexBSPNode;
_local4 = [];
_local5 = [];
_local6 = [];
_local7 = [];
_local8 = _arg3[0];
_local10 = (_local8.x * VERTEX_ORDER);
_local11 = (_local8.y * VERTEX_ORDER);
_local13 = 0;
_local12 = 1;
while (_local12 < _arg1) {
_local9 = _arg2[_local12];
_local14 = ((_local10 * _local9.x) + (_local11 * _local9.y));
if (_local14 >= 0){
_local4[_local4.length] = _local12;
} else {
_local5[_local5.length] = _local12;
};
if ((((_local13 >= 0)) && ((_local14 >= 0)))){
_local6[_local6.length] = [(_local12 - 1), _local12];
} else {
if ((((_local13 <= 0)) && ((_local14 <= 0)))){
_local7[_local7.length] = [(_local12 - 1), _local12];
} else {
_local6[_local6.length] = [(_local12 - 1), _local12];
_local7[_local7.length] = [(_local12 - 1), _local12];
};
};
_local13 = _local14;
_local12++;
};
_local7[_local7.length] = [(_arg1 - 1), 0];
_local15 = createInternalNode(_arg1, _arg2, _arg3, _local4, _local6);
_local16 = createInternalNode(_arg1, _arg2, _arg3, _local5, _local7);
return (createNode(0, _local15, _local16));
}
public static function createNode(_arg1:int, _arg2:ConvexBSPNode=null, _arg3:ConvexBSPNode=null):ConvexBSPNode{
var _local4:ConvexBSPNode = new ConvexBSPNode();
_local4.I = _arg1;
_local4.R = _arg2;
_local4.L = _arg3;
_local4.right = _arg2;
_local4.left = _arg3;
return (_local4);
}
}
}//package de.polygonal.motor2.math
Section 82
//ConvexBSPNode (de.polygonal.motor2.math.ConvexBSPNode)
package de.polygonal.motor2.math {
import de.polygonal.ds.*;
public class ConvexBSPNode extends BinaryTreeNode {
public var R:ConvexBSPNode;
public var V:V2;
public var I:int;
public var L:ConvexBSPNode;
public var N:V2;
public function ConvexBSPNode(){
super(null);
init();
}
private function init():void{
L = (R = null);
N = (V = null);
I = -1;
}
}
}//package de.polygonal.motor2.math
Section 83
//E2 (de.polygonal.motor2.math.E2)
package de.polygonal.motor2.math {
public class E2 {
public var d:V2;
public var v:V2;
public var w:V2;
public var mag:Number;// = 0
public var n:V2;
}
}//package de.polygonal.motor2.math
Section 84
//Tri2 (de.polygonal.motor2.math.Tri2)
package de.polygonal.motor2.math {
public class Tri2 {
public var a:V2;
public var c:V2;
public var b:V2;
public var cm:V2;
public var area:Number;
public var next:Tri2;
public function Tri2(_arg1:V2, _arg2:V2, _arg3:V2){
this.a = _arg1;
this.b = _arg2;
this.c = _arg3;
area = ((((_arg2.x - _arg1.x) * (_arg3.y - _arg1.y)) - ((_arg2.y - _arg1.y) * (_arg3.x - _arg1.x))) / 2);
cm = new V2((((_arg1.x + _arg2.x) + _arg3.x) / 3), (((_arg1.y + _arg2.y) + _arg3.y) / 3));
}
}
}//package de.polygonal.motor2.math
Section 85
//V2 (de.polygonal.motor2.math.V2)
package de.polygonal.motor2.math {
import flash.geom.*;
public class V2 extends Point {
public var I:int;
public var prev:V2;
public var userData;
public var last:Boolean;
public var next:V2;
public function V2(_arg1:Number=0, _arg2:Number=0){
super(_arg1, _arg2);
next = (prev = null);
last = false;
I = -1;
}
public function getAt(_arg1:int):V2{
var _local2:V2 = this;
while (_local2) {
if (_local2.I == _arg1){
return (_local2);
};
if (_local2.last){
break;
};
_local2 = _local2.next;
};
return (null);
}
override public function toString():String{
return ((((((((("{V2, x=" + x.toFixed(2)) + ", y=") + y.toFixed(2)) + ", I=") + I) + ", last = ") + int(last)) + "}"));
}
public function copy():V2{
return (new V2(x, y));
}
public function deconstruct():void{
var _local2:V2;
var _local1:V2 = this;
while (_local1) {
_local2 = _local1.next;
_local1 = null;
_local1 = _local2;
};
}
public function toArray():Array{
var _local1:V2 = this;
var _local2 = 1;
var _local3:Array = [_local1];
if (last){
return (_local3);
};
_local1 = _local1.next;
while (_local1) {
var _temp1 = _local2;
_local2 = (_local2 + 1);
var _local4 = _temp1;
_local3[_local4] = _local1;
if (_local1.last){
break;
};
_local1 = _local1.next;
};
return (_local3);
}
}
}//package de.polygonal.motor2.math
Section 86
//Constants (de.polygonal.motor2.Constants)
package de.polygonal.motor2 {
public class Constants {
public static const k_velocityThreshold:Number = 50;
public static const k_timeUnitsPerSecond:Number = 1;
public static const k_maxManifoldPoints:int = 2;
public static const k_linSleepToleranceSq:Number = 0.25;
public static const k_linSleepTolerance:Number = 0.5;
public static const k_linSlopSq:Number = 0.0625;
public static const k_linSlop:Number = 0.25;
public static const k_angSleepToleranceSq:Number = 0;
public static const k_maxForceGenerators:int = 0x0200;
public static const k_maxShapesPerBody:int = 64;
public static const k_maxLinCorrection:Number = 10;
public static const k_angSlop:Number = 0;
public static const k_lengthUnitsPerMeter:Number = 50;
public static const k_maxProxies:int = 0x0200;
public static const k_maxPolyVertices:int = 8;
public static const k_contactBaumgarte:Number = 0.2;
public static const k_maxAngCorrection:Number = 0.139626340159546;
public static const k_maxPairs:int = 4096;
public static const k_angSleepTolerance:Number = 0;
public static const k_massUnitsPerKilogram:Number = 1;
public static const k_timeToSleep:Number = 0.5;
}
}//package de.polygonal.motor2
Section 87
//World (de.polygonal.motor2.World)
package de.polygonal.motor2 {
import flash.events.*;
import de.polygonal.motor2.math.*;
import de.polygonal.motor2.dynamics.*;
import de.polygonal.motor2.collision.nbody.*;
import de.polygonal.motor2.dynamics.joints.*;
import de.polygonal.motor2.dynamics.joints.data.*;
import de.polygonal.motor2.dynamics.forces.*;
import de.polygonal.motor2.collision.shapes.*;
import de.polygonal.motor2.dynamics.contact.*;
public class World extends EventDispatcher {
public const gravity:V2;
private var _jointCount:int;
public var jointList:Joint;
public var groundBody:RigidBody;
public var doSleep:Boolean;
public var contactCount:int;
private var _contactManager:ContactManager;
private var _bodyCount:int;
public var contactList:Contact;
public var bodyList:RigidBody;
private var _forceRegistry:ForceRegistry;
private var _broadphase:IBroadPhase;
private var _contactCount:int;
public var worldAABB:AABB2;
private var _bodyIdCount:int;
private var _island:Island;
public var bodyDestroyList:RigidBody;
public static var doWarmStarting:Boolean = true;
public static var doPositionCorrection:Boolean = true;
public static var stats_timeSimStep:int = 0;
public static var stats_SepAxisQueryCount:int = 0;
public function World(_arg1:AABB2, _arg2:Boolean=true){
gravity = new V2();
super();
this.worldAABB = _arg1.copy();
this.doSleep = _arg2;
init();
}
private function cleanBodyList():void{
var _local2:RigidBody;
var _local3:JointNode;
var _local4:JointNode;
_contactManager.destroyImmediate = true;
var _local1:RigidBody = bodyDestroyList;
while (_local1) {
_local2 = _local1;
_local1 = _local1.next;
_local3 = _local2.jointList;
while (_local3) {
_local4 = _local3;
_local3 = _local3.next;
destroyJoint(_local4.joint);
};
_local2.deconstruct();
_local2 = null;
};
bodyDestroyList = null;
_contactManager.destroyImmediate = false;
}
public function destroyBody(_arg1:RigidBody):Boolean{
if (_bodyCount == 0){
return (false);
};
if ((_arg1.stateBits & RigidBody.k_bitDestroy)){
return (false);
};
if (_arg1.prev){
_arg1.prev.next = _arg1.next;
};
if (_arg1.next){
_arg1.next.prev = _arg1.prev;
};
if (_arg1 == bodyList){
bodyList = _arg1.next;
};
_arg1.stateBits = (_arg1.stateBits | RigidBody.k_bitDestroy);
if (_bodyCount > 0){
_bodyCount--;
};
_arg1.prev = null;
_arg1.next = bodyDestroyList;
bodyDestroyList = _arg1;
return (true);
}
public function deconstruct():void{
destroyBody(groundBody);
_broadphase = null;
}
public function setWorldBounds(_arg1:AABB2):void{
}
public function addForce(_arg1:RigidBody, _arg2:ForceGenerator):Boolean{
var _local3:ShapeSkeleton;
if (_arg1 == null){
return (false);
};
if ((_arg2 is Buoyancy)){
_local3 = _arg1.shapeList;
while (_local3) {
_local3.triangulate();
_local3 = _local3.next;
};
};
_forceRegistry.add(_arg1, _arg2);
return (true);
}
public function getBroadPhase():IBroadPhase{
return (_broadphase);
}
public function setGravity(_arg1:Number, _arg2:Number):void{
gravity.x = _arg1;
gravity.y = _arg2;
}
public function setBroadPhase(_arg1:IBroadPhase):void{
if (bodyList){
return;
};
_broadphase = _arg1;
_broadphase.setWorld(this);
_broadphase.setWorldBounds(worldAABB);
_broadphase.setPairHandler(_contactManager);
}
public function removeForce(_arg1:RigidBody, _arg2:ForceGenerator):Boolean{
return (_forceRegistry.remove(_arg1, _arg2));
}
public function getWorldBounds():AABB2{
return (null);
}
public function createJoint(_arg1:JointData):Joint{
var _local4:RigidBody;
var _local5:ShapeSkeleton;
var _local2:Class = _arg1.getJointClass();
var _local3:Joint = (new _local2(_arg1) as Joint);
_local3.prev = null;
_local3.next = jointList;
if (jointList){
jointList.prev = _local3;
};
jointList = _local3;
_jointCount++;
_local3.node1.joint = _local3;
_local3.node1.other = _local3.body2;
_local3.node1.prev = null;
_local3.node1.next = _local3.body1.jointList;
if (_local3.body1.jointList){
_local3.body1.jointList.prev = _local3.node1;
};
_local3.body1.jointList = _local3.node1;
_local3.node2.joint = _local3;
_local3.node2.other = _local3.body1;
_local3.node2.prev = null;
_local3.node2.next = _local3.body2.jointList;
if (_local3.body2.jointList){
_local3.body2.jointList.prev = _local3.node2;
};
_local3.body2.jointList = _local3.node2;
if (!_arg1.collideConnected){
_local4 = ((_arg1.body1.shapeCount < _arg1.body2.shapeCount)) ? _arg1.body1 : _arg1.body2;
_local5 = _local4.shapeList;
while (_local5) {
_local5 = _local5.next;
};
};
return (_local3);
}
private function destroyJoint(_arg1:Joint):void{
var _local5:RigidBody;
var _local6:ShapeSkeleton;
var _local2:Boolean = _arg1.collideConnected;
if (_arg1.prev){
_arg1.prev.next = _arg1.next;
};
if (_arg1.next){
_arg1.next.prev = _arg1.prev;
};
if (_arg1 == jointList){
jointList = _arg1.next;
};
var _local3:RigidBody = _arg1.body1;
var _local4:RigidBody = _arg1.body2;
_local3.wakeUp();
_local4.wakeUp();
if (_arg1.node1.prev){
_arg1.node1.prev.next = _arg1.node1.next;
};
if (_arg1.node1.next){
_arg1.node1.next.prev = _arg1.node1.prev;
};
if (_arg1.node1 == _local3.jointList){
_local3.jointList = _arg1.node1.next;
};
_arg1.node1.prev = null;
_arg1.node1.next = null;
if (_arg1.node2.prev){
_arg1.node2.prev.next = _arg1.node2.next;
};
if (_arg1.node2.next){
_arg1.node2.next.prev = _arg1.node2.prev;
};
if (_arg1.node2 == _local4.jointList){
_local4.jointList = _arg1.node2.next;
};
_arg1.node2.prev = null;
_arg1.node2.next = null;
_jointCount--;
if (!_local2){
_local5 = ((_local3.shapeCount < _local4.shapeCount)) ? _local3 : _local4;
_local6 = _local5.shapeList;
while (_local6) {
_local6 = _local6.next;
};
};
}
public function step(_arg1:Number, _arg2:int):void{
var _local3:RigidBody;
var _local4:Contact;
var _local5:Joint;
var _local6:int;
var _local8:int;
var _local9:RigidBody;
var _local10:ContactNode;
var _local11:JointNode;
var _local12:RigidBody;
var _local13:Joint;
_contactManager.cleanContactList();
cleanBodyList();
_contactManager.collide();
_forceRegistry.evaluate();
_local3 = bodyList;
while (_local3) {
_local3.stateBits = (_local3.stateBits & ~(32));
_local3 = _local3.next;
};
_local4 = contactList;
while (_local4) {
_local4.stateBits = (_local4.stateBits & ~(Contact.k_bitIsland));
_local4 = _local4.next;
};
_local5 = jointList;
while (_local5) {
_local5.stateBits = (_local5.stateBits & ~(32));
_local5 = _local5.next;
};
var _local7:Array = [];
_local12 = bodyList;
while (_local12 != null) {
if ((_local12.stateBits & RigidBody.k_bitExclude)){
} else {
_island.bodyCount = 0;
_island.contactCount = 0;
_island.jointCount = 0;
_local7[0] = _local12;
_local8 = 1;
_local12.stateBits = (_local12.stateBits | 32);
while (_local8 > 0) {
--_local8;
_local3 = _local7[_local8];
_island.bodies[int(_island.bodyCount++)] = _local3;
_local3.stateBits = (_local3.stateBits & ~(RigidBody.k_bitSleep));
if ((_local3.stateBits & RigidBody.k_bitStatic)){
} else {
_local10 = _local3.contactList;
while (_local10) {
if ((_local10.contact.stateBits & Contact.k_bitIsland)){
} else {
_island.contacts[int(_island.contactCount++)] = _local10.contact;
_local10.contact.stateBits = (_local10.contact.stateBits | Contact.k_bitIsland);
_local9 = _local10.other;
if ((_local9.stateBits & 32)){
} else {
var _temp1 = _local8;
_local8 = (_local8 + 1);
var _local14 = _temp1;
_local7[_local14] = _local9;
_local9.stateBits = (_local9.stateBits | 32);
};
};
_local10 = _local10.next;
};
_local11 = _local3.jointList;
while (_local11) {
_local13 = _local11.joint;
if ((_local13.stateBits & 32)){
} else {
_island.joints[int(_island.jointCount++)] = _local13;
_local13.stateBits = (_local13.stateBits | 32);
_local9 = _local11.other;
if ((_local9.stateBits & 32)){
} else {
var _temp2 = _local8;
_local8 = (_local8 + 1);
_local14 = _temp2;
_local7[_local14] = _local9;
_local9.stateBits = (_local9.stateBits | 32);
};
};
_local11 = _local11.next;
};
};
};
_island.solve(gravity.x, gravity.y, _arg2, _arg1);
if (doSleep){
_island.updateSleep(_arg1);
};
_local6 = 0;
while (_local6 < _island.bodyCount) {
_local3 = _island.bodies[_local6];
if ((_local3.stateBits & RigidBody.k_bitStatic)){
_local3.stateBits = (_local3.stateBits & ~(32));
};
if ((_local3.stateBits & RigidBody.k_bitFrozen)){
};
_local6++;
};
};
_local12 = _local12.next;
};
_broadphase.search();
}
public function init():void{
bodyList = null;
bodyDestroyList = null;
contactList = null;
jointList = null;
_bodyCount = 0;
_contactCount = 0;
setGravity(0, 100);
_contactManager = new ContactManager(this);
_forceRegistry = new ForceRegistry();
_island = new Island();
_bodyIdCount = 0;
setBroadPhase(new ExhaustiveSearch());
}
public function createBody(_arg1:RigidBodyData):RigidBody{
var _local2:RigidBody = new RigidBody(this, _arg1);
_local2.id = _bodyIdCount++;
_local2.next = bodyList;
if (bodyList){
bodyList.prev = _local2;
};
bodyList = _local2;
_bodyCount++;
return (_local2);
}
public function getGroundBody():RigidBody{
return (null);
}
}
}//package de.polygonal.motor2
Section 88
//ByteArrayAsset (mx.core.ByteArrayAsset)
package mx.core {
import flash.utils.*;
public class ByteArrayAsset extends ByteArray implements IFlexAsset {
mx_internal static const VERSION:String = "3.0.0.0";
}
}//package mx.core
Section 89
//IFlexAsset (mx.core.IFlexAsset)
package mx.core {
public interface IFlexAsset {
}
}//package mx.core
Section 90
//mx_internal (mx.core.mx_internal)
package mx.core {
public namespace mx_internal = "http://www.adobe.com/2006/flex/mx/internal";
}//package mx.core
Section 91
//ExtendedSound (uk.co.stdio.sound.ExtendedSound)
package uk.co.stdio.sound {
import flash.events.*;
import flash.media.*;
import flash.utils.*;
public class ExtendedSound extends Sound {
protected var fadeStartVolume:Number;
protected var fadeEndVolume:Number;
protected var panStartPosition:Number;
protected var panDuration:Number;
protected var panEndPosition:Number;
protected var masterVolume:Number;// = 1
protected var fadeTimer:Timer;
protected var panTimer:Timer;
protected var fadeDuration:Number;
protected var panStartTime:Number;
protected var fadeStartTime:Number;
protected var soundChannel:SoundChannel;
private static const TIMER_UPDATE_RATE:Number = 20;
public function fadeIn(_arg1:Number=0, _arg2:Number=1, _arg3:Number=0, _arg4:int=0, _arg5:Number=0):SoundChannel{
fadeStartVolume = Math.max(0, Math.min(1, _arg1));
soundChannel = super.play(_arg5, _arg4, new SoundTransform((fadeStartVolume * masterVolume)));
if (_arg3 > 0){
fadeStartTime = getTimer();
fadeDuration = _arg3;
fadeEndVolume = Math.max(0, Math.min(1, _arg2));
startFade();
};
return (soundChannel);
}
public function stop():void{
if (soundChannel != null){
soundChannel.stop();
};
}
public function fadeOut(_arg1:Number=0):void{
if ((((((_arg1 > 0)) && (soundChannel))) && (soundChannel.soundTransform))){
fadeStartTime = getTimer();
fadeDuration = _arg1;
fadeStartVolume = (soundChannel.soundTransform.volume / masterVolume);
fadeEndVolume = 0;
startFade();
} else {
stop();
};
}
protected function stopPan():void{
if (((!((panTimer == null))) && (panTimer.running))){
panTimer.reset();
};
}
protected function startPan():void{
if (panTimer == null){
panTimer = new Timer(TIMER_UPDATE_RATE);
panTimer.addEventListener(TimerEvent.TIMER, updatePan);
};
stopPan();
panTimer.start();
}
public function fadeTo(_arg1:Number, _arg2:Number):void{
if (((soundChannel) && (soundChannel.soundTransform))){
fadeStartTime = getTimer();
fadeDuration = _arg2;
fadeStartVolume = (soundChannel.soundTransform.volume / masterVolume);
fadeEndVolume = _arg1;
startFade();
};
}
public function setPan(_arg1:Number):void{
var _local2:Number;
if (soundChannel != null){
_arg1 = Math.max(-1, Math.min(1, _arg1));
_local2 = soundChannel.soundTransform.volume;
soundChannel.soundTransform = new SoundTransform(_local2, _arg1);
stopPan();
};
}
public function setMasterVolume(_arg1:Number):void{
var _local2:Number;
masterVolume = Math.max(0, Math.min(1, _arg1));
if (soundChannel != null){
_local2 = soundChannel.soundTransform.pan;
soundChannel.soundTransform = new SoundTransform((_arg1 * masterVolume), _local2);
};
}
protected function stopFade():void{
if (((!((fadeTimer == null))) && (fadeTimer.running))){
fadeTimer.reset();
};
}
public function getSoundChannel():SoundChannel{
return (soundChannel);
}
public function setVolume(_arg1:Number):void{
var _local2:Number;
if (soundChannel != null){
_arg1 = Math.max(0, Math.min(1, _arg1));
_local2 = soundChannel.soundTransform.pan;
soundChannel.soundTransform = new SoundTransform((_arg1 * masterVolume), _local2);
stopFade();
};
}
override public function toString():String{
var _local1:String = getQualifiedClassName(this);
if (soundChannel != null){
_local1 = (_local1 + ((" vol[" + (soundChannel.soundTransform.volume / masterVolume)) + "]"));
_local1 = (_local1 + ((" pan[" + soundChannel.soundTransform.pan) + "]"));
};
return (_local1);
}
protected function updatePan(_arg1:TimerEvent):void{
var _local2:Number;
var _local3:Number = ((getTimer() - panStartTime) / panDuration);
if (_local3 >= 1){
stopPan();
_local2 = panEndPosition;
} else {
if (_local3 > 0){
_local2 = ((_local3 * (panEndPosition - panStartPosition)) + panStartPosition);
};
};
var _local4:Number = soundChannel.soundTransform.volume;
soundChannel.soundTransform = new SoundTransform(_local4, _local2);
}
override public function play(_arg1:Number=0, _arg2:int=0, _arg3:SoundTransform=null):SoundChannel{
if (_arg3 != null){
_arg3.volume = (_arg3.volume * masterVolume);
} else {
_arg3 = new SoundTransform(masterVolume);
};
soundChannel = super.play(_arg1, _arg2, _arg3);
return (soundChannel);
}
protected function updateFade(_arg1:TimerEvent):void{
var _local2:Number;
var _local3:Number = ((getTimer() - fadeStartTime) / fadeDuration);
if (_local3 >= 1){
stopFade();
_local2 = fadeEndVolume;
} else {
if (_local3 > 0){
_local2 = ((_local3 * (fadeEndVolume - fadeStartVolume)) + fadeStartVolume);
};
};
var _local4:Number = soundChannel.soundTransform.pan;
soundChannel.soundTransform = new SoundTransform((_local2 * masterVolume), _local4);
}
protected function startFade():void{
if (fadeTimer == null){
fadeTimer = new Timer(TIMER_UPDATE_RATE);
fadeTimer.addEventListener(TimerEvent.TIMER, updateFade);
};
stopFade();
fadeTimer.start();
}
public function panTo(_arg1:Number, _arg2:Number):void{
if (_arg2 > 0){
panStartTime = getTimer();
panDuration = _arg2;
panStartPosition = soundChannel.soundTransform.pan;
panEndPosition = _arg1;
startPan();
} else {
setPan(_arg1);
};
}
}
}//package uk.co.stdio.sound
Section 92
//Sequence (uk.co.stdio.sound.Sequence)
package uk.co.stdio.sound {
import flash.events.*;
import flash.media.*;
public class Sequence extends EventDispatcher {
var cut:Boolean;// = false
private var steps:Array;
private var _currStep:int;// = -1
public static const EVENT_SEQUENCE_COMPLETE:String = "onSequenceComplete";
public static const EVENT_STEP_COMPLETE:String = "onStepComplete";
public function Sequence(){
steps = new Array();
super();
}
public function addStepAt(_arg1:uint, _arg2:ExtendedSound, _arg3:uint):void{
steps.splice(_arg1, 0, new SequenceStep(_arg2, _arg3));
}
function start(_arg1:int=-1):void{
reset();
_currStep = _arg1;
playNextStep();
}
private function playNextStep():void{
var _local1:SequenceStep;
var _local2:ExtendedSound;
var _local3:SoundChannel;
_currStep++;
if (_currStep == steps.length){
reset();
dispatchEvent(new Event(EVENT_SEQUENCE_COMPLETE));
} else {
if (!cut){
_local1 = steps[_currStep];
_local2 = _local1.es;
_local2.play(0, _local1.numLoops);
_local3 = steps[_currStep].es.getSoundChannel();
_local3.addEventListener(Event.SOUND_COMPLETE, onSoundComplete);
};
dispatchEvent(new Event(EVENT_STEP_COMPLETE));
};
}
public function addStep(_arg1:ExtendedSound, _arg2:uint):void{
steps.push(new SequenceStep(_arg1, _arg2));
}
private function reset():void{
var channel:SoundChannel;
try {
channel = steps[_currStep].es.getSoundChannel();
channel.removeEventListener(Event.SOUND_COMPLETE, onSoundComplete);
} catch(e:Error) {
};
_currStep = -1;
cut = false;
}
public function removeStep(_arg1:uint):void{
steps.splice(_arg1, 1);
}
function stop():void{
steps[_currStep].es.stop();
reset();
}
private function onSoundComplete(_arg1:Event):void{
var _local2:SoundChannel;
_local2 = steps[_currStep].es.getSoundChannel();
_local2.removeEventListener(Event.SOUND_COMPLETE, onSoundComplete);
playNextStep();
}
public function get currSound():ExtendedSound{
if ((((_currStep < 0)) || ((_currStep >= steps.length)))){
if (steps.length > 0){
return (steps[0].sound);
};
return (null);
//unresolved jump
};
return (steps[_currStep].sound);
}
public function get currStep():int{
return (_currStep);
}
}
}//package uk.co.stdio.sound
Section 93
//Sequencer (uk.co.stdio.sound.Sequencer)
package uk.co.stdio.sound {
import flash.events.*;
public class Sequencer extends SoundManager {
private var playAfterCurrentStep:Boolean;
private var nextSequence:Sequence;
private var nextFirstStep:int;
private var _playing:Boolean;
private var _currSequence:Sequence;
private var currLoop:int;
private var currNumLoops:uint;
private var nextNumLoops:uint;
public function Sequencer(_arg1:String=""){
super(_arg1);
_playing = false;
}
public function stop():void{
_currSequence.stop();
_playing = false;
}
public function get currSequence():Sequence{
return (_currSequence);
}
public function playSequence(_arg1:Sequence, _arg2:uint=0, _arg3:Boolean=true):void{
nextSequence = _arg1;
nextNumLoops = _arg2;
playAfterCurrentStep = false;
nextFirstStep = -1;
if (_arg3){
playNewSequence();
};
_playing = true;
}
private function onSequenceComplete(_arg1:Event):void{
currLoop++;
if (currLoop >= currNumLoops){
playNewSequence();
} else {
_currSequence.start();
};
}
public function start():void{
_currSequence.start();
_playing = true;
}
private function onStepComplete(_arg1:Event):void{
if (((nextSequence) && (playAfterCurrentStep))){
_currSequence.stop();
playNewSequence();
playAfterCurrentStep = false;
};
}
private function playNewSequence():void{
if (nextSequence == null){
if (currNumLoops == 0){
currLoop = 0;
_currSequence.start();
};
} else {
if (_currSequence != null){
_currSequence.removeEventListener(Sequence.EVENT_SEQUENCE_COMPLETE, onSequenceComplete);
_currSequence.removeEventListener(Sequence.EVENT_STEP_COMPLETE, onStepComplete);
};
_currSequence = nextSequence;
_currSequence.addEventListener(Sequence.EVENT_SEQUENCE_COMPLETE, onSequenceComplete);
_currSequence.addEventListener(Sequence.EVENT_STEP_COMPLETE, onStepComplete);
currNumLoops = nextNumLoops;
nextSequence = null;
currLoop = 0;
_currSequence.start(nextFirstStep);
nextFirstStep = -1;
};
}
public function get playing():Boolean{
return (_playing);
}
public function cutToSequence(_arg1:Sequence, _arg2:uint=0, _arg3:int=0):void{
nextSequence = _arg1;
nextNumLoops = _arg2;
nextFirstStep = _arg3;
playAfterCurrentStep = true;
currSequence.cut = true;
}
}
}//package uk.co.stdio.sound
Section 94
//SequenceStep (uk.co.stdio.sound.SequenceStep)
package uk.co.stdio.sound {
import uk.co.stdio.sound.*;
class SequenceStep {
var numLoops:uint;
var es:ExtendedSound;
function SequenceStep(_arg1:ExtendedSound, _arg2:uint){
this.es = _arg1;
this.numLoops = _arg2;
}
public function get sound():ExtendedSound{
return (es);
}
}
}//package uk.co.stdio.sound
Section 95
//SoundManager (uk.co.stdio.sound.SoundManager)
package uk.co.stdio.sound {
public class SoundManager {
private var sounds:Array;
private var prevMasterVolume:Number;
private var muteState:Boolean;// = false
private var id:String;
private var masterVolume:Number;// = 1
private static var instanceList:Array = new Array();
private static var muted:Boolean = false;
public function SoundManager(_arg1:String=""){
prevMasterVolume = masterVolume;
sounds = new Array();
super();
this.id = _arg1;
instanceList.push(this);
}
public function stopAllSounds():void{
var _local1:String;
for (_local1 in sounds) {
sounds[_local1].stop();
};
}
public function getSoundFromID(_arg1:String):ExtendedSound{
return (sounds[_arg1]);
}
public function get muted():Boolean{
return (muteState);
}
public function registerSound(_arg1:ExtendedSound, _arg2:String):void{
if (sounds[_arg2] != null){
throw (new Error((((("ID conflict: A sound with the id[" + _arg2) + "] already exists in SoundManager[") + this.id) + "]'s sound list.")));
};
sounds[_arg2] = _arg1;
_arg1.setMasterVolume(masterVolume);
}
public function setMasterVolume(_arg1:Number):void{
var _local2:String;
prevMasterVolume = masterVolume;
masterVolume = Math.max(0, Math.min(1, _arg1));
for (_local2 in sounds) {
sounds[_local2].setMasterVolume(masterVolume);
};
}
public function toString():String{
var _local2:String;
var _local1 = "====================\n";
_local1 = (_local1 + (("SoundManager [" + id) + "]\n"));
_local1 = (_local1 + "--------------------\n");
_local1 = (_local1 + (("master vol[" + masterVolume) + "]\n"));
_local1 = (_local1 + "--------------------");
for (_local2 in sounds) {
_local1 = (_local1 + ("\n" + sounds[_local2].toString()));
};
_local1 = (_local1 + "\n====================");
return (_local1);
}
public function unmute():void{
if (muteState){
muteState = false;
setMasterVolume(prevMasterVolume);
};
}
public function mute():void{
if (!muteState){
muteState = true;
setMasterVolume(0);
};
}
public static function isGloballyMuted():Boolean{
return (muted);
}
public static function globalUnmute():void{
var _local1:int;
while (_local1 < instanceList.length) {
instanceList[_local1].unmute();
_local1++;
};
muted = false;
}
public static function globalMute():void{
var _local1:int;
while (_local1 < instanceList.length) {
instanceList[_local1].mute();
_local1++;
};
muted = true;
}
}
}//package uk.co.stdio.sound
Section 96
//Level (uk.kerb.locoRoco.game.level1.Level)
package uk.kerb.locoRoco.game.level1 {
import uk.co.stdio.sound.*;
import uk.kerb.locoRoco.game.*;
import uk.kerb.utils.game.*;
public class Level extends BaseLevel {
public function Level(_arg1:AssetFactory){
super(_arg1);
}
override protected function init():void{
var _local9:Sequence;
var _local10:ExtendedSound;
gravity = 140;
levelTime = 120000;
var _local1:Number = 2800;
var _local2:Number = 1100;
var _local3:Number = 650;
var _local4:Number = 530;
physics = new Physics(_local1, _local2, gravity, _local3, _local4);
var _local5:Number = 275;
var _local6:Number = 200;
var _local7:Number = 1650;
var _local8:Number = 1200;
renderer = new Renderer(_local5, _local6, _local7, _local8, _local1, _local2, af, physics);
house = new House(-830, 666, af);
house.frontMC.scaleX = -1;
house.backMC.scaleX = -1;
targets = new Array();
targets.push(new Target(1, renderer.flowers[0], renderer.lines[0], BaseLevel.ID_GREEN));
targets.push(new Target(1, renderer.flowers[1], renderer.lines[1], BaseLevel.ID_BLUE));
targets.push(new Target(1, renderer.flowers[2], renderer.lines[2], BaseLevel.ID_YELLOW));
powerups = new Array();
powerups.push(new Powerup(-940, -303, 100, Powerup.TYPE_POINTS));
powerups.push(new Powerup(-940, -438, 100, Powerup.TYPE_POINTS));
powerups.push(new Powerup(-418, -265, 100, Powerup.TYPE_POINTS));
powerups.push(new Powerup(-415, -383, 100, Powerup.TYPE_POINTS));
powerups.push(new Powerup(-249, 584, 100, Powerup.TYPE_POINTS));
powerups.push(new Powerup(-97, 542, 100, Powerup.TYPE_POINTS));
powerups.push(new Powerup(74, 510, 100, Powerup.TYPE_POINTS));
powerups.push(new Powerup(248, 510, 100, Powerup.TYPE_POINTS));
powerups.push(new Powerup(404, 540, 100, Powerup.TYPE_POINTS));
powerups.push(new Powerup(1360, 188, 100, Powerup.TYPE_POINTS));
powerups.push(new Powerup(1360, 40, 30000, Powerup.TYPE_TIME));
numPointsPowerups = 10;
musicLoops = new Array();
_local10 = smSequencer.getSoundFromID("Africa1");
_local9 = new Sequence();
_local9.addStep(_local10, 0);
musicLoops.push(_local9);
_local10 = smSequencer.getSoundFromID("Africa2");
_local9 = new Sequence();
_local9.addStep(_local10, 0);
musicLoops.push(_local9);
_local10 = smSequencer.getSoundFromID("Africa3");
_local9 = new Sequence();
_local9.addStep(_local10, 0);
musicLoops.push(_local9);
_local10 = smSequencer.getSoundFromID("Africa4");
_local9 = new Sequence();
_local9.addStep(_local10, 0);
musicLoops.push(_local9);
super.init();
}
}
}//package uk.kerb.locoRoco.game.level1
Section 97
//Physics (uk.kerb.locoRoco.game.level1.Physics)
package uk.kerb.locoRoco.game.level1 {
import uk.kerb.locoRoco.game.*;
import uk.kerb.utils.game.*;
import de.polygonal.motor2.dynamics.*;
import de.polygonal.motor2.collision.shapes.data.*;
public class Physics extends BasePhysics {
private var dividerStep:int;
private var d0:RigidBody;
private var d1:RigidBody;
private var d2:RigidBody;
private var toge:RigidBody;
private var dividerX:Array;
private var dividerY:Array;
private var dividerOffset0:int;
private var dividerOffset1:int;
private var dividerOffset2:int;
private var drumHead:RigidBody;
private var dividerR:Array;
private var numDividerSteps:int;
public function Physics(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Number){
var _local7:RigidBody;
var _local8:Array;
var _local9:CircleData;
var _local10:BoxData;
var _local6:Number = 8;
super(_arg1, _arg2, _arg3, _arg4, _arg5, _local6);
initWorldEdges(-1031, -1300, 1500, 800);
_local7 = createBody(defineCircle(65, 0, 0.5, 0.1), -887, 19);
bodies.push(_local7);
_local7 = createBody(defineCircle(65, 0, 0.5, 0.1), -871, 305);
bodies.push(_local7);
_local7 = createBody(defineBox(200, 80, 0, 0.5, 0.1, 0, 0, (105 * DEG_2_RAD)), -893, 129);
bodies.push(_local7);
_local7 = createBody(defineBox(200, 80, 0, 0.5, 0.1, 0, 0, (76 * DEG_2_RAD)), -869, 212);
bodies.push(_local7);
_local7 = createBody(defineBox(175, 800, 0, 0.5, 0.1), -950, 359);
bodies.push(_local7);
_local7 = createBody(defineBox(200, 80, 0, 0.5, 0.1, 0, 0, (24.6 * DEG_2_RAD)), -971, -46);
bodies.push(_local7);
_local7 = createBody(defineCircle(55, 0, 0.5, 0.1), -751, 576);
bodies.push(_local7);
_local8 = [-87, -66, 54, 26, 87, 66, -87, 66];
_local7 = createBody(definePoly(_local8, 0, 0.5, 0.1), -791, 481);
bodies.push(_local7);
_local7 = createBody(defineBox(400, 80, 0, 0.5, 0.1), -690, 748);
bodies.push(_local7);
_local7 = createBody(defineBox(1000, 80, 0, 0, 0.1, 0, 0, (1 * DEG_2_RAD)), 785, 733);
bodies.push(_local7);
_local7 = createBody(defineBox(160, 80, 0, 0.5, 0.1, 0, 0, (-15 * DEG_2_RAD)), 1303, 717);
bodies.push(_local7);
_local7 = createBody(defineBox(160, 80, 0, 0.5, 0.1, 0, 0, (-35 * DEG_2_RAD)), 1364, 687);
bodies.push(_local7);
_local7 = createBody(defineBox(160, 80, 0, 0.5, 0.1, 0, 0, (-60 * DEG_2_RAD)), 1444, 588);
bodies.push(_local7);
_local7 = createBody(defineBox(160, 80, 0, 0.5, 0.1, 0, 0, (-80 * DEG_2_RAD)), 1470, 493);
bodies.push(_local7);
_local7 = createBody(defineBox(80, 377, 0, 0.5, 0.1, 0, 0, (-2 * DEG_2_RAD)), 1477, 377);
bodies.push(_local7);
_local7 = createBody(defineBox(80, 270, 0, 0.5, 0.1, 0, 0, (4 * DEG_2_RAD)), 1480, 59);
bodies.push(_local7);
_local7 = createBody(defineCircle(157, 0, 0.5, 0.1), 1604, -46);
bodies.push(_local7);
_local7 = createBody(defineCircle(185, 0, 0.999, 0.001), 908, 815);
bodies.push(_local7);
_local7 = createBody(defineBox(309, 80, 0, 0.999, 0.001, 0, 0, 0.06), 740, 660);
bodies.push(_local7);
_local7 = createBody(defineBox(383, 79, 0, 0.999, 0.001, 0, 0, 0.15), 465, 624);
bodies.push(_local7);
_local7 = createBody(defineCircle(110, 0, 0.999, 0.001), -87, 0);
bodies.push(_local7);
_local7 = createBody(defineCircle(71, 0, 0.999, 0.001), -403, -132);
bodies.push(_local7);
_local7 = createBody(defineCircle(131, 0, 0.999, 0.001), -669, -52);
bodies.push(_local7);
_local7 = createBody(defineBox(317, 79, 0, 0.999, 0.001, 0, 0, 0.28), -239, -117);
bodies.push(_local7);
_local7 = createBody(defineBox(348, 79, 0, 0.999, 0.001, 0, 0, 0.51), -268, -21);
bodies.push(_local7);
_local7 = createBody(defineCircle(700, 0, 0.999, 0.001), 155, 1245);
bodies.push(_local7);
_local7 = createBody(defineBox(349, 80, 0, 0.999, 0.001, 0, 0, -0.15), -445, 719);
bodies.push(_local7);
_local7 = createBody(defineBox(348, 80, 0, 0.999, 0.001, 0, 0, -0.27), -220, 662);
bodies.push(_local7);
_local9 = defineCircle(70, 0, 0.999, 0.001);
_local9.groupIndex = -1;
_local7 = createBody(_local9, 1192, 332);
bodies.push(_local7);
_local10 = defineBox(0x0100, 116, 0, 0.999, 0.001, 0, 0, -0.11);
_local10.groupIndex = -1;
_local7 = createBody(_local10, 1318, 305);
bodies.push(_local7);
_local10 = defineBox(280, 80, 0, 0.999, 0.001, 0, 0, 0.04);
_local10.groupIndex = -1;
_local7 = createBody(_local10, 1323, 368);
bodies.push(_local7);
toge = createBody(defineCircle(25, 0, 0.5, 0.1), 1064, 676);
bodies.push(toge);
dividerOffset0 = 1;
dividerOffset1 = 57;
dividerOffset2 = 110;
var _local11:Number = 603;
var _local12:Number = 56;
var _local13:Number = 0.1;
var _local14:Number = 0.9;
dividerX = [(_local11 + 57), (_local11 + 64), (_local11 + 71), (_local11 + 78), (_local11 + 85), (_local11 + 92), (_local11 + 99), (_local11 + 106), (_local11 + 113), (_local11 + 120), (_local11 + 126), (_local11 + 132), (_local11 + 138), (_local11 + 144), (_local11 + 150), (_local11 + 156), (_local11 + 162), (_local11 + 168), (_local11 + 174), (_local11 + 180), (_local11 + 186), (_local11 + 192), (_local11 + 198), (_local11 + 204), (_local11 + 210), (_local11 + 219), (_local11 + 229), (_local11 + 238), (_local11 + 247), (_local11 + 0x0100), (_local11 + 264), (_local11 + 272), (_local11 + 274), (_local11 + 276), (_local11 + 277), (_local11 + 279), (_local11 + 281), (_local11 + 282), (_local11 + 280), (_local11 + 278), (_local11 + 276), (_local11 + 274), (_local11 + 271), (_local11 + 268), (_local11 + 265), (_local11 + 262), (_local11 + 258), (_local11 + 0xFF), (_local11 + 251), (_local11 + 247), (_local11 + 242), (_local11 + 237), (_local11 + 231), (_local11 + 226), (_local11 + 221), (_local11 + 216), (_local11 + 211), (_local11 + 206), (_local11 + 201), (_local11 + 196), (_local11 + 191), (_local11 + 186), (_local11 + 180), (_local11 + 175), (_local11 + 170), (_local11 + 165), (_local11 + 160), (_local11 + 154), (_local11 + 148), (_local11 + 142), (_local11 + 135), (_local11 + 129), (_local11 + 123), (_local11 + 117), (_local11 + 110), (_local11 + 104), (_local11 + 98), (_local11 + 91), (_local11 + 85), (_local11 + 79), (_local11 + 73), (_local11 + 66), (_local11 + 60), (_local11 + 54), (_local11 + 48), (_local11 + 41), (_local11 + 34), (_local11 + 28), (_local11 + 21), (_local11 + 14), (_local11 + 7), _local11, (_local11 - 7), (_local11 - 14), (_local11 - 21), (_local11 - 28), (_local11 - 35), (_local11 - 41), (_local11 - 48), (_local11 - 54), (_local11 - 61), (_local11 - 67), (_local11 - 74), (_local11 - 80), (_local11 - 86), (_local11 - 93), (_local11 - 99), (_local11 - 106), (_local11 - 112), (_local11 - 119), (_local11 - 126), (_local11 - 130), (_local11 - 135), (_local11 - 139), (_local11 - 144), (_local11 - 148), (_local11 - 152), (_local11 - 155), (_local11 - 158), (_local11 - 161), (_local11 - 161), (_local11 - 162), (_local11 - 162), (_local11 - 162), (_local11 - 161), (_local11 - 160), (_local11 - 158), (_local11 - 157), (_local11 - 152), (_local11 - 147), (_local11 - 141), (_local11 - 136), (_local11 - 130), (_local11 - 123), (_local11 - 116), (_local11 - 107), (_local11 - 99), (_local11 - 90), (_local11 - 82), (_local11 - 75), (_local11 - 67), (_local11 - 59), (_local11 - 51), (_local11 - 46), (_local11 - 41), (_local11 - 36), (_local11 - 30), (_local11 - 25), (_local11 - 19), (_local11 - 14), (_local11 - 14), (_local11 - 7), _local11, (_local11 + 7), (_local11 + 14), (_local11 + 21), (_local11 + 29), (_local11 + 36), (_local11 + 43), (_local11 + 50)];
dividerY = [(_local12 + 20), (_local12 + 19), (_local12 + 17), (_local12 + 16), (_local12 + 15), (_local12 + 14), (_local12 + 12), (_local12 + 11), (_local12 + 10), (_local12 + 9), (_local12 + 7), (_local12 + 4), (_local12 + 2), _local12, (_local12 - 2), (_local12 - 5), (_local12 - 7), (_local12 - 9), (_local12 - 11), (_local12 - 13), (_local12 - 15), (_local12 - 17), (_local12 - 19), (_local12 - 20), (_local12 - 22), (_local12 - 20), (_local12 - 16), (_local12 - 12), (_local12 - 7), (_local12 - 2), (_local12 + 4), (_local12 + 10), (_local12 + 15), (_local12 + 19), (_local12 + 24), (_local12 + 29), (_local12 + 33), (_local12 + 38), (_local12 + 44), (_local12 + 50), (_local12 + 56), (_local12 + 62), (_local12 + 68), (_local12 + 74), (_local12 + 80), (_local12 + 86), (_local12 + 92), (_local12 + 97), (_local12 + 103), (_local12 + 108), (_local12 + 111), (_local12 + 113), (_local12 + 115), (_local12 + 118), (_local12 + 121), (_local12 + 123), (_local12 + 126), (_local12 + 128), (_local12 + 131), (_local12 + 133), (_local12 + 135), (_local12 + 138), (_local12 + 140), (_local12 + 143), (_local12 + 145), (_local12 + 148), (_local12 + 150), (_local12 + 151), (_local12 + 152), (_local12 + 153), (_local12 + 154), (_local12 + 156), (_local12 + 157), (_local12 + 158), (_local12 + 159), (_local12 + 160), (_local12 + 161), (_local12 + 161), (_local12 + 162), (_local12 + 163), (_local12 + 164), (_local12 + 165), (_local12 + 166), (_local12 + 167), (_local12 + 168), (_local12 + 169), (_local12 + 168), (_local12 + 168), (_local12 + 168), (_local12 + 168), (_local12 + 168), (_local12 + 168), (_local12 + 167), (_local12 + 167), (_local12 + 167), (_local12 + 167), (_local12 + 164), (_local12 + 162), (_local12 + 160), (_local12 + 158), (_local12 + 155), (_local12 + 153), (_local12 + 151), (_local12 + 149), (_local12 + 146), (_local12 + 144), (_local12 + 141), (_local12 + 139), (_local12 + 136), (_local12 + 133), (_local12 + 130), (_local12 + 126), (_local12 + 121), (_local12 + 117), (_local12 + 111), (_local12 + 106), (_local12 + 101), (_local12 + 95), (_local12 + 89), (_local12 + 82), (_local12 + 75), (_local12 + 67), (_local12 + 59), (_local12 + 51), (_local12 + 45), (_local12 + 40), (_local12 + 34), (_local12 + 28), (_local12 + 22), (_local12 + 16), (_local12 + 10), (_local12 + 5), _local12, (_local12 - 6), (_local12 - 11), (_local12 - 12), (_local12 - 13), (_local12 - 14), (_local12 - 13), (_local12 - 11), (_local12 - 10), (_local12 - 8), (_local12 - 6), (_local12 - 4), (_local12 - 1), (_local12 + 2), (_local12 + 4), (_local12 + 7), (_local12 + 9), (_local12 + 12), (_local12 + 12), (_local12 + 13), (_local12 + 14), (_local12 + 15), (_local12 + 16), (_local12 + 17), (_local12 + 18), (_local12 + 19), (_local12 + 20), (_local12 + 21)];
dividerR = [-0.13, -0.17, -0.2, -0.23, -0.26, -0.29, -0.32, -0.35, -0.38, -0.41, -0.38, -0.34, -0.31, -0.27, -0.24, -0.2, -0.17, -0.13, -0.1, -0.06, -0.03, 0, 0.03, 0.07, 0.11, 0.25, 0.4, 0.55, 0.7, 0.84, 0.99, 1.14, 1.21, 1.28, 1.34, 1.41, 1.48, 1.54, 1.62, 1.71, 1.79, 1.87, 1.96, 2.04, 2.12, 2.2, 2.29, 2.37, 2.45, 2.54, 2.55, 2.57, 2.58, 2.59, 2.61, 2.62, 2.64, 2.65, 2.67, 2.68, 2.69, 2.71, 2.72, 2.74, 2.75, 2.77, 2.78, 2.8, 2.83, 2.85, 2.87, 2.9, 2.92, 2.94, 2.96, 2.98, 3.01, 3.03, 3.05, 3.08, 3.1, 3.12, -3.13, -3.11, -3.09, -3.06, -3.04, -3.02, -3, -2.97, -2.95, -2.93, -2.91, -2.89, -2.86, -2.84, -2.82, -2.8, -2.77, -2.75, -2.73, -2.71, -2.68, -2.66, -2.64, -2.61, -2.58, -2.55, -2.51, -2.48, -2.45, -2.37, -2.29, -2.21, -2.13, -2.05, -1.97, -1.87, -1.78, -1.68, -1.58, -1.49, -1.4, -1.3, -1.21, -1.12, -1.04, -0.95, -0.86, -0.77, -0.69, -0.6, -0.51, -0.41, -0.3, -0.19, -0.08, 0.02, 0.07, 0.11, 0.16, 0.21, 0.26, 0.24, 0.23, 0.21, 0.2, 0.19, 0.17, 0.16, 0.16, 0.13, 0.1, 0.07, 0.04, 0.01, -0.01, -0.04, -0.07, -0.1];
dividerStep = -1;
numDividerSteps = dividerX.length;
_local7 = createBody(defineCircle(50, 0, _local13, _local14), (_local11 - 86), (_local12 + 66));
bodies.push(_local7);
_local7 = createBody(defineCircle(40, 0, _local13, _local14), (_local11 + 214), (_local12 + 44));
bodies.push(_local7);
_local8 = [-68, 18, 48, 42, 28, 142, -64, 128, -108, 112];
_local7 = createBody(definePoly(_local8, 0, _local13, _local14), _local11, _local12);
bodies.push(_local7);
_local8 = [48, 42, 94, 38, 96, 138, 28, 142];
_local7 = createBody(definePoly(_local8, 0, _local13, _local14), _local11, _local12);
bodies.push(_local7);
_local8 = [94, 38, 202, 6, 246, 70, 220, 94, 174, 118, 96, 138];
_local7 = createBody(definePoly(_local8, 0, _local13, _local14), _local11, _local12);
bodies.push(_local7);
d0 = createBody(defineBox(50, 80, 0, _local13, _local14), -1000, -1000);
bodies.push(d0);
d1 = createBody(defineBox(50, 80, 0, _local13, _local14), -1100, -1000);
bodies.push(d1);
d2 = createBody(defineBox(50, 80, 0, _local13, _local14), -1200, -1000);
bodies.push(d2);
}
override public function step(_arg1:Number, _arg2:Boolean):void{
var _local3:int;
var _local4:int;
var _local5:Number;
var _local6:Number;
var _local7:Number;
if (_arg2){
_local4 = 0;
while (_local4 < 6) {
super.step(_arg1, true);
_local4++;
};
blob.step(world, _arg1);
};
dividerStep++;
_local3 = ((dividerStep + dividerOffset0) % numDividerSteps);
d0.setCenter(dividerX[_local3], dividerY[_local3], dividerR[_local3]);
_local3 = ((dividerStep + dividerOffset1) % numDividerSteps);
d1.setCenter(dividerX[_local3], dividerY[_local3], dividerR[_local3]);
_local3 = ((dividerStep + dividerOffset2) % numDividerSteps);
d2.setCenter(dividerX[_local3], dividerY[_local3], dividerR[_local3]);
if (toge.contactList){
_local5 = (blob.centreNode.x - toge.x);
_local6 = (blob.centreNode.y - toge.y);
_local7 = Math.sqrt(((_local5 * _local5) + (_local6 * _local6)));
_local5 = (_local5 / _local7);
_local6 = (_local6 / _local7);
_local5 = (_local5 * 8000);
_local6 = (_local6 * 8000);
blob.canJump = true;
blob.jump(_local5, _local6, world);
Main.smSFX.getSoundFromID("SpikeSFX").play();
};
}
}
}//package uk.kerb.locoRoco.game.level1
Section 98
//Renderer (uk.kerb.locoRoco.game.level1.Renderer)
package uk.kerb.locoRoco.game.level1 {
import uk.kerb.locoRoco.game.*;
import uk.kerb.utils.game.*;
import flash.display.*;
public class Renderer extends BaseRenderer {
private var conveyor:MovieClip;
public function Renderer(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Number, _arg6:Number, _arg7:AssetFactory, _arg8:BasePhysics){
super(_arg1, _arg2, _arg3, _arg4, _arg5, _arg6, _arg7, _arg8);
var _local9:MovieClip = (_arg7.createDisplayObject("Level1BGAsset") as MovieClip);
backgroundSprite.addChild(_local9);
flowers = new Array();
flowers.push(_local9.conveyor.flower0);
flowers.push(_local9.conveyor.flower1);
flowers.push(_local9.conveyor.flower2);
lines = new Array();
lines.push(_local9.conveyor.line0);
lines.push(_local9.conveyor.line1);
lines.push(_local9.conveyor.line2);
conveyor = _local9.conveyor;
}
override public function resumeAnimations():void{
var _local1:int;
conveyor.play();
_local1 = 0;
while (_local1 < flowers.length) {
flowers[_local1].play();
_local1++;
};
_local1 = 0;
while (_local1 < lines.length) {
lines[_local1].play();
_local1++;
};
conveyor.gear0.play();
conveyor.gear1.play();
conveyor.gear2.play();
conveyor.gear3.play();
conveyor.gear4.play();
}
override public function pauseAnimations():void{
var _local1:int;
conveyor.stop();
_local1 = 0;
while (_local1 < flowers.length) {
flowers[_local1].stop();
_local1++;
};
_local1 = 0;
while (_local1 < lines.length) {
lines[_local1].stop();
_local1++;
};
conveyor.gear0.stop();
conveyor.gear1.stop();
conveyor.gear2.stop();
conveyor.gear3.stop();
conveyor.gear4.stop();
}
}
}//package uk.kerb.locoRoco.game.level1
Section 99
//Level (uk.kerb.locoRoco.game.level2.Level)
package uk.kerb.locoRoco.game.level2 {
import uk.co.stdio.sound.*;
import uk.kerb.locoRoco.game.*;
import uk.kerb.utils.game.*;
public class Level extends BaseLevel {
public function Level(_arg1:AssetFactory){
super(_arg1);
}
override protected function init():void{
var _local9:Sequence;
var _local10:ExtendedSound;
gravity = 140;
levelTime = 120000;
var _local1:Number = 2200;
var _local2:Number = 1500;
var _local3:Number = 100;
var _local4:Number = -320;
physics = new Physics(_local1, _local2, gravity, _local3, _local4);
var _local5:Number = 275;
var _local6:Number = 200;
var _local7:Number = 1650;
var _local8:Number = 1200;
renderer = new Renderer(_local5, _local6, _local7, _local8, _local1, _local2, af, physics);
house = new House(422, 666, af);
targets = new Array();
targets.push(new Target(1, renderer.flowers[0], renderer.lines[0], BaseLevel.ID_PURPLE));
targets.push(new Target(1, renderer.flowers[1], renderer.lines[1], BaseLevel.ID_GREEN));
targets.push(new Target(1, renderer.flowers[2], renderer.lines[2], BaseLevel.ID_YELLOW));
powerups = new Array();
powerups.push(new Powerup(891, -300, 100, Powerup.TYPE_POINTS));
powerups.push(new Powerup(891, -420, 100, Powerup.TYPE_POINTS));
powerups.push(new Powerup(891, -540, 30000, Powerup.TYPE_TIME));
powerups.push(new Powerup(-445, 161, 100, Powerup.TYPE_POINTS));
powerups.push(new Powerup(-768, 360, 100, Powerup.TYPE_POINTS));
powerups.push(new Powerup(-842, 247, 100, Powerup.TYPE_POINTS));
powerups.push(new Powerup(-899, 125, 100, Powerup.TYPE_POINTS));
powerups.push(new Powerup(-926, -200, 100, Powerup.TYPE_POINTS));
powerups.push(new Powerup(-926, -350, 100, Powerup.TYPE_POINTS));
powerups.push(new Powerup(0, -310, 100, Powerup.TYPE_POINTS));
powerups.push(new Powerup(-51, 80, 100, Powerup.TYPE_POINTS));
numPointsPowerups = 10;
(physics as Physics).drum1MC = (renderer as Renderer).drum1;
(physics as Physics).drum2MC = (renderer as Renderer).drum2;
(physics as Physics).drum3MC = (renderer as Renderer).drum3;
musicLoops = new Array();
_local10 = smSequencer.getSoundFromID("Africa1");
_local9 = new Sequence();
_local9.addStep(_local10, 0);
musicLoops.push(_local9);
_local10 = smSequencer.getSoundFromID("Africa2");
_local9 = new Sequence();
_local9.addStep(_local10, 0);
musicLoops.push(_local9);
_local10 = smSequencer.getSoundFromID("Africa3");
_local9 = new Sequence();
_local9.addStep(_local10, 0);
musicLoops.push(_local9);
_local10 = smSequencer.getSoundFromID("Africa4");
_local9 = new Sequence();
_local9.addStep(_local10, 0);
musicLoops.push(_local9);
super.init();
}
}
}//package uk.kerb.locoRoco.game.level2
Section 100
//Physics (uk.kerb.locoRoco.game.level2.Physics)
package uk.kerb.locoRoco.game.level2 {
import uk.kerb.locoRoco.game.*;
import uk.kerb.utils.game.*;
import flash.display.*;
import de.polygonal.motor2.dynamics.*;
import de.polygonal.motor2.collision.shapes.data.*;
import de.polygonal.motor2.dynamics.contact.*;
public class Physics extends BasePhysics {
private var dividerStep:int;
private var movingBlockStep:Number;// = 1
private var d0:RigidBody;
private var d1:RigidBody;
private var d2:RigidBody;
private var drum1:RigidBody;
private var drum3:RigidBody;
private var dividerR:Array;
private var drum2:RigidBody;
private var dividerX:Array;
private var dividerY:Array;
public var drum2MC:MovieClip;
public var drum3MC:MovieClip;
private var dividerOffset0:int;
private var dividerOffset1:int;
private var dividerOffset2:int;
private var movingBlock:RigidBody;
public var drum1MC:MovieClip;
private var toge:RigidBody;
private var numDividerSteps:int;
public function Physics(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Number){
var _local7:RigidBody;
var _local8:Array;
var _local9:BoxData;
var _local10:CircleData;
var _local6:Number = 8;
super(_arg1, _arg2, _arg3, _arg4, _arg5, _local6);
initWorldEdges(-1031, -1250, 1031, 750);
_local7 = createBody(defineBox(240, 80, 0, 0.5, 0.1, 0, 0, (-25 * DEG_2_RAD)), 579, -55);
bodies.push(_local7);
_local7 = createBody(defineCircle(65, 0, 0.5, 0.1), 478, 19);
bodies.push(_local7);
_local7 = createBody(defineBox(200, 80, 0, 0.5, 0.1, 0, 0, (-105 * DEG_2_RAD)), 483, 129);
bodies.push(_local7);
_local7 = createBody(defineBox(200, 80, 0, 0.5, 0.1, 0, 0, (-76 * DEG_2_RAD)), 460, 212);
bodies.push(_local7);
_local7 = createBody(defineBox(175, 800, 0, 0.5, 0.1), 541, 359);
bodies.push(_local7);
_local7 = createBody(defineBox(400, 80, 0, 0.5, 0.1), 872, -101);
bodies.push(_local7);
_local7 = createBody(defineBox(300, 50, 0, 0.5, 0.1), 395, 297);
bodies.push(_local7);
_local7 = createBody(defineBox(200, 80, 0, 0.5, 0.1, 0, 0, (-12 * DEG_2_RAD)), 352, 337);
bodies.push(_local7);
_local7 = createBody(defineCircle(62, 0, 0.5, 0.1), 252, 335);
bodies.push(_local7);
_local7 = createBody(defineCircle(55, 0, 0.5, 0.1), 342, 576);
bodies.push(_local7);
_local8 = [-87, 66, -54, 26, 87, -66, 87, 66];
_local7 = createBody(definePoly(_local8, 0, 0.5, 0.1), 382, 481);
bodies.push(_local7);
_local7 = createBody(defineBox(1200, 80, 0, 0.5, 0.1, 0, 0, (1.5 * DEG_2_RAD)), 462, 750);
bodies.push(_local7);
_local7 = createBody(defineCircle(157, 0, 0.5, 0.1), -1133, -46);
bodies.push(_local7);
_local7 = createBody(defineBox(80, 200, 0, 0, 0.1, 0, 0, (-8.6 * DEG_2_RAD)), -1001, 59);
bodies.push(_local7);
_local7 = createBody(defineBox(80, 300, 0, 0, 0.1, 0, 0, (-24.3 * DEG_2_RAD)), -927, 265);
bodies.push(_local7);
_local7 = createBody(defineBox(80, 300, 0, 0, 0.1, 0, 0, (-41.2 * DEG_2_RAD)), -786, 468);
bodies.push(_local7);
_local7 = createBody(defineBox(80, 250, 0, 0, 0.1, 0, 0, (-52.3 * DEG_2_RAD)), -646, 591);
bodies.push(_local7);
_local7 = createBody(defineBox(250, 80, 0, 0, 0.1, 0, 0, (18.8 * DEG_2_RAD)), -447, 691);
bodies.push(_local7);
_local7 = createBody(defineBox(250, 80, 0, 0, 0.1, 0, 0, (1.3 * DEG_2_RAD)), -197, 734);
bodies.push(_local7);
_local7 = createBody(defineCircle(70, 0, 0.5, 0.1), -802, -344);
bodies.push(_local7);
_local8 = [-53, -96, 78, 18, 72, 95, -64, 96, -78, -22];
_local7 = createBody(definePoly(_local8, 0, 0.5, 0.1), -806, -422);
bodies.push(_local7);
drum1 = createBody(defineBox(170, 80, 0, 0.5, 0.1, 0, 0, (55.7 * DEG_2_RAD)), -780, -471);
bodies.push(drum1);
_local7 = createBody(defineCircle(70, 0, 0.5, 0.1), -595, 393);
bodies.push(_local7);
_local8 = [-53, -96, 78, 18, 72, 95, -64, 96, -78, -22];
_local7 = createBody(definePoly(_local8, 0, 0.5, 0.1), -599, 315);
bodies.push(_local7);
drum2 = createBody(defineBox(170, 80, 0, 0.5, 0.1, 0, 0, (55.7 * DEG_2_RAD)), -573, 266);
bodies.push(drum2);
_local7 = createBody(defineCircle(80, 0, 0.5, 0.1), 109, 230);
bodies.push(_local7);
_local8 = [9, -110, 60, -77, 96, 60, -39, 110, -96, 24];
_local7 = createBody(definePoly(_local8, 0, 0.5, 0.1), 93, 178);
bodies.push(_local7);
drum3 = createBody(defineBox(170, 80, 0, 0.5, 0.1, 0, 0, (-49.8 * DEG_2_RAD)), 51, 136);
bodies.push(drum3);
_local9 = defineBox(492, 119, 0, 0.999, 0.001, 0, 0, 0);
_local9.groupIndex = -1;
_local7 = createBody(_local9, -819, -55);
bodies.push(_local7);
_local10 = defineCircle(68, 0, 0.999, 0.001);
_local10.groupIndex = -1;
_local7 = createBody(_local10, -578, -50);
bodies.push(_local7);
_local9 = defineBox(252, 64, 0, 0.999, 0.001, 0, 0, 0);
_local9.groupIndex = -1;
_local7 = createBody(_local9, 14, -212);
bodies.push(_local7);
_local10 = defineCircle(53, 0, 0.999, 0.001);
_local10.groupIndex = -1;
_local7 = createBody(_local10, -115, -194);
bodies.push(_local7);
_local10 = defineCircle(37, 0, 0.999, 0.001);
_local10.groupIndex = -1;
_local7 = createBody(_local10, 137, -208);
bodies.push(_local7);
toge = createBody(defineCircle(25, 0, 0.5, 0.1), 707, -163);
bodies.push(toge);
dividerOffset0 = 1;
dividerOffset1 = 57;
dividerOffset2 = 110;
var _local11:Number = -39;
var _local12:Number = -709;
var _local13:Number = 0.1;
var _local14:Number = 0.9;
dividerX = [(_local11 + 57), (_local11 + 64), (_local11 + 71), (_local11 + 78), (_local11 + 85), (_local11 + 92), (_local11 + 99), (_local11 + 106), (_local11 + 113), (_local11 + 120), (_local11 + 126), (_local11 + 132), (_local11 + 138), (_local11 + 144), (_local11 + 150), (_local11 + 156), (_local11 + 162), (_local11 + 168), (_local11 + 174), (_local11 + 180), (_local11 + 186), (_local11 + 192), (_local11 + 198), (_local11 + 204), (_local11 + 210), (_local11 + 219), (_local11 + 229), (_local11 + 238), (_local11 + 247), (_local11 + 0x0100), (_local11 + 264), (_local11 + 272), (_local11 + 274), (_local11 + 276), (_local11 + 277), (_local11 + 279), (_local11 + 281), (_local11 + 282), (_local11 + 280), (_local11 + 278), (_local11 + 276), (_local11 + 274), (_local11 + 271), (_local11 + 268), (_local11 + 265), (_local11 + 262), (_local11 + 258), (_local11 + 0xFF), (_local11 + 251), (_local11 + 247), (_local11 + 242), (_local11 + 237), (_local11 + 231), (_local11 + 226), (_local11 + 221), (_local11 + 216), (_local11 + 211), (_local11 + 206), (_local11 + 201), (_local11 + 196), (_local11 + 191), (_local11 + 186), (_local11 + 180), (_local11 + 175), (_local11 + 170), (_local11 + 165), (_local11 + 160), (_local11 + 154), (_local11 + 148), (_local11 + 142), (_local11 + 135), (_local11 + 129), (_local11 + 123), (_local11 + 117), (_local11 + 110), (_local11 + 104), (_local11 + 98), (_local11 + 91), (_local11 + 85), (_local11 + 79), (_local11 + 73), (_local11 + 66), (_local11 + 60), (_local11 + 54), (_local11 + 48), (_local11 + 41), (_local11 + 34), (_local11 + 28), (_local11 + 21), (_local11 + 14), (_local11 + 7), _local11, (_local11 - 7), (_local11 - 14), (_local11 - 21), (_local11 - 28), (_local11 - 35), (_local11 - 41), (_local11 - 48), (_local11 - 54), (_local11 - 61), (_local11 - 67), (_local11 - 74), (_local11 - 80), (_local11 - 86), (_local11 - 93), (_local11 - 99), (_local11 - 106), (_local11 - 112), (_local11 - 119), (_local11 - 126), (_local11 - 130), (_local11 - 135), (_local11 - 139), (_local11 - 144), (_local11 - 148), (_local11 - 152), (_local11 - 155), (_local11 - 158), (_local11 - 161), (_local11 - 161), (_local11 - 162), (_local11 - 162), (_local11 - 162), (_local11 - 161), (_local11 - 160), (_local11 - 158), (_local11 - 157), (_local11 - 152), (_local11 - 147), (_local11 - 141), (_local11 - 136), (_local11 - 130), (_local11 - 123), (_local11 - 116), (_local11 - 107), (_local11 - 99), (_local11 - 90), (_local11 - 82), (_local11 - 75), (_local11 - 67), (_local11 - 59), (_local11 - 51), (_local11 - 46), (_local11 - 41), (_local11 - 36), (_local11 - 30), (_local11 - 25), (_local11 - 19), (_local11 - 14), (_local11 - 14), (_local11 - 7), _local11, (_local11 + 7), (_local11 + 14), (_local11 + 21), (_local11 + 29), (_local11 + 36), (_local11 + 43), (_local11 + 50)];
dividerY = [(_local12 + 20), (_local12 + 19), (_local12 + 17), (_local12 + 16), (_local12 + 15), (_local12 + 14), (_local12 + 12), (_local12 + 11), (_local12 + 10), (_local12 + 9), (_local12 + 7), (_local12 + 4), (_local12 + 2), _local12, (_local12 - 2), (_local12 - 5), (_local12 - 7), (_local12 - 9), (_local12 - 11), (_local12 - 13), (_local12 - 15), (_local12 - 17), (_local12 - 19), (_local12 - 20), (_local12 - 22), (_local12 - 20), (_local12 - 16), (_local12 - 12), (_local12 - 7), (_local12 - 2), (_local12 + 4), (_local12 + 10), (_local12 + 15), (_local12 + 19), (_local12 + 24), (_local12 + 29), (_local12 + 33), (_local12 + 38), (_local12 + 44), (_local12 + 50), (_local12 + 56), (_local12 + 62), (_local12 + 68), (_local12 + 74), (_local12 + 80), (_local12 + 86), (_local12 + 92), (_local12 + 97), (_local12 + 103), (_local12 + 108), (_local12 + 111), (_local12 + 113), (_local12 + 115), (_local12 + 118), (_local12 + 121), (_local12 + 123), (_local12 + 126), (_local12 + 128), (_local12 + 131), (_local12 + 133), (_local12 + 135), (_local12 + 138), (_local12 + 140), (_local12 + 143), (_local12 + 145), (_local12 + 148), (_local12 + 150), (_local12 + 151), (_local12 + 152), (_local12 + 153), (_local12 + 154), (_local12 + 156), (_local12 + 157), (_local12 + 158), (_local12 + 159), (_local12 + 160), (_local12 + 161), (_local12 + 161), (_local12 + 162), (_local12 + 163), (_local12 + 164), (_local12 + 165), (_local12 + 166), (_local12 + 167), (_local12 + 168), (_local12 + 169), (_local12 + 168), (_local12 + 168), (_local12 + 168), (_local12 + 168), (_local12 + 168), (_local12 + 168), (_local12 + 167), (_local12 + 167), (_local12 + 167), (_local12 + 167), (_local12 + 164), (_local12 + 162), (_local12 + 160), (_local12 + 158), (_local12 + 155), (_local12 + 153), (_local12 + 151), (_local12 + 149), (_local12 + 146), (_local12 + 144), (_local12 + 141), (_local12 + 139), (_local12 + 136), (_local12 + 133), (_local12 + 130), (_local12 + 126), (_local12 + 121), (_local12 + 117), (_local12 + 111), (_local12 + 106), (_local12 + 101), (_local12 + 95), (_local12 + 89), (_local12 + 82), (_local12 + 75), (_local12 + 67), (_local12 + 59), (_local12 + 51), (_local12 + 45), (_local12 + 40), (_local12 + 34), (_local12 + 28), (_local12 + 22), (_local12 + 16), (_local12 + 10), (_local12 + 5), _local12, (_local12 - 6), (_local12 - 11), (_local12 - 12), (_local12 - 13), (_local12 - 14), (_local12 - 13), (_local12 - 11), (_local12 - 10), (_local12 - 8), (_local12 - 6), (_local12 - 4), (_local12 - 1), (_local12 + 2), (_local12 + 4), (_local12 + 7), (_local12 + 9), (_local12 + 12), (_local12 + 12), (_local12 + 13), (_local12 + 14), (_local12 + 15), (_local12 + 16), (_local12 + 17), (_local12 + 18), (_local12 + 19), (_local12 + 20), (_local12 + 21)];
dividerR = [-0.13, -0.17, -0.2, -0.23, -0.26, -0.29, -0.32, -0.35, -0.38, -0.41, -0.38, -0.34, -0.31, -0.27, -0.24, -0.2, -0.17, -0.13, -0.1, -0.06, -0.03, 0, 0.03, 0.07, 0.11, 0.25, 0.4, 0.55, 0.7, 0.84, 0.99, 1.14, 1.21, 1.28, 1.34, 1.41, 1.48, 1.54, 1.62, 1.71, 1.79, 1.87, 1.96, 2.04, 2.12, 2.2, 2.29, 2.37, 2.45, 2.54, 2.55, 2.57, 2.58, 2.59, 2.61, 2.62, 2.64, 2.65, 2.67, 2.68, 2.69, 2.71, 2.72, 2.74, 2.75, 2.77, 2.78, 2.8, 2.83, 2.85, 2.87, 2.9, 2.92, 2.94, 2.96, 2.98, 3.01, 3.03, 3.05, 3.08, 3.1, 3.12, -3.13, -3.11, -3.09, -3.06, -3.04, -3.02, -3, -2.97, -2.95, -2.93, -2.91, -2.89, -2.86, -2.84, -2.82, -2.8, -2.77, -2.75, -2.73, -2.71, -2.68, -2.66, -2.64, -2.61, -2.58, -2.55, -2.51, -2.48, -2.45, -2.37, -2.29, -2.21, -2.13, -2.05, -1.97, -1.87, -1.78, -1.68, -1.58, -1.49, -1.4, -1.3, -1.21, -1.12, -1.04, -0.95, -0.86, -0.77, -0.69, -0.6, -0.51, -0.41, -0.3, -0.19, -0.08, 0.02, 0.07, 0.11, 0.16, 0.21, 0.26, 0.24, 0.23, 0.21, 0.2, 0.19, 0.17, 0.16, 0.16, 0.13, 0.1, 0.07, 0.04, 0.01, -0.01, -0.04, -0.07, -0.1];
dividerStep = -1;
numDividerSteps = dividerX.length;
_local7 = createBody(defineCircle(50, 0, _local13, _local14), (_local11 - 86), (_local12 + 66));
bodies.push(_local7);
_local7 = createBody(defineCircle(40, 0, _local13, _local14), (_local11 + 214), (_local12 + 44));
bodies.push(_local7);
_local8 = [-68, 18, 48, 42, 28, 142, -64, 128, -108, 112];
_local7 = createBody(definePoly(_local8, 0, _local13, _local14), _local11, _local12);
bodies.push(_local7);
_local8 = [48, 42, 94, 38, 96, 138, 28, 142];
_local7 = createBody(definePoly(_local8, 0, _local13, _local14), _local11, _local12);
bodies.push(_local7);
_local8 = [94, 38, 202, 6, 246, 70, 220, 94, 174, 118, 96, 138];
_local7 = createBody(definePoly(_local8, 0, _local13, _local14), _local11, _local12);
bodies.push(_local7);
d0 = createBody(defineBox(50, 80, 0, _local13, _local14), -1000, -1000);
bodies.push(d0);
d1 = createBody(defineBox(50, 80, 0, _local13, _local14), -1100, -1000);
bodies.push(d1);
d2 = createBody(defineBox(50, 80, 0, _local13, _local14), -1200, -1000);
bodies.push(d2);
}
override public function step(_arg1:Number, _arg2:Boolean):void{
var _local3:int;
var _local4:Manifold;
var _local5:Number;
var _local6:Number;
var _local7:int;
var _local8:Number;
var _local9:Number;
var _local10:Number;
if (_arg2){
_local7 = 0;
while (_local7 < 6) {
super.step(_arg1, true);
_local7++;
};
blob.step(world, _arg1);
};
dividerStep++;
_local3 = ((dividerStep + dividerOffset0) % numDividerSteps);
d0.setCenter(dividerX[_local3], dividerY[_local3], dividerR[_local3]);
_local3 = ((dividerStep + dividerOffset1) % numDividerSteps);
d1.setCenter(dividerX[_local3], dividerY[_local3], dividerR[_local3]);
_local3 = ((dividerStep + dividerOffset2) % numDividerSteps);
d2.setCenter(dividerX[_local3], dividerY[_local3], dividerR[_local3]);
if (toge.contactList){
_local8 = (blob.centreNode.x - toge.x);
_local9 = (blob.centreNode.y - toge.y);
_local10 = Math.sqrt(((_local8 * _local8) + (_local9 * _local9)));
_local8 = (_local8 / _local10);
_local9 = (_local9 / _local10);
_local8 = (_local8 * 8000);
_local9 = (_local9 * 8000);
blob.canJump = true;
blob.jump(_local8, _local9, world);
Main.smSFX.getSoundFromID("SpikeSFX").play();
};
if (drum1.contactList){
_local4 = drum1.contactList.contact.manifolds[0];
if ((((_local4.nx > 0.8)) && ((_local4.ny < -0.5)))){
_local5 = 13000;
_local6 = -13000;
blob.canJump = true;
blob.jump(_local5, _local6, world);
drum1MC.gotoAndPlay("hit");
Main.smSFX.getSoundFromID("DrumSFX").play();
};
} else {
if (drum2.contactList){
_local4 = drum2.contactList.contact.manifolds[0];
if ((((_local4.nx > 0.8)) && ((_local4.ny < -0.5)))){
_local5 = 18228;
_local6 = -9000;
blob.canJump = true;
blob.jump(_local5, _local6, world);
drum2MC.gotoAndPlay("hit");
Main.smSFX.getSoundFromID("DrumSFX").play();
};
} else {
if (drum3.contactList){
_local4 = drum3.contactList.contact.manifolds[0];
if ((((_local4.nx < -0.7)) && ((_local4.ny < -0.6)))){
_local5 = -13000;
_local6 = -17000;
blob.canJump = true;
blob.jump(_local5, _local6, world);
drum3MC.gotoAndPlay("hit");
Main.smSFX.getSoundFromID("DrumSFX").play();
};
};
};
};
}
}
}//package uk.kerb.locoRoco.game.level2
Section 101
//Renderer (uk.kerb.locoRoco.game.level2.Renderer)
package uk.kerb.locoRoco.game.level2 {
import uk.kerb.locoRoco.game.*;
import uk.kerb.utils.game.*;
import flash.display.*;
public class Renderer extends BaseRenderer {
private var conveyor:MovieClip;
public var drum3:MovieClip;
public var drum1:MovieClip;
public var drum2:MovieClip;
public function Renderer(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Number, _arg6:Number, _arg7:AssetFactory, _arg8:BasePhysics){
super(_arg1, _arg2, _arg3, _arg4, _arg5, _arg6, _arg7, _arg8);
var _local9:MovieClip = (_arg7.createDisplayObject("Level2BGAsset") as MovieClip);
backgroundSprite.addChild(_local9);
flowers = new Array();
flowers.push(_local9.conveyor.flower0);
flowers.push(_local9.conveyor.flower1);
flowers.push(_local9.conveyor.flower2);
lines = new Array();
lines.push(_local9.conveyor.line0);
lines.push(_local9.conveyor.line1);
lines.push(_local9.conveyor.line2);
conveyor = _local9.conveyor;
drum1 = _local9.drum1.head;
drum2 = _local9.drum2.head;
drum3 = _local9.drum3.head;
}
override public function pauseAnimations():void{
var _local1:int;
conveyor.stop();
_local1 = 0;
while (_local1 < flowers.length) {
flowers[_local1].stop();
_local1++;
};
_local1 = 0;
while (_local1 < lines.length) {
lines[_local1].stop();
_local1++;
};
conveyor.gear0.stop();
conveyor.gear1.stop();
conveyor.gear2.stop();
conveyor.gear3.stop();
conveyor.gear4.stop();
}
override public function resumeAnimations():void{
var _local1:int;
conveyor.play();
_local1 = 0;
while (_local1 < flowers.length) {
flowers[_local1].play();
_local1++;
};
_local1 = 0;
while (_local1 < lines.length) {
lines[_local1].play();
_local1++;
};
conveyor.gear0.play();
conveyor.gear1.play();
conveyor.gear2.play();
conveyor.gear3.play();
conveyor.gear4.play();
}
}
}//package uk.kerb.locoRoco.game.level2
Section 102
//Level (uk.kerb.locoRoco.game.level3.Level)
package uk.kerb.locoRoco.game.level3 {
import uk.co.stdio.sound.*;
import uk.kerb.locoRoco.game.*;
import uk.kerb.utils.game.*;
public class Level extends BaseLevel {
public function Level(_arg1:AssetFactory){
super(_arg1);
}
override protected function init():void{
var _local9:Sequence;
var _local10:ExtendedSound;
gravity = 140;
levelTime = 120000;
var _local1:Number = 3000;
var _local2:Number = 2400;
var _local3:Number = 950;
var _local4:Number = -460;
physics = new Physics(_local1, _local2, gravity, _local3, _local4);
var _local5:Number = 275;
var _local6:Number = 200;
var _local7:Number = 1650;
var _local8:Number = 1200;
renderer = new Renderer(_local5, _local6, _local7, _local8, _local1, _local2, af, physics);
house = new House(-1288, 1160, af);
house.frontMC.scaleX = -1;
house.backMC.scaleX = -1;
targets = new Array();
targets.push(new Target(1, renderer.flowers[0], renderer.lines[0], BaseLevel.ID_RED));
targets.push(new Target(1, renderer.flowers[1], renderer.lines[1], BaseLevel.ID_YELLOW));
targets.push(new Target(1, renderer.flowers[2], renderer.lines[2], BaseLevel.ID_GREEN));
powerups = new Array();
powerups.push(new Powerup(-1346, -600, 30000, Powerup.TYPE_TIME));
powerups.push(new Powerup(-1015, -602, 100, Powerup.TYPE_POINTS));
powerups.push(new Powerup(-894, -501, 100, Powerup.TYPE_POINTS));
powerups.push(new Powerup(-813, -355, 100, Powerup.TYPE_POINTS));
powerups.push(new Powerup(-754, -169, 100, Powerup.TYPE_POINTS));
powerups.push(new Powerup(1354, -842, 30000, Powerup.TYPE_TIME));
powerups.push(new Powerup(1354, -577, 100, Powerup.TYPE_POINTS));
powerups.push(new Powerup(1354, -712, 100, Powerup.TYPE_POINTS));
powerups.push(new Powerup(60, 500, 100, Powerup.TYPE_POINTS));
powerups.push(new Powerup(260, 500, 100, Powerup.TYPE_POINTS));
powerups.push(new Powerup(260, 300, 100, Powerup.TYPE_POINTS));
powerups.push(new Powerup(60, 300, 100, Powerup.TYPE_POINTS));
numPointsPowerups = 10;
musicLoops = new Array();
_local10 = smSequencer.getSoundFromID("Star1");
_local9 = new Sequence();
_local9.addStep(_local10, 0);
musicLoops.push(_local9);
_local10 = smSequencer.getSoundFromID("Star2");
_local9 = new Sequence();
_local9.addStep(_local10, 0);
musicLoops.push(_local9);
_local10 = smSequencer.getSoundFromID("Star3");
_local9 = new Sequence();
_local9.addStep(_local10, 0);
musicLoops.push(_local9);
_local10 = smSequencer.getSoundFromID("Star4");
_local9 = new Sequence();
_local9.addStep(_local10, 0);
musicLoops.push(_local9);
super.init();
}
}
}//package uk.kerb.locoRoco.game.level3
Section 103
//Physics (uk.kerb.locoRoco.game.level3.Physics)
package uk.kerb.locoRoco.game.level3 {
import uk.kerb.locoRoco.game.*;
import uk.kerb.utils.game.*;
import de.polygonal.motor2.dynamics.*;
import de.polygonal.motor2.collision.shapes.data.*;
public class Physics extends BasePhysics {
private var dividerStep:int;
private var movingBlockStep:Number;// = 1
private var d0:RigidBody;
private var d1:RigidBody;
private var d2:RigidBody;
private var dividerR:Array;
private var dividerX:Array;
private var dividerY:Array;
private var dividerOffset0:int;
private var dividerOffset1:int;
private var dividerOffset2:int;
private var movingBlock:RigidBody;
private var toge:RigidBody;
private var numDividerSteps:int;
public function Physics(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Number){
var _local7:RigidBody;
var _local8:Array;
var _local9:CircleData;
var _local10:BoxData;
var _local6:Number = 8;
super(_arg1, _arg2, _arg3, _arg4, _arg5, _local6);
initWorldEdges(-1500, -1200, 1500, 1200);
_local9 = defineCircle(725, 0, 0.001, 0.001);
_local9.groupIndex = -1;
_local7 = createBody(_local9, -428, 1640);
bodies.push(_local7);
_local9 = defineCircle(330, 0, 0.001, 0.001);
_local9.groupIndex = -1;
_local7 = createBody(_local9, 138, 1289);
bodies.push(_local7);
_local10 = defineBox(200, 80, 0, 0.5, 0.1, 0, 0, (-5.5 * DEG_2_RAD));
_local10.groupIndex = -1;
_local7 = createBody(_local10, -16, 1013);
bodies.push(_local7);
_local10 = defineBox(650, 80, 0, 0.5, 0.1);
_local10.groupIndex = -1;
_local7 = createBody(_local10, -1232, 577);
bodies.push(_local7);
_local9 = defineCircle(77, 0, 0, 0);
_local9.groupIndex = -1;
_local7 = createBody(_local9, -1206, -183);
bodies.push(_local7);
_local9 = defineCircle(41, 0, 0, 0);
_local9.groupIndex = -1;
_local7 = createBody(_local9, -840, 160);
bodies.push(_local7);
_local10 = defineBox(600, 80, 0, 0.5, 0.1);
_local10.groupIndex = -1;
_local7 = createBody(_local10, -549, 161);
bodies.push(_local7);
_local9 = defineCircle(81, 0, 0, 0);
_local9.groupIndex = -1;
_local7 = createBody(_local9, -260, 201);
bodies.push(_local7);
_local10 = defineBox(600, 80, 0, 0.5, 0.1);
_local10.groupIndex = -1;
_local7 = createBody(_local10, -1500, -220);
bodies.push(_local7);
_local10 = defineBox(80, 80, 0, 0.5, 0.1, 0, 0, (-36.8 * DEG_2_RAD));
_local10.groupIndex = -1;
_local7 = createBody(_local10, -975, 562);
bodies.push(_local7);
_local9 = defineCircle(77, 0, 0, 0);
_local9.groupIndex = -1;
_local7 = createBody(_local9, -914, 540);
bodies.push(_local7);
_local9 = defineCircle(100, 0, 0.5, 0.1);
_local9.groupIndex = -1;
_local7 = createBody(_local9, -40, -166);
bodies.push(_local7);
_local10 = defineBox(300, 80, 0, 0.5, 0.1, 0, 0, (10 * DEG_2_RAD));
_local10.groupIndex = -1;
_local7 = createBody(_local10, 121, -199);
bodies.push(_local7);
_local9 = defineCircle(75, 0, 0.5, 0.1);
_local9.groupIndex = -1;
_local7 = createBody(_local9, 262, -138);
bodies.push(_local7);
_local9 = defineCircle(80, 0, 0.5, 0.1);
_local9.groupIndex = -1;
_local7 = createBody(_local9, 470, -218);
bodies.push(_local7);
_local10 = defineBox(200, 80, 0, 0.5, 0.1, 0, 0, (-39.1 * DEG_2_RAD));
_local10.groupIndex = -1;
_local7 = createBody(_local10, 527, -317);
bodies.push(_local7);
_local9 = defineCircle(120, 0, 0.5, 0.1);
_local9.groupIndex = -1;
_local7 = createBody(_local9, 649, -312);
bodies.push(_local7);
_local9 = defineCircle(75, 0, 0.5, 0.1);
_local9.groupIndex = -1;
_local7 = createBody(_local9, 882, -341);
bodies.push(_local7);
_local10 = defineBox(700, 80, 0, 0.5, 0.1, 0, 0, (-4 * DEG_2_RAD));
_local10.groupIndex = -1;
_local7 = createBody(_local10, 1234, -400);
bodies.push(_local7);
_local9 = defineCircle(120, 0, 0, 0);
_local9.groupIndex = -1;
_local7 = createBody(_local9, 0x0606, 1);
bodies.push(_local7);
_local10 = defineBox(80, 250, 0, 0, 0, 0, 0, (2 * DEG_2_RAD));
_local10.groupIndex = -1;
_local7 = createBody(_local10, 1459, 128);
bodies.push(_local7);
_local10 = defineBox(80, 250, 0, 0, 0, 0, 0, (7 * DEG_2_RAD));
_local10.groupIndex = -1;
_local7 = createBody(_local10, 1438, 350);
bodies.push(_local7);
_local10 = defineBox(80, 250, 0, 0, 0, 0, 0, (15 * DEG_2_RAD));
_local10.groupIndex = -1;
_local7 = createBody(_local10, 1394, 555);
bodies.push(_local7);
_local10 = defineBox(80, 250, 0, 0, 0, 0, 0, (26 * DEG_2_RAD));
_local10.groupIndex = -1;
_local7 = createBody(_local10, 1318, 753);
bodies.push(_local7);
_local10 = defineBox(80, 250, 0, 0, 0, 0, 0, (40 * DEG_2_RAD));
_local10.groupIndex = -1;
_local7 = createBody(_local10, 1198, 926);
bodies.push(_local7);
_local10 = defineBox(80, 250, 0, 0, 0, 0, 0, (60 * DEG_2_RAD));
_local10.groupIndex = -1;
_local7 = createBody(_local10, 1032, 1057);
bodies.push(_local7);
_local10 = defineBox(80, 250, 0, 0, 0, 0, 0, (85 * DEG_2_RAD));
_local10.groupIndex = -1;
_local7 = createBody(_local10, 814, 1120);
bodies.push(_local7);
_local10 = defineBox(80, 250, 0, 0, 0, 0, 0, (95 * DEG_2_RAD));
_local10.groupIndex = -1;
_local7 = createBody(_local10, 607, 1120);
bodies.push(_local7);
_local10 = defineBox(80, 250, 0, 0, 0, 0, 0, (110 * DEG_2_RAD));
_local10.groupIndex = -1;
_local7 = createBody(_local10, 389, 1073);
bodies.push(_local7);
_local10 = defineBox(387, 80, 0, 0.999, 0.001, 0, 0, 3.07);
_local10.groupIndex = -1;
_local7 = createBody(_local10, 144, 595);
bodies.push(_local7);
_local9 = defineCircle(86, 0, 0.999, 0.001);
_local9.groupIndex = -1;
_local7 = createBody(_local9, -61, 649);
bodies.push(_local7);
_local9 = defineCircle(43, 0, 0.999, 0.001);
_local9.groupIndex = -1;
_local7 = createBody(_local9, 338, 580);
bodies.push(_local7);
_local10 = defineBox(200, 600, 0, 0.5, 0.1);
_local10.groupIndex = -1;
_local7 = createBody(_local10, -1435, 905);
bodies.push(_local7);
_local9 = defineCircle(55, 0, 0.5, 0.1);
_local9.groupIndex = -1;
_local7 = createBody(_local9, -1208, 1055);
bodies.push(_local7);
_local8 = [-87, -66, 54, 26, 87, 66, -87, 66];
_local7 = createBody(definePoly(_local8, 0, 0.5, 0.1), -1248, 960);
bodies.push(_local7);
toge = createBody(defineCircle(25, 0, 0.5, 0.1), 1093, -450);
bodies.push(toge);
dividerOffset0 = 1;
dividerOffset1 = 57;
dividerOffset2 = 110;
var _local11:Number = 779;
var _local12:Number = -74;
var _local13:Number = 0.1;
var _local14:Number = 0.9;
dividerX = [(_local11 + 57), (_local11 + 64), (_local11 + 71), (_local11 + 78), (_local11 + 85), (_local11 + 92), (_local11 + 99), (_local11 + 106), (_local11 + 113), (_local11 + 120), (_local11 + 126), (_local11 + 132), (_local11 + 138), (_local11 + 144), (_local11 + 150), (_local11 + 156), (_local11 + 162), (_local11 + 168), (_local11 + 174), (_local11 + 180), (_local11 + 186), (_local11 + 192), (_local11 + 198), (_local11 + 204), (_local11 + 210), (_local11 + 219), (_local11 + 229), (_local11 + 238), (_local11 + 247), (_local11 + 0x0100), (_local11 + 264), (_local11 + 272), (_local11 + 274), (_local11 + 276), (_local11 + 277), (_local11 + 279), (_local11 + 281), (_local11 + 282), (_local11 + 280), (_local11 + 278), (_local11 + 276), (_local11 + 274), (_local11 + 271), (_local11 + 268), (_local11 + 265), (_local11 + 262), (_local11 + 258), (_local11 + 0xFF), (_local11 + 251), (_local11 + 247), (_local11 + 242), (_local11 + 237), (_local11 + 231), (_local11 + 226), (_local11 + 221), (_local11 + 216), (_local11 + 211), (_local11 + 206), (_local11 + 201), (_local11 + 196), (_local11 + 191), (_local11 + 186), (_local11 + 180), (_local11 + 175), (_local11 + 170), (_local11 + 165), (_local11 + 160), (_local11 + 154), (_local11 + 148), (_local11 + 142), (_local11 + 135), (_local11 + 129), (_local11 + 123), (_local11 + 117), (_local11 + 110), (_local11 + 104), (_local11 + 98), (_local11 + 91), (_local11 + 85), (_local11 + 79), (_local11 + 73), (_local11 + 66), (_local11 + 60), (_local11 + 54), (_local11 + 48), (_local11 + 41), (_local11 + 34), (_local11 + 28), (_local11 + 21), (_local11 + 14), (_local11 + 7), _local11, (_local11 - 7), (_local11 - 14), (_local11 - 21), (_local11 - 28), (_local11 - 35), (_local11 - 41), (_local11 - 48), (_local11 - 54), (_local11 - 61), (_local11 - 67), (_local11 - 74), (_local11 - 80), (_local11 - 86), (_local11 - 93), (_local11 - 99), (_local11 - 106), (_local11 - 112), (_local11 - 119), (_local11 - 126), (_local11 - 130), (_local11 - 135), (_local11 - 139), (_local11 - 144), (_local11 - 148), (_local11 - 152), (_local11 - 155), (_local11 - 158), (_local11 - 161), (_local11 - 161), (_local11 - 162), (_local11 - 162), (_local11 - 162), (_local11 - 161), (_local11 - 160), (_local11 - 158), (_local11 - 157), (_local11 - 152), (_local11 - 147), (_local11 - 141), (_local11 - 136), (_local11 - 130), (_local11 - 123), (_local11 - 116), (_local11 - 107), (_local11 - 99), (_local11 - 90), (_local11 - 82), (_local11 - 75), (_local11 - 67), (_local11 - 59), (_local11 - 51), (_local11 - 46), (_local11 - 41), (_local11 - 36), (_local11 - 30), (_local11 - 25), (_local11 - 19), (_local11 - 14), (_local11 - 14), (_local11 - 7), _local11, (_local11 + 7), (_local11 + 14), (_local11 + 21), (_local11 + 29), (_local11 + 36), (_local11 + 43), (_local11 + 50)];
dividerY = [(_local12 + 20), (_local12 + 19), (_local12 + 17), (_local12 + 16), (_local12 + 15), (_local12 + 14), (_local12 + 12), (_local12 + 11), (_local12 + 10), (_local12 + 9), (_local12 + 7), (_local12 + 4), (_local12 + 2), _local12, (_local12 - 2), (_local12 - 5), (_local12 - 7), (_local12 - 9), (_local12 - 11), (_local12 - 13), (_local12 - 15), (_local12 - 17), (_local12 - 19), (_local12 - 20), (_local12 - 22), (_local12 - 20), (_local12 - 16), (_local12 - 12), (_local12 - 7), (_local12 - 2), (_local12 + 4), (_local12 + 10), (_local12 + 15), (_local12 + 19), (_local12 + 24), (_local12 + 29), (_local12 + 33), (_local12 + 38), (_local12 + 44), (_local12 + 50), (_local12 + 56), (_local12 + 62), (_local12 + 68), (_local12 + 74), (_local12 + 80), (_local12 + 86), (_local12 + 92), (_local12 + 97), (_local12 + 103), (_local12 + 108), (_local12 + 111), (_local12 + 113), (_local12 + 115), (_local12 + 118), (_local12 + 121), (_local12 + 123), (_local12 + 126), (_local12 + 128), (_local12 + 131), (_local12 + 133), (_local12 + 135), (_local12 + 138), (_local12 + 140), (_local12 + 143), (_local12 + 145), (_local12 + 148), (_local12 + 150), (_local12 + 151), (_local12 + 152), (_local12 + 153), (_local12 + 154), (_local12 + 156), (_local12 + 157), (_local12 + 158), (_local12 + 159), (_local12 + 160), (_local12 + 161), (_local12 + 161), (_local12 + 162), (_local12 + 163), (_local12 + 164), (_local12 + 165), (_local12 + 166), (_local12 + 167), (_local12 + 168), (_local12 + 169), (_local12 + 168), (_local12 + 168), (_local12 + 168), (_local12 + 168), (_local12 + 168), (_local12 + 168), (_local12 + 167), (_local12 + 167), (_local12 + 167), (_local12 + 167), (_local12 + 164), (_local12 + 162), (_local12 + 160), (_local12 + 158), (_local12 + 155), (_local12 + 153), (_local12 + 151), (_local12 + 149), (_local12 + 146), (_local12 + 144), (_local12 + 141), (_local12 + 139), (_local12 + 136), (_local12 + 133), (_local12 + 130), (_local12 + 126), (_local12 + 121), (_local12 + 117), (_local12 + 111), (_local12 + 106), (_local12 + 101), (_local12 + 95), (_local12 + 89), (_local12 + 82), (_local12 + 75), (_local12 + 67), (_local12 + 59), (_local12 + 51), (_local12 + 45), (_local12 + 40), (_local12 + 34), (_local12 + 28), (_local12 + 22), (_local12 + 16), (_local12 + 10), (_local12 + 5), _local12, (_local12 - 6), (_local12 - 11), (_local12 - 12), (_local12 - 13), (_local12 - 14), (_local12 - 13), (_local12 - 11), (_local12 - 10), (_local12 - 8), (_local12 - 6), (_local12 - 4), (_local12 - 1), (_local12 + 2), (_local12 + 4), (_local12 + 7), (_local12 + 9), (_local12 + 12), (_local12 + 12), (_local12 + 13), (_local12 + 14), (_local12 + 15), (_local12 + 16), (_local12 + 17), (_local12 + 18), (_local12 + 19), (_local12 + 20), (_local12 + 21)];
dividerR = [-0.13, -0.17, -0.2, -0.23, -0.26, -0.29, -0.32, -0.35, -0.38, -0.41, -0.38, -0.34, -0.31, -0.27, -0.24, -0.2, -0.17, -0.13, -0.1, -0.06, -0.03, 0, 0.03, 0.07, 0.11, 0.25, 0.4, 0.55, 0.7, 0.84, 0.99, 1.14, 1.21, 1.28, 1.34, 1.41, 1.48, 1.54, 1.62, 1.71, 1.79, 1.87, 1.96, 2.04, 2.12, 2.2, 2.29, 2.37, 2.45, 2.54, 2.55, 2.57, 2.58, 2.59, 2.61, 2.62, 2.64, 2.65, 2.67, 2.68, 2.69, 2.71, 2.72, 2.74, 2.75, 2.77, 2.78, 2.8, 2.83, 2.85, 2.87, 2.9, 2.92, 2.94, 2.96, 2.98, 3.01, 3.03, 3.05, 3.08, 3.1, 3.12, -3.13, -3.11, -3.09, -3.06, -3.04, -3.02, -3, -2.97, -2.95, -2.93, -2.91, -2.89, -2.86, -2.84, -2.82, -2.8, -2.77, -2.75, -2.73, -2.71, -2.68, -2.66, -2.64, -2.61, -2.58, -2.55, -2.51, -2.48, -2.45, -2.37, -2.29, -2.21, -2.13, -2.05, -1.97, -1.87, -1.78, -1.68, -1.58, -1.49, -1.4, -1.3, -1.21, -1.12, -1.04, -0.95, -0.86, -0.77, -0.69, -0.6, -0.51, -0.41, -0.3, -0.19, -0.08, 0.02, 0.07, 0.11, 0.16, 0.21, 0.26, 0.24, 0.23, 0.21, 0.2, 0.19, 0.17, 0.16, 0.16, 0.13, 0.1, 0.07, 0.04, 0.01, -0.01, -0.04, -0.07, -0.1];
dividerStep = -1;
numDividerSteps = dividerX.length;
_local7 = createBody(defineCircle(50, 0, _local13, _local14), (_local11 - 86), (_local12 + 66));
bodies.push(_local7);
_local7 = createBody(defineCircle(40, 0, _local13, _local14), (_local11 + 214), (_local12 + 44));
bodies.push(_local7);
_local8 = [-68, 18, 48, 42, 28, 142, -64, 128, -108, 112];
_local7 = createBody(definePoly(_local8, 0, _local13, _local14), _local11, _local12);
bodies.push(_local7);
_local8 = [48, 42, 94, 38, 96, 138, 28, 142];
_local7 = createBody(definePoly(_local8, 0, _local13, _local14), _local11, _local12);
bodies.push(_local7);
_local8 = [94, 38, 202, 6, 246, 70, 220, 94, 174, 118, 96, 138];
_local7 = createBody(definePoly(_local8, 0, _local13, _local14), _local11, _local12);
bodies.push(_local7);
d0 = createBody(defineBox(50, 80, 0, _local13, _local14), -1000, -1000);
bodies.push(d0);
d1 = createBody(defineBox(50, 80, 0, _local13, _local14), -1100, -1000);
bodies.push(d1);
d2 = createBody(defineBox(50, 80, 0, _local13, _local14), -1200, -1000);
bodies.push(d2);
}
override public function step(_arg1:Number, _arg2:Boolean):void{
var _local3:int;
var _local4:int;
var _local5:Number;
var _local6:Number;
var _local7:Number;
if (_arg2){
_local4 = 0;
while (_local4 < 6) {
super.step(_arg1, true);
_local4++;
};
blob.step(world, _arg1);
};
dividerStep++;
_local3 = ((dividerStep + dividerOffset0) % numDividerSteps);
d0.setCenter(dividerX[_local3], dividerY[_local3], dividerR[_local3]);
_local3 = ((dividerStep + dividerOffset1) % numDividerSteps);
d1.setCenter(dividerX[_local3], dividerY[_local3], dividerR[_local3]);
_local3 = ((dividerStep + dividerOffset2) % numDividerSteps);
d2.setCenter(dividerX[_local3], dividerY[_local3], dividerR[_local3]);
if (toge.contactList){
_local5 = (blob.centreNode.x - toge.x);
_local6 = (blob.centreNode.y - toge.y);
_local7 = Math.sqrt(((_local5 * _local5) + (_local6 * _local6)));
_local5 = (_local5 / _local7);
_local6 = (_local6 / _local7);
_local5 = (_local5 * 8000);
_local6 = (_local6 * 8000);
blob.canJump = true;
blob.jump(_local5, _local6, world);
Main.smSFX.getSoundFromID("SpikeSFX").play();
};
}
}
}//package uk.kerb.locoRoco.game.level3
Section 104
//Renderer (uk.kerb.locoRoco.game.level3.Renderer)
package uk.kerb.locoRoco.game.level3 {
import uk.kerb.locoRoco.game.*;
import uk.kerb.utils.game.*;
import flash.display.*;
public class Renderer extends BaseRenderer {
private var conveyor:MovieClip;
public function Renderer(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Number, _arg6:Number, _arg7:AssetFactory, _arg8:BasePhysics){
super(_arg1, _arg2, _arg3, _arg4, _arg5, _arg6, _arg7, _arg8);
var _local9:MovieClip = (_arg7.createDisplayObject("Level4BGAsset") as MovieClip);
backgroundSprite.addChild(_local9);
flowers = new Array();
flowers.push(_local9.conveyor.flower0);
flowers.push(_local9.conveyor.flower1);
flowers.push(_local9.conveyor.flower2);
lines = new Array();
lines.push(_local9.conveyor.line0);
lines.push(_local9.conveyor.line1);
lines.push(_local9.conveyor.line2);
conveyor = _local9.conveyor;
}
override public function resumeAnimations():void{
var _local1:int;
conveyor.play();
_local1 = 0;
while (_local1 < flowers.length) {
flowers[_local1].play();
_local1++;
};
_local1 = 0;
while (_local1 < lines.length) {
lines[_local1].play();
_local1++;
};
conveyor.flowerCog1.play();
conveyor.flowerCog2.play();
conveyor.gear0.play();
conveyor.gear1.play();
conveyor.gear2.play();
conveyor.gear3.play();
conveyor.gear4.play();
}
override public function pauseAnimations():void{
var _local1:int;
conveyor.stop();
_local1 = 0;
while (_local1 < flowers.length) {
flowers[_local1].stop();
_local1++;
};
_local1 = 0;
while (_local1 < lines.length) {
lines[_local1].stop();
_local1++;
};
conveyor.flowerCog1.stop();
conveyor.flowerCog2.stop();
conveyor.gear0.stop();
conveyor.gear1.stop();
conveyor.gear2.stop();
conveyor.gear3.stop();
conveyor.gear4.stop();
}
}
}//package uk.kerb.locoRoco.game.level3
Section 105
//Level (uk.kerb.locoRoco.game.level4.Level)
package uk.kerb.locoRoco.game.level4 {
import uk.co.stdio.sound.*;
import uk.kerb.locoRoco.game.*;
import uk.kerb.utils.game.*;
public class Level extends BaseLevel {
public function Level(_arg1:AssetFactory){
super(_arg1);
}
override protected function init():void{
var _local9:Sequence;
var _local10:ExtendedSound;
gravity = 140;
levelTime = 120000;
var _local1:Number = 3000;
var _local2:Number = 1500;
var _local3:Number = 1000;
var _local4:Number = -290;
physics = new Physics(_local1, _local2, gravity, _local3, _local4);
var _local5:Number = 275;
var _local6:Number = 200;
var _local7:Number = 1650;
var _local8:Number = 1200;
renderer = new Renderer(_local5, _local6, _local7, _local8, _local1, _local2, af, physics);
house = new House(1415, 440, af);
targets = new Array();
targets.push(new Target(1, renderer.flowers[0], renderer.lines[0], BaseLevel.ID_PINK));
targets.push(new Target(1, renderer.flowers[1], renderer.lines[1], BaseLevel.ID_PURPLE));
targets.push(new Target(1, renderer.flowers[2], renderer.lines[2], BaseLevel.ID_RED));
powerups = new Array();
powerups.push(new Powerup(-1420, -508, 30000, Powerup.TYPE_TIME));
powerups.push(new Powerup(-1420, -243, 100, Powerup.TYPE_POINTS));
powerups.push(new Powerup(-1420, -378, 100, Powerup.TYPE_POINTS));
powerups.push(new Powerup(-60, -289, 100, Powerup.TYPE_POINTS));
powerups.push(new Powerup(100, -365, 100, Powerup.TYPE_POINTS));
powerups.push(new Powerup(260, -421, 100, Powerup.TYPE_POINTS));
powerups.push(new Powerup(420, -471, 100, Powerup.TYPE_POINTS));
powerups.push(new Powerup(580, -535, 100, Powerup.TYPE_POINTS));
powerups.push(new Powerup(-640, -276, 100, Powerup.TYPE_POINTS));
powerups.push(new Powerup(-640, -139, 100, Powerup.TYPE_POINTS));
powerups.push(new Powerup(-448, -193, 100, Powerup.TYPE_POINTS));
powerups.push(new Powerup(-448, -328, 30000, Powerup.TYPE_TIME));
numPointsPowerups = 10;
(physics as Physics).block1MC = (renderer as Renderer).block1;
(physics as Physics).block2MC = (renderer as Renderer).block2;
(physics as Physics).block3MC = (renderer as Renderer).block3;
(physics as Physics).block4MC = (renderer as Renderer).block4;
(physics as Physics).block5MC = (renderer as Renderer).block5;
musicLoops = new Array();
_local10 = smSequencer.getSoundFromID("Star1");
_local9 = new Sequence();
_local9.addStep(_local10, 0);
musicLoops.push(_local9);
_local10 = smSequencer.getSoundFromID("Star2");
_local9 = new Sequence();
_local9.addStep(_local10, 0);
musicLoops.push(_local9);
_local10 = smSequencer.getSoundFromID("Star3");
_local9 = new Sequence();
_local9.addStep(_local10, 0);
musicLoops.push(_local9);
_local10 = smSequencer.getSoundFromID("Star4");
_local9 = new Sequence();
_local9.addStep(_local10, 0);
musicLoops.push(_local9);
super.init();
}
}
}//package uk.kerb.locoRoco.game.level4
Section 106
//Physics (uk.kerb.locoRoco.game.level4.Physics)
package uk.kerb.locoRoco.game.level4 {
import uk.kerb.locoRoco.game.*;
import flash.display.*;
import de.polygonal.motor2.dynamics.*;
import de.polygonal.motor2.collision.shapes.data.*;
public class Physics extends BasePhysics {
private var dividerStep:int;
private var blocks:Array;
private var movingBlockStep:Number;// = 1
private var d0:RigidBody;
private var d1:RigidBody;
private var d2:RigidBody;
private var dividerR:Array;
private var dividerX:Array;
private var dividerY:Array;
private var dividerOffset0:int;
private var dividerOffset1:int;
private var dividerOffset2:int;
private var movingBlock:RigidBody;
private var blockMCs:Array;
private var blockCounters:Array;
private var numDividerSteps:int;
private var blockYDown:Array;
private var blockYUp:Array;
private static const BLOCK_UP_SPEED:Number = -5;
private static const BLOCK_DOWN_EASING:Number = 0.02;
public function Physics(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Number){
var _local7:RigidBody;
var _local8:Array;
var _local10:CircleData;
var _local11:BoxData;
var _local6:Number = 8;
super(_arg1, _arg2, _arg3, _arg4, _arg5, _local6);
initWorldEdges(-1500, -950, 1500, 750);
_local7 = createBody(defineCircle(55, 0, 0.5, 0.1), 1335, 349);
bodies.push(_local7);
_local8 = [-87, 66, -54, 26, 87, -66, 87, 66];
_local7 = createBody(definePoly(_local8, 0, 0.5, 0.1), 1375, 254);
bodies.push(_local7);
_local7 = createBody(defineBox(120, 320, 0, 0.5, 0.1), 1522, 338);
bodies.push(_local7);
blockYUp = new Array();
blockYDown = new Array();
blocks = new Array();
blockMCs = new Array();
blocks[0] = createBody(defineBox(150, 200, 0, 0.999, 0.001), -60, -230);
bodies.push(blocks[0]);
blocks[1] = createBody(defineBox(150, 200, 0, 0.999, 0.001), 100, -308);
bodies.push(blocks[1]);
blocks[2] = createBody(defineBox(150, 200, 0, 0.999, 0.001), 260, -363);
bodies.push(blocks[2]);
blocks[3] = createBody(defineBox(150, 200, 0, 0.999, 0.001), 420, -410);
bodies.push(blocks[3]);
blocks[4] = createBody(defineBox(150, 200, 0, 0.999, 0.001), 580, -478);
bodies.push(blocks[4]);
blockCounters = [0, 0, 0, 0, 0];
var _local9:int;
while (_local9 < blocks.length) {
blockYUp.push(blocks[_local9].y);
blockYDown.push((blocks[_local9].y + 120));
_local9++;
};
_local10 = defineCircle(450, 0, 0.999, 0.001);
_local10.groupIndex = -1;
_local7 = createBody(_local10, 448, 1017);
bodies.push(_local7);
_local10 = defineCircle(600, 0, 0.999, 0.001);
_local10.groupIndex = -1;
_local7 = createBody(_local10, -480, 1137);
bodies.push(_local7);
_local11 = defineBox(299, 80, 0, 0.999, 0.001, 0, 0, 0.27);
_local11.groupIndex = -1;
_local7 = createBody(_local11, -115, 660);
bodies.push(_local7);
_local11 = defineBox(120, 80, 0, 0.999, 0.001, 0, 0, 0);
_local11.groupIndex = -1;
_local7 = createBody(_local11, 20, 679);
bodies.push(_local7);
_local11 = defineBox(179, 80, 0, 0.999, 0.001, 0, 0, -0.13);
_local11.groupIndex = -1;
_local7 = createBody(_local11, 161, 666);
bodies.push(_local7);
_local11 = defineBox(1049, 80, 0, 0.999, 0.001, 0, 0, 3.12);
_local11.groupIndex = -1;
_local7 = createBody(_local11, -673, 730);
bodies.push(_local7);
_local10 = defineCircle(157, 0, 0.999, 0.001);
_local10.groupIndex = -1;
_local7 = createBody(_local10, -1543, -42);
bodies.push(_local7);
_local11 = defineBox(80, 270, 0, 0.999, 0.001, 0, 0, 3.07);
_local11.groupIndex = -1;
_local7 = createBody(_local11, -1419, 62);
bodies.push(_local7);
_local11 = defineBox(80, 376, 0, 0.999, 0.001, 0, 0, -3.1);
_local11.groupIndex = -1;
_local7 = createBody(_local11, -1417, 380);
bodies.push(_local7);
_local11 = defineBox(160, 80, 0, 0.999, 0.001, 0, 0, -2.87);
_local11.groupIndex = -1;
_local7 = createBody(_local11, -1242, 720);
bodies.push(_local7);
_local11 = defineBox(160, 80, 0, 0.999, 0.001, 0, 0, -2.53);
_local11.groupIndex = -1;
_local7 = createBody(_local11, -1303, 691);
bodies.push(_local7);
_local11 = defineBox(160, 80, 0, 0.999, 0.001, 0, 0, -2.09);
_local11.groupIndex = -1;
_local7 = createBody(_local11, -1383, 591);
bodies.push(_local7);
_local11 = defineBox(159, 79, 0, 0.999, 0.001, 0, 0, -1.75);
_local11.groupIndex = -1;
_local7 = createBody(_local11, -1410, 496);
bodies.push(_local7);
_local10 = defineCircle(39, 0, 0.999, 0.001);
_local10.groupIndex = -1;
_local7 = createBody(_local10, -937, 278);
bodies.push(_local7);
_local10 = defineCircle(48, 0, 0.999, 0.001);
_local10.groupIndex = -1;
_local7 = createBody(_local10, -1293, 0x0101);
bodies.push(_local7);
_local11 = defineBox(359, 50, 0, 0.999, 0.001, 0, 0, -3.05);
_local11.groupIndex = -1;
_local7 = createBody(_local11, -1116, 250);
bodies.push(_local7);
_local11 = defineBox(359, 50, 0, 0.999, 0.001, 0, 0, 0.03);
_local11.groupIndex = -1;
_local7 = createBody(_local11, -1113, 286);
bodies.push(_local7);
_local10 = defineCircle(40, 0, 0.999, 0.001);
_local10.groupIndex = -1;
_local7 = createBody(_local10, -695, 11);
bodies.push(_local7);
_local10 = defineCircle(51, 0, 0.999, 0.001);
_local10.groupIndex = -1;
_local7 = createBody(_local10, -354, -90);
bodies.push(_local7);
_local11 = defineBox(359, 50, 0, 0.999, 0.001, 0, 0, -0.26);
_local11.groupIndex = -1;
_local7 = createBody(_local11, -517, -22);
bodies.push(_local7);
_local11 = defineBox(359, 50, 0, 0.999, 0.001, 0, 0, 2.82);
_local11.groupIndex = -1;
_local7 = createBody(_local11, -532, -56);
bodies.push(_local7);
_local10 = defineCircle(426, 0, 0.999, 0.001);
_local10.groupIndex = -1;
_local7 = createBody(_local10, -217, -1104);
bodies.push(_local7);
_local10 = defineCircle(323, 0, 0.999, 0.001);
_local10.groupIndex = -1;
_local7 = createBody(_local10, 360, -1109);
bodies.push(_local7);
_local11 = defineBox(399, 80, 0, 0.999, 0.001, 0, 0, -0.16);
_local11.groupIndex = -1;
_local7 = createBody(_local11, 124, -832);
bodies.push(_local7);
_local11 = defineBox(206, 80, 0, 0.999, 0.001, 0, 0, -0.25);
_local11.groupIndex = -1;
_local7 = createBody(_local11, 1130, 556);
bodies.push(_local7);
_local11 = defineBox(206, 80, 0, 0.999, 0.001, 0, 0, -0.15);
_local11.groupIndex = -1;
_local7 = createBody(_local11, 984, 583);
bodies.push(_local7);
_local11 = defineBox(205, 79, 0, 0.999, 0.001, 0, 0, -0.05);
_local11.groupIndex = -1;
_local7 = createBody(_local11, 837, 596);
bodies.push(_local7);
_local11 = defineBox(205, 79, 0, 0.999, 0.001, 0, 0, -0.04);
_local11.groupIndex = -1;
_local7 = createBody(_local11, 692, 603);
bodies.push(_local7);
_local11 = defineBox(205, 79, 0, 0.999, 0.001, 0, 0, -0.01);
_local11.groupIndex = -1;
_local7 = createBody(_local11, 567, 606);
bodies.push(_local7);
_local11 = defineBox(334, 80, 0, 0.999, 0.001, 0, 0, -0.06);
_local11.groupIndex = -1;
_local7 = createBody(_local11, 1388, 521);
bodies.push(_local7);
_local10 = defineCircle(130, 0, 0.999, 0.001);
_local10.groupIndex = -1;
_local7 = createBody(_local10, -1340, -9);
bodies.push(_local7);
_local11 = defineBox(177, 80, 0, 0.999, 0.001, 0, 0, 0.21);
_local11.groupIndex = -1;
_local7 = createBody(_local11, -1430, -119);
bodies.push(_local7);
_local10 = defineCircle(142, 0, 0.999, 0.001);
_local10.groupIndex = -1;
_local7 = createBody(_local10, 963, -73);
bodies.push(_local7);
_local10 = defineCircle(95, 0, 0.999, 0.001);
_local10.groupIndex = -1;
_local7 = createBody(_local10, 600, -350);
bodies.push(_local7);
_local11 = defineBox(377, 116, 0, 0.999, 0.001, 0, 0, 0.45);
_local11.groupIndex = -1;
_local7 = createBody(_local11, 834, -232);
bodies.push(_local7);
_local11 = defineBox(80, 417, 0, 0.999, 0.001, 0, 0, -0.74);
_local11.groupIndex = -1;
_local7 = createBody(_local11, 761, -138);
bodies.push(_local7);
dividerOffset0 = 1;
dividerOffset1 = 57;
dividerOffset2 = 110;
var _local12:Number = 935;
var _local13:Number = -604;
var _local14:Number = 0.1;
var _local15:Number = 0.9;
dividerX = [(_local12 + 57), (_local12 + 64), (_local12 + 71), (_local12 + 78), (_local12 + 85), (_local12 + 92), (_local12 + 99), (_local12 + 106), (_local12 + 113), (_local12 + 120), (_local12 + 126), (_local12 + 132), (_local12 + 138), (_local12 + 144), (_local12 + 150), (_local12 + 156), (_local12 + 162), (_local12 + 168), (_local12 + 174), (_local12 + 180), (_local12 + 186), (_local12 + 192), (_local12 + 198), (_local12 + 204), (_local12 + 210), (_local12 + 219), (_local12 + 229), (_local12 + 238), (_local12 + 247), (_local12 + 0x0100), (_local12 + 264), (_local12 + 272), (_local12 + 274), (_local12 + 276), (_local12 + 277), (_local12 + 279), (_local12 + 281), (_local12 + 282), (_local12 + 280), (_local12 + 278), (_local12 + 276), (_local12 + 274), (_local12 + 271), (_local12 + 268), (_local12 + 265), (_local12 + 262), (_local12 + 258), (_local12 + 0xFF), (_local12 + 251), (_local12 + 247), (_local12 + 242), (_local12 + 237), (_local12 + 231), (_local12 + 226), (_local12 + 221), (_local12 + 216), (_local12 + 211), (_local12 + 206), (_local12 + 201), (_local12 + 196), (_local12 + 191), (_local12 + 186), (_local12 + 180), (_local12 + 175), (_local12 + 170), (_local12 + 165), (_local12 + 160), (_local12 + 154), (_local12 + 148), (_local12 + 142), (_local12 + 135), (_local12 + 129), (_local12 + 123), (_local12 + 117), (_local12 + 110), (_local12 + 104), (_local12 + 98), (_local12 + 91), (_local12 + 85), (_local12 + 79), (_local12 + 73), (_local12 + 66), (_local12 + 60), (_local12 + 54), (_local12 + 48), (_local12 + 41), (_local12 + 34), (_local12 + 28), (_local12 + 21), (_local12 + 14), (_local12 + 7), _local12, (_local12 - 7), (_local12 - 14), (_local12 - 21), (_local12 - 28), (_local12 - 35), (_local12 - 41), (_local12 - 48), (_local12 - 54), (_local12 - 61), (_local12 - 67), (_local12 - 74), (_local12 - 80), (_local12 - 86), (_local12 - 93), (_local12 - 99), (_local12 - 106), (_local12 - 112), (_local12 - 119), (_local12 - 126), (_local12 - 130), (_local12 - 135), (_local12 - 139), (_local12 - 144), (_local12 - 148), (_local12 - 152), (_local12 - 155), (_local12 - 158), (_local12 - 161), (_local12 - 161), (_local12 - 162), (_local12 - 162), (_local12 - 162), (_local12 - 161), (_local12 - 160), (_local12 - 158), (_local12 - 157), (_local12 - 152), (_local12 - 147), (_local12 - 141), (_local12 - 136), (_local12 - 130), (_local12 - 123), (_local12 - 116), (_local12 - 107), (_local12 - 99), (_local12 - 90), (_local12 - 82), (_local12 - 75), (_local12 - 67), (_local12 - 59), (_local12 - 51), (_local12 - 46), (_local12 - 41), (_local12 - 36), (_local12 - 30), (_local12 - 25), (_local12 - 19), (_local12 - 14), (_local12 - 14), (_local12 - 7), _local12, (_local12 + 7), (_local12 + 14), (_local12 + 21), (_local12 + 29), (_local12 + 36), (_local12 + 43), (_local12 + 50)];
dividerY = [(_local13 + 20), (_local13 + 19), (_local13 + 17), (_local13 + 16), (_local13 + 15), (_local13 + 14), (_local13 + 12), (_local13 + 11), (_local13 + 10), (_local13 + 9), (_local13 + 7), (_local13 + 4), (_local13 + 2), _local13, (_local13 - 2), (_local13 - 5), (_local13 - 7), (_local13 - 9), (_local13 - 11), (_local13 - 13), (_local13 - 15), (_local13 - 17), (_local13 - 19), (_local13 - 20), (_local13 - 22), (_local13 - 20), (_local13 - 16), (_local13 - 12), (_local13 - 7), (_local13 - 2), (_local13 + 4), (_local13 + 10), (_local13 + 15), (_local13 + 19), (_local13 + 24), (_local13 + 29), (_local13 + 33), (_local13 + 38), (_local13 + 44), (_local13 + 50), (_local13 + 56), (_local13 + 62), (_local13 + 68), (_local13 + 74), (_local13 + 80), (_local13 + 86), (_local13 + 92), (_local13 + 97), (_local13 + 103), (_local13 + 108), (_local13 + 111), (_local13 + 113), (_local13 + 115), (_local13 + 118), (_local13 + 121), (_local13 + 123), (_local13 + 126), (_local13 + 128), (_local13 + 131), (_local13 + 133), (_local13 + 135), (_local13 + 138), (_local13 + 140), (_local13 + 143), (_local13 + 145), (_local13 + 148), (_local13 + 150), (_local13 + 151), (_local13 + 152), (_local13 + 153), (_local13 + 154), (_local13 + 156), (_local13 + 157), (_local13 + 158), (_local13 + 159), (_local13 + 160), (_local13 + 161), (_local13 + 161), (_local13 + 162), (_local13 + 163), (_local13 + 164), (_local13 + 165), (_local13 + 166), (_local13 + 167), (_local13 + 168), (_local13 + 169), (_local13 + 168), (_local13 + 168), (_local13 + 168), (_local13 + 168), (_local13 + 168), (_local13 + 168), (_local13 + 167), (_local13 + 167), (_local13 + 167), (_local13 + 167), (_local13 + 164), (_local13 + 162), (_local13 + 160), (_local13 + 158), (_local13 + 155), (_local13 + 153), (_local13 + 151), (_local13 + 149), (_local13 + 146), (_local13 + 144), (_local13 + 141), (_local13 + 139), (_local13 + 136), (_local13 + 133), (_local13 + 130), (_local13 + 126), (_local13 + 121), (_local13 + 117), (_local13 + 111), (_local13 + 106), (_local13 + 101), (_local13 + 95), (_local13 + 89), (_local13 + 82), (_local13 + 75), (_local13 + 67), (_local13 + 59), (_local13 + 51), (_local13 + 45), (_local13 + 40), (_local13 + 34), (_local13 + 28), (_local13 + 22), (_local13 + 16), (_local13 + 10), (_local13 + 5), _local13, (_local13 - 6), (_local13 - 11), (_local13 - 12), (_local13 - 13), (_local13 - 14), (_local13 - 13), (_local13 - 11), (_local13 - 10), (_local13 - 8), (_local13 - 6), (_local13 - 4), (_local13 - 1), (_local13 + 2), (_local13 + 4), (_local13 + 7), (_local13 + 9), (_local13 + 12), (_local13 + 12), (_local13 + 13), (_local13 + 14), (_local13 + 15), (_local13 + 16), (_local13 + 17), (_local13 + 18), (_local13 + 19), (_local13 + 20), (_local13 + 21)];
dividerR = [-0.13, -0.17, -0.2, -0.23, -0.26, -0.29, -0.32, -0.35, -0.38, -0.41, -0.38, -0.34, -0.31, -0.27, -0.24, -0.2, -0.17, -0.13, -0.1, -0.06, -0.03, 0, 0.03, 0.07, 0.11, 0.25, 0.4, 0.55, 0.7, 0.84, 0.99, 1.14, 1.21, 1.28, 1.34, 1.41, 1.48, 1.54, 1.62, 1.71, 1.79, 1.87, 1.96, 2.04, 2.12, 2.2, 2.29, 2.37, 2.45, 2.54, 2.55, 2.57, 2.58, 2.59, 2.61, 2.62, 2.64, 2.65, 2.67, 2.68, 2.69, 2.71, 2.72, 2.74, 2.75, 2.77, 2.78, 2.8, 2.83, 2.85, 2.87, 2.9, 2.92, 2.94, 2.96, 2.98, 3.01, 3.03, 3.05, 3.08, 3.1, 3.12, -3.13, -3.11, -3.09, -3.06, -3.04, -3.02, -3, -2.97, -2.95, -2.93, -2.91, -2.89, -2.86, -2.84, -2.82, -2.8, -2.77, -2.75, -2.73, -2.71, -2.68, -2.66, -2.64, -2.61, -2.58, -2.55, -2.51, -2.48, -2.45, -2.37, -2.29, -2.21, -2.13, -2.05, -1.97, -1.87, -1.78, -1.68, -1.58, -1.49, -1.4, -1.3, -1.21, -1.12, -1.04, -0.95, -0.86, -0.77, -0.69, -0.6, -0.51, -0.41, -0.3, -0.19, -0.08, 0.02, 0.07, 0.11, 0.16, 0.21, 0.26, 0.24, 0.23, 0.21, 0.2, 0.19, 0.17, 0.16, 0.16, 0.13, 0.1, 0.07, 0.04, 0.01, -0.01, -0.04, -0.07, -0.1];
dividerStep = -1;
numDividerSteps = dividerX.length;
_local7 = createBody(defineCircle(50, 0, _local14, _local15), (_local12 - 86), (_local13 + 66));
_local7.freeze();
bodies.push(_local7);
_local7 = createBody(defineCircle(40, 0, _local14, _local15), (_local12 + 214), (_local13 + 44));
_local7.freeze();
bodies.push(_local7);
_local8 = [-68, 18, 48, 42, 28, 142, -64, 128, -108, 112];
_local7 = createBody(definePoly(_local8, 0, _local14, _local15), _local12, _local13);
_local7.freeze();
bodies.push(_local7);
_local8 = [48, 42, 94, 38, 96, 138, 28, 142];
_local7 = createBody(definePoly(_local8, 0, _local14, _local15), _local12, _local13);
_local7.freeze();
bodies.push(_local7);
_local8 = [94, 38, 202, 6, 246, 70, 220, 94, 174, 118, 96, 138];
_local7 = createBody(definePoly(_local8, 0, _local14, _local15), _local12, _local13);
_local7.freeze();
bodies.push(_local7);
d0 = createBody(defineBox(50, 80, 0, _local14, _local15), -1000, -1000);
bodies.push(d0);
d1 = createBody(defineBox(50, 80, 0, _local14, _local15), -1100, -1000);
bodies.push(d1);
d2 = createBody(defineBox(50, 80, 0, _local14, _local15), -1200, -1000);
bodies.push(d2);
}
public function set block4MC(_arg1:MovieClip):void{
blockMCs[3] = _arg1;
}
public function set block3MC(_arg1:MovieClip):void{
blockMCs[2] = _arg1;
}
override public function step(_arg1:Number, _arg2:Boolean):void{
var _local3:int;
var _local4:Number;
var _local5:RigidBody;
var _local6:int;
if (_arg2){
_local6 = 0;
while (_local6 < 6) {
super.step(_arg1, true);
_local6++;
};
blob.step(world, _arg1);
};
dividerStep++;
_local3 = ((dividerStep + dividerOffset0) % numDividerSteps);
d0.setCenter(dividerX[_local3], dividerY[_local3], dividerR[_local3]);
_local3 = ((dividerStep + dividerOffset1) % numDividerSteps);
d1.setCenter(dividerX[_local3], dividerY[_local3], dividerR[_local3]);
_local3 = ((dividerStep + dividerOffset2) % numDividerSteps);
d2.setCenter(dividerX[_local3], dividerY[_local3], dividerR[_local3]);
_local6 = 0;
while (_local6 < 5) {
_local5 = blocks[_local6];
if (_local5.contactList){
_local4 = (_local5.y + (BLOCK_DOWN_EASING * (blockYDown[_local6] - _local5.y)));
blob.moveBy(0, (_local4 - _local5.y));
_local5.setCenter(_local5.x, _local4, 0);
blockMCs[_local6].y = _local5.y;
} else {
if (_local5.y > blockYUp[_local6]){
_local4 = (_local5.y + BLOCK_UP_SPEED);
if (_local4 < blockYUp[_local6]){
_local4 = blockYUp[_local6];
};
_local5.setCenter(_local5.x, _local4, 0);
blockMCs[_local6].y = _local5.y;
};
};
_local6++;
};
}
public function set block1MC(_arg1:MovieClip):void{
blockMCs[0] = _arg1;
}
public function set block5MC(_arg1:MovieClip):void{
blockMCs[4] = _arg1;
}
public function set block2MC(_arg1:MovieClip):void{
blockMCs[1] = _arg1;
}
}
}//package uk.kerb.locoRoco.game.level4
Section 107
//Renderer (uk.kerb.locoRoco.game.level4.Renderer)
package uk.kerb.locoRoco.game.level4 {
import uk.kerb.locoRoco.game.*;
import uk.kerb.utils.game.*;
import flash.display.*;
public class Renderer extends BaseRenderer {
public var block1:MovieClip;
public var block2:MovieClip;
public var block3:MovieClip;
public var block4:MovieClip;
private var conveyor:MovieClip;
public var block5:MovieClip;
public function Renderer(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Number, _arg6:Number, _arg7:AssetFactory, _arg8:BasePhysics){
super(_arg1, _arg2, _arg3, _arg4, _arg5, _arg6, _arg7, _arg8);
var _local9:MovieClip = (_arg7.createDisplayObject("Level3BGAsset") as MovieClip);
backgroundSprite.addChild(_local9);
flowers = new Array();
flowers.push(_local9.conveyor.flower0);
flowers.push(_local9.conveyor.flower1);
flowers.push(_local9.conveyor.flower2);
lines = new Array();
lines.push(_local9.conveyor.line0);
lines.push(_local9.conveyor.line1);
lines.push(_local9.conveyor.line2);
conveyor = _local9.conveyor;
block1 = _local9.block1;
block2 = _local9.block2;
block3 = _local9.block3;
block4 = _local9.block4;
block5 = _local9.block5;
}
override public function pauseAnimations():void{
var _local1:int;
conveyor.stop();
_local1 = 0;
while (_local1 < flowers.length) {
flowers[_local1].stop();
_local1++;
};
_local1 = 0;
while (_local1 < lines.length) {
lines[_local1].stop();
_local1++;
};
conveyor.flowerCog1.stop();
conveyor.flowerCog2.stop();
conveyor.gear0.stop();
conveyor.gear1.stop();
conveyor.gear2.stop();
conveyor.gear3.stop();
conveyor.gear4.stop();
}
override public function resumeAnimations():void{
var _local1:int;
conveyor.play();
_local1 = 0;
while (_local1 < flowers.length) {
flowers[_local1].play();
_local1++;
};
_local1 = 0;
while (_local1 < lines.length) {
lines[_local1].play();
_local1++;
};
conveyor.flowerCog1.play();
conveyor.flowerCog2.play();
conveyor.gear0.play();
conveyor.gear1.play();
conveyor.gear2.play();
conveyor.gear3.play();
conveyor.gear4.play();
}
}
}//package uk.kerb.locoRoco.game.level4
Section 108
//Level (uk.kerb.locoRoco.game.level5.Level)
package uk.kerb.locoRoco.game.level5 {
import uk.co.stdio.sound.*;
import uk.kerb.locoRoco.game.*;
import uk.kerb.utils.game.*;
public class Level extends BaseLevel {
public function Level(_arg1:AssetFactory){
super(_arg1);
}
override protected function init():void{
var _local9:Sequence;
var _local10:ExtendedSound;
gravity = 140;
levelTime = 120000;
var _local1:Number = 2062;
var _local2:Number = 1500;
var _local3:Number = -170;
var _local4:Number = -50;
physics = new Physics(_local1, _local2, gravity, _local3, _local4);
var _local5:Number = 275;
var _local6:Number = 200;
var _local7:Number = 1650;
var _local8:Number = 1200;
renderer = new Renderer(_local5, _local6, _local7, _local8, _local1, _local2, af, physics);
house = new House(822, 666, af);
targets = new Array();
targets.push(new Target(1, renderer.flowers[0], renderer.lines[0], BaseLevel.ID_RED));
targets.push(new Target(1, renderer.flowers[1], renderer.lines[1], BaseLevel.ID_BLUE));
targets.push(new Target(1, renderer.flowers[2], renderer.lines[2], BaseLevel.ID_PURPLE));
targets.push(new Target(1, renderer.flowers[3], renderer.lines[3], BaseLevel.ID_PINK));
powerups = new Array();
powerups.push(new Powerup(-1049, -528, 30000, Powerup.TYPE_TIME));
powerups.push(new Powerup(991, -1128, 30000, Powerup.TYPE_TIME));
powerups.push(new Powerup(-1049, -262, 100, Powerup.TYPE_POINTS));
powerups.push(new Powerup(-1049, -398, 100, Powerup.TYPE_POINTS));
powerups.push(new Powerup(-96, 520, 100, Powerup.TYPE_POINTS));
powerups.push(new Powerup(84, 497, 100, Powerup.TYPE_POINTS));
powerups.push(new Powerup(284, 0x0200, 100, Powerup.TYPE_POINTS));
powerups.push(new Powerup(437, 568, 100, Powerup.TYPE_POINTS));
powerups.push(new Powerup(991, -863, 100, Powerup.TYPE_POINTS));
powerups.push(new Powerup(991, -998, 100, Powerup.TYPE_POINTS));
powerups.push(new Powerup(289, 160, 100, Powerup.TYPE_POINTS));
powerups.push(new Powerup(179, 76, 100, Powerup.TYPE_POINTS));
numPointsPowerups = 10;
(physics as Physics).cog1MC = (renderer as Renderer).cog1;
(physics as Physics).cog2MC = (renderer as Renderer).cog2;
musicLoops = new Array();
_local10 = smSequencer.getSoundFromID("Jungle1");
_local9 = new Sequence();
_local9.addStep(_local10, 0);
musicLoops.push(_local9);
_local10 = smSequencer.getSoundFromID("Jungle3");
_local9 = new Sequence();
_local9.addStep(_local10, 0);
musicLoops.push(_local9);
_local10 = smSequencer.getSoundFromID("Jungle2");
_local9 = new Sequence();
_local9.addStep(_local10, 0);
musicLoops.push(_local9);
_local10 = smSequencer.getSoundFromID("Jungle4");
_local9 = new Sequence();
_local9.addStep(_local10, 0);
musicLoops.push(_local9);
_local10 = smSequencer.getSoundFromID("Jungle6");
_local9 = new Sequence();
_local9.addStep(_local10, 0);
musicLoops.push(_local9);
super.init();
}
}
}//package uk.kerb.locoRoco.game.level5
Section 109
//Physics (uk.kerb.locoRoco.game.level5.Physics)
package uk.kerb.locoRoco.game.level5 {
import uk.kerb.locoRoco.game.*;
import uk.kerb.utils.game.*;
import flash.display.*;
import de.polygonal.motor2.dynamics.*;
import de.polygonal.motor2.collision.shapes.data.*;
public class Physics extends BasePhysics {
private var dividerStep:int;
private var d0:RigidBody;
private var d1:RigidBody;
private var d2:RigidBody;
private var d3:RigidBody;
private var cog1:RigidBody;
private var cog2:RigidBody;
private var dividerR:Array;
private var dividerX:Array;
private var dividerY:Array;
private var dividerOffset0:int;
private var dividerOffset1:int;
private var dividerOffset2:int;
private var dividerOffset3:int;
public var cog2MC:MovieClip;
private var toge:RigidBody;
public var cog1MC:MovieClip;
private var numDividerSteps:int;
private static const COG_1_SPEED:Number = -0.01;
private static const COG_2_SPEED:Number = 0.01;
private static const RAD_2_DEG:Number = 57.2957795130823;
public function Physics(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Number){
var _local7:RigidBody;
var _local8:Array;
var _local9:CircleData;
var _local10:BoxData;
var _local12:ShapeData;
var _local13:int;
var _local6:Number = 8;
super(_arg1, _arg2, _arg3, _arg4, _arg5, _local6);
initWorldEdges(-1131, -1400, 1100, 800);
_local7 = createBody(defineBox(1000, 80, 0, 0.5, 0.1, 0, 0, (-0.7 * DEG_2_RAD)), -512, 733);
bodies.push(_local7);
_local7 = createBody(defineCircle(700, 0, 0, 0.1), 118, 1245);
bodies.push(_local7);
_local7 = createBody(defineCircle(55, 0, 0.5, 0.1), 744, 576);
bodies.push(_local7);
_local8 = [-87, 66, -54, 26, 87, -66, 87, 66];
_local7 = createBody(definePoly(_local8, 0, 0.5, 0.1), 784, 481);
bodies.push(_local7);
_local7 = createBody(defineBox(175, 800, 0, 0.5, 0.1), 943, 359);
bodies.push(_local7);
_local7 = createBody(defineBox(400, 80, 0, 0.5, 0.1), 683, 748);
bodies.push(_local7);
_local7 = createBody(defineCircle(55, 0, 0.5, 0.1), -36, 68);
bodies.push(_local7);
_local7 = createBody(defineCircle(125, 0, 0.5, 0.1), 156, 252);
bodies.push(_local7);
_local7 = createBody(defineBox(240, 80, 0, 0.5, 0.1, 0, 0, (28.9 * DEG_2_RAD)), 73, 111);
bodies.push(_local7);
_local7 = createBody(defineBox(240, 80, 0, 0.5, 0.1, 0, 0, (60.7 * DEG_2_RAD)), 30, 200);
bodies.push(_local7);
_local9 = defineCircle(73, 0, 0.999, 0.001);
_local9.groupIndex = -1;
_local7 = createBody(_local9, -279, 85);
bodies.push(_local7);
_local9 = defineCircle(101, 0, 0.999, 0.001);
_local9.groupIndex = -1;
_local7 = createBody(_local9, -49, 113);
bodies.push(_local7);
_local10 = defineBox(232, 80, 0, 0.999, 0.001, 0, 0, 0);
_local10.groupIndex = -1;
_local7 = createBody(_local10, -165, 52);
bodies.push(_local7);
_local10 = defineBox(221, 80, 0, 0.999, 0.001, 0, 0, 0.24);
_local10.groupIndex = -1;
_local7 = createBody(_local10, -161, 146);
bodies.push(_local7);
var _local11:Array = new Array();
var _local14 = 6;
_local12 = defineCircle(500, 0, 3.999, 0.001, 0, 0);
_local11.push(_local12);
_local13 = 0;
while (_local13 < _local14) {
_local12 = defineBox(100, 1250, 0, 3.999, 0.001, 0, 0, ((Math.PI * _local13) / _local14));
_local11.push(_local12);
_local13++;
};
cog1 = createBody(_local11, -850, 540);
bodies.push(cog1);
_local7 = createBody(defineCircle(205, 0, 0.5, 0.1), -1160, 112);
bodies.push(_local7);
_local11 = new Array();
_local14 = 5;
_local12 = defineCircle(385, 0, 3.999, 0.001, 0, 0);
_local11.push(_local12);
_local13 = 0;
while (_local13 < _local14) {
_local12 = defineBox(90, 1000, 0, 0.001, 0.001, 0, 0, ((Math.PI * _local13) / _local14));
_local11.push(_local12);
_local13++;
};
cog2 = createBody(_local11, 738, -123);
bodies.push(cog2);
_local7 = createBody(defineCircle(165, 0, 0.5, 0.1), 885, -528);
bodies.push(_local7);
_local7 = createBody(defineBox(260, 80, 0, 0.5, 0.1, 0, 0, (-40.9 * DEG_2_RAD)), 688, -522);
bodies.push(_local7);
_local7 = createBody(defineBox(300, 80, 0, 0.5, 0.1, 0, 0, (-13.5 * DEG_2_RAD)), 1036, -689);
bodies.push(_local7);
toge = createBody(defineCircle(25, 0, 0.5, 0.1), 26, 9);
bodies.push(toge);
dividerOffset0 = 1;
dividerOffset1 = 40;
dividerOffset2 = 80;
dividerOffset3 = 122;
var _local15:Number = -244;
var _local16:Number = -675;
var _local17:Number = 0.1;
var _local18:Number = 0.9;
dividerX = [(_local15 + 57), (_local15 + 64), (_local15 + 71), (_local15 + 78), (_local15 + 85), (_local15 + 92), (_local15 + 99), (_local15 + 106), (_local15 + 113), (_local15 + 120), (_local15 + 126), (_local15 + 132), (_local15 + 138), (_local15 + 144), (_local15 + 150), (_local15 + 156), (_local15 + 162), (_local15 + 168), (_local15 + 174), (_local15 + 180), (_local15 + 186), (_local15 + 192), (_local15 + 198), (_local15 + 204), (_local15 + 210), (_local15 + 219), (_local15 + 229), (_local15 + 238), (_local15 + 247), (_local15 + 0x0100), (_local15 + 264), (_local15 + 272), (_local15 + 274), (_local15 + 276), (_local15 + 277), (_local15 + 279), (_local15 + 281), (_local15 + 282), (_local15 + 280), (_local15 + 278), (_local15 + 276), (_local15 + 274), (_local15 + 271), (_local15 + 268), (_local15 + 265), (_local15 + 262), (_local15 + 258), (_local15 + 0xFF), (_local15 + 251), (_local15 + 247), (_local15 + 242), (_local15 + 237), (_local15 + 231), (_local15 + 226), (_local15 + 221), (_local15 + 216), (_local15 + 211), (_local15 + 206), (_local15 + 201), (_local15 + 196), (_local15 + 191), (_local15 + 186), (_local15 + 180), (_local15 + 175), (_local15 + 170), (_local15 + 165), (_local15 + 160), (_local15 + 154), (_local15 + 148), (_local15 + 142), (_local15 + 135), (_local15 + 129), (_local15 + 123), (_local15 + 117), (_local15 + 110), (_local15 + 104), (_local15 + 98), (_local15 + 91), (_local15 + 85), (_local15 + 79), (_local15 + 73), (_local15 + 66), (_local15 + 60), (_local15 + 54), (_local15 + 48), (_local15 + 41), (_local15 + 34), (_local15 + 28), (_local15 + 21), (_local15 + 14), (_local15 + 7), _local15, (_local15 - 7), (_local15 - 14), (_local15 - 21), (_local15 - 28), (_local15 - 35), (_local15 - 41), (_local15 - 48), (_local15 - 54), (_local15 - 61), (_local15 - 67), (_local15 - 74), (_local15 - 80), (_local15 - 86), (_local15 - 93), (_local15 - 99), (_local15 - 106), (_local15 - 112), (_local15 - 119), (_local15 - 126), (_local15 - 130), (_local15 - 135), (_local15 - 139), (_local15 - 144), (_local15 - 148), (_local15 - 152), (_local15 - 155), (_local15 - 158), (_local15 - 161), (_local15 - 161), (_local15 - 162), (_local15 - 162), (_local15 - 162), (_local15 - 161), (_local15 - 160), (_local15 - 158), (_local15 - 157), (_local15 - 152), (_local15 - 147), (_local15 - 141), (_local15 - 136), (_local15 - 130), (_local15 - 123), (_local15 - 116), (_local15 - 107), (_local15 - 99), (_local15 - 90), (_local15 - 82), (_local15 - 75), (_local15 - 67), (_local15 - 59), (_local15 - 51), (_local15 - 46), (_local15 - 41), (_local15 - 36), (_local15 - 30), (_local15 - 25), (_local15 - 19), (_local15 - 14), (_local15 - 14), (_local15 - 7), _local15, (_local15 + 7), (_local15 + 14), (_local15 + 21), (_local15 + 29), (_local15 + 36), (_local15 + 43), (_local15 + 50)];
dividerY = [(_local16 + 20), (_local16 + 19), (_local16 + 17), (_local16 + 16), (_local16 + 15), (_local16 + 14), (_local16 + 12), (_local16 + 11), (_local16 + 10), (_local16 + 9), (_local16 + 7), (_local16 + 4), (_local16 + 2), _local16, (_local16 - 2), (_local16 - 5), (_local16 - 7), (_local16 - 9), (_local16 - 11), (_local16 - 13), (_local16 - 15), (_local16 - 17), (_local16 - 19), (_local16 - 20), (_local16 - 22), (_local16 - 20), (_local16 - 16), (_local16 - 12), (_local16 - 7), (_local16 - 2), (_local16 + 4), (_local16 + 10), (_local16 + 15), (_local16 + 19), (_local16 + 24), (_local16 + 29), (_local16 + 33), (_local16 + 38), (_local16 + 44), (_local16 + 50), (_local16 + 56), (_local16 + 62), (_local16 + 68), (_local16 + 74), (_local16 + 80), (_local16 + 86), (_local16 + 92), (_local16 + 97), (_local16 + 103), (_local16 + 108), (_local16 + 111), (_local16 + 113), (_local16 + 115), (_local16 + 118), (_local16 + 121), (_local16 + 123), (_local16 + 126), (_local16 + 128), (_local16 + 131), (_local16 + 133), (_local16 + 135), (_local16 + 138), (_local16 + 140), (_local16 + 143), (_local16 + 145), (_local16 + 148), (_local16 + 150), (_local16 + 151), (_local16 + 152), (_local16 + 153), (_local16 + 154), (_local16 + 156), (_local16 + 157), (_local16 + 158), (_local16 + 159), (_local16 + 160), (_local16 + 161), (_local16 + 161), (_local16 + 162), (_local16 + 163), (_local16 + 164), (_local16 + 165), (_local16 + 166), (_local16 + 167), (_local16 + 168), (_local16 + 169), (_local16 + 168), (_local16 + 168), (_local16 + 168), (_local16 + 168), (_local16 + 168), (_local16 + 168), (_local16 + 167), (_local16 + 167), (_local16 + 167), (_local16 + 167), (_local16 + 164), (_local16 + 162), (_local16 + 160), (_local16 + 158), (_local16 + 155), (_local16 + 153), (_local16 + 151), (_local16 + 149), (_local16 + 146), (_local16 + 144), (_local16 + 141), (_local16 + 139), (_local16 + 136), (_local16 + 133), (_local16 + 130), (_local16 + 126), (_local16 + 121), (_local16 + 117), (_local16 + 111), (_local16 + 106), (_local16 + 101), (_local16 + 95), (_local16 + 89), (_local16 + 82), (_local16 + 75), (_local16 + 67), (_local16 + 59), (_local16 + 51), (_local16 + 45), (_local16 + 40), (_local16 + 34), (_local16 + 28), (_local16 + 22), (_local16 + 16), (_local16 + 10), (_local16 + 5), _local16, (_local16 - 6), (_local16 - 11), (_local16 - 12), (_local16 - 13), (_local16 - 14), (_local16 - 13), (_local16 - 11), (_local16 - 10), (_local16 - 8), (_local16 - 6), (_local16 - 4), (_local16 - 1), (_local16 + 2), (_local16 + 4), (_local16 + 7), (_local16 + 9), (_local16 + 12), (_local16 + 12), (_local16 + 13), (_local16 + 14), (_local16 + 15), (_local16 + 16), (_local16 + 17), (_local16 + 18), (_local16 + 19), (_local16 + 20), (_local16 + 21)];
dividerR = [-0.13, -0.17, -0.2, -0.23, -0.26, -0.29, -0.32, -0.35, -0.38, -0.41, -0.38, -0.34, -0.31, -0.27, -0.24, -0.2, -0.17, -0.13, -0.1, -0.06, -0.03, 0, 0.03, 0.07, 0.11, 0.25, 0.4, 0.55, 0.7, 0.84, 0.99, 1.14, 1.21, 1.28, 1.34, 1.41, 1.48, 1.54, 1.62, 1.71, 1.79, 1.87, 1.96, 2.04, 2.12, 2.2, 2.29, 2.37, 2.45, 2.54, 2.55, 2.57, 2.58, 2.59, 2.61, 2.62, 2.64, 2.65, 2.67, 2.68, 2.69, 2.71, 2.72, 2.74, 2.75, 2.77, 2.78, 2.8, 2.83, 2.85, 2.87, 2.9, 2.92, 2.94, 2.96, 2.98, 3.01, 3.03, 3.05, 3.08, 3.1, 3.12, -3.13, -3.11, -3.09, -3.06, -3.04, -3.02, -3, -2.97, -2.95, -2.93, -2.91, -2.89, -2.86, -2.84, -2.82, -2.8, -2.77, -2.75, -2.73, -2.71, -2.68, -2.66, -2.64, -2.61, -2.58, -2.55, -2.51, -2.48, -2.45, -2.37, -2.29, -2.21, -2.13, -2.05, -1.97, -1.87, -1.78, -1.68, -1.58, -1.49, -1.4, -1.3, -1.21, -1.12, -1.04, -0.95, -0.86, -0.77, -0.69, -0.6, -0.51, -0.41, -0.3, -0.19, -0.08, 0.02, 0.07, 0.11, 0.16, 0.21, 0.26, 0.24, 0.23, 0.21, 0.2, 0.19, 0.17, 0.16, 0.16, 0.13, 0.1, 0.07, 0.04, 0.01, -0.01, -0.04, -0.07, -0.1];
dividerStep = -1;
numDividerSteps = dividerX.length;
_local7 = createBody(defineCircle(50, 0, _local17, _local18), (_local15 - 86), (_local16 + 66));
bodies.push(_local7);
_local7 = createBody(defineCircle(40, 0, _local17, _local18), (_local15 + 214), (_local16 + 44));
bodies.push(_local7);
_local8 = [-68, 18, 48, 42, 28, 142, -64, 128, -108, 112];
_local7 = createBody(definePoly(_local8, 0, _local17, _local18), _local15, _local16);
bodies.push(_local7);
_local8 = [48, 42, 94, 38, 96, 138, 28, 142];
_local7 = createBody(definePoly(_local8, 0, _local17, _local18), _local15, _local16);
bodies.push(_local7);
_local8 = [94, 38, 202, 6, 246, 70, 220, 94, 174, 118, 96, 138];
_local7 = createBody(definePoly(_local8, 0, _local17, _local18), _local15, _local16);
bodies.push(_local7);
d0 = createBody(defineBox(50, 80, 0, _local17, _local18), -1000, -1000);
bodies.push(d0);
d1 = createBody(defineBox(50, 80, 0, _local17, _local18), -1100, -1000);
bodies.push(d1);
d2 = createBody(defineBox(50, 80, 0, _local17, _local18), -1200, -1000);
bodies.push(d2);
d3 = createBody(defineBox(50, 80, 0, _local17, _local18), -1300, -1000);
bodies.push(d3);
}
override public function step(_arg1:Number, _arg2:Boolean):void{
var _local3:int;
var _local4:int;
var _local5:Number;
var _local6:Number;
var _local7:Number;
if (_arg2){
_local4 = 0;
while (_local4 < 6) {
super.step(_arg1, true);
_local4++;
};
blob.step(world, _arg1);
};
dividerStep++;
_local3 = ((dividerStep + dividerOffset0) % numDividerSteps);
d0.setCenter(dividerX[_local3], dividerY[_local3], dividerR[_local3]);
_local3 = ((dividerStep + dividerOffset1) % numDividerSteps);
d1.setCenter(dividerX[_local3], dividerY[_local3], dividerR[_local3]);
_local3 = ((dividerStep + dividerOffset2) % numDividerSteps);
d2.setCenter(dividerX[_local3], dividerY[_local3], dividerR[_local3]);
_local3 = ((dividerStep + dividerOffset3) % numDividerSteps);
d3.setCenter(dividerX[_local3], dividerY[_local3], dividerR[_local3]);
if (toge.contactList){
_local5 = (blob.centreNode.x - toge.x);
_local6 = (blob.centreNode.y - toge.y);
_local7 = Math.sqrt(((_local5 * _local5) + (_local6 * _local6)));
_local5 = (_local5 / _local7);
_local6 = (_local6 / _local7);
_local5 = (_local5 * 8000);
_local6 = (_local6 * 8000);
blob.canJump = true;
blob.jump(_local5, _local6, world);
Main.smSFX.getSoundFromID("SpikeSFX").play();
};
cog1.setCenter(cog1.x, cog1.y, (cog1.r + COG_1_SPEED));
cog2.setCenter(cog2.x, cog2.y, (cog2.r + COG_2_SPEED));
cog1MC.rotation = (RAD_2_DEG * cog1.r);
cog2MC.rotation = (RAD_2_DEG * cog2.r);
}
}
}//package uk.kerb.locoRoco.game.level5
Section 110
//Renderer (uk.kerb.locoRoco.game.level5.Renderer)
package uk.kerb.locoRoco.game.level5 {
import uk.kerb.locoRoco.game.*;
import uk.kerb.utils.game.*;
import flash.display.*;
public class Renderer extends BaseRenderer {
public var cog1:MovieClip;
public var cog2:MovieClip;
private var conveyor:MovieClip;
public function Renderer(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Number, _arg6:Number, _arg7:AssetFactory, _arg8:BasePhysics){
super(_arg1, _arg2, _arg3, _arg4, _arg5, _arg6, _arg7, _arg8);
var _local9:MovieClip = (_arg7.createDisplayObject("Level5BGAsset") as MovieClip);
backgroundSprite.addChild(_local9);
flowers = new Array();
flowers.push(_local9.conveyor.flower0);
flowers.push(_local9.conveyor.flower1);
flowers.push(_local9.conveyor.flower2);
flowers.push(_local9.conveyor.flower3);
lines = new Array();
lines.push(_local9.conveyor.line0);
lines.push(_local9.conveyor.line1);
lines.push(_local9.conveyor.line2);
lines.push(_local9.conveyor.line3);
conveyor = _local9.conveyor;
cog1 = _local9.cog1;
cog2 = _local9.cog2;
}
override public function resumeAnimations():void{
var _local1:int;
conveyor.play();
_local1 = 0;
while (_local1 < flowers.length) {
flowers[_local1].play();
_local1++;
};
_local1 = 0;
while (_local1 < lines.length) {
lines[_local1].play();
_local1++;
};
conveyor.flowerCog1.play();
conveyor.flowerCog2.play();
conveyor.gear0.play();
conveyor.gear1.play();
conveyor.gear2.play();
conveyor.gear3.play();
conveyor.gear4.play();
}
override public function pauseAnimations():void{
var _local1:int;
conveyor.stop();
_local1 = 0;
while (_local1 < flowers.length) {
flowers[_local1].stop();
_local1++;
};
_local1 = 0;
while (_local1 < lines.length) {
lines[_local1].stop();
_local1++;
};
conveyor.flowerCog1.stop();
conveyor.flowerCog2.stop();
conveyor.gear0.stop();
conveyor.gear1.stop();
conveyor.gear2.stop();
conveyor.gear3.stop();
conveyor.gear4.stop();
}
}
}//package uk.kerb.locoRoco.game.level5
Section 111
//Level (uk.kerb.locoRoco.game.level6.Level)
package uk.kerb.locoRoco.game.level6 {
import uk.co.stdio.sound.*;
import uk.kerb.locoRoco.game.*;
import uk.kerb.utils.game.*;
public class Level extends BaseLevel {
public function Level(_arg1:AssetFactory){
super(_arg1);
}
override protected function init():void{
var _local9:Sequence;
var _local10:ExtendedSound;
gravity = 140;
levelTime = 120000;
var _local1:Number = 2062;
var _local2:Number = 1500;
var _local3:Number = 330;
var _local4:Number = 40;
physics = new Physics(_local1, _local2, gravity, _local3, _local4);
var _local5:Number = 275;
var _local6:Number = 200;
var _local7:Number = 1650;
var _local8:Number = 1200;
renderer = new Renderer(_local5, _local6, _local7, _local8, _local1, _local2, af, physics);
house = new House(942, 1034, af);
targets = new Array();
targets.push(new Target(1, renderer.flowers[0], renderer.lines[0], BaseLevel.ID_RED));
targets.push(new Target(1, renderer.flowers[1], renderer.lines[1], BaseLevel.ID_BLUE));
targets.push(new Target(1, renderer.flowers[2], renderer.lines[2], BaseLevel.ID_YELLOW));
targets.push(new Target(1, renderer.flowers[3], renderer.lines[3], BaseLevel.ID_PINK));
powerups = new Array();
powerups.push(new Powerup(-876, -26, 30000, Powerup.TYPE_TIME));
powerups.push(new Powerup(-876, 106, 100, Powerup.TYPE_POINTS));
powerups.push(new Powerup(-876, 246, 100, Powerup.TYPE_POINTS));
powerups.push(new Powerup(-876, 376, 100, Powerup.TYPE_POINTS));
powerups.push(new Powerup(-876, 0x0200, 100, Powerup.TYPE_POINTS));
powerups.push(new Powerup(858, -150, 100, Powerup.TYPE_POINTS));
powerups.push(new Powerup(860, -60, 100, Powerup.TYPE_POINTS));
powerups.push(new Powerup(860, 30, 100, Powerup.TYPE_POINTS));
powerups.push(new Powerup(860, 120, 100, Powerup.TYPE_POINTS));
powerups.push(new Powerup(-67, 469, 30000, Powerup.TYPE_TIME));
powerups.push(new Powerup(457, 231, 30000, Powerup.TYPE_TIME));
powerups.push(new Powerup(45, 211, 100, Powerup.TYPE_POINTS));
powerups.push(new Powerup(-501, 449, 100, Powerup.TYPE_POINTS));
numPointsPowerups = 10;
(physics as Physics).platform1MC = (renderer as Renderer).platform1;
(physics as Physics).platform2MC = (renderer as Renderer).platform2;
(physics as Physics).platform3MC = (renderer as Renderer).platform3;
(physics as Physics).nyokkiMC = (renderer as Renderer).nyokki;
musicLoops = new Array();
_local10 = smSequencer.getSoundFromID("Jungle1");
_local9 = new Sequence();
_local9.addStep(_local10, 0);
musicLoops.push(_local9);
_local10 = smSequencer.getSoundFromID("Jungle3");
_local9 = new Sequence();
_local9.addStep(_local10, 0);
musicLoops.push(_local9);
_local10 = smSequencer.getSoundFromID("Jungle2");
_local9 = new Sequence();
_local9.addStep(_local10, 0);
musicLoops.push(_local9);
_local10 = smSequencer.getSoundFromID("Jungle4");
_local9 = new Sequence();
_local9.addStep(_local10, 0);
musicLoops.push(_local9);
_local10 = smSequencer.getSoundFromID("Jungle6");
_local9 = new Sequence();
_local9.addStep(_local10, 0);
musicLoops.push(_local9);
super.init();
}
}
}//package uk.kerb.locoRoco.game.level6
Section 112
//Physics (uk.kerb.locoRoco.game.level6.Physics)
package uk.kerb.locoRoco.game.level6 {
import uk.kerb.locoRoco.game.*;
import uk.kerb.utils.game.*;
import flash.display.*;
import flash.geom.*;
import de.polygonal.motor2.dynamics.*;
import de.polygonal.motor2.collision.shapes.data.*;
import de.polygonal.motor2.dynamics.joints.data.*;
import de.polygonal.motor2.dynamics.contact.*;
public class Physics extends BasePhysics {
private var dividerStep:int;
private var nyokki:RigidBody;
private var nyokkiState:int;
private var toge:RigidBody;
private var platform2:RigidBody;
private var platform3:RigidBody;
private var dividerOffset0:int;
private var dividerOffset1:int;
private var dividerOffset2:int;
private var dividerOffset3:int;
private var platform1:RigidBody;
private var nyokkiMoving:Boolean;
private var numDividerSteps:int;
public var platform3MC:MovieClip;
private var nyokkiCounter:int;
public var platform1MC:MovieClip;
private var platform3Counter:int;// = 0
private var d0:RigidBody;
private var d1:RigidBody;
private var d2:RigidBody;
private var d3:RigidBody;
private var dividerR:Array;
public var nyokkiMC:MovieClip;
private var platform2Counter:int;// = 0
private var dividerX:Array;
private var dividerY:Array;
public var platform2MC:MovieClip;
private var platform1Counter:int;// = 0
private static const NYOKKI_DOWN_SPEED:Number = 10;
private static const NYOKKI_UP_SPEED:Number = -160;
private static const RAD_2_DEG:Number = 57.2957795130823;
private static const NYOKKI_CHARGING_SPEED:Number = 6;
private static const NYOKKI_STATE_RESETTING:int = 2;
private static const NYOKKI_STATE_IDLE:int = 0;
private static const NYOKKI_STATE_UP:int = 3;
private static const NYOKKI_GRAPHIC_OFFSET:Number = 797;
private static const NYOKKI_BOTTOM:Number = 1945;
private static const NYOKKI_STATE_DOWN:int = 4;
private static const NYOKKI_STATE_CHARGING:int = 1;
private static const NYOKKI_TOP:Number = 927;
private static const NYOKKI_NORM:Number = 1745;
public function Physics(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Number){
var _local7:RigidBody;
var _local8:Array;
var _local10:ShapeData;
var _local12:RevoluteJointData;
var _local15:CircleData;
var _local16:BoxData;
var _local6:Number = 8;
super(_arg1, _arg2, _arg3, _arg4, _arg5, _local6);
initWorldEdges(-1031, -1500, 1031, 1200);
_local7 = createBody(defineCircle(55, 0, 0.5, 0.1), 865, 943);
bodies.push(_local7);
_local8 = [-87, 66, -54, 26, 87, -66, 87, 66];
_local7 = createBody(definePoly(_local8, 0, 0.5, 0.1), 905, 848);
bodies.push(_local7);
_local7 = createBody(defineBox(120, 400, 0, 0.999, 0.001, 0, 0, 0), 1052, 981);
bodies.push(_local7);
_local7 = createBody(defineCircle(365, 0, 0.999, 0.001), 847, 1443);
bodies.push(_local7);
_local7 = createBody(defineBox(226, 80, 0, 0.999, 0.001, 0, 0, 0), 932, 1118);
bodies.push(_local7);
_local7 = createBody(defineBox(226, 79, 0, 0.999, 0.001, 0, 0, -0.22), 616, 1165);
bodies.push(_local7);
_local7 = createBody(defineBox(226, 79, 0, 0.999, 0.001, 0, 0, -0.14), 480, 1187);
bodies.push(_local7);
_local7 = createBody(defineBox(226, 79, 0, 0.999, 0.001, 0, 0, -0.12), 343, 1205);
bodies.push(_local7);
_local7 = createBody(defineCircle(244, 0, 0.999, 0.001), 212, 1422);
bodies.push(_local7);
_local7 = createBody(defineBox(140, 79, 0, 0.999, 0.001, 0, 0, -0.16), 63, 1242);
bodies.push(_local7);
var _local9:Array = new Array();
var _local11:Number = 1;
_local10 = defineCircle(25, 0, 0.999, 0.001, -224, -17);
_local9.push(_local10);
_local10 = defineCircle(30, 0, 0.999, 0.001, 219, -10);
_local9.push(_local10);
_local8 = [-226, -42, 217, -40, 226, 20, 125, 40, -128, 40, -226, 8];
_local10 = definePoly(_local8, _local11, 0.999, 0.001, 2, 0);
_local9.push(_local10);
platform1 = createBody(_local9, -292, 402);
bodies.push(platform1);
platform2 = createBody(_local9, 249, 162);
bodies.push(platform2);
var _local13:Point = new Point();
var _local14:Number = (0.16 * Math.PI);
_local13.x = platform1.x;
_local13.y = platform1.y;
_local12 = new RevoluteJointData(_local7, platform1, _local13);
_local12.enableLimit = true;
_local12.lowerAngle = -(_local14);
_local12.upperAngle = _local14;
world.createJoint(_local12);
_local13.x = platform2.x;
_local13.y = platform2.y;
_local12 = new RevoluteJointData(_local7, platform2, _local13);
_local12.enableLimit = true;
_local12.lowerAngle = -(_local14);
_local12.upperAngle = _local14;
world.createJoint(_local12);
_local7 = createBody(defineCircle(100, 0, 0.999, 0.001), 1061, 142);
bodies.push(_local7);
_local7 = createBody(defineBox(200, 80, 0, 0.999, 0.001, 0, 0, (15 * DEG_2_RAD)), 1027, 329);
bodies.push(_local7);
_local7 = createBody(defineBox(200, 80, 0, 0.999, 0.001, 0, 0, (40 * DEG_2_RAD)), 1067, 378);
bodies.push(_local7);
_local7 = createBody(defineBox(300, 80, 0, 0.999, 0.001, 0, 0, (-2.5 * DEG_2_RAD)), 851, 268);
bodies.push(_local7);
_local7 = createBody(defineBox(100, 80, 0, 0.999, 0.001, 0, 0, (-62.3 * DEG_2_RAD)), 988, 207);
bodies.push(_local7);
_local8 = [-156, -38, -76, -57, 170, 57, 41, 57, -112, 35, -170, -14];
_local7 = createBody(definePoly(_local8, 0, 0.999, 0.001), 775, 292);
bodies.push(_local7);
_local16 = defineBox(552, 102, 0, 0.999, 0.001, 0, 0, 0.16);
_local16.groupIndex = -1;
_local7 = createBody(_local16, -312, 742);
bodies.push(_local7);
_local15 = defineCircle(111, 0, 0.999, 0.001);
_local15.groupIndex = -1;
_local7 = createBody(_local15, -576, 757);
bodies.push(_local7);
_local15 = defineCircle(111, 0, 0.999, 0.001);
_local15.groupIndex = -1;
_local7 = createBody(_local15, 156, 573);
bodies.push(_local7);
_local15 = defineCircle(155, 0, 0.999, 0.001);
_local15.groupIndex = -1;
_local7 = createBody(_local15, 378, 617);
bodies.push(_local7);
_local15 = defineCircle(88, 0, 0.999, 0.001);
_local15.groupIndex = -1;
_local7 = createBody(_local15, -41, 823);
bodies.push(_local7);
_local16 = defineBox(552, 102, 0, 0.999, 0.001, 0, 0, 0.07);
_local16.groupIndex = -1;
_local7 = createBody(_local16, -305, 838);
bodies.push(_local7);
_local16 = defineBox(232, 80, 0, 0.999, 0.001, 0, 0, 0);
_local16.groupIndex = -1;
_local7 = createBody(_local16, 266, 502);
bodies.push(_local7);
_local16 = defineBox(187, 79, 0, 0.999, 0.001, 0, 0, 0.42);
_local16.groupIndex = -1;
_local7 = createBody(_local16, 250, 686);
bodies.push(_local7);
_local9 = new Array();
_local10 = defineBox(308, 1500, 0, 0.999, 0.001);
_local9.push(_local10);
_local10 = defineCircle(38, 0, 3.999, 0.001, -117, -754);
_local9.push(_local10);
_local10 = defineCircle(45, 0, 3.999, 0.001, 108, -748);
_local9.push(_local10);
_local10 = defineBox(120, 120, 0, 3.999, 0.001, -63, -723, (9 * DEG_2_RAD));
_local9.push(_local10);
_local10 = defineBox(135, 120, 0, 3.999, 0.001, 45, -721, (-11 * DEG_2_RAD));
_local9.push(_local10);
nyokki = createBody(_local9, -877, NYOKKI_NORM);
bodies.push(nyokki);
nyokkiState = NYOKKI_STATE_IDLE;
nyokkiCounter = 0;
toge = createBody(defineCircle(25, 0, 0.5, 0.1), 736, 213);
bodies.push(toge);
dividerOffset0 = 1;
dividerOffset1 = 40;
dividerOffset2 = 80;
dividerOffset3 = 122;
var _local17:Number = 413;
var _local18:Number = -342;
var _local19:Number = 0.1;
var _local20:Number = 0.9;
dividerX = [(_local17 + 57), (_local17 + 64), (_local17 + 71), (_local17 + 78), (_local17 + 85), (_local17 + 92), (_local17 + 99), (_local17 + 106), (_local17 + 113), (_local17 + 120), (_local17 + 126), (_local17 + 132), (_local17 + 138), (_local17 + 144), (_local17 + 150), (_local17 + 156), (_local17 + 162), (_local17 + 168), (_local17 + 174), (_local17 + 180), (_local17 + 186), (_local17 + 192), (_local17 + 198), (_local17 + 204), (_local17 + 210), (_local17 + 219), (_local17 + 229), (_local17 + 238), (_local17 + 247), (_local17 + 0x0100), (_local17 + 264), (_local17 + 272), (_local17 + 274), (_local17 + 276), (_local17 + 277), (_local17 + 279), (_local17 + 281), (_local17 + 282), (_local17 + 280), (_local17 + 278), (_local17 + 276), (_local17 + 274), (_local17 + 271), (_local17 + 268), (_local17 + 265), (_local17 + 262), (_local17 + 258), (_local17 + 0xFF), (_local17 + 251), (_local17 + 247), (_local17 + 242), (_local17 + 237), (_local17 + 231), (_local17 + 226), (_local17 + 221), (_local17 + 216), (_local17 + 211), (_local17 + 206), (_local17 + 201), (_local17 + 196), (_local17 + 191), (_local17 + 186), (_local17 + 180), (_local17 + 175), (_local17 + 170), (_local17 + 165), (_local17 + 160), (_local17 + 154), (_local17 + 148), (_local17 + 142), (_local17 + 135), (_local17 + 129), (_local17 + 123), (_local17 + 117), (_local17 + 110), (_local17 + 104), (_local17 + 98), (_local17 + 91), (_local17 + 85), (_local17 + 79), (_local17 + 73), (_local17 + 66), (_local17 + 60), (_local17 + 54), (_local17 + 48), (_local17 + 41), (_local17 + 34), (_local17 + 28), (_local17 + 21), (_local17 + 14), (_local17 + 7), _local17, (_local17 - 7), (_local17 - 14), (_local17 - 21), (_local17 - 28), (_local17 - 35), (_local17 - 41), (_local17 - 48), (_local17 - 54), (_local17 - 61), (_local17 - 67), (_local17 - 74), (_local17 - 80), (_local17 - 86), (_local17 - 93), (_local17 - 99), (_local17 - 106), (_local17 - 112), (_local17 - 119), (_local17 - 126), (_local17 - 130), (_local17 - 135), (_local17 - 139), (_local17 - 144), (_local17 - 148), (_local17 - 152), (_local17 - 155), (_local17 - 158), (_local17 - 161), (_local17 - 161), (_local17 - 162), (_local17 - 162), (_local17 - 162), (_local17 - 161), (_local17 - 160), (_local17 - 158), (_local17 - 157), (_local17 - 152), (_local17 - 147), (_local17 - 141), (_local17 - 136), (_local17 - 130), (_local17 - 123), (_local17 - 116), (_local17 - 107), (_local17 - 99), (_local17 - 90), (_local17 - 82), (_local17 - 75), (_local17 - 67), (_local17 - 59), (_local17 - 51), (_local17 - 46), (_local17 - 41), (_local17 - 36), (_local17 - 30), (_local17 - 25), (_local17 - 19), (_local17 - 14), (_local17 - 14), (_local17 - 7), _local17, (_local17 + 7), (_local17 + 14), (_local17 + 21), (_local17 + 29), (_local17 + 36), (_local17 + 43), (_local17 + 50)];
dividerY = [(_local18 + 20), (_local18 + 19), (_local18 + 17), (_local18 + 16), (_local18 + 15), (_local18 + 14), (_local18 + 12), (_local18 + 11), (_local18 + 10), (_local18 + 9), (_local18 + 7), (_local18 + 4), (_local18 + 2), _local18, (_local18 - 2), (_local18 - 5), (_local18 - 7), (_local18 - 9), (_local18 - 11), (_local18 - 13), (_local18 - 15), (_local18 - 17), (_local18 - 19), (_local18 - 20), (_local18 - 22), (_local18 - 20), (_local18 - 16), (_local18 - 12), (_local18 - 7), (_local18 - 2), (_local18 + 4), (_local18 + 10), (_local18 + 15), (_local18 + 19), (_local18 + 24), (_local18 + 29), (_local18 + 33), (_local18 + 38), (_local18 + 44), (_local18 + 50), (_local18 + 56), (_local18 + 62), (_local18 + 68), (_local18 + 74), (_local18 + 80), (_local18 + 86), (_local18 + 92), (_local18 + 97), (_local18 + 103), (_local18 + 108), (_local18 + 111), (_local18 + 113), (_local18 + 115), (_local18 + 118), (_local18 + 121), (_local18 + 123), (_local18 + 126), (_local18 + 128), (_local18 + 131), (_local18 + 133), (_local18 + 135), (_local18 + 138), (_local18 + 140), (_local18 + 143), (_local18 + 145), (_local18 + 148), (_local18 + 150), (_local18 + 151), (_local18 + 152), (_local18 + 153), (_local18 + 154), (_local18 + 156), (_local18 + 157), (_local18 + 158), (_local18 + 159), (_local18 + 160), (_local18 + 161), (_local18 + 161), (_local18 + 162), (_local18 + 163), (_local18 + 164), (_local18 + 165), (_local18 + 166), (_local18 + 167), (_local18 + 168), (_local18 + 169), (_local18 + 168), (_local18 + 168), (_local18 + 168), (_local18 + 168), (_local18 + 168), (_local18 + 168), (_local18 + 167), (_local18 + 167), (_local18 + 167), (_local18 + 167), (_local18 + 164), (_local18 + 162), (_local18 + 160), (_local18 + 158), (_local18 + 155), (_local18 + 153), (_local18 + 151), (_local18 + 149), (_local18 + 146), (_local18 + 144), (_local18 + 141), (_local18 + 139), (_local18 + 136), (_local18 + 133), (_local18 + 130), (_local18 + 126), (_local18 + 121), (_local18 + 117), (_local18 + 111), (_local18 + 106), (_local18 + 101), (_local18 + 95), (_local18 + 89), (_local18 + 82), (_local18 + 75), (_local18 + 67), (_local18 + 59), (_local18 + 51), (_local18 + 45), (_local18 + 40), (_local18 + 34), (_local18 + 28), (_local18 + 22), (_local18 + 16), (_local18 + 10), (_local18 + 5), _local18, (_local18 - 6), (_local18 - 11), (_local18 - 12), (_local18 - 13), (_local18 - 14), (_local18 - 13), (_local18 - 11), (_local18 - 10), (_local18 - 8), (_local18 - 6), (_local18 - 4), (_local18 - 1), (_local18 + 2), (_local18 + 4), (_local18 + 7), (_local18 + 9), (_local18 + 12), (_local18 + 12), (_local18 + 13), (_local18 + 14), (_local18 + 15), (_local18 + 16), (_local18 + 17), (_local18 + 18), (_local18 + 19), (_local18 + 20), (_local18 + 21)];
dividerR = [-0.13, -0.17, -0.2, -0.23, -0.26, -0.29, -0.32, -0.35, -0.38, -0.41, -0.38, -0.34, -0.31, -0.27, -0.24, -0.2, -0.17, -0.13, -0.1, -0.06, -0.03, 0, 0.03, 0.07, 0.11, 0.25, 0.4, 0.55, 0.7, 0.84, 0.99, 1.14, 1.21, 1.28, 1.34, 1.41, 1.48, 1.54, 1.62, 1.71, 1.79, 1.87, 1.96, 2.04, 2.12, 2.2, 2.29, 2.37, 2.45, 2.54, 2.55, 2.57, 2.58, 2.59, 2.61, 2.62, 2.64, 2.65, 2.67, 2.68, 2.69, 2.71, 2.72, 2.74, 2.75, 2.77, 2.78, 2.8, 2.83, 2.85, 2.87, 2.9, 2.92, 2.94, 2.96, 2.98, 3.01, 3.03, 3.05, 3.08, 3.1, 3.12, -3.13, -3.11, -3.09, -3.06, -3.04, -3.02, -3, -2.97, -2.95, -2.93, -2.91, -2.89, -2.86, -2.84, -2.82, -2.8, -2.77, -2.75, -2.73, -2.71, -2.68, -2.66, -2.64, -2.61, -2.58, -2.55, -2.51, -2.48, -2.45, -2.37, -2.29, -2.21, -2.13, -2.05, -1.97, -1.87, -1.78, -1.68, -1.58, -1.49, -1.4, -1.3, -1.21, -1.12, -1.04, -0.95, -0.86, -0.77, -0.69, -0.6, -0.51, -0.41, -0.3, -0.19, -0.08, 0.02, 0.07, 0.11, 0.16, 0.21, 0.26, 0.24, 0.23, 0.21, 0.2, 0.19, 0.17, 0.16, 0.16, 0.13, 0.1, 0.07, 0.04, 0.01, -0.01, -0.04, -0.07, -0.1];
dividerStep = -1;
numDividerSteps = dividerX.length;
_local7 = createBody(defineCircle(50, 0, _local19, _local20), (_local17 - 86), (_local18 + 66));
bodies.push(_local7);
_local7 = createBody(defineCircle(40, 0, _local19, _local20), (_local17 + 214), (_local18 + 44));
bodies.push(_local7);
_local8 = [-68, 18, 48, 42, 28, 142, -64, 128, -108, 112];
_local7 = createBody(definePoly(_local8, 0, _local19, _local20), _local17, _local18);
bodies.push(_local7);
_local8 = [48, 42, 94, 38, 96, 138, 28, 142];
_local7 = createBody(definePoly(_local8, 0, _local19, _local20), _local17, _local18);
bodies.push(_local7);
_local8 = [94, 38, 202, 6, 246, 70, 220, 94, 174, 118, 96, 138];
_local7 = createBody(definePoly(_local8, 0, _local19, _local20), _local17, _local18);
bodies.push(_local7);
d0 = createBody(defineBox(50, 80, 0, _local19, _local20), -1000, -1000);
bodies.push(d0);
d1 = createBody(defineBox(50, 80, 0, _local19, _local20), -1100, -1000);
bodies.push(d1);
d2 = createBody(defineBox(50, 80, 0, _local19, _local20), -1200, -1000);
bodies.push(d2);
d3 = createBody(defineBox(50, 80, 0, _local19, _local20), -1300, -1000);
bodies.push(d3);
}
override public function step(_arg1:Number, _arg2:Boolean):void{
var _local3:Manifold;
var _local7:int;
var _local8:int;
var _local9:Number;
if (nyokkiState == NYOKKI_STATE_UP){
nyokki.setCenter(nyokki.x, (nyokki.y + NYOKKI_UP_SPEED), 0);
blob.moveBy(0, NYOKKI_UP_SPEED);
nyokkiMC.y = (nyokki.y - NYOKKI_GRAPHIC_OFFSET);
if (nyokki.y < NYOKKI_TOP){
nyokki.y = NYOKKI_TOP;
nyokkiState = NYOKKI_STATE_DOWN;
blob.jump(0, -25000, world);
nyokkiMC.gotoAndStop("down");
};
} else {
if (nyokkiState == NYOKKI_STATE_DOWN){
nyokki.setCenter(nyokki.x, (nyokki.y + NYOKKI_DOWN_SPEED), 0);
nyokkiMC.y = (nyokki.y - NYOKKI_GRAPHIC_OFFSET);
if (nyokki.y > NYOKKI_NORM){
nyokki.y = NYOKKI_NORM;
nyokkiState = NYOKKI_STATE_IDLE;
nyokkiMC.gotoAndPlay("sleep");
};
} else {
if (nyokkiState == NYOKKI_STATE_CHARGING){
if (nyokkiCounter == 65){
Main.smSFX.getSoundFromID("NyokkiDownSFX").play();
};
if (++nyokkiCounter > 20){
nyokki.setCenter(nyokki.x, (nyokki.y + NYOKKI_CHARGING_SPEED), 0);
blob.moveBy(0, NYOKKI_CHARGING_SPEED);
nyokkiMC.y = (nyokki.y - NYOKKI_GRAPHIC_OFFSET);
if (nyokki.y > NYOKKI_BOTTOM){
nyokki.y = NYOKKI_BOTTOM;
nyokkiCounter = 0;
if (nyokki.contactList){
_local3 = nyokki.contactList.contact.manifolds[0];
if (_local3.ny != 0){
nyokkiState = NYOKKI_STATE_UP;
nyokkiMC.gotoAndStop("up");
Main.smSFX.getSoundFromID("NyokkiUpSFX").play();
} else {
nyokkiState = NYOKKI_STATE_RESETTING;
};
} else {
nyokkiState = NYOKKI_STATE_RESETTING;
};
};
};
} else {
if (nyokkiState == NYOKKI_STATE_RESETTING){
nyokki.setCenter(nyokki.x, (nyokki.y - NYOKKI_CHARGING_SPEED), 0);
nyokkiMC.y = (nyokki.y - NYOKKI_GRAPHIC_OFFSET);
if (nyokki.y < NYOKKI_NORM){
nyokki.y = NYOKKI_NORM;
nyokkiState = NYOKKI_STATE_IDLE;
nyokkiMC.gotoAndPlay("sleep");
};
if (nyokki.contactList){
_local3 = nyokki.contactList.contact.manifolds[0];
if (_local3.ny != 0){
nyokkiState = NYOKKI_STATE_CHARGING;
nyokkiMC.gotoAndPlay("wake");
};
};
} else {
nyokkiCounter = 0;
if (nyokki.contactList){
_local3 = nyokki.contactList.contact.manifolds[0];
if (_local3.ny != 0){
nyokkiState = NYOKKI_STATE_CHARGING;
nyokkiMC.gotoAndPlay("wake");
};
};
};
};
};
};
var _local4:Number = (blob.centreNode.x - nyokki.x);
var _local5:Number = ((blob.centreNode.y - nyokki.y) + 570);
var _local6:Number = ((Math.atan2(_local5, _local4) * 180) / Math.PI);
if (nyokkiMC.leftEye){
nyokkiMC.leftEye.rotation = _local6;
};
if (nyokkiMC.rightEye){
nyokkiMC.rightEye.rotation = (_local6 - 16);
};
if (_arg2){
_local8 = 0;
while (_local8 < 6) {
super.step(_arg1, true);
_local8++;
};
blob.step(world, _arg1);
};
dividerStep++;
_local7 = ((dividerStep + dividerOffset0) % numDividerSteps);
d0.setCenter(dividerX[_local7], dividerY[_local7], dividerR[_local7]);
_local7 = ((dividerStep + dividerOffset1) % numDividerSteps);
d1.setCenter(dividerX[_local7], dividerY[_local7], dividerR[_local7]);
_local7 = ((dividerStep + dividerOffset2) % numDividerSteps);
d2.setCenter(dividerX[_local7], dividerY[_local7], dividerR[_local7]);
_local7 = ((dividerStep + dividerOffset3) % numDividerSteps);
d3.setCenter(dividerX[_local7], dividerY[_local7], dividerR[_local7]);
platform1MC.rotation = (RAD_2_DEG * platform1.r);
platform1MC.vine1.rotation = -(platform1MC.rotation);
platform1MC.vine2.rotation = -(platform1MC.rotation);
platform2MC.rotation = (RAD_2_DEG * platform2.r);
platform2MC.vine1.rotation = -(platform2MC.rotation);
platform2MC.vine2.rotation = -(platform2MC.rotation);
if (toge.contactList){
_local4 = (blob.centreNode.x - toge.x);
_local5 = (blob.centreNode.y - toge.y);
_local9 = Math.sqrt(((_local4 * _local4) + (_local5 * _local5)));
_local4 = (_local4 / _local9);
_local5 = (_local5 / _local9);
_local4 = (_local4 * 8000);
_local5 = (_local5 * 8000);
blob.canJump = true;
blob.jump(_local4, _local5, world);
Main.smSFX.getSoundFromID("SpikeSFX").play();
};
}
}
}//package uk.kerb.locoRoco.game.level6
Section 113
//Renderer (uk.kerb.locoRoco.game.level6.Renderer)
package uk.kerb.locoRoco.game.level6 {
import uk.kerb.locoRoco.game.*;
import uk.kerb.utils.game.*;
import flash.display.*;
public class Renderer extends BaseRenderer {
public var platform3:MovieClip;
public var nyokki:MovieClip;
private var conveyor:MovieClip;
public var platform1:MovieClip;
public var platform2:MovieClip;
public function Renderer(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Number, _arg6:Number, _arg7:AssetFactory, _arg8:BasePhysics){
super(_arg1, _arg2, _arg3, _arg4, _arg5, _arg6, _arg7, _arg8);
var _local9:MovieClip = (_arg7.createDisplayObject("Level6BGAsset") as MovieClip);
backgroundSprite.addChild(_local9);
flowers = new Array();
flowers.push(_local9.conveyor.flower0);
flowers.push(_local9.conveyor.flower1);
flowers.push(_local9.conveyor.flower2);
flowers.push(_local9.conveyor.flower3);
lines = new Array();
lines.push(_local9.conveyor.line0);
lines.push(_local9.conveyor.line1);
lines.push(_local9.conveyor.line2);
lines.push(_local9.conveyor.line3);
conveyor = _local9.conveyor;
platform1 = _local9.platform1;
platform2 = _local9.platform2;
platform3 = _local9.platform3;
nyokki = _local9.nyokki;
}
override public function resumeAnimations():void{
var _local1:int;
conveyor.play();
_local1 = 0;
while (_local1 < flowers.length) {
flowers[_local1].play();
_local1++;
};
_local1 = 0;
while (_local1 < lines.length) {
lines[_local1].play();
_local1++;
};
conveyor.flowerCog1.play();
conveyor.flowerCog2.play();
conveyor.gear0.play();
conveyor.gear1.play();
conveyor.gear2.play();
conveyor.gear3.play();
conveyor.gear4.play();
}
override public function pauseAnimations():void{
var _local1:int;
conveyor.stop();
_local1 = 0;
while (_local1 < flowers.length) {
flowers[_local1].stop();
_local1++;
};
_local1 = 0;
while (_local1 < lines.length) {
lines[_local1].stop();
_local1++;
};
conveyor.flowerCog1.stop();
conveyor.flowerCog2.stop();
conveyor.gear0.stop();
conveyor.gear1.stop();
conveyor.gear2.stop();
conveyor.gear3.stop();
conveyor.gear4.stop();
}
}
}//package uk.kerb.locoRoco.game.level6
Section 114
//Level (uk.kerb.locoRoco.game.level7.Level)
package uk.kerb.locoRoco.game.level7 {
import uk.co.stdio.sound.*;
import uk.kerb.locoRoco.game.*;
import uk.kerb.utils.game.*;
public class Level extends BaseLevel {
public function Level(_arg1:AssetFactory){
super(_arg1);
}
override protected function init():void{
var _local9:Sequence;
var _local10:ExtendedSound;
gravity = 140;
levelTime = 60000;
var _local1:Number = 2600;
var _local2:Number = 2000;
var _local3:Number = 300;
var _local4:Number = -860;
physics = new Physics(_local1, _local2, gravity, _local3, _local4);
var _local5:Number = 275;
var _local6:Number = 200;
var _local7:Number = 1650;
var _local8:Number = 1200;
renderer = new Renderer(_local5, _local6, _local7, _local8, _local1, _local2, af, physics);
house = new House(823, 670, af);
targets = new Array();
targets.push(new Target(1, renderer.flowers[0], renderer.lines[0], BaseLevel.ID_BLACK));
targets.push(new Target(1, renderer.flowers[1], renderer.lines[1], BaseLevel.ID_PINK));
targets.push(new Target(1, renderer.flowers[2], renderer.lines[2], BaseLevel.ID_BLUE));
targets.push(new Target(1, renderer.flowers[3], renderer.lines[3], BaseLevel.ID_GREEN));
targets.push(new Target(1, renderer.flowers[4], renderer.lines[4], BaseLevel.ID_PURPLE));
powerups = new Array();
powerups.push(new Powerup(232, -67, 30000, Powerup.TYPE_TIME));
powerups.push(new Powerup(1276, -838, 30000, Powerup.TYPE_TIME));
powerups.push(new Powerup(-68, 13, 30000, Powerup.TYPE_TIME));
powerups.push(new Powerup(263, 178, 30000, Powerup.TYPE_TIME));
powerups.push(new Powerup(35, -293, 100, Powerup.TYPE_POINTS));
powerups.push(new Powerup(442, 48, 100, Powerup.TYPE_POINTS));
powerups.push(new Powerup(507, -145, 100, Powerup.TYPE_POINTS));
powerups.push(new Powerup(621, -256, 100, Powerup.TYPE_POINTS));
powerups.push(new Powerup(775, 32, 100, Powerup.TYPE_POINTS));
powerups.push(new Powerup(926, -124, 100, Powerup.TYPE_POINTS));
powerups.push(new Powerup(1096, -730, 100, Powerup.TYPE_POINTS));
powerups.push(new Powerup(-1144, -814, 100, Powerup.TYPE_POINTS));
powerups.push(new Powerup(-1144, -674, 100, Powerup.TYPE_POINTS));
powerups.push(new Powerup(-1146, -544, 100, Powerup.TYPE_POINTS));
numPointsPowerups = 10;
musicLoops = new Array();
_local10 = smSequencer.getSoundFromID("Snow1And2");
_local9 = new Sequence();
_local9.addStep(_local10, 0);
musicLoops.push(_local9);
_local10 = smSequencer.getSoundFromID("Snow3");
_local9 = new Sequence();
_local9.addStep(_local10, 0);
musicLoops.push(_local9);
_local10 = smSequencer.getSoundFromID("Snow4");
_local9 = new Sequence();
_local9.addStep(_local10, 0);
musicLoops.push(_local9);
_local10 = smSequencer.getSoundFromID("Snow5");
_local9 = new Sequence();
_local9.addStep(_local10, 0);
musicLoops.push(_local9);
_local10 = smSequencer.getSoundFromID("Snow6");
_local9 = new Sequence();
_local9.addStep(_local10, 0);
musicLoops.push(_local9);
_local10 = smSequencer.getSoundFromID("Snow7And8");
_local9 = new Sequence();
_local9.addStep(_local10, 0);
musicLoops.push(_local9);
super.init();
}
}
}//package uk.kerb.locoRoco.game.level7
Section 115
//Physics (uk.kerb.locoRoco.game.level7.Physics)
package uk.kerb.locoRoco.game.level7 {
import uk.kerb.locoRoco.game.*;
import uk.kerb.utils.game.*;
import de.polygonal.motor2.dynamics.*;
import de.polygonal.motor2.collision.shapes.data.*;
public class Physics extends BasePhysics {
private var dividerStep:int;
private var d0:RigidBody;
private var d1:RigidBody;
private var d2:RigidBody;
private var d3:RigidBody;
private var d4:RigidBody;
private var dividerR:Array;
private var dividerX:Array;
private var dividerY:Array;
private var dividerOffset0:int;
private var dividerOffset1:int;
private var dividerOffset2:int;
private var dividerOffset3:int;
private var dividerOffset4:int;
private var toge:RigidBody;
private var numDividerSteps:int;
public function Physics(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Number){
var _local7:RigidBody;
var _local8:Array;
var _local9:CircleData;
var _local10:BoxData;
var _local6:Number = 0.1;
super(_arg1, _arg2, _arg3, _arg4, _arg5, _local6);
initWorldEdges(-1300, -1800, 1331, 750);
toge = createBody(defineCircle(25, 0, 0.5, 0.1), -217, -430);
bodies.push(toge);
_local9 = defineCircle(215, 0, 0.999, 0.001);
_local9.groupIndex = -1;
_local7 = createBody(_local9, 1176, -471);
bodies.push(_local7);
_local9 = defineCircle(240, 0, 0.999, 0.001);
_local9.groupIndex = -1;
_local7 = createBody(_local9, 1197, -48);
bodies.push(_local7);
_local10 = defineBox(408, 79, 0, 0.999, 0.001, 0, 0, -0.56);
_local10.groupIndex = -1;
_local7 = createBody(_local10, 1231, -713);
bodies.push(_local7);
_local10 = defineBox(80, 171, 0, 0.999, 0.001, 0, 0, -0.17);
_local10.groupIndex = -1;
_local7 = createBody(_local10, 1057, -265);
bodies.push(_local7);
_local10 = defineBox(79, 153, 0, 0.999, 0.001, 0, 0, 0.32);
_local10.groupIndex = -1;
_local7 = createBody(_local10, 1030, -183);
bodies.push(_local7);
_local9 = defineCircle(215, 0, 0.999, 0.001);
_local9.groupIndex = -1;
_local7 = createBody(_local9, -211, -194);
bodies.push(_local7);
_local9 = defineCircle(90, 0, 0.999, 0.001);
_local9.groupIndex = -1;
_local7 = createBody(_local9, 304, -744);
bodies.push(_local7);
_local9 = defineCircle(105, 0, 0.999, 0.001);
_local9.groupIndex = -1;
_local7 = createBody(_local9, 44, -444);
bodies.push(_local7);
_local10 = defineBox(380, 79, 0, 0.999, 0.001, 0, 0, -0.82);
_local10.groupIndex = -1;
_local7 = createBody(_local10, 137, -638);
bodies.push(_local7);
_local9 = defineCircle(150, 0, 0.999, 0.001);
_local9.groupIndex = -1;
_local7 = createBody(_local9, 809, -268);
bodies.push(_local7);
_local9 = defineCircle(150, 0, 0.999, 0.001);
_local9.groupIndex = -1;
_local7 = createBody(_local9, 610, 133);
bodies.push(_local7);
_local9 = defineCircle(125, 0, 0.999, 0.001);
_local9.groupIndex = -1;
_local7 = createBody(_local9, 662, -93);
bodies.push(_local7);
_local9 = defineCircle(101, 0, 0.999, 0.001);
_local9.groupIndex = -1;
_local7 = createBody(_local9, 510, -347);
bodies.push(_local7);
_local9 = defineCircle(101, 0, 0.999, 0.001);
_local9.groupIndex = -1;
_local7 = createBody(_local9, 379, -73);
bodies.push(_local7);
_local9 = defineCircle(101, 0, 0.999, 0.001);
_local9.groupIndex = -1;
_local7 = createBody(_local9, 396, -238);
bodies.push(_local7);
_local9 = defineCircle(101, 0, 0.999, 0.001);
_local9.groupIndex = -1;
_local7 = createBody(_local9, 396, 182);
bodies.push(_local7);
_local9 = defineCircle(101, 0, 0.999, 0.001);
_local9.groupIndex = -1;
_local7 = createBody(_local9, 144, -193);
bodies.push(_local7);
_local9 = defineCircle(146, 0, 0.999, 0.001);
_local9.groupIndex = -1;
_local7 = createBody(_local9, 103, 90);
bodies.push(_local7);
_local9 = defineCircle(146, 0, 0.999, 0.001);
_local9.groupIndex = -1;
_local7 = createBody(_local9, -103, 196);
bodies.push(_local7);
_local9 = defineCircle(146, 0, 0.999, 0.001);
_local9.groupIndex = -1;
_local7 = createBody(_local9, 120, 288);
bodies.push(_local7);
_local10 = defineBox(314, 79, 0, 0.999, 0.001, 0, 0, 0.65);
_local10.groupIndex = -1;
_local7 = createBody(_local10, 262, -351);
bodies.push(_local7);
_local10 = defineBox(219, 80, 0, 0.999, 0.001, 0, 0, 0.03);
_local10.groupIndex = -1;
_local7 = createBody(_local10, 221, 745);
bodies.push(_local7);
_local10 = defineBox(219, 80, 0, 0.999, 0.001, 0, 0, 0.11);
_local10.groupIndex = -1;
_local7 = createBody(_local10, 112, 732);
bodies.push(_local7);
_local10 = defineBox(219, 80, 0, 0.999, 0.001, 0, 0, 0.17);
_local10.groupIndex = -1;
_local7 = createBody(_local10, 2, 712);
bodies.push(_local7);
_local10 = defineBox(219, 79, 0, 0.999, 0.001, 0, 0, 0.26);
_local10.groupIndex = -1;
_local7 = createBody(_local10, -84, 687);
bodies.push(_local7);
_local10 = defineBox(219, 79, 0, 0.999, 0.001, 0, 0, 0.35);
_local10.groupIndex = -1;
_local7 = createBody(_local10, -202, 644);
bodies.push(_local7);
_local10 = defineBox(219, 79, 0, 0.999, 0.001, 0, 0, 0.45);
_local10.groupIndex = -1;
_local7 = createBody(_local10, -317, 590);
bodies.push(_local7);
_local10 = defineBox(236, 79, 0, 0.999, 0.001, 0, 0, 0.56);
_local10.groupIndex = -1;
_local7 = createBody(_local10, -429, 521);
bodies.push(_local7);
_local10 = defineBox(236, 79, 0, 0.999, 0.001, 0, 0, 0.64);
_local10.groupIndex = -1;
_local7 = createBody(_local10, -519, 453);
bodies.push(_local7);
_local10 = defineBox(236, 79, 0, 0.999, 0.001, 0, 0, 0.73);
_local10.groupIndex = -1;
_local7 = createBody(_local10, -628, 359);
bodies.push(_local7);
_local10 = defineBox(236, 79, 0, 0.999, 0.001, 0, 0, 0.82);
_local10.groupIndex = -1;
_local7 = createBody(_local10, -713, 267);
bodies.push(_local7);
_local10 = defineBox(236, 79, 0, 0.999, 0.001, 0, 0, 0.89);
_local10.groupIndex = -1;
_local7 = createBody(_local10, -792, 168);
bodies.push(_local7);
_local10 = defineBox(236, 79, 0, 0.999, 0.001, 0, 0, 0.97);
_local10.groupIndex = -1;
_local7 = createBody(_local10, -859, 70);
bodies.push(_local7);
_local10 = defineBox(236, 79, 0, 0.999, 0.001, 0, 0, 1.08);
_local10.groupIndex = -1;
_local7 = createBody(_local10, -915, -36);
bodies.push(_local7);
_local10 = defineBox(236, 79, 0, 0.999, 0.001, 0, 0, 1.15);
_local10.groupIndex = -1;
_local7 = createBody(_local10, -967, -153);
bodies.push(_local7);
_local10 = defineBox(236, 79, 0, 0.999, 0.001, 0, 0, 1.31);
_local10.groupIndex = -1;
_local7 = createBody(_local10, -997, -267);
bodies.push(_local7);
_local9 = defineCircle(55, 0, 0.999, 0.001);
_local9.groupIndex = -1;
_local7 = createBody(_local9, -1037, -364);
bodies.push(_local7);
_local10 = defineBox(354, 120, 0, 0.999, 0.001, 0, 0, 0);
_local10.groupIndex = -1;
_local7 = createBody(_local10, -1215, -359);
bodies.push(_local7);
_local10 = defineBox(79, 235, 0, 0.999, 0.001, 0, 0, -1.11);
_local10.groupIndex = -1;
_local7 = createBody(_local10, 398, -463);
bodies.push(_local7);
_local10 = defineBox(79, 171, 0, 0.999, 0.001, 0, 0, -0.92);
_local10.groupIndex = -1;
_local7 = createBody(_local10, 368, -499);
bodies.push(_local7);
_local10 = defineBox(79, 171, 0, 0.999, 0.001, 0, 0, -0.56);
_local10.groupIndex = -1;
_local7 = createBody(_local10, 317, -578);
bodies.push(_local7);
_local10 = defineBox(79, 171, 0, 0.999, 0.001, 0, 0, -0.3);
_local10.groupIndex = -1;
_local7 = createBody(_local10, 302, -647);
bodies.push(_local7);
_local10 = defineBox(79, 171, 0, 0.999, 0.001, 0, 0, -0.04);
_local10.groupIndex = -1;
_local7 = createBody(_local10, 311, -694);
bodies.push(_local7);
_local7 = createBody(defineCircle(55, 0, 0, 0.1), 742, 577);
bodies.push(_local7);
_local8 = [-87, 66, -54, 26, 87, -66, 87, 66];
_local7 = createBody(definePoly(_local8, 0, 0.5, 0.1), 782, 482);
bodies.push(_local7);
_local7 = createBody(defineBox(548, 80, 0, 0.5, 0.1), 606, 749);
bodies.push(_local7);
_local7 = createBody(defineBox(175, 800, 0, 0.5, 0.1), 941, 360);
bodies.push(_local7);
_local7 = createBody(defineCircle(65, 0, 0, 0.1), 878, 20);
bodies.push(_local7);
_local7 = createBody(defineCircle(65, 0, 0, 0.1), 862, 307);
bodies.push(_local7);
_local7 = createBody(defineBox(200, 80, 0, 0.5, 0.1, 0, 0, (-24.6 * DEG_2_RAD)), 961, -45);
bodies.push(_local7);
_local7 = createBody(defineBox(80, 200, 0, 0.5, 0.1, 0, 0, (-15 * DEG_2_RAD)), 883, 130);
bodies.push(_local7);
_local7 = createBody(defineBox(80, 200, 0, 0.5, 0.1, 0, 0, (14 * DEG_2_RAD)), 860, 213);
bodies.push(_local7);
dividerOffset0 = 2;
dividerOffset1 = 33;
dividerOffset2 = 67;
dividerOffset3 = 99;
dividerOffset4 = 131;
var _local11:Number = 607;
var _local12:Number = -704;
var _local13:Number = 0.1;
var _local14:Number = 0.9;
dividerX = [(_local11 + 57), (_local11 + 64), (_local11 + 71), (_local11 + 78), (_local11 + 85), (_local11 + 92), (_local11 + 99), (_local11 + 106), (_local11 + 113), (_local11 + 120), (_local11 + 126), (_local11 + 132), (_local11 + 138), (_local11 + 144), (_local11 + 150), (_local11 + 156), (_local11 + 162), (_local11 + 168), (_local11 + 174), (_local11 + 180), (_local11 + 186), (_local11 + 192), (_local11 + 198), (_local11 + 204), (_local11 + 210), (_local11 + 219), (_local11 + 229), (_local11 + 238), (_local11 + 247), (_local11 + 0x0100), (_local11 + 264), (_local11 + 272), (_local11 + 274), (_local11 + 276), (_local11 + 277), (_local11 + 279), (_local11 + 281), (_local11 + 282), (_local11 + 280), (_local11 + 278), (_local11 + 276), (_local11 + 274), (_local11 + 271), (_local11 + 268), (_local11 + 265), (_local11 + 262), (_local11 + 258), (_local11 + 0xFF), (_local11 + 251), (_local11 + 247), (_local11 + 242), (_local11 + 237), (_local11 + 231), (_local11 + 226), (_local11 + 221), (_local11 + 216), (_local11 + 211), (_local11 + 206), (_local11 + 201), (_local11 + 196), (_local11 + 191), (_local11 + 186), (_local11 + 180), (_local11 + 175), (_local11 + 170), (_local11 + 165), (_local11 + 160), (_local11 + 154), (_local11 + 148), (_local11 + 142), (_local11 + 135), (_local11 + 129), (_local11 + 123), (_local11 + 117), (_local11 + 110), (_local11 + 104), (_local11 + 98), (_local11 + 91), (_local11 + 85), (_local11 + 79), (_local11 + 73), (_local11 + 66), (_local11 + 60), (_local11 + 54), (_local11 + 48), (_local11 + 41), (_local11 + 34), (_local11 + 28), (_local11 + 21), (_local11 + 14), (_local11 + 7), _local11, (_local11 - 7), (_local11 - 14), (_local11 - 21), (_local11 - 28), (_local11 - 35), (_local11 - 41), (_local11 - 48), (_local11 - 54), (_local11 - 61), (_local11 - 67), (_local11 - 74), (_local11 - 80), (_local11 - 86), (_local11 - 93), (_local11 - 99), (_local11 - 106), (_local11 - 112), (_local11 - 119), (_local11 - 126), (_local11 - 130), (_local11 - 135), (_local11 - 139), (_local11 - 144), (_local11 - 148), (_local11 - 152), (_local11 - 155), (_local11 - 158), (_local11 - 161), (_local11 - 161), (_local11 - 162), (_local11 - 162), (_local11 - 162), (_local11 - 161), (_local11 - 160), (_local11 - 158), (_local11 - 157), (_local11 - 152), (_local11 - 147), (_local11 - 141), (_local11 - 136), (_local11 - 130), (_local11 - 123), (_local11 - 116), (_local11 - 107), (_local11 - 99), (_local11 - 90), (_local11 - 82), (_local11 - 75), (_local11 - 67), (_local11 - 59), (_local11 - 51), (_local11 - 46), (_local11 - 41), (_local11 - 36), (_local11 - 30), (_local11 - 25), (_local11 - 19), (_local11 - 14), (_local11 - 14), (_local11 - 7), _local11, (_local11 + 7), (_local11 + 14), (_local11 + 21), (_local11 + 29), (_local11 + 36), (_local11 + 43), (_local11 + 50)];
dividerY = [(_local12 + 20), (_local12 + 19), (_local12 + 17), (_local12 + 16), (_local12 + 15), (_local12 + 14), (_local12 + 12), (_local12 + 11), (_local12 + 10), (_local12 + 9), (_local12 + 7), (_local12 + 4), (_local12 + 2), _local12, (_local12 - 2), (_local12 - 5), (_local12 - 7), (_local12 - 9), (_local12 - 11), (_local12 - 13), (_local12 - 15), (_local12 - 17), (_local12 - 19), (_local12 - 20), (_local12 - 22), (_local12 - 20), (_local12 - 16), (_local12 - 12), (_local12 - 7), (_local12 - 2), (_local12 + 4), (_local12 + 10), (_local12 + 15), (_local12 + 19), (_local12 + 24), (_local12 + 29), (_local12 + 33), (_local12 + 38), (_local12 + 44), (_local12 + 50), (_local12 + 56), (_local12 + 62), (_local12 + 68), (_local12 + 74), (_local12 + 80), (_local12 + 86), (_local12 + 92), (_local12 + 97), (_local12 + 103), (_local12 + 108), (_local12 + 111), (_local12 + 113), (_local12 + 115), (_local12 + 118), (_local12 + 121), (_local12 + 123), (_local12 + 126), (_local12 + 128), (_local12 + 131), (_local12 + 133), (_local12 + 135), (_local12 + 138), (_local12 + 140), (_local12 + 143), (_local12 + 145), (_local12 + 148), (_local12 + 150), (_local12 + 151), (_local12 + 152), (_local12 + 153), (_local12 + 154), (_local12 + 156), (_local12 + 157), (_local12 + 158), (_local12 + 159), (_local12 + 160), (_local12 + 161), (_local12 + 161), (_local12 + 162), (_local12 + 163), (_local12 + 164), (_local12 + 165), (_local12 + 166), (_local12 + 167), (_local12 + 168), (_local12 + 169), (_local12 + 168), (_local12 + 168), (_local12 + 168), (_local12 + 168), (_local12 + 168), (_local12 + 168), (_local12 + 167), (_local12 + 167), (_local12 + 167), (_local12 + 167), (_local12 + 164), (_local12 + 162), (_local12 + 160), (_local12 + 158), (_local12 + 155), (_local12 + 153), (_local12 + 151), (_local12 + 149), (_local12 + 146), (_local12 + 144), (_local12 + 141), (_local12 + 139), (_local12 + 136), (_local12 + 133), (_local12 + 130), (_local12 + 126), (_local12 + 121), (_local12 + 117), (_local12 + 111), (_local12 + 106), (_local12 + 101), (_local12 + 95), (_local12 + 89), (_local12 + 82), (_local12 + 75), (_local12 + 67), (_local12 + 59), (_local12 + 51), (_local12 + 45), (_local12 + 40), (_local12 + 34), (_local12 + 28), (_local12 + 22), (_local12 + 16), (_local12 + 10), (_local12 + 5), _local12, (_local12 - 6), (_local12 - 11), (_local12 - 12), (_local12 - 13), (_local12 - 14), (_local12 - 13), (_local12 - 11), (_local12 - 10), (_local12 - 8), (_local12 - 6), (_local12 - 4), (_local12 - 1), (_local12 + 2), (_local12 + 4), (_local12 + 7), (_local12 + 9), (_local12 + 12), (_local12 + 12), (_local12 + 13), (_local12 + 14), (_local12 + 15), (_local12 + 16), (_local12 + 17), (_local12 + 18), (_local12 + 19), (_local12 + 20), (_local12 + 21)];
dividerR = [-0.13, -0.17, -0.2, -0.23, -0.26, -0.29, -0.32, -0.35, -0.38, -0.41, -0.38, -0.34, -0.31, -0.27, -0.24, -0.2, -0.17, -0.13, -0.1, -0.06, -0.03, 0, 0.03, 0.07, 0.11, 0.25, 0.4, 0.55, 0.7, 0.84, 0.99, 1.14, 1.21, 1.28, 1.34, 1.41, 1.48, 1.54, 1.62, 1.71, 1.79, 1.87, 1.96, 2.04, 2.12, 2.2, 2.29, 2.37, 2.45, 2.54, 2.55, 2.57, 2.58, 2.59, 2.61, 2.62, 2.64, 2.65, 2.67, 2.68, 2.69, 2.71, 2.72, 2.74, 2.75, 2.77, 2.78, 2.8, 2.83, 2.85, 2.87, 2.9, 2.92, 2.94, 2.96, 2.98, 3.01, 3.03, 3.05, 3.08, 3.1, 3.12, -3.13, -3.11, -3.09, -3.06, -3.04, -3.02, -3, -2.97, -2.95, -2.93, -2.91, -2.89, -2.86, -2.84, -2.82, -2.8, -2.77, -2.75, -2.73, -2.71, -2.68, -2.66, -2.64, -2.61, -2.58, -2.55, -2.51, -2.48, -2.45, -2.37, -2.29, -2.21, -2.13, -2.05, -1.97, -1.87, -1.78, -1.68, -1.58, -1.49, -1.4, -1.3, -1.21, -1.12, -1.04, -0.95, -0.86, -0.77, -0.69, -0.6, -0.51, -0.41, -0.3, -0.19, -0.08, 0.02, 0.07, 0.11, 0.16, 0.21, 0.26, 0.24, 0.23, 0.21, 0.2, 0.19, 0.17, 0.16, 0.16, 0.13, 0.1, 0.07, 0.04, 0.01, -0.01, -0.04, -0.07, -0.1];
dividerStep = -1;
numDividerSteps = dividerX.length;
_local7 = createBody(defineCircle(50, 0, _local13, _local14), (_local11 - 86), (_local12 + 66));
_local7.freeze();
bodies.push(_local7);
_local7 = createBody(defineCircle(40, 0, _local13, _local14), (_local11 + 214), (_local12 + 44));
_local7.freeze();
bodies.push(_local7);
_local8 = [-68, 18, 48, 42, 28, 142, -64, 128, -108, 112];
_local7 = createBody(definePoly(_local8, 0, _local13, _local14), _local11, _local12);
_local7.freeze();
bodies.push(_local7);
_local8 = [48, 42, 94, 38, 96, 138, 28, 142];
_local7 = createBody(definePoly(_local8, 0, _local13, _local14), _local11, _local12);
_local7.freeze();
bodies.push(_local7);
_local8 = [94, 38, 202, 6, 246, 70, 220, 94, 174, 118, 96, 138];
_local7 = createBody(definePoly(_local8, 0, _local13, _local14), _local11, _local12);
_local7.freeze();
bodies.push(_local7);
d0 = createBody(defineBox(50, 80, 0, _local13, _local14), -1000, -1000);
bodies.push(d0);
d1 = createBody(defineBox(50, 80, 0, _local13, _local14), -1100, -1000);
bodies.push(d1);
d2 = createBody(defineBox(50, 80, 0, _local13, _local14), -1200, -1000);
bodies.push(d2);
d3 = createBody(defineBox(50, 80, 0, _local13, _local14), -1300, -1000);
bodies.push(d3);
d4 = createBody(defineBox(50, 80, 0, _local13, _local14), -1400, -1000);
bodies.push(d4);
}
override public function step(_arg1:Number, _arg2:Boolean):void{
var _local3:int;
var _local4:int;
var _local5:Number;
var _local6:Number;
var _local7:Number;
if (_arg2){
_local4 = 0;
while (_local4 < 6) {
super.step(_arg1, true);
_local4++;
};
blob.step(world, _arg1);
};
dividerStep++;
_local3 = ((dividerStep + dividerOffset0) % numDividerSteps);
d0.setCenter(dividerX[_local3], dividerY[_local3], dividerR[_local3]);
_local3 = ((dividerStep + dividerOffset1) % numDividerSteps);
d1.setCenter(dividerX[_local3], dividerY[_local3], dividerR[_local3]);
_local3 = ((dividerStep + dividerOffset2) % numDividerSteps);
d2.setCenter(dividerX[_local3], dividerY[_local3], dividerR[_local3]);
_local3 = ((dividerStep + dividerOffset3) % numDividerSteps);
d3.setCenter(dividerX[_local3], dividerY[_local3], dividerR[_local3]);
_local3 = ((dividerStep + dividerOffset4) % numDividerSteps);
d4.setCenter(dividerX[_local3], dividerY[_local3], dividerR[_local3]);
if (toge.contactList){
_local5 = (blob.centreNode.x - toge.x);
_local6 = (blob.centreNode.y - toge.y);
_local7 = Math.sqrt(((_local5 * _local5) + (_local6 * _local6)));
_local5 = (_local5 / _local7);
_local6 = (_local6 / _local7);
_local5 = (_local5 * 8000);
_local6 = (_local6 * 8000);
blob.canJump = true;
blob.jump(_local5, _local6, world);
Main.smSFX.getSoundFromID("SpikeSFX").play();
};
}
}
}//package uk.kerb.locoRoco.game.level7
Section 116
//Renderer (uk.kerb.locoRoco.game.level7.Renderer)
package uk.kerb.locoRoco.game.level7 {
import uk.kerb.locoRoco.game.*;
import uk.kerb.utils.game.*;
import flash.display.*;
public class Renderer extends BaseRenderer {
private var conveyor:MovieClip;
public function Renderer(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Number, _arg6:Number, _arg7:AssetFactory, _arg8:BasePhysics){
super(_arg1, _arg2, _arg3, _arg4, _arg5, _arg6, _arg7, _arg8);
var _local9:MovieClip = (_arg7.createDisplayObject("Level7BGAsset") as MovieClip);
backgroundSprite.addChild(_local9);
flowers = new Array();
flowers.push(_local9.conveyor.flower0);
flowers.push(_local9.conveyor.flower1);
flowers.push(_local9.conveyor.flower2);
flowers.push(_local9.conveyor.flower3);
flowers.push(_local9.conveyor.flower4);
lines = new Array();
lines.push(_local9.conveyor.line0);
lines.push(_local9.conveyor.line1);
lines.push(_local9.conveyor.line2);
lines.push(_local9.conveyor.line3);
lines.push(_local9.conveyor.line4);
conveyor = _local9.conveyor;
}
override public function resumeAnimations():void{
var _local1:int;
conveyor.play();
_local1 = 0;
while (_local1 < flowers.length) {
flowers[_local1].play();
_local1++;
};
_local1 = 0;
while (_local1 < lines.length) {
lines[_local1].play();
_local1++;
};
conveyor.snowflake0.play();
conveyor.snowflake1.play();
conveyor.snowflake2.play();
conveyor.gear0.play();
conveyor.gear1.play();
conveyor.gear2.play();
conveyor.gear3.play();
conveyor.gear4.play();
}
override public function pauseAnimations():void{
var _local1:int;
conveyor.stop();
_local1 = 0;
while (_local1 < flowers.length) {
flowers[_local1].stop();
_local1++;
};
_local1 = 0;
while (_local1 < lines.length) {
lines[_local1].stop();
_local1++;
};
conveyor.snowflake0.stop();
conveyor.snowflake1.stop();
conveyor.snowflake2.stop();
conveyor.gear0.stop();
conveyor.gear1.stop();
conveyor.gear2.stop();
conveyor.gear3.stop();
conveyor.gear4.stop();
}
}
}//package uk.kerb.locoRoco.game.level7
Section 117
//Level (uk.kerb.locoRoco.game.level8.Level)
package uk.kerb.locoRoco.game.level8 {
import uk.co.stdio.sound.*;
import uk.kerb.locoRoco.game.*;
import uk.kerb.utils.game.*;
public class Level extends BaseLevel {
public function Level(_arg1:AssetFactory){
super(_arg1);
}
override protected function init():void{
var _local9:Sequence;
var _local10:ExtendedSound;
gravity = 140;
levelTime = 30000;
var _local1:Number = 2062;
var _local2:Number = 1500;
var _local3:Number = -825;
var _local4:Number = 400;
physics = new Physics(_local1, _local2, gravity, _local3, _local4);
var _local5:Number = 275;
var _local6:Number = 200;
var _local7:Number = 1650;
var _local8:Number = 1200;
renderer = new Renderer(_local5, _local6, _local7, _local8, _local1, _local2, af, physics);
house = new House(-1199, 850, af);
house.frontMC.scaleX = -1;
house.backMC.scaleX = -1;
targets = new Array();
targets.push(new Target(1, renderer.flowers[0], renderer.lines[0], BaseLevel.ID_BLACK));
targets.push(new Target(1, renderer.flowers[1], renderer.lines[1], BaseLevel.ID_YELLOW));
targets.push(new Target(1, renderer.flowers[2], renderer.lines[2], BaseLevel.ID_RED));
targets.push(new Target(1, renderer.flowers[3], renderer.lines[3], BaseLevel.ID_GREEN));
targets.push(new Target(1, renderer.flowers[4], renderer.lines[4], BaseLevel.ID_BLUE));
powerups = new Array();
powerups.push(new Powerup(-1214, -390, 30000, Powerup.TYPE_TIME));
powerups.push(new Powerup(-565, -188, 30000, Powerup.TYPE_TIME));
powerups.push(new Powerup(-888, -379, 30000, Powerup.TYPE_TIME));
powerups.push(new Powerup(-969, -64, 30000, Powerup.TYPE_TIME));
powerups.push(new Powerup(-629, -524, 30000, Powerup.TYPE_TIME));
powerups.push(new Powerup(-1121, -613, 30000, Powerup.TYPE_TIME));
powerups.push(new Powerup(1192, -319, 100, Powerup.TYPE_POINTS));
powerups.push(new Powerup(1192, -449, 100, Powerup.TYPE_POINTS));
powerups.push(new Powerup(1190, -589, 100, Powerup.TYPE_POINTS));
powerups.push(new Powerup(-813, -244, 100, Powerup.TYPE_POINTS));
powerups.push(new Powerup(-1045, -474, 100, Powerup.TYPE_POINTS));
powerups.push(new Powerup(-1047, -198, 100, Powerup.TYPE_POINTS));
powerups.push(new Powerup(-633, -59, 100, Powerup.TYPE_POINTS));
powerups.push(new Powerup(-809, -540, 100, Powerup.TYPE_POINTS));
powerups.push(new Powerup(-1209, -109, 100, Powerup.TYPE_POINTS));
powerups.push(new Powerup(-651, -335, 100, Powerup.TYPE_POINTS));
numPointsPowerups = 10;
musicLoops = new Array();
_local10 = smSequencer.getSoundFromID("Snow1And2");
_local9 = new Sequence();
_local9.addStep(_local10, 0);
musicLoops.push(_local9);
_local10 = smSequencer.getSoundFromID("Snow3");
_local9 = new Sequence();
_local9.addStep(_local10, 0);
musicLoops.push(_local9);
_local10 = smSequencer.getSoundFromID("Snow4");
_local9 = new Sequence();
_local9.addStep(_local10, 0);
musicLoops.push(_local9);
_local10 = smSequencer.getSoundFromID("Snow5");
_local9 = new Sequence();
_local9.addStep(_local10, 0);
musicLoops.push(_local9);
_local10 = smSequencer.getSoundFromID("Snow6");
_local9 = new Sequence();
_local9.addStep(_local10, 0);
musicLoops.push(_local9);
_local10 = smSequencer.getSoundFromID("Snow7And8");
_local9 = new Sequence();
_local9.addStep(_local10, 0);
musicLoops.push(_local9);
super.init();
}
}
}//package uk.kerb.locoRoco.game.level8
Section 118
//Physics (uk.kerb.locoRoco.game.level8.Physics)
package uk.kerb.locoRoco.game.level8 {
import uk.kerb.locoRoco.game.*;
import uk.kerb.utils.game.*;
import de.polygonal.motor2.dynamics.*;
import de.polygonal.motor2.collision.shapes.data.*;
public class Physics extends BasePhysics {
private var dividerStep:int;
private var d0:RigidBody;
private var d1:RigidBody;
private var d2:RigidBody;
private var d3:RigidBody;
private var d4:RigidBody;
private var dividerR:Array;
private var dividerX:Array;
private var dividerY:Array;
private var dividerOffset0:int;
private var dividerOffset1:int;
private var dividerOffset2:int;
private var dividerOffset3:int;
private var dividerOffset4:int;
private var toge:RigidBody;
private var numDividerSteps:int;
private var rainbow:RigidBody;
public function Physics(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Number){
var _local7:RigidBody;
var _local8:Array;
var _local9:CircleData;
var _local10:BoxData;
var _local6:Number = 0.1;
super(_arg1, _arg2, _arg3, _arg4, _arg5, _local6);
initWorldEdges(-1300, -1400, 1331, 900);
toge = createBody(defineCircle(25, 0, 0.5, 0.1), -151, -661);
bodies.push(toge);
_local7 = createBody(defineCircle(65, 0, 0.999, 0.001), -1254, 202);
bodies.push(_local7);
_local7 = createBody(defineCircle(65, 0, 0.999, 0.001), -1238, 488);
bodies.push(_local7);
_local7 = createBody(defineBox(200, 80, 0, 0.5, 0.1, 0, 0, (24.6 * DEG_2_RAD)), -1338, 137);
bodies.push(_local7);
_local7 = createBody(defineBox(80, 200, 0, 0.5, 0.1, 0, 0, (15 * DEG_2_RAD)), -1260, 312);
bodies.push(_local7);
_local7 = createBody(defineBox(80, 200, 0, 0.5, 0.1, 0, 0, (-14 * DEG_2_RAD)), -1236, 395);
bodies.push(_local7);
_local7 = createBody(defineBox(175, 2500, 0, 0.5, 0.1), -1317, -200);
bodies.push(_local7);
_local7 = createBody(defineCircle(65, 0, 0.999, 0.001), -1118, 759);
bodies.push(_local7);
_local8 = [-87, -66, 54, 26, 87, 66, -87, 66];
_local7 = createBody(definePoly(_local8, 0, 0.5, 0.1), -1158, 664);
bodies.push(_local7);
_local9 = defineCircle(2000, 0, 0.999, 0.001);
_local9.groupIndex = -1;
rainbow = createBody(_local9, 1128, 1816);
bodies.push(rainbow);
_local10 = defineBox(327, 148, 0, 0.999, 0.001, 0, 0, -0.07);
_local10.groupIndex = -1;
_local7 = createBody(_local10, 1286, -120);
bodies.push(_local7);
_local10 = defineBox(491, 79, 0, 0.999, 0.001, 0, 0, -0.81);
_local10.groupIndex = -1;
_local7 = createBody(_local10, -646, 357);
bodies.push(_local7);
_local9 = defineCircle(131, 0, 0.999, 0.001);
_local9.groupIndex = -1;
_local7 = createBody(_local9, -523, 96);
bodies.push(_local7);
_local9 = defineCircle(87, 0, 0.999, 0.001);
_local9.groupIndex = -1;
_local7 = createBody(_local9, -780, 567);
bodies.push(_local7);
_local9 = defineCircle(139, 0, 0.999, 0.001);
_local9.groupIndex = -1;
_local7 = createBody(_local9, -1037, 505);
bodies.push(_local7);
_local10 = defineBox(472, 112, 0, 0.999, 0.001, 0, 0, 0);
_local10.groupIndex = -1;
_local7 = createBody(_local10, 489, -532);
bodies.push(_local7);
_local10 = defineBox(472, 75, 0, 0.999, 0.001, 0, 0, 0.2);
_local10.groupIndex = -1;
_local7 = createBody(_local10, -268, -624);
bodies.push(_local7);
_local9 = defineCircle(94, 0, 0.999, 0.001);
_local9.groupIndex = -1;
_local7 = createBody(_local9, -504, -614);
bodies.push(_local7);
_local10 = defineBox(114, 720, 0, 0.999, 0.001, 0, 0, -0.02);
_local10.groupIndex = -1;
_local7 = createBody(_local10, -458, -265);
bodies.push(_local7);
_local9 = defineCircle(45, 0, 0.001, 0.001);
_local9.groupIndex = -1;
_local7 = createBody(_local9, -731, -560);
bodies.push(_local7);
_local7 = createBody(_local9, -888, -560);
bodies.push(_local7);
_local7 = createBody(_local9, -1046, -560);
bodies.push(_local7);
_local7 = createBody(_local9, -967, -424);
bodies.push(_local7);
_local7 = createBody(_local9, -810, -424);
bodies.push(_local7);
_local7 = createBody(_local9, -1124, -424);
bodies.push(_local7);
_local7 = createBody(_local9, -653, -424);
bodies.push(_local7);
_local7 = createBody(_local9, -967, -151);
bodies.push(_local7);
_local7 = createBody(_local9, -810, -152);
bodies.push(_local7);
_local7 = createBody(_local9, -1125, -152);
bodies.push(_local7);
_local7 = createBody(_local9, -653, -151);
bodies.push(_local7);
_local7 = createBody(_local9, -731, -288);
bodies.push(_local7);
_local7 = createBody(_local9, -889, -288);
bodies.push(_local7);
_local7 = createBody(_local9, -1046, -288);
bodies.push(_local7);
_local7 = createBody(_local9, -731, -15);
bodies.push(_local7);
_local7 = createBody(_local9, -888, -15);
bodies.push(_local7);
_local7 = createBody(_local9, -1046, -15);
bodies.push(_local7);
_local7 = createBody(_local9, -1203, -560);
bodies.push(_local7);
_local7 = createBody(_local9, -1203, -288);
bodies.push(_local7);
_local7 = createBody(_local9, -1203, -15);
bodies.push(_local7);
_local7 = createBody(_local9, -574, -288);
bodies.push(_local7);
dividerOffset0 = 2;
dividerOffset1 = 33;
dividerOffset2 = 67;
dividerOffset3 = 99;
dividerOffset4 = 131;
var _local11:Number = -977;
var _local12:Number = 150;
var _local13:Number = 0.1;
var _local14:Number = 0.9;
dividerX = [(_local11 + 57), (_local11 + 64), (_local11 + 71), (_local11 + 78), (_local11 + 85), (_local11 + 92), (_local11 + 99), (_local11 + 106), (_local11 + 113), (_local11 + 120), (_local11 + 126), (_local11 + 132), (_local11 + 138), (_local11 + 144), (_local11 + 150), (_local11 + 156), (_local11 + 162), (_local11 + 168), (_local11 + 174), (_local11 + 180), (_local11 + 186), (_local11 + 192), (_local11 + 198), (_local11 + 204), (_local11 + 210), (_local11 + 219), (_local11 + 229), (_local11 + 238), (_local11 + 247), (_local11 + 0x0100), (_local11 + 264), (_local11 + 272), (_local11 + 274), (_local11 + 276), (_local11 + 277), (_local11 + 279), (_local11 + 281), (_local11 + 282), (_local11 + 280), (_local11 + 278), (_local11 + 276), (_local11 + 274), (_local11 + 271), (_local11 + 268), (_local11 + 265), (_local11 + 262), (_local11 + 258), (_local11 + 0xFF), (_local11 + 251), (_local11 + 247), (_local11 + 242), (_local11 + 237), (_local11 + 231), (_local11 + 226), (_local11 + 221), (_local11 + 216), (_local11 + 211), (_local11 + 206), (_local11 + 201), (_local11 + 196), (_local11 + 191), (_local11 + 186), (_local11 + 180), (_local11 + 175), (_local11 + 170), (_local11 + 165), (_local11 + 160), (_local11 + 154), (_local11 + 148), (_local11 + 142), (_local11 + 135), (_local11 + 129), (_local11 + 123), (_local11 + 117), (_local11 + 110), (_local11 + 104), (_local11 + 98), (_local11 + 91), (_local11 + 85), (_local11 + 79), (_local11 + 73), (_local11 + 66), (_local11 + 60), (_local11 + 54), (_local11 + 48), (_local11 + 41), (_local11 + 34), (_local11 + 28), (_local11 + 21), (_local11 + 14), (_local11 + 7), _local11, (_local11 - 7), (_local11 - 14), (_local11 - 21), (_local11 - 28), (_local11 - 35), (_local11 - 41), (_local11 - 48), (_local11 - 54), (_local11 - 61), (_local11 - 67), (_local11 - 74), (_local11 - 80), (_local11 - 86), (_local11 - 93), (_local11 - 99), (_local11 - 106), (_local11 - 112), (_local11 - 119), (_local11 - 126), (_local11 - 130), (_local11 - 135), (_local11 - 139), (_local11 - 144), (_local11 - 148), (_local11 - 152), (_local11 - 155), (_local11 - 158), (_local11 - 161), (_local11 - 161), (_local11 - 162), (_local11 - 162), (_local11 - 162), (_local11 - 161), (_local11 - 160), (_local11 - 158), (_local11 - 157), (_local11 - 152), (_local11 - 147), (_local11 - 141), (_local11 - 136), (_local11 - 130), (_local11 - 123), (_local11 - 116), (_local11 - 107), (_local11 - 99), (_local11 - 90), (_local11 - 82), (_local11 - 75), (_local11 - 67), (_local11 - 59), (_local11 - 51), (_local11 - 46), (_local11 - 41), (_local11 - 36), (_local11 - 30), (_local11 - 25), (_local11 - 19), (_local11 - 14), (_local11 - 14), (_local11 - 7), _local11, (_local11 + 7), (_local11 + 14), (_local11 + 21), (_local11 + 29), (_local11 + 36), (_local11 + 43), (_local11 + 50)];
dividerY = [(_local12 + 20), (_local12 + 19), (_local12 + 17), (_local12 + 16), (_local12 + 15), (_local12 + 14), (_local12 + 12), (_local12 + 11), (_local12 + 10), (_local12 + 9), (_local12 + 7), (_local12 + 4), (_local12 + 2), _local12, (_local12 - 2), (_local12 - 5), (_local12 - 7), (_local12 - 9), (_local12 - 11), (_local12 - 13), (_local12 - 15), (_local12 - 17), (_local12 - 19), (_local12 - 20), (_local12 - 22), (_local12 - 20), (_local12 - 16), (_local12 - 12), (_local12 - 7), (_local12 - 2), (_local12 + 4), (_local12 + 10), (_local12 + 15), (_local12 + 19), (_local12 + 24), (_local12 + 29), (_local12 + 33), (_local12 + 38), (_local12 + 44), (_local12 + 50), (_local12 + 56), (_local12 + 62), (_local12 + 68), (_local12 + 74), (_local12 + 80), (_local12 + 86), (_local12 + 92), (_local12 + 97), (_local12 + 103), (_local12 + 108), (_local12 + 111), (_local12 + 113), (_local12 + 115), (_local12 + 118), (_local12 + 121), (_local12 + 123), (_local12 + 126), (_local12 + 128), (_local12 + 131), (_local12 + 133), (_local12 + 135), (_local12 + 138), (_local12 + 140), (_local12 + 143), (_local12 + 145), (_local12 + 148), (_local12 + 150), (_local12 + 151), (_local12 + 152), (_local12 + 153), (_local12 + 154), (_local12 + 156), (_local12 + 157), (_local12 + 158), (_local12 + 159), (_local12 + 160), (_local12 + 161), (_local12 + 161), (_local12 + 162), (_local12 + 163), (_local12 + 164), (_local12 + 165), (_local12 + 166), (_local12 + 167), (_local12 + 168), (_local12 + 169), (_local12 + 168), (_local12 + 168), (_local12 + 168), (_local12 + 168), (_local12 + 168), (_local12 + 168), (_local12 + 167), (_local12 + 167), (_local12 + 167), (_local12 + 167), (_local12 + 164), (_local12 + 162), (_local12 + 160), (_local12 + 158), (_local12 + 155), (_local12 + 153), (_local12 + 151), (_local12 + 149), (_local12 + 146), (_local12 + 144), (_local12 + 141), (_local12 + 139), (_local12 + 136), (_local12 + 133), (_local12 + 130), (_local12 + 126), (_local12 + 121), (_local12 + 117), (_local12 + 111), (_local12 + 106), (_local12 + 101), (_local12 + 95), (_local12 + 89), (_local12 + 82), (_local12 + 75), (_local12 + 67), (_local12 + 59), (_local12 + 51), (_local12 + 45), (_local12 + 40), (_local12 + 34), (_local12 + 28), (_local12 + 22), (_local12 + 16), (_local12 + 10), (_local12 + 5), _local12, (_local12 - 6), (_local12 - 11), (_local12 - 12), (_local12 - 13), (_local12 - 14), (_local12 - 13), (_local12 - 11), (_local12 - 10), (_local12 - 8), (_local12 - 6), (_local12 - 4), (_local12 - 1), (_local12 + 2), (_local12 + 4), (_local12 + 7), (_local12 + 9), (_local12 + 12), (_local12 + 12), (_local12 + 13), (_local12 + 14), (_local12 + 15), (_local12 + 16), (_local12 + 17), (_local12 + 18), (_local12 + 19), (_local12 + 20), (_local12 + 21)];
dividerR = [-0.13, -0.17, -0.2, -0.23, -0.26, -0.29, -0.32, -0.35, -0.38, -0.41, -0.38, -0.34, -0.31, -0.27, -0.24, -0.2, -0.17, -0.13, -0.1, -0.06, -0.03, 0, 0.03, 0.07, 0.11, 0.25, 0.4, 0.55, 0.7, 0.84, 0.99, 1.14, 1.21, 1.28, 1.34, 1.41, 1.48, 1.54, 1.62, 1.71, 1.79, 1.87, 1.96, 2.04, 2.12, 2.2, 2.29, 2.37, 2.45, 2.54, 2.55, 2.57, 2.58, 2.59, 2.61, 2.62, 2.64, 2.65, 2.67, 2.68, 2.69, 2.71, 2.72, 2.74, 2.75, 2.77, 2.78, 2.8, 2.83, 2.85, 2.87, 2.9, 2.92, 2.94, 2.96, 2.98, 3.01, 3.03, 3.05, 3.08, 3.1, 3.12, -3.13, -3.11, -3.09, -3.06, -3.04, -3.02, -3, -2.97, -2.95, -2.93, -2.91, -2.89, -2.86, -2.84, -2.82, -2.8, -2.77, -2.75, -2.73, -2.71, -2.68, -2.66, -2.64, -2.61, -2.58, -2.55, -2.51, -2.48, -2.45, -2.37, -2.29, -2.21, -2.13, -2.05, -1.97, -1.87, -1.78, -1.68, -1.58, -1.49, -1.4, -1.3, -1.21, -1.12, -1.04, -0.95, -0.86, -0.77, -0.69, -0.6, -0.51, -0.41, -0.3, -0.19, -0.08, 0.02, 0.07, 0.11, 0.16, 0.21, 0.26, 0.24, 0.23, 0.21, 0.2, 0.19, 0.17, 0.16, 0.16, 0.13, 0.1, 0.07, 0.04, 0.01, -0.01, -0.04, -0.07, -0.1];
dividerStep = -1;
numDividerSteps = dividerX.length;
_local7 = createBody(defineCircle(50, 0, _local13, _local14), (_local11 - 86), (_local12 + 66));
_local7.freeze();
bodies.push(_local7);
_local7 = createBody(defineCircle(40, 0, _local13, _local14), (_local11 + 214), (_local12 + 44));
_local7.freeze();
bodies.push(_local7);
_local8 = [-68, 18, 48, 42, 28, 142, -64, 128, -108, 112];
_local7 = createBody(definePoly(_local8, 0, _local13, _local14), _local11, _local12);
_local7.freeze();
bodies.push(_local7);
_local8 = [48, 42, 94, 38, 96, 138, 28, 142];
_local7 = createBody(definePoly(_local8, 0, _local13, _local14), _local11, _local12);
_local7.freeze();
bodies.push(_local7);
_local8 = [94, 38, 202, 6, 246, 70, 220, 94, 174, 118, 96, 138];
_local7 = createBody(definePoly(_local8, 0, _local13, _local14), _local11, _local12);
_local7.freeze();
bodies.push(_local7);
d0 = createBody(defineBox(50, 80, 0, _local13, _local14), -1000, -1000);
bodies.push(d0);
d1 = createBody(defineBox(50, 80, 0, _local13, _local14), -1100, -1000);
bodies.push(d1);
d2 = createBody(defineBox(50, 80, 0, _local13, _local14), -1200, -1000);
bodies.push(d2);
d3 = createBody(defineBox(50, 80, 0, _local13, _local14), -1300, -1000);
bodies.push(d3);
d4 = createBody(defineBox(50, 80, 0, _local13, _local14), -1400, -1000);
bodies.push(d4);
}
override public function step(_arg1:Number, _arg2:Boolean):void{
var _local3:int;
var _local4:int;
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:Number;
if (_arg2){
_local4 = 0;
while (_local4 < 6) {
super.step(_arg1, true);
_local4++;
};
blob.step(world, _arg1);
};
if (rainbow.contactList){
_local5 = ((rainbow.x - blob.centreNode.x) / 50);
_local6 = ((rainbow.y - blob.centreNode.y) / 50);
if (blob.centreNode.x < 1000){
blob.moveBy(_local6, -(_local5));
} else {
_local7 = ((blob.centreNode.x - 1000) / 50);
if (_local7 > 1){
_local7 = 1;
};
_local7 = (1 - _local7);
blob.moveBy((_local7 * _local6), (_local7 * -(_local5)));
};
};
dividerStep++;
_local3 = ((dividerStep + dividerOffset0) % numDividerSteps);
d0.setCenter(dividerX[_local3], dividerY[_local3], dividerR[_local3]);
_local3 = ((dividerStep + dividerOffset1) % numDividerSteps);
d1.setCenter(dividerX[_local3], dividerY[_local3], dividerR[_local3]);
_local3 = ((dividerStep + dividerOffset2) % numDividerSteps);
d2.setCenter(dividerX[_local3], dividerY[_local3], dividerR[_local3]);
_local3 = ((dividerStep + dividerOffset3) % numDividerSteps);
d3.setCenter(dividerX[_local3], dividerY[_local3], dividerR[_local3]);
_local3 = ((dividerStep + dividerOffset4) % numDividerSteps);
d4.setCenter(dividerX[_local3], dividerY[_local3], dividerR[_local3]);
if (toge.contactList){
_local5 = (blob.centreNode.x - toge.x);
_local6 = (blob.centreNode.y - toge.y);
_local8 = Math.sqrt(((_local5 * _local5) + (_local6 * _local6)));
_local5 = (_local5 / _local8);
_local6 = (_local6 / _local8);
_local5 = (_local5 * 8000);
_local6 = (_local6 * 8000);
blob.canJump = true;
blob.jump(_local5, _local6, world);
Main.smSFX.getSoundFromID("SpikeSFX").play();
};
}
}
}//package uk.kerb.locoRoco.game.level8
Section 119
//Renderer (uk.kerb.locoRoco.game.level8.Renderer)
package uk.kerb.locoRoco.game.level8 {
import uk.kerb.locoRoco.game.*;
import uk.kerb.utils.game.*;
import flash.display.*;
public class Renderer extends BaseRenderer {
private var conveyor:MovieClip;
public function Renderer(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Number, _arg6:Number, _arg7:AssetFactory, _arg8:BasePhysics){
super(_arg1, _arg2, _arg3, _arg4, _arg5, _arg6, _arg7, _arg8);
var _local9:MovieClip = (_arg7.createDisplayObject("Level8BGAsset") as MovieClip);
backgroundSprite.addChild(_local9);
flowers = new Array();
flowers.push(_local9.conveyor.flower0);
flowers.push(_local9.conveyor.flower1);
flowers.push(_local9.conveyor.flower2);
flowers.push(_local9.conveyor.flower3);
flowers.push(_local9.conveyor.flower4);
lines = new Array();
lines.push(_local9.conveyor.line0);
lines.push(_local9.conveyor.line1);
lines.push(_local9.conveyor.line2);
lines.push(_local9.conveyor.line3);
lines.push(_local9.conveyor.line4);
conveyor = _local9.conveyor;
}
override public function resumeAnimations():void{
var _local1:int;
conveyor.play();
_local1 = 0;
while (_local1 < flowers.length) {
flowers[_local1].play();
_local1++;
};
_local1 = 0;
while (_local1 < lines.length) {
lines[_local1].play();
_local1++;
};
conveyor.snowflake0.play();
conveyor.snowflake1.play();
conveyor.snowflake2.play();
conveyor.gear0.play();
conveyor.gear1.play();
conveyor.gear2.play();
conveyor.gear3.play();
conveyor.gear4.play();
}
override public function pauseAnimations():void{
var _local1:int;
conveyor.stop();
_local1 = 0;
while (_local1 < flowers.length) {
flowers[_local1].stop();
_local1++;
};
_local1 = 0;
while (_local1 < lines.length) {
lines[_local1].stop();
_local1++;
};
conveyor.snowflake0.stop();
conveyor.snowflake1.stop();
conveyor.snowflake2.stop();
conveyor.gear0.stop();
conveyor.gear1.stop();
conveyor.gear2.stop();
conveyor.gear3.stop();
conveyor.gear4.stop();
}
}
}//package uk.kerb.locoRoco.game.level8
Section 120
//BaseLevel (uk.kerb.locoRoco.game.BaseLevel)
package uk.kerb.locoRoco.game {
import flash.events.*;
import uk.co.stdio.sound.*;
import uk.kerb.locoRoco.*;
import uk.kerb.utils.game.*;
import flash.display.*;
import flash.geom.*;
import flash.utils.*;
public class BaseLevel extends Sprite {
protected var targets:Array;
protected var musicalNotes:Array;
protected var powerups:Array;
protected var smSequencer:Sequencer;
public var numTargets:int;
protected var house:House;
protected var af:AssetFactory;
protected var zoomingTimestamp:int;
public var musicLoops:Array;
protected var targetCounter:int;
protected var pt:Point;
public var numPointsPowerupsHit:int;
protected var ids:Array;
protected var numPowerups:int;
public var numPointsPowerups:int;
protected var tilt:Number;
protected var inactivityTimestamp:int;
protected var renderer:BaseRenderer;
protected var physics:BasePhysics;
protected var currJumpForce:Number;
protected var gravity:Number;
protected var smSFX:SoundManager;
public var currMusicLoop:int;
protected var kc:KeyControl;
private var houseCounter:int;
protected var currTarget:int;
public var levelTime:int;
protected var inHouse:Boolean;
public var totalPowerupPoints:int;
private static const INACTIVITY_MAX_JUMP:int = 6400;
public static const ID_BLUE:String = "blue";
private static const ZOOMING_TIMEOUT:int = 8000;
public static const ID_YELLOW:String = "yellow";
public static const ID_PINK:String = "pink";
private static const TILT_SPEED:Number = 0.0383972435438753;
private static const NUM_NOTES_PER_TARGET:int = 6;
private static const INACTIVITY_TIMEOUT:int = 5000;
public static const EVENT_LOSE:String = "onEventLose";
public static const ID_BLACK:String = "black";
public static const PURPLE:uint = 10042774;
public static const ID_GREEN:String = "green";
private static const INACTIVITY_MIN_JUMP:int = 1600;
private static const TARGET_HIT_TIMEOUT:int = 40;
public static const ID_RED:String = "red";
private static const MAX_JUMP_FORCE:Number = 16000;
private static const NOTE_DELAY:int = 5;
private static const MAX_TILT:Number = 0.523598775598299;
public static const BLUE:uint = 160961;
public static const BLACK:uint = 0;
public static const ALL_IDS:Array = new Array(ID_RED, ID_BLUE, ID_YELLOW, ID_PINK, ID_GREEN, ID_PURPLE, ID_BLACK);
public static const GREEN:uint = 6459948;
public static const ID_PURPLE:String = "purple";
private static const INACTIVITY_INTERVAL:int = 3000;
public static const RED:uint = 0xED0000;
public static const PINK:uint = 16218042;
public static const EVENT_WIN:String = "onEventWin";
public static const YELLOW:uint = 16235037;
public static var ALL_COLOURS:Dictionary;
public function BaseLevel(_arg1:AssetFactory){
pt = new Point();
super();
addEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
this.af = _arg1;
if (ALL_COLOURS == null){
ALL_COLOURS = new Dictionary();
ALL_COLOURS[ID_YELLOW] = YELLOW;
ALL_COLOURS[ID_PINK] = PINK;
ALL_COLOURS[ID_BLACK] = BLACK;
ALL_COLOURS[ID_BLUE] = BLUE;
ALL_COLOURS[ID_RED] = RED;
ALL_COLOURS[ID_GREEN] = GREEN;
ALL_COLOURS[ID_PURPLE] = PURPLE;
};
smSequencer = Main.smSequencer;
smSFX = Main.smSFX;
}
private function onPrepareJump(_arg1:Event):void{
renderer.verticalOffset = 4;
currJumpForce = MAX_JUMP_FORCE;
}
protected function init():void{
tilt = 0;
currJumpForce = 0;
currTarget = -1;
targetCounter = 0;
numPointsPowerupsHit = 0;
totalPowerupPoints = 0;
currMusicLoop = 0;
houseCounter = 0;
inHouse = false;
musicalNotes = new Array();
numTargets = targets.length;
numPowerups = powerups.length;
initIDs();
renderer.setPowerups(powerups);
renderer.setHouse(house);
addChild(renderer);
kc = new KeyControl(stage);
kc.addEventListener(KeyControl.EVENT_JUMP, onJump);
kc.addEventListener(KeyControl.EVENT_PREPARE_JUMP, onPrepareJump);
dispatchEvent(new Event(Event.INIT));
smSequencer.playSequence(musicLoops[currMusicLoop]);
var _local1:Sequence = musicLoops[currMusicLoop];
_local1.currSound.setVolume(1);
}
public function dispose():void{
if (kc){
kc.removeEventListener(KeyControl.EVENT_JUMP, onJump);
kc.removeEventListener(KeyControl.EVENT_PREPARE_JUMP, onPrepareJump);
};
}
public function getNumTargetsHit():int{
var _local1:int;
var _local2:int;
while (_local2 < numTargets) {
if (targets[_local2].numBlobs == targets[_local2].targetBlobs){
_local1++;
};
_local2++;
};
return (_local1);
}
private function initIDs():void{
var _local1:int;
var _local2:int;
ids = new Array();
_local1 = 0;
while (_local1 < numTargets) {
ids[_local1] = targets[_local1].id;
_local1++;
};
_local2 = Math.floor((Math.random() * ids.length));
physics.blob.id = ids[_local2];
physics.blob.colour = ALL_COLOURS[ids[_local2]];
renderer.setFace(ids[_local2]);
}
private function onAddedToStage(_arg1:Event):void{
removeEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
init();
}
public function resume():void{
renderer.resumeAnimations();
}
private function checkKeys():void{
var _local2:Number;
var _local3:Number;
var _local4:int;
var _local1:Number = tilt;
if (kc.left){
_local1 = (_local1 - TILT_SPEED);
if (_local1 < -(MAX_TILT)){
_local1 = -(MAX_TILT);
};
} else {
if (kc.right){
_local1 = (_local1 + TILT_SPEED);
if (_local1 > MAX_TILT){
_local1 = MAX_TILT;
};
};
};
if (kc.either){
_local4 = getTimer();
renderer.zooming = false;
inactivityTimestamp = _local4;
zoomingTimestamp = _local4;
};
if (tilt != _local1){
tilt = _local1;
_local2 = (gravity * Math.sin(tilt));
_local3 = (gravity * Math.cos(tilt));
physics.setGravity(_local2, _local3);
};
}
private function resolveTargetHit(_arg1:Target):Boolean{
var _local3:int;
var _local4:int;
var _local5:MusicalNote;
var _local2:Boolean;
if (physics.blob.colour == _arg1.colour){
if (_arg1.numBlobs < _arg1.targetBlobs){
_arg1.numBlobs++;
_local2 = true;
_local4 = 0;
while (_local4 < NUM_NOTES_PER_TARGET) {
_local5 = new MusicalNote(_arg1.flower, ((_local4 * NOTE_DELAY) + 1), MusicalNote.LEFT, af);
musicalNotes.push(_local5);
renderer.addMusicalNote(_local5.mc);
_local4++;
};
smSFX.getSoundFromID("YeahSFX").play();
if (currMusicLoop < musicLoops.length){
currMusicLoop++;
};
smSequencer.playSequence(musicLoops[currMusicLoop], 0, false);
dispatchEvent(new LevelEvent(LevelEvent.TYPE_POINTS, QuickGame.POINTS_PER_TARGET));
_arg1.updateFlower();
};
};
return (_local2);
}
private function checkWin():Boolean{
var _local1:Boolean;
var _local2:int;
while (_local2 < numTargets) {
if (targets[_local2].numBlobs < targets[_local2].targetBlobs){
_local1 = false;
break;
};
_local2++;
};
return (_local1);
}
private function onJump(_arg1:Event=null, _arg2:Number=0):void{
renderer.verticalOffset = 0;
var _local3:Number = (-(currJumpForce) * Math.sin(_arg2));
var _local4:Number = (-(currJumpForce) * Math.cos(_arg2));
physics.jump(_local3, _local4);
}
public function step():void{
var _local1:int;
var _local4:Powerup;
var _local6:Boolean;
var _local7:Target;
var _local8:Number;
var _local2:Number = physics.blob.centreNode.x;
var _local3:Number = physics.blob.centreNode.y;
checkKeys();
physics.step(tilt, (--houseCounter < 1));
if (houseCounter == 0){
renderer.blobSprite.visible = true;
physics.blob.canJump = true;
physics.blob.jump(((-(house.frontMC.scaleX) * 2) * MAX_JUMP_FORCE), 0, physics.world);
};
if (--targetCounter < 0){
_local6 = false;
pt.x = _local2;
pt.y = _local3;
pt = renderer.blobSprite.localToGlobal(pt);
_local1 = 0;
while (_local1 < numTargets) {
_local7 = targets[_local1];
if (_local7.hitTest(pt.x, pt.y)){
_local6 = resolveTargetHit(_local7);
break;
};
_local1++;
};
if (_local6){
currTarget = _local1;
targetCounter = TARGET_HIT_TIMEOUT;
} else {
currTarget = -1;
};
};
if (house.hitTest(_local2, _local3)){
if (!inHouse){
setBlobColour();
inHouse = true;
house.frontMC.play();
house.backMC.play();
houseCounter = 27;
smSFX.getSoundFromID("HouseSFX").play();
renderer.blobSprite.visible = false;
};
} else {
inHouse = false;
};
_local1 = numPowerups;
while (--_local1 > -1) {
_local4 = powerups[_local1];
if (((!(_local4.taken)) && (_local4.hitTest(_local2, _local3)))){
if (_local4.type == Powerup.TYPE_POINTS){
_local4.mc2.scaleX = 1.5;
_local4.mc2.scaleY = 1.5;
totalPowerupPoints = (totalPowerupPoints + _local4.value);
numPointsPowerupsHit++;
smSFX.getSoundFromID("PointsBonusSFX").play();
} else {
if (_local4.type == Powerup.TYPE_TIME){
dispatchEvent(new LevelEvent(LevelEvent.TYPE_TIME, _local4.value));
_local4.mc.gotoAndPlay("taken");
smSFX.getSoundFromID("TimeBonusSFX").play();
};
};
_local4.taken = true;
break;
};
};
var _local5:int = getTimer();
if ((((physics.blob.dir == Blob.NONE)) && (((_local5 - inactivityTimestamp) > INACTIVITY_TIMEOUT)))){
currJumpForce = ((Math.random() * (INACTIVITY_MAX_JUMP - INACTIVITY_MIN_JUMP)) + INACTIVITY_MIN_JUMP);
_local8 = ((Math.random() * 0.4) - 0.2);
onJump(null, _local8);
inactivityTimestamp = (inactivityTimestamp + INACTIVITY_INTERVAL);
};
if ((_local5 - zoomingTimestamp) > ZOOMING_TIMEOUT){
zoomingTimestamp = _local5;
renderer.zooming = true;
};
_local1 = musicalNotes.length;
while (--_local1 > -1) {
if (musicalNotes[_local1].step(_local2, _local3)){
renderer.removeMusicalNote(musicalNotes[_local1].mc);
musicalNotes[_local1] = null;
musicalNotes.splice(_local1, 1);
};
};
if (musicalNotes.length == 0){
if (checkWin()){
dispatchEvent(new Event(EVENT_WIN));
};
};
renderer.draw(tilt);
}
private function setBlobColour():void{
var _local3:int;
var _local1:Array = new Array();
var _local2:int;
while (_local2 < numTargets) {
if (targets[_local2].numBlobs < targets[_local2].targetBlobs){
if (physics.blob.id != targets[_local2].id){
_local1.push(targets[_local2].id);
};
};
_local2++;
};
if (_local1.length > 0){
_local3 = Math.floor((Math.random() * _local1.length));
physics.blob.id = _local1[_local3];
physics.blob.colour = ALL_COLOURS[_local1[_local3]];
renderer.setFace(_local1[_local3]);
};
}
public function resetDisplay():void{
kc.dispose();
tilt = (tilt * 0.95);
physics.step(tilt, true);
renderer.draw(tilt);
}
public function pause():void{
renderer.pauseAnimations();
}
}
}//package uk.kerb.locoRoco.game
Section 121
//BasePhysics (uk.kerb.locoRoco.game.BasePhysics)
package uk.kerb.locoRoco.game {
import flash.display.*;
import de.polygonal.motor2.*;
import flash.geom.*;
import de.polygonal.motor2.math.*;
import de.polygonal.motor2.dynamics.*;
import de.polygonal.motor2.collision.shapes.data.*;
import de.polygonal.motor2.collision.shapes.*;
public class BasePhysics {
protected const DEG_2_RAD:Number = 0.0174532925199433;
protected var bodies:Array;
public var world:World;
protected var worldWidth:Number;
protected var worldHeight:Number;
public var blob:Blob;
private var numIterations:Number;
private var stepSize:Number;
public var rollForce:Number;
protected var drags:Array;
public function BasePhysics(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Number, _arg6:Number){
this.worldWidth = _arg1;
this.worldHeight = _arg2;
this.rollForce = _arg6;
init(_arg3, _arg4, _arg5);
}
public function drawBlob(_arg1:Graphics):void{
blob.draw(_arg1);
}
public function getBlobTop():Point{
return (new Point(blob.nodes[0].x, blob.nodes[0].y));
}
public function createBody(_arg1, _arg2:Number, _arg3:Number):RigidBody{
var _local5:int;
var _local4:RigidBodyData = new RigidBodyData();
if ((_arg1 is ShapeData)){
_local4.addShapeData(_arg1);
} else {
if ((_arg1 is Array)){
_local5 = 0;
while (_local5 < _arg1.length) {
_local4.addShapeData(_arg1[_local5]);
_local5++;
};
} else {
throw (new Error("BasePhysics::createBody data argument must be a ShapeData object or an Array of ShapeData objects"));
};
};
_local4.x = _arg2;
_local4.y = _arg3;
return (world.createBody(_local4));
}
public function step(_arg1:Number, _arg2:Boolean):void{
world.step(stepSize, numIterations);
}
private function init(_arg1:Number, _arg2:Number, _arg3:Number):void{
numIterations = 10;
stepSize = (1 / 48);
World.doWarmStarting = false;
world = new World(new AABB2(-50, -50, (worldWidth + 50), (worldHeight + 50)), true);
world.setGravity(0, _arg1);
bodies = new Array();
blob = new Blob(_arg2, _arg3, 45, 16, this);
}
public function getCentre():Point{
return (new Point(blob.centreNode.x, blob.centreNode.y));
}
public function setGravity(_arg1:Number, _arg2:Number):void{
var _local3:RigidBody = world.bodyList;
while (_local3) {
_local3.wakeUp();
_local3 = _local3.next;
};
world.setGravity(_arg1, _arg2);
}
public function defineBox(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number=0.2, _arg5:Number=0, _arg6:Number=0, _arg7:Number=0, _arg8:Number=0):BoxData{
var _local9:BoxData = new BoxData(_arg3, _arg1, _arg2);
_local9.friction = _arg4;
_local9.restitution = _arg5;
_local9.mx = _arg6;
_local9.my = _arg7;
_local9.mr = _arg8;
return (_local9);
}
protected function initWorldEdges(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number):void{
var _local5:BoxData;
var _local6:RigidBody;
var _local7:Number = 0.99;
var _local8:Number = 0.1;
var _local9:Number = (0.5 * (_arg1 + _arg3));
var _local10:Number = (0.5 * (_arg2 + _arg4));
var _local11:Number = ((_arg3 - _arg1) + 100);
var _local12:Number = ((_arg4 - _arg2) + 100);
_local5 = defineBox(_local11, 50, 0, _local7, _local8);
_local5.groupIndex = -1;
_local6 = createBody(_local5, _local9, (_arg2 - 25));
_local6.stateBits = (RigidBody.k_bitSleep | RigidBody.k_bitStatic);
bodies.push(_local6);
_local5 = defineBox(_local11, 50, 0, _local7, _local8);
_local5.groupIndex = -1;
_local6 = createBody(_local5, _local9, (_arg4 + 25));
_local6.stateBits = (RigidBody.k_bitSleep | RigidBody.k_bitStatic);
bodies.push(_local6);
_local5 = defineBox(50, _local12, 0, _local7, _local8);
_local5.groupIndex = -1;
_local6 = createBody(_local5, (_arg1 - 25), _local10);
_local6.stateBits = (RigidBody.k_bitSleep | RigidBody.k_bitStatic);
bodies.push(_local6);
_local5 = defineBox(50, _local12, 0, _local7, _local8);
_local5.groupIndex = -1;
_local6 = createBody(_local5, (_arg3 + 25), _local10);
_local6.stateBits = (RigidBody.k_bitSleep | RigidBody.k_bitStatic);
bodies.push(_local6);
}
private function drawVertexChain(_arg1:Graphics, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:V2):void{
var _local6:V2 = _arg5;
var _local7:Point = new Point();
var _local8:Matrix = new Matrix();
_local7.x = 0;
_local7.y = 0;
_local8.translate(_local6.x, _local6.y);
_local8.rotate(_arg4);
_local7 = _local8.transformPoint(_local7);
_arg1.moveTo((_local7.x + _arg2), (_local7.y + _arg3));
while (true) {
_local7.x = 0;
_local7.y = 0;
_local8.identity();
_local8.translate(_local6.x, _local6.y);
_local8.rotate(_arg4);
_local7 = _local8.transformPoint(_local7);
_arg1.lineTo((_local7.x + _arg2), (_local7.y + _arg3));
if (_local6.last){
_local7.x = 0;
_local7.y = 0;
_local8.identity();
_local8.translate(_local6.next.x, _local6.next.y);
_local8.rotate(_arg4);
_local7 = _local8.transformPoint(_local7);
_arg1.lineTo((_local7.x + _arg2), (_local7.y + _arg3));
break;
};
_local6 = _local6.next;
};
}
public function definePoly(_arg1:Array, _arg2:Number, _arg3:Number=0.2, _arg4:Number=0, _arg5:Number=0, _arg6:Number=0):PolyData{
var _local7:PolyData = new PolyData(_arg2, _arg1);
_local7.friction = _arg3;
_local7.restitution = _arg4;
_local7.mx = _arg5;
_local7.my = _arg6;
return (_local7);
}
public function defineCircle(_arg1:Number, _arg2:Number, _arg3:Number=0.2, _arg4:Number=0, _arg5:Number=0, _arg6:Number=0):CircleData{
var _local7:CircleData = new CircleData(_arg2, _arg1);
_local7.friction = _arg3;
_local7.restitution = _arg4;
_local7.mx = _arg5;
_local7.my = _arg6;
return (_local7);
}
public function drawWireFrames(_arg1:Graphics, _arg2:Number, _arg3:uint, _arg4:Boolean=true):void{
var _local5:RigidBody;
var _local6:ShapeSkeleton;
var _local7:int;
_local7 = 0;
while (_local7 < bodies.length) {
_local5 = bodies[_local7];
_arg1.lineStyle(_arg2, _arg3);
_local6 = _local5.shapeList;
while (_local6) {
if (_local6.type == ShapeTypes.CIRCLE){
_arg1.drawCircle((_local5.x + _local6.mx), (_local5.y + _local6.my), _local6.radius);
} else {
drawVertexChain(_arg1, _local5.x, _local5.y, _local5.r, _local6.modelVertexChain);
};
_local6 = _local6.next;
};
_arg1.lineStyle();
_local7++;
};
if (_arg4){
_local7 = 0;
while (_local7 <= blob.nodes.length) {
if (_local7 == blob.nodes.length){
_local5 = blob.centreNode;
} else {
_local5 = blob.nodes[_local7];
};
if (_local7 == 0){
_arg1.lineStyle(_arg2, 0xFF0000);
} else {
if (_local5.contactList){
_arg1.lineStyle(_arg2, 0xFF);
} else {
_arg1.lineStyle(_arg2, _arg3);
};
};
_local6 = _local5.shapeList;
if (_local6.type == ShapeTypes.CIRCLE){
_arg1.drawCircle(_local5.x, _local5.y, _local6.radius);
} else {
drawVertexChain(_arg1, _local5.x, _local5.y, _local5.r, _local6.modelVertexChain);
};
_arg1.lineStyle();
_local7++;
};
};
}
public function jump(_arg1:Number, _arg2:Number):void{
blob.jump(_arg1, _arg2, world);
}
}
}//package uk.kerb.locoRoco.game
Section 122
//BaseRenderer (uk.kerb.locoRoco.game.BaseRenderer)
package uk.kerb.locoRoco.game {
import uk.kerb.utils.game.*;
import flash.display.*;
import flash.geom.*;
public class BaseRenderer extends Sprite {
private var houseSprite:Sprite;
protected var pt:Point;
protected var m:Matrix;
protected var backgroundSprite:Sprite;
protected var powerups:Array;
protected var af:AssetFactory;
public var verticalOffset:Number;
public var zooming:Boolean;
protected var baseY:Number;
protected var viewportWidth:Number;
public var blobSprite:Sprite;
protected var physics:BasePhysics;
protected var worldWidth:Number;
protected var worldHeight:Number;
protected var face:MovieClip;
protected var foregroundSprite:Sprite;
protected var viewportHeight:Number;
protected var wireframeSprite:Sprite;
public var flowers:Array;
protected var renderSprite:Sprite;
public var lines:Array;
protected static const DRAW_WIREFRAMES:Boolean = false;
protected static const RAD_2_DEG:Number = 57.2957795130823;
protected static const EASING:Number = 0.1;
protected static const MAX_SCALE:Number = 1;
protected static const DRAW_BLOB_WIREFRAMES:Boolean = false;
protected static const SCALE_INCREMENT:Number = 0.001;
protected static const BASE_SCALE:Number = 0.4;
public function BaseRenderer(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Number, _arg6:Number, _arg7:AssetFactory, _arg8:BasePhysics){
pt = new Point();
m = new Matrix();
super();
this.x = _arg1;
this.y = _arg2;
this.viewportWidth = _arg3;
this.viewportHeight = _arg4;
this.worldWidth = _arg5;
this.worldHeight = _arg6;
this.af = _arg7;
this.physics = _arg8;
init();
}
public function pauseAnimations():void{
}
private function init():void{
verticalOffset = 0;
baseY = y;
zooming = false;
scaleX = BASE_SCALE;
scaleY = BASE_SCALE;
renderSprite = new Sprite();
addChild(renderSprite);
backgroundSprite = new Sprite();
renderSprite.addChild(backgroundSprite);
blobSprite = new Sprite();
renderSprite.addChild(blobSprite);
foregroundSprite = new Sprite();
renderSprite.addChild(foregroundSprite);
houseSprite = new Sprite();
renderSprite.addChild(houseSprite);
if (DRAW_WIREFRAMES){
wireframeSprite = new Sprite();
wireframeSprite.blendMode = "invert";
renderSprite.addChild(wireframeSprite);
};
var _local1:Shape = new Shape();
_local1.graphics.beginFill(0);
_local1.graphics.drawRect((-0.5 * viewportWidth), (-0.5 * viewportHeight), viewportWidth, viewportHeight);
addChild(_local1);
renderSprite.mask = _local1;
face = (af.createDisplayObject("FaceAsset") as MovieClip);
blobSprite.addChild(face);
var _local2:Point = physics.getCentre();
var _local3:Point = new Point(-(_local2.x), -(_local2.y));
_local3.x = (_local3.x + (((_local2.x * viewportWidth) * scaleX) / worldWidth));
_local3.y = (_local3.y + (((_local2.y * viewportHeight) * scaleY) / worldHeight));
renderSprite.x = _local3.x;
renderSprite.y = _local3.y;
}
public function setPowerups(_arg1:Array):void{
var _local2:Powerup;
var _local3:MovieClip;
this.powerups = _arg1;
var _local4:int;
while (_local4 < _arg1.length) {
_local2 = _arg1[_local4];
if (_local2.type == Powerup.TYPE_POINTS){
_local3 = (af.createDisplayObject("PointsPowerupBodyAsset") as MovieClip);
_local3.x = _local2.x;
_local3.y = _local2.y;
_local2.mc = _local3;
foregroundSprite.addChild(_local3);
_local3 = (af.createDisplayObject("PointsPowerupHeadAsset") as MovieClip);
_local3.x = _local2.x;
_local3.y = _local2.y;
_local2.mc2 = _local3;
foregroundSprite.addChild(_local3);
} else {
if (_local2.type == Powerup.TYPE_TIME){
_local3 = (af.createDisplayObject("TimePowerupAsset") as MovieClip);
_local3.x = _local2.x;
_local3.y = _local2.y;
_local2.mc = _local3;
foregroundSprite.addChild(_local3);
};
};
_local4++;
};
}
public function addMusicalNote(_arg1:MovieClip):void{
foregroundSprite.addChild(_arg1);
}
public function draw(_arg1:Number):void{
var _local8:Powerup;
var _local9:MovieClip;
var _local10:Number;
var _local11:Number;
var _local12:Number;
var _local2:Point = physics.getCentre();
var _local3:Point = physics.getBlobTop();
m.identity();
m.translate(-(_local2.x), -(_local2.y));
m.rotate(_arg1);
pt.x = 0;
pt.y = 0;
pt = m.transformPoint(pt);
if (!zooming){
pt.x = (pt.x + (((_local2.x * viewportWidth) * scaleX) / worldWidth));
pt.y = (pt.y + (((_local2.y * viewportHeight) * scaleY) / worldHeight));
};
renderSprite.x = (renderSprite.x + (EASING * (pt.x - renderSprite.x)));
renderSprite.y = (renderSprite.y + (EASING * (pt.y - renderSprite.y)));
renderSprite.rotation = ((_arg1 * 180) / Math.PI);
y = (baseY + verticalOffset);
if (zooming){
scaleX = (scaleX + SCALE_INCREMENT);
scaleY = (scaleY + SCALE_INCREMENT);
if ((((scaleX > MAX_SCALE)) || ((scaleY > MAX_SCALE)))){
scaleX = MAX_SCALE;
scaleY = MAX_SCALE;
};
} else {
scaleX = (scaleX + (EASING * (BASE_SCALE - scaleX)));
scaleY = (scaleY + (EASING * (BASE_SCALE - scaleY)));
};
blobSprite.graphics.clear();
physics.drawBlob(blobSprite.graphics);
var _local4:Number = (_local3.x - _local2.x);
var _local5:Number = (_local3.y - _local2.y);
var _local6:Number = Math.atan2(_local5, _local4);
_local6 = (_local6 * RAD_2_DEG);
face.x = _local3.x;
face.y = _local3.y;
face.rotation = (_local6 + 90);
if (face.animation){
if (face.animation.currentLabel != physics.blob.face){
face.animation.gotoAndStop(physics.blob.face);
};
if (physics.blob.blink){
physics.blob.blink = false;
if (face.animation.eyes){
face.animation.eyes.gotoAndPlay("blink");
};
};
};
var _local7:int = powerups.length;
while (--_local7 > -1) {
_local8 = powerups[_local7];
_local9 = _local8.mc;
if (((!((_local9 == null))) && ((_local8.type == Powerup.TYPE_POINTS)))){
if (_local8.taken){
_local10 = (((0.25 * _local4) + _local2.x) - _local9.x);
_local11 = (((0.25 * _local5) + _local2.y) - _local9.y);
_local12 = ((_local10 * _local10) + (_local11 * _local11));
_local9.x = (_local9.x + (0.3 * _local10));
_local9.y = (_local9.y + (0.3 * _local11));
if (_local12 < 2000){
physics.blob.eat();
if (_local9.scaleX < 0.02){
foregroundSprite.removeChild(_local9);
_local8.mc = null;
};
_local9.scaleX = (_local9.scaleX - ((0.15 * _local12) / 1000));
_local9.scaleY = _local9.scaleX;
};
} else {
_local8.step();
};
};
_local9 = _local8.mc2;
if (((_local9) && (_local8.taken))){
_local9.y = (_local9.y - 5);
_local9.x = (_local9.x + ((Math.random() * 4) - 2));
_local9.scaleX = (_local9.scaleX * 0.98);
_local9.scaleY = (_local9.scaleY * 0.98);
if (_local9.scaleX < 0.3){
foregroundSprite.removeChild(_local9);
_local8.mc2 = null;
};
};
};
if (DRAW_WIREFRAMES){
wireframeSprite.graphics.clear();
physics.drawWireFrames(wireframeSprite.graphics, 1, 0xFFFFFF, DRAW_BLOB_WIREFRAMES);
wireframeSprite.graphics.lineStyle(1, 0);
_local7 = powerups.length;
while (--_local7 > -1) {
_local8 = powerups[_local7];
if (_local8.mc){
wireframeSprite.graphics.drawCircle(_local8.mc.x, _local8.mc.y, Powerup.TARGET_RADIUS);
};
};
};
}
public function setHouse(_arg1:House):void{
houseSprite.addChild(_arg1.frontMC);
backgroundSprite.addChild(_arg1.backMC);
}
public function setFace(_arg1:String):void{
if (face){
face.gotoAndStop(_arg1);
};
}
public function resumeAnimations():void{
}
public function removeMusicalNote(_arg1:MovieClip):void{
foregroundSprite.removeChild(_arg1);
}
}
}//package uk.kerb.locoRoco.game
Section 123
//Blob (uk.kerb.locoRoco.game.Blob)
package uk.kerb.locoRoco.game {
import flash.display.*;
import de.polygonal.motor2.*;
import flash.geom.*;
import de.polygonal.motor2.dynamics.*;
import de.polygonal.motor2.collision.shapes.data.*;
import de.polygonal.motor2.dynamics.forces.*;
public class Blob {
private var blinkCounter:Number;
protected var pt:Point;
private var springs:Array;
public var dir:String;
private var radius:Number;
private var dragForce:Drag;
public var id:String;
public var canJump:Boolean;
private var numSprings:int;
public var nodes:Array;
private var startY:Number;
private var startX:Number;
private var dragFlags:Array;
private var numNodes:int;
public var colour:uint;
private var xPrev:Number;
public var blink:Boolean;
public var face:String;
private var faceCounter:int;
private var jumpX:Number;
private var jumpY:Number;
protected var m:Matrix;
public var centreNode:RigidBody;
private static const CENTRE_NODE_SCALE:Number = 2;
private static const JUMP_FORCE_DECAY:Number = 0.5;
public static const LEFT:String = "left";
private static const NODE_DIAMETER:Number = 6;
public static const MAX_SPEED:Number = 4000000;
public static const JUMP:String = "jump";
private static const BLINK_STEP:Number = 0;
public static const NONE:String = "none";
private static const MIN_FACE_FRAMES:int = 12;
public static const RIGHT:String = "right";
private static const MOVEMENT_TOLERANCE:Number = 0.5;
public function Blob(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:int, _arg5:BasePhysics){
pt = new Point();
m = new Matrix();
super();
this.startX = _arg1;
this.startY = _arg2;
this.radius = _arg3;
init(_arg4, _arg5);
}
public function moveBy(_arg1:Number, _arg2:Number):void{
var _local4:RigidBody;
centreNode.setCenter((centreNode.x + _arg1), (centreNode.y + _arg2), 0);
var _local3:int;
while (_local3 < numNodes) {
_local4 = nodes[_local3];
nodes[_local3].setCenter((_local4.x + _arg1), (_local4.y + _arg2), 0);
_local3++;
};
}
private function init(_arg1:int, _arg2:BasePhysics):void{
var _local3:int;
var _local4:Number;
var _local6:Number;
var _local7:Number;
var _local8:Number;
var _local9:Number;
var _local10:Number;
var _local11:int;
var _local12:int;
var _local13:CircleData;
var _local14:RigidBody;
var _local15:Spring;
var _local18:int;
var _local5:Number = ((2 * Math.PI) / _arg1);
canJump = false;
faceCounter = 0;
jumpX = 0;
jumpY = 0;
blinkCounter = 0;
blink = false;
dir = NONE;
face = NONE;
xPrev = startX;
numNodes = _arg1;
nodes = new Array();
springs = new Array();
var _local16:Number = 0;
var _local17:Number = 0.1;
_local13 = _arg2.defineCircle((CENTRE_NODE_SCALE * NODE_DIAMETER), 1, 0);
centreNode = _arg2.createBody(_local13, startX, startY);
centreNode.allowSleeping(false);
_local11 = 0;
while (_local11 < _arg1) {
_local4 = ((_local11 * _local5) - (0.5 * Math.PI));
_local6 = ((radius * Math.cos(_local4)) + startX);
_local7 = ((radius * Math.sin(_local4)) + startY);
_local13 = _arg2.defineCircle(NODE_DIAMETER, 1, _local16, _local17);
_local13.groupIndex = 2;
_local14 = _arg2.createBody(_local13, _local6, _local7);
_local14.allowSleeping(false);
nodes.push(_local14);
_local11++;
};
_local11 = 0;
while (_local11 < _arg1) {
_local6 = (nodes[_local11].x - centreNode.x);
_local7 = (nodes[_local11].y - centreNode.y);
_local8 = 1000;
_local9 = Math.sqrt(((_local6 * _local6) + (_local7 * _local7)));
_local10 = 100;
_local15 = new Spring(centreNode, _local8, _local9, _local10);
_arg2.world.addForce(nodes[_local11], _local15);
springs.push(_local15);
_local3 = ((_local11 + 1) % nodes.length);
_local6 = (nodes[_local11].x - nodes[_local3].x);
_local7 = (nodes[_local11].y - nodes[_local3].y);
_local8 = 8000;
_local9 = (0.5 * Math.sqrt(((_local6 * _local6) + (_local7 * _local7))));
_local10 = 10;
_local15 = new Spring(nodes[_local3], _local8, _local9, _local10);
_arg2.world.addForce(nodes[_local11], _local15);
springs.push(_local15);
_local18 = 2;
_local12 = 1;
while (_local12 <= _local18) {
_local3 = ((_local11 + int(((_local12 * nodes.length) / (_local18 + 1)))) % nodes.length);
_local6 = (nodes[_local11].x - nodes[_local3].x);
_local7 = (nodes[_local11].y - nodes[_local3].y);
_local8 = 500;
_local9 = Math.sqrt(((_local6 * _local6) + (_local7 * _local7)));
_local10 = 40;
_local15 = new Spring(nodes[_local3], _local8, _local9, _local10);
_arg2.world.addForce(nodes[_local11], _local15);
springs.push(_local15);
_local12++;
};
_local11++;
};
numSprings = springs.length;
dragForce = new Drag(_arg2.rollForce, _arg2.rollForce);
dragFlags = new Array();
_local11 = 0;
while (_local11 < _arg1) {
dragFlags.push(false);
_local11++;
};
}
private function nodeIsColliding(_arg1:int):Boolean{
var _local3:int;
var _local4:int;
var _local5:Boolean;
var _local6:Boolean;
var _local7:Boolean;
var _local8:Boolean;
var _local2:RigidBody = nodes[_arg1];
if (((_local2) && (_local2.contactList))){
_local3 = ((_arg1 + 1) % numNodes);
_local4 = (((_arg1 - 1) + numNodes) % numNodes);
_local5 = (_local2.contactList.other == nodes[_local3]);
_local6 = (_local2.contactList.other == nodes[_local4]);
_local7 = (_local2.contactList.other == centreNode);
_local8 = (_local2.contactList.next == null);
return (!(((((((_local5) || (_local6))) || (_local7))) && (_local8))));
};
return (false);
}
public function jump(_arg1:Number, _arg2:Number, _arg3:World):void{
var _local4:int;
if (canJump){
_local4 = 0;
while (_local4 < numSprings) {
springs[_local4].jump();
_local4++;
};
_local4 = 0;
while (_local4 < numNodes) {
nodes[_local4].vx = 0;
nodes[_local4].vy = 0;
nodes[_local4].applyImpulse(_arg1, _arg2);
if (dragFlags[_local4]){
_arg3.removeForce(nodes[_local4], dragForce);
dragFlags[_local4] = false;
};
_local4++;
};
centreNode.vx = 0;
centreNode.vy = 0;
centreNode.applyImpulse(_arg1, _arg2);
jumpX = _arg1;
jumpY = _arg2;
face = JUMP;
faceCounter = MIN_FACE_FRAMES;
};
}
public function draw(_arg1:Graphics):void{
var _local2:Number;
var _local3:Number;
var _local4:int;
_arg1.beginFill(colour);
_arg1.lineStyle((2 * NODE_DIAMETER), colour);
_local2 = (0.5 * (nodes[0].x + nodes[(numNodes - 1)].x));
_local3 = (0.5 * (nodes[0].y + nodes[(numNodes - 1)].y));
_arg1.moveTo(_local2, _local3);
var _local5:int;
while (_local5 < numNodes) {
_local4 = ((_local5 + 1) % numNodes);
_local2 = (0.5 * (nodes[_local5].x + nodes[_local4].x));
_local3 = (0.5 * (nodes[_local5].y + nodes[_local4].y));
_arg1.curveTo(nodes[_local5].x, nodes[_local5].y, _local2, _local3);
_local5++;
};
_arg1.endFill();
}
public function reset():void{
var _local1:Number;
var _local3:Number;
var _local4:Number;
var _local2:Number = ((2 * Math.PI) / numNodes);
centreNode.x = startX;
centreNode.y = startY;
centreNode.vx = 0;
centreNode.vy = 0;
var _local5:int;
while (_local5 < numNodes) {
_local1 = ((_local5 * _local2) - (0.5 * Math.PI));
_local3 = ((radius * Math.cos(_local1)) + startX);
_local4 = ((radius * Math.sin(_local1)) + startY);
nodes[_local5].x = _local3;
nodes[_local5].y = _local4;
nodes[_local5].vx = 0;
nodes[_local5].vy = 0;
_local5++;
};
}
public function step(_arg1:World, _arg2:Number):void{
var _local3:int;
var _local4:RigidBody;
var _local8:Number;
var _local9:Number;
var _local13:Number;
var _local14:Number;
var _local15:Number;
var _local16:Number;
var _local17:Number;
var _local18:Number;
var _local5:Number = -(Number.MIN_VALUE);
var _local6 = -1;
var _local7:Number = 1;
var _local10:Boolean;
var _local11:Number = nodes[(numNodes - 1)].x;
var _local12:Number = nodes[(numNodes - 1)].y;
var _local19:Number = 0;
var _local20:Number = 0;
var _local21:Number = (centreNode.x - xPrev);
if (_local21 < -(MOVEMENT_TOLERANCE)){
dir = LEFT;
} else {
if (_local21 > MOVEMENT_TOLERANCE){
dir = RIGHT;
} else {
dir = NONE;
};
};
xPrev = centreNode.x;
canJump = false;
m.identity();
m.rotate(_arg2);
pt.x = 0;
pt.y = 0;
_local3 = 0;
while (_local3 < numNodes) {
_local4 = nodes[_local3];
pt.x = (_local4.x - centreNode.x);
pt.y = (_local4.y - centreNode.y);
m.transformPoint(pt);
if (pt.y > _local5){
_local5 = pt.y;
_local6 = _local3;
};
_local4.applyImpulse(jumpX, jumpY);
if (nodeIsColliding(_local3)){
if (!dragFlags[_local3]){
_arg1.addForce(nodes[_local3], dragForce);
dragFlags[_local3] = true;
};
} else {
if (dragFlags[_local3]){
_arg1.removeForce(nodes[_local3], dragForce);
dragFlags[_local3] = false;
};
};
_local8 = ((_local4.vx * _local4.vx) + (_local4.vy * _local4.vy));
if (_local8 > MAX_SPEED){
_local9 = (MAX_SPEED / _local8);
if (_local7 > _local9){
_local7 = _local9;
};
};
_local19 = (_local19 + _local4.x);
_local20 = (_local20 + _local4.y);
_local13 = _local4.x;
_local14 = _local4.y;
if (_local13 > _local11){
_local15 = _local11;
_local16 = _local13;
_local17 = _local12;
_local18 = _local14;
} else {
_local15 = _local13;
_local16 = _local11;
_local17 = _local14;
_local18 = _local12;
};
if (((((_local13 < centreNode.x) == (centreNode.x <= _local11))) && ((((centreNode.y - _local17) * (_local16 - _local15)) < ((_local18 - _local17) * (centreNode.x - _local15)))))){
_local10 = !(_local10);
};
_local11 = _local13;
_local12 = _local14;
_local3++;
};
if (_local7 < 1){
_local3 = 0;
while (_local3 < numNodes) {
nodes[_local3].vx = (nodes[_local3].vx * _local7);
nodes[_local3].vy = (nodes[_local3].vy * _local7);
_local3++;
};
centreNode.vx = (centreNode.vx * _local7);
centreNode.vy = (centreNode.vy * _local7);
};
if (!_local10){
_local19 = (_local19 / numNodes);
_local20 = (_local20 / numNodes);
centreNode.setCenter(_local19, _local20, 0);
};
centreNode.applyImpulse(jumpX, jumpY);
jumpX = (jumpX * JUMP_FORCE_DECAY);
jumpY = (jumpY * JUMP_FORCE_DECAY);
if (nodeIsColliding(_local6)){
canJump = true;
} else {
if (nodeIsColliding(((_local6 + 1) % numNodes))){
canJump = true;
} else {
if (nodeIsColliding((((_local6 - 1) + numNodes) % numNodes))){
canJump = true;
};
};
};
if (canJump){
if (face == JUMP){
if (faceCounter < 0){
face = dir;
faceCounter = MIN_FACE_FRAMES;
};
} else {
face = dir;
faceCounter = MIN_FACE_FRAMES;
};
} else {
if (((!((face == JUMP))) && ((faceCounter < 0)))){
face = JUMP;
faceCounter = MIN_FACE_FRAMES;
};
};
faceCounter--;
if (face == JUMP){
blinkCounter = 0;
} else {
blinkCounter = (blinkCounter + BLINK_STEP);
if (Math.random() < (((blinkCounter * blinkCounter) * blinkCounter) * blinkCounter)){
blink = true;
blinkCounter = 0;
};
};
}
public function eat():void{
face = JUMP;
faceCounter = MIN_FACE_FRAMES;
}
}
}//package uk.kerb.locoRoco.game
Section 124
//House (uk.kerb.locoRoco.game.House)
package uk.kerb.locoRoco.game {
import uk.kerb.utils.game.*;
import flash.display.*;
public class House {
private var hitX:Number;
private var hitY:Number;
public var backMC:MovieClip;
public var frontMC:MovieClip;
private static const TARGET_RADIUS:Number = 40;
private static const TARGET_RADIUS_SQUARED:Number = 1600;
public function House(_arg1:Number, _arg2:Number, _arg3:AssetFactory){
frontMC = (_arg3.createDisplayObject("HouseFrontAsset") as MovieClip);
frontMC.x = _arg1;
frontMC.y = _arg2;
backMC = (_arg3.createDisplayObject("HouseBackAsset") as MovieClip);
backMC.x = _arg1;
backMC.y = _arg2;
hitX = _arg1;
hitY = _arg2;
}
public function hitTest(_arg1:Number, _arg2:Number):Boolean{
var _local3:Number = (hitX - _arg1);
var _local4:Number = (hitY - _arg2);
var _local5:Number = ((_local3 * _local3) + (_local4 * _local4));
return ((_local5 < TARGET_RADIUS_SQUARED));
}
}
}//package uk.kerb.locoRoco.game
Section 125
//KeyControl (uk.kerb.locoRoco.game.KeyControl)
package uk.kerb.locoRoco.game {
import flash.events.*;
import flash.display.*;
import flash.ui.*;
public class KeyControl extends EventDispatcher {
private var rightDown:Boolean;
private var spaceDown:Boolean;
private var leftDown:Boolean;
private var waitingToJump:Boolean;
private var spacebarJumps:Boolean;
private var stage:Stage;
public static const EVENT_JUMP:String = "onJump";
public static const EVENT_PREPARE_JUMP:String = "onPrepareJump";
public function KeyControl(_arg1:Stage){
this.stage = _arg1;
leftDown = false;
rightDown = false;
spaceDown = false;
waitingToJump = false;
spacebarJumps = false;
_arg1.addEventListener(KeyboardEvent.KEY_DOWN, onKeyDown);
_arg1.addEventListener(KeyboardEvent.KEY_UP, onKeyUp);
_arg1.focus = _arg1;
}
public function get both():Boolean{
return (((rightDown) && (leftDown)));
}
private function onKeyDown(_arg1:KeyboardEvent):void{
if (_arg1.keyCode == Keyboard.LEFT){
leftDown = true;
} else {
if (_arg1.keyCode == Keyboard.RIGHT){
rightDown = true;
} else {
if (_arg1.keyCode == Keyboard.SPACE){
spaceDown = true;
};
};
};
if (!waitingToJump){
if (((spacebarJumps) && (spaceDown))){
dispatchEvent(new Event(EVENT_PREPARE_JUMP));
dispatchEvent(new Event(EVENT_JUMP));
waitingToJump = true;
} else {
if (((((!(spacebarJumps)) && (leftDown))) && (rightDown))){
dispatchEvent(new Event(EVENT_PREPARE_JUMP));
waitingToJump = true;
};
};
};
}
public function get left():Boolean{
return (((leftDown) && (!(rightDown))));
}
public function get right():Boolean{
return (((rightDown) && (!(leftDown))));
}
public function get either():Boolean{
return (((rightDown) || (leftDown)));
}
private function onKeyUp(_arg1:KeyboardEvent):void{
if (_arg1.keyCode == Keyboard.LEFT){
leftDown = false;
waitingToJump = false;
} else {
if (_arg1.keyCode == Keyboard.RIGHT){
rightDown = false;
waitingToJump = false;
} else {
if (_arg1.keyCode == Keyboard.SPACE){
spaceDown = false;
waitingToJump = false;
};
};
};
if (((!(spacebarJumps)) && (((left) || (right))))){
dispatchEvent(new Event(EVENT_JUMP));
};
}
public function dispose():void{
stage.removeEventListener(KeyboardEvent.KEY_DOWN, onKeyDown);
stage.removeEventListener(KeyboardEvent.KEY_UP, onKeyUp);
}
}
}//package uk.kerb.locoRoco.game
Section 126
//LevelEvent (uk.kerb.locoRoco.game.LevelEvent)
package uk.kerb.locoRoco.game {
import flash.events.*;
public class LevelEvent extends Event {
private var _value:int;
public static const TYPE_POINTS:String = "onPoints";
public static const TYPE_TIME:String = "onTime";
public function LevelEvent(_arg1:String, _arg2:int, _arg3:Boolean=false, _arg4:Boolean=false){
this._value = _arg2;
super(_arg1, _arg3, _arg4);
}
public function get value():int{
return (_value);
}
}
}//package uk.kerb.locoRoco.game
Section 127
//LevelSelectCarousel (uk.kerb.locoRoco.game.LevelSelectCarousel)
package uk.kerb.locoRoco.game {
import flash.events.*;
import flash.text.*;
import uk.kerb.utils.game.*;
import flash.display.*;
import uk.kerb.utils.ui.*;
import flash.utils.*;
import com.robertpenner.easing.*;
import uk.kerb.utils.*;
public class LevelSelectCarousel extends EventDispatcher {
private var positions:Array;
public var helpShowing:Boolean;
private var timer:Timer;
private var bg:MovieClip;
private var bestScore:MovieClip;
private var tweenCounter:int;
private var revealTweens:Array;
private var icons:Array;
private var closeTweenCounter:int;
private var _selectedLevel:int;
private var movement:int;
private var data:PanelData;
private var level_txt:TextField;
private var numIconsToReveal:int;
private static const ICON_CLOSE_DELAY:int = 70;
private static const ICON_REVEAL_DELAY:int = 50;
private static const ICON_MOVEMENT_DURATION:int = 200;
public function LevelSelectCarousel(_arg1:PanelData, _arg2:Array, _arg3:TextField, _arg4:MovieClip, _arg5:Boolean, _arg6:MovieClip){
this.data = _arg1;
this.icons = _arg2;
this.level_txt = _arg3;
this.bestScore = _arg4;
this.bg = _arg6;
numIconsToReveal = (_arg5) ? _arg2.length : (_arg2.length - 1);
positions = new Array();
positions.push(new Position(0, -35, 0.85));
positions.push(new Position(-146, -15, 0.28));
positions.push(new Position(-125, 61, 0.24));
positions.push(new Position(-67, 101, 0.2));
positions.push(new Position(0, 115, 0.18));
positions.push(new Position(65, 101, 0.2));
positions.push(new Position(131, 61, 0.24));
positions.push(new Position(151, -15, 0.28));
movement = 0;
helpShowing = false;
revealTweens = new Array();
_arg3.text = (_arg1.levelNum + 1).toString();
showHighScore(_arg1.levelNum);
var _local7:int;
while (_local7 < _arg2.length) {
_arg2[_local7].levelNum = ((_arg1.levelNum + _local7) % 8);
_arg2[_local7].position = _local7;
_arg2[_local7].x = positions[_local7].x;
_arg2[_local7].y = positions[_local7].y;
if ((((_local7 == 0)) && (!(_arg5)))){
positions[_local7].scale;
positions[_local7].scale;
} else {
_arg2[_local7].scaleX = 0;
_arg2[_local7].scaleY = 0;
};
if (_arg1.highScores[_arg2[_local7].levelNum] > 0){
_arg2[_local7].petals.gotoAndStop("open");
_arg2[_local7].uncompleted_btn.visible = false;
_arg2[_local7].completed_btn.icon = _arg2[_local7];
_arg2[_local7].completed_btn.addEventListener(MouseEvent.MOUSE_DOWN, onButtonPress);
_arg2[_local7].completed_btn.addEventListener(MouseEvent.CLICK, onIconClick);
} else {
_arg2[_local7].completed_btn.visible = false;
_arg2[_local7].uncompleted_btn.icon = _arg2[_local7];
_arg2[_local7].uncompleted_btn.addEventListener(MouseEvent.MOUSE_DOWN, onButtonPress);
_arg2[_local7].uncompleted_btn.addEventListener(MouseEvent.CLICK, onIconClick);
};
_local7++;
};
tweenCounter = 0;
timer = new Timer(ICON_REVEAL_DELAY, numIconsToReveal);
timer.addEventListener(TimerEvent.TIMER, onRevealTimer);
timer.start();
_arg2[0].addEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
}
private function moveIcons():void{
var _local1:int;
var _local2:int;
var _local3:Tween;
var _local7:MovieClip;
var _local4:Function = Linear.easeIn;
var _local5:Function = Elastic.easeOut;
var _local6:int = ((movement > 0)) ? -1 : 1;
if (movement != 0){
_local1 = 0;
while (_local1 < icons.length) {
_local7 = icons[_local1];
if ((((_local7.position == 1)) && ((_local6 == -1)))){
_local7.parent.setChildIndex(_local7, (_local7.parent.numChildren - 1));
} else {
if ((((_local7.position == 7)) && ((_local6 == 1)))){
_local7.parent.setChildIndex(_local7, (_local7.parent.numChildren - 1));
};
};
_local2 = (((_local7.position + icons.length) + _local6) % icons.length);
_local7.position = _local2;
_local3 = new Tween(_local7, ["x"], _local7.x, positions[_local2].x, ICON_MOVEMENT_DURATION, _local4);
_local3.addEventListener(Tween.EVENT_TWEEN_COMPLETE, onTweenComplete);
tweenCounter++;
_local3 = new Tween(_local7, ["y"], _local7.y, positions[_local2].y, ICON_MOVEMENT_DURATION, _local4);
_local3.addEventListener(Tween.EVENT_TWEEN_COMPLETE, onTweenComplete);
tweenCounter++;
_local3 = new Tween(_local7, ["scaleX", "scaleY"], _local7.scaleX, positions[_local2].scale, ICON_MOVEMENT_DURATION, _local4);
_local3.addEventListener(Tween.EVENT_TWEEN_COMPLETE, onTweenComplete);
tweenCounter++;
_local1++;
};
movement = (movement + _local6);
};
}
private function onRightClick(_arg1:MouseEvent):void{
Main.smSFX.getSoundFromID("ButtonReleaseSFX").play();
move(1);
}
private function onAddedToStage(_arg1:Event):void{
icons[0].removeEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
icons[0].stage.addEventListener(KeyboardEvent.KEY_DOWN, onKeyDown);
icons[0].stage.focus = icons[0].stage;
}
private function showHighScore(_arg1:int):void{
bestScore.animation.bestScore_txt.text = ("00000" + data.highScores[_arg1]).substr(-5);
if (data.highScores[_arg1] > 0){
bestScore.play();
};
}
private function initIconClose(_arg1:int):void{
var _local2:Function;
var _local3:Tween;
var _local4:MovieClip;
var _local5:int;
while (_local5 < icons.length) {
if (icons[_local5].position == _arg1){
_local4 = icons[_local5];
break;
};
_local5++;
};
if (_arg1 == 0){
_local2 = Bounce.easeInOut;
new Tween(_local4, ["rotation"], 0, 10, 800, _local2);
_local2 = Elastic.easeInOut;
_local3 = new Tween(_local4, ["scaleX", "scaleY"], _local4.scaleX, 0, 800, _local2);
} else {
_local2 = Elastic.easeInOut;
_local3 = new Tween(_local4, ["scaleX", "scaleY"], _local4.scaleX, 0, 500, _local2);
};
_local3.addEventListener(Tween.EVENT_TWEEN_COMPLETE, onCloseTweenComplete);
}
public function move(_arg1:int):void{
movement = (movement + _arg1);
if (movement < -8){
movement = (movement + 8);
} else {
if (movement > 8){
movement = (movement - 8);
};
};
if ((((tweenCounter == 0)) && (!((movement == 0))))){
moveIcons();
};
}
private function onRevealTimer(_arg1:TimerEvent):void{
var _local2:int = (_arg1.target as Timer).currentCount;
var _local3:Function = Elastic.easeOut;
if (numIconsToReveal == icons.length){
_local2--;
};
var _local4:Tween = new Tween(icons[_local2], ["scaleX", "scaleY"], 0, positions[_local2].scale, 1500, _local3);
_local4.addEventListener(Tween.EVENT_TWEEN_COMPLETE, onTweenComplete);
tweenCounter++;
revealTweens.push(_local4);
if (_local2 == numIconsToReveal){
timer.removeEventListener(TimerEvent.TIMER, onRevealTimer);
timer = null;
};
}
private function onButtonPress(_arg1:MouseEvent):void{
Main.smSFX.getSoundFromID("ButtonPressSFX").play();
}
private function onKeyDown(_arg1:KeyboardEvent):void{
var _local2:int;
if (!helpShowing){
if (_arg1.keyCode == 37){
move(-1);
} else {
if (_arg1.keyCode == 39){
move(1);
} else {
if ((((_arg1.keyCode == 13)) || ((_arg1.keyCode == 32)))){
_local2 = 0;
while (_local2 < icons.length) {
if (icons[_local2].position == 0){
_selectedLevel = icons[_local2].levelNum;
initCloseAnimation();
break;
};
_local2++;
};
};
};
};
};
}
private function onTweenComplete(_arg1:Event):void{
var _local2:int;
_arg1.target.removeEventListener(Tween.EVENT_TWEEN_COMPLETE, onTweenComplete);
tweenCounter--;
_local2 = 0;
while (_local2 < revealTweens.length) {
if (revealTweens[_local2] == _arg1.target){
revealTweens.splice(_local2, 1);
break;
};
_local2++;
};
if (tweenCounter == 0){
if (movement == 0){
_local2 = 0;
while (_local2 < icons.length) {
if (icons[_local2].position == 0){
level_txt.text = (icons[_local2].levelNum + 1).toString();
showHighScore(icons[_local2].levelNum);
break;
};
_local2++;
};
} else {
moveIcons();
};
};
}
private function initCloseAnimation():void{
var _local1:int;
var _local2:Tween;
var _local3:Function;
if (timer){
timer.stop();
timer.removeEventListener(TimerEvent.TIMER, onRevealTimer);
timer = null;
};
_local1 = 0;
while (_local1 < revealTweens.length) {
revealTweens[_local1].dispose();
_local1++;
};
icons[0].stage.removeEventListener(KeyboardEvent.KEY_DOWN, onKeyDown);
_local1 = 0;
while (_local1 < icons.length) {
icons[_local1].completed_btn.removeEventListener(MouseEvent.MOUSE_DOWN, onButtonPress);
icons[_local1].completed_btn.removeEventListener(MouseEvent.CLICK, onIconClick);
icons[_local1].uncompleted_btn.removeEventListener(MouseEvent.MOUSE_DOWN, onButtonPress);
icons[_local1].uncompleted_btn.removeEventListener(MouseEvent.CLICK, onIconClick);
_local1++;
};
closeTweenCounter = 0;
_local3 = Expo.easeIn;
_local2 = new Tween(bg, ["alpha"], 1, 0, 1000, _local3);
_local2.addEventListener(Tween.EVENT_TWEEN_COMPLETE, onCloseTweenComplete);
closeTweenCounter++;
timer = new Timer(10, icons.length);
timer.addEventListener(TimerEvent.TIMER, onCloseTimer);
timer.start();
closeTweenCounter = (closeTweenCounter + icons.length);
dispatchEvent(new Event(Event.SELECT));
}
private function onCloseTimer(_arg1:TimerEvent):void{
var _local2:int = ((_arg1.target as Timer).currentCount % icons.length);
initIconClose(_local2);
if (_local2 == 3){
initIconClose(0);
};
timer.delay = ICON_CLOSE_DELAY;
if (_local2 == 7){
timer.removeEventListener(TimerEvent.TIMER, onCloseTimer);
timer = null;
};
}
public function get selectedLevel():int{
return (_selectedLevel);
}
private function onCloseTweenComplete(_arg1:Event):void{
_arg1.target.removeEventListener(Tween.EVENT_TWEEN_COMPLETE, onCloseTweenComplete);
closeTweenCounter--;
if (closeTweenCounter == 0){
dispatchEvent(new Event(Event.CLOSE));
};
}
private function onIconClick(_arg1:MouseEvent):void{
Main.smSFX.getSoundFromID("ButtonReleaseSFX").play();
var _local2:MovieClip = (_arg1.currentTarget as DynamicButton).icon;
if (_local2.position == 0){
_selectedLevel = _local2.levelNum;
initCloseAnimation();
} else {
if (_local2.position > 4){
move((_local2.position - 8));
} else {
move(_local2.position);
};
};
}
private function onLeftClick(_arg1:MouseEvent):void{
Main.smSFX.getSoundFromID("ButtonReleaseSFX").play();
move(-1);
}
}
}//package uk.kerb.locoRoco.game
class Position {
public var x:Number;
public var y:Number;
public var scale:Number;
private function Position(_arg1:Number, _arg2:Number, _arg3:Number){
this.x = _arg1;
this.y = _arg2;
this.scale = _arg3;
}
}
Section 128
//MusicalNote (uk.kerb.locoRoco.game.MusicalNote)
package uk.kerb.locoRoco.game {
import uk.kerb.utils.game.*;
import flash.display.*;
import flash.geom.*;
public class MusicalNote {
protected var pt:Point;
private var yDirection:int;
private var speed:Number;
private var xPrev:Number;
private var lx:Number;
private var ly:Number;
private var angle:Number;
public var mc:MovieClip;
private var initDelay:int;
private var yPrev:Number;
private var xDirection:int;
private var lifespan:int;
private var postLissajous:Boolean;
private var yRadius:Number;
private var curve:Number;
private var xRadius:Number;
private var cx:Number;
private var cy:Number;
private var x:Number;
private var y:Number;
private var flower:MovieClip;
private static const LISSAJOUS_END:Number = 2.35619449019234;
public static const LEFT:int = -1;
private static const COLOURS:Array = new Array(16371553, 16359631, 5152467, 15879501, 9548651, 12023733);
private static const ALL_NOTES:Array = ["Note1Asset", "Note2Asset", "Note3Asset", "Note4Asset"];
private static const SPEED_MAX:Number = 0.04;
private static const MAX_LIFEPAN:int = 150;
private static const SPEED_MIN:Number = 0.03;
private static const INIT_SCALE:Number = 0.1;
public static const RIGHT:int = 1;
private static const HIT_RADIUS:Number = 2500;
public function MusicalNote(_arg1:MovieClip, _arg2:int, _arg3:int, _arg4:AssetFactory){
pt = new Point();
super();
this.flower = _arg1;
this.xDirection = _arg3;
this.yDirection = ((Math.random() < 0.5)) ? -1 : 1;
this.initDelay = _arg2;
var _local5:int = (Math.random() * ALL_NOTES.length);
mc = (_arg4.createDisplayObject(ALL_NOTES[_local5]) as MovieClip);
mc.scaleX = INIT_SCALE;
mc.scaleY = INIT_SCALE;
_local5 = (Math.random() * COLOURS.length);
var _local6:ColorTransform = new ColorTransform();
_local6.color = COLOURS[_local5];
mc.transform.colorTransform = _local6;
mc.visible = false;
speed = ((Math.random() * (SPEED_MAX - SPEED_MIN)) + SPEED_MIN);
angle = 0;
lx = 2;
ly = 4;
curve = 0.2;
xRadius = 300;
yRadius = 150;
lifespan = MAX_LIFEPAN;
postLissajous = false;
}
public function step(_arg1:Number, _arg2:Number):Boolean{
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 _local3:Boolean;
if (--initDelay > -1){
if (initDelay == 0){
pt.x = 0;
pt.y = 0;
pt = flower.flower.localToGlobal(pt);
pt = mc.parent.globalToLocal(pt);
x = pt.x;
y = pt.y;
cx = (pt.x - (xDirection * xRadius));
cy = pt.y;
mc.visible = true;
};
return (false);
};
if (postLissajous){
_local4 = (_arg1 - x);
_local5 = (_arg2 - y);
_local6 = Math.atan2(_local5, _local4);
_local7 = (_local6 - angle);
if (_local7 > Math.PI){
angle = (angle + (2 * Math.PI));
} else {
if (_local7 < -(Math.PI)){
angle = (angle - (2 * Math.PI));
};
};
angle = (angle + (curve * (_local6 - angle)));
xPrev = x;
yPrev = y;
x = (x + (speed * Math.cos(angle)));
y = (y + (speed * Math.sin(angle)));
_local3 = (((_local4 * _local4) + (_local5 * _local5)) < HIT_RADIUS);
} else {
x = (((xDirection * xRadius) * Math.cos((lx * angle))) + cx);
y = (((yDirection * yRadius) * Math.sin((ly * angle))) + cy);
angle = (angle + speed);
if (angle > LISSAJOUS_END){
_local8 = (x - xPrev);
_local9 = (y - yPrev);
speed = Math.sqrt(((_local8 * _local8) + (_local9 * _local9)));
_local10 = (x - xPrev);
_local11 = (y - yPrev);
angle = Math.atan2(_local11, _local10);
postLissajous = true;
};
xPrev = x;
yPrev = y;
mc.scaleX = (mc.scaleX + (0.2 * (1 - mc.scaleX)));
mc.scaleY = mc.scaleX;
};
mc.x = x;
mc.y = y;
if (--lifespan == 0){
_local3 = true;
};
return (_local3);
}
}
}//package uk.kerb.locoRoco.game
Section 129
//PanelData (uk.kerb.locoRoco.game.PanelData)
package uk.kerb.locoRoco.game {
import uk.co.stdio.sound.*;
public class PanelData {
public var timeScore:int;
public var numFlowers:int;
public var totalFlowers:int;
public var levelNum:int;
public var highScores:Array;
public var music:ExtendedSound;
public var remainingTime:int;
public var levelRef:int;
public var bonusScore:int;
public var nextLevelNum:int;
public var numBonus:int;
public var flowersScore:int;
public var totalBonus:int;
public function get bestScore():int{
if (highScores){
return (highScores[levelNum]);
};
return (0);
}
public function get totalScore():int{
var _local2:int;
var _local1:int;
if (highScores){
_local2 = 0;
while (_local2 < highScores.length) {
_local1 = (_local1 + highScores[_local2]);
_local2++;
};
};
return (_local1);
}
}
}//package uk.kerb.locoRoco.game
Section 130
//PanelManager (uk.kerb.locoRoco.game.PanelManager)
package uk.kerb.locoRoco.game {
import flash.events.*;
import uk.co.stdio.sound.*;
import uk.kerb.locoRoco.*;
import uk.kerb.utils.game.*;
import flash.display.*;
import flash.net.*;
import flash.utils.*;
import com.robertpenner.easing.*;
import uk.kerb.utils.*;
import uk.kerb.tracking.*;
public class PanelManager extends Sprite {
private var emitter0:ParticleEmitter;
private var emitter1:ParticleEmitter;
private var emitter3:ParticleEmitter;
private var panel:MovieClip;
private var emitter2:ParticleEmitter;
public var panelShowing:Boolean;
private var af:AssetFactory;
private var data:PanelData;
private var timer:Timer;
private var carousel:LevelSelectCarousel;
private var showLevelSelectPanel:Boolean;
private var quickNumLevelSelected:int;// = -1
private var winIcon:MovieClip;
private static const LEVEL_LOSE_DISPLAY_TIME:int = 3000;
public static const EVENT_GOTO_TITLE:String = "gotoMenu";
public static const EVENT_GOTO_BONUS:String = "gotoBonus";
private static const TIME_SCORE_STEP:int = 20;
private static const BONUS_SCORE_STEP:int = 20;
public static const EVENT_GOTO_SCORE_SUBMIT:String = "gotoScoreSubmit";
private static const FLOWER_SCORE_STEP:int = 20;
private static const LEVEL_WIN_PAUSE:int = 1000;
public function PanelManager(_arg1:AssetFactory){
this.af = _arg1;
panelShowing = false;
}
private function onBonusClick(_arg1:MouseEvent):void{
dispatchEvent(new Event(EVENT_GOTO_BONUS));
}
private function onSonyClick(_arg1:MouseEvent):void{
DoubleQuick.event(209);
navigateToURL(new URLRequest(Constants.PLAYSTATION_URL));
}
private function onLevelWinEnterFrame(_arg1:Event):void{
var _local3:Function;
var _local2:Boolean = updateScoreDisplays(panel);
if (panel.bestScoreLabel){
panel.bestScoreLabel.gotoAndStop(Constants.lang);
};
if (panel.levelScoreLabel){
panel.levelScoreLabel.gotoAndStop(Constants.lang);
};
if (panel.stageClear){
panel.stageClear.textMC.gotoAndStop(Constants.lang);
};
if (panel.currentFrame == 35){
_local3 = Elastic.easeOut;
new Tween(winIcon, ["scaleX", "scaleY"], 0, 0.85, 1500, _local3);
};
if (panel.levelScore){
panel.levelScore.animation.score_txt.text = ("00000" + data.totalScore).substr(-5);
};
if (_local2){
removeEventListener(Event.ENTER_FRAME, onLevelWinEnterFrame);
addEventListener(Event.ENTER_FRAME, onLevelWinScoreEnterFrame);
};
}
private function onNextLevelClick(_arg1:MouseEvent=null):void{
Main.smSFX.getSoundFromID("ButtonReleaseSFX").play();
panel.next_btn.removeEventListener(MouseEvent.MOUSE_DOWN, onButtonPress);
panel.next_btn.removeEventListener(MouseEvent.CLICK, onNextLevelClick);
panel.menu_btn.removeEventListener(MouseEvent.MOUSE_DOWN, onButtonPress);
panel.menu_btn.removeEventListener(MouseEvent.CLICK, onMenuClick);
quickNumLevelSelected = (data.levelNum + 1);
dispatchEvent(new Event(Event.SELECT));
var _local2:Function = Expo.easeIn;
var _local3:Tween = new Tween(panel, ["alpha"], 1, 0, 1000, _local2);
_local3.addEventListener(Tween.EVENT_TWEEN_COMPLETE, onCloseTweenComplete);
stage.removeEventListener(KeyboardEvent.KEY_DOWN, onWinKeyDown);
}
private function onGameCompleteScoreEnterFrame(_arg1:Event):void{
var _local2:Boolean = incrementScores(panel.animation);
if (panel.animation){
if (panel.animation.wellDone){
panel.animation.wellDone.gotoAndStop(Constants.lang);
};
if (panel.animation.gameComplete){
panel.animation.gameComplete.gotoAndStop(Constants.lang);
};
};
if (_local2){
removeEventListener(Event.ENTER_FRAME, onGameCompleteScoreEnterFrame);
panel.animation.total.animation.score_txt.text = ("00000" + data.totalScore).substr(-5);
Constants.score = data.totalScore;
timer = new Timer(LEVEL_WIN_PAUSE, 1);
timer.addEventListener(TimerEvent.TIMER_COMPLETE, onGameCompleteTimer);
timer.start();
data.music.fadeOut((LEVEL_WIN_PAUSE + 100));
};
if (panel.animation.bonus_btn){
panel.animation.bonus_btn.visible = Constants.bonusUnlocked;
};
if (panel.animation.bonusLabel_txt){
panel.animation.bonusLabel_txt.visible = Constants.bonusUnlocked;
};
}
private function onSubmitHighScoreClick(_arg1:MouseEvent):void{
dispatchEvent(new Event(EVENT_GOTO_SCORE_SUBMIT));
}
public function set helpShowing(_arg1:Boolean):void{
if (carousel){
carousel.helpShowing = _arg1;
};
}
private function onGameCompleteTimer(_arg1:TimerEvent):void{
var _local2:ExtendedSound;
timer.removeEventListener(TimerEvent.TIMER_COMPLETE, onGameCompleteTimer);
timer = null;
panel.animation.play();
data.music.stop();
var _local3:Sequence = new Sequence();
_local2 = Main.smSequencer.getSoundFromID("ThemeChorus");
_local3.addStep(_local2, 1);
_local2 = Main.smSequencer.getSoundFromID("ThemeMiddle8");
_local3.addStep(_local2, 1);
Main.smSequencer.playSequence(_local3);
addEventListener(Event.ENTER_FRAME, onGameCompleteAnimationEnterFrame);
}
private function onPlayAgainClick(_arg1:MouseEvent=null):void{
Main.smSFX.getSoundFromID("ButtonReleaseSFX").play();
panel.again_btn.removeEventListener(MouseEvent.MOUSE_DOWN, onButtonPress);
panel.again_btn.removeEventListener(MouseEvent.MOUSE_DOWN, onPlayAgainClick);
panel.menu_btn.removeEventListener(MouseEvent.MOUSE_DOWN, onButtonPress);
panel.menu_btn.removeEventListener(MouseEvent.CLICK, onMenuClick);
quickNumLevelSelected = data.levelNum;
dispatchEvent(new Event(Event.SELECT));
var _local2:Function = Expo.easeIn;
var _local3:Tween = new Tween(panel, ["alpha"], 1, 0, 1000, _local2);
_local3.addEventListener(Tween.EVENT_TWEEN_COMPLETE, onCloseTweenComplete);
stage.removeEventListener(KeyboardEvent.KEY_DOWN, onLoseKeyDown);
}
private function onQuickNextClick(_arg1:MouseEvent=null):void{
Main.smSFX.getSoundFromID("ButtonReleaseSFX").play();
panel.again_btn.removeEventListener(MouseEvent.MOUSE_DOWN, onButtonPress);
panel.again_btn.removeEventListener(MouseEvent.MOUSE_DOWN, onQuickAgainClick);
panel.next_btn.removeEventListener(MouseEvent.MOUSE_DOWN, onButtonPress);
panel.next_btn.removeEventListener(MouseEvent.MOUSE_DOWN, onQuickNextClick);
panel.menu_btn.removeEventListener(MouseEvent.MOUSE_DOWN, onButtonPress);
panel.menu_btn.removeEventListener(MouseEvent.CLICK, onMenuClick);
data.levelNum = data.nextLevelNum;
removeEventListener(Event.ENTER_FRAME, onLevelWinScoreEnterFrame);
removeChild(panel);
panel = null;
showLevelQuit(data);
stage.removeEventListener(KeyboardEvent.KEY_DOWN, onQuickKeyDown);
}
public function get selectedLevel():int{
if (carousel){
return (carousel.selectedLevel);
};
return (quickNumLevelSelected);
}
private function onNextClick(_arg1:MouseEvent):void{
Main.smSFX.getSoundFromID("ButtonReleaseSFX").play();
panel.animation.next_btn.removeEventListener(MouseEvent.MOUSE_DOWN, onButtonPress);
panel.animation.next_btn.removeEventListener(MouseEvent.CLICK, onNextClick);
showLevelSelect(data);
}
public function showLevelLose(_arg1:PanelData):void{
this.data = _arg1;
panel = (af.createDisplayObject("LevelLosePanelAsset") as MovieClip);
addChild(panel);
panel.level_txt.text = (_arg1.levelNum + 1);
panel.outOfTime.textMC.gotoAndStop(Constants.lang);
panel.again_btn.addEventListener(MouseEvent.MOUSE_DOWN, onButtonPress);
panel.again_btn.addEventListener(MouseEvent.CLICK, onPlayAgainClick);
panel.menu_btn.addEventListener(MouseEvent.MOUSE_DOWN, onButtonPress);
panel.menu_btn.addEventListener(MouseEvent.CLICK, onMenuClick);
showLevelSelectPanel = true;
panelShowing = true;
stage.addEventListener(KeyboardEvent.KEY_DOWN, onLoseKeyDown);
}
private function onLevelSelect(_arg1:Event):void{
dispatchEvent(_arg1);
panel.total.visible = false;
}
public function showQuickLevelEnd(_arg1:PanelData):void{
this.data = _arg1;
panel = (af.createDisplayObject("LevelQuickPanelAsset") as MovieClip);
var _local2 = 1;
while (_local2 <= 8) {
winIcon = (panel.getChildByName((("level" + _local2) + "_mc")) as MovieClip);
winIcon.visible = (_local2 == _arg1.levelRef);
_local2++;
};
winIcon = (panel.getChildByName((("level" + _arg1.levelRef) + "_mc")) as MovieClip);
winIcon.uncompleted_btn.visible = false;
winIcon.completed_btn.enabled = false;
winIcon.petals.gotoAndStop("grow");
winIcon.scaleX = 0;
winIcon.scaleY = 0;
if (_arg1.numFlowers == _arg1.totalFlowers){
panel.outOfTime.visible = false;
panel.stageClear.visible = true;
} else {
panel.outOfTime.visible = true;
panel.stageClear.visible = false;
};
panel.miniPanel.numLevels_txt.text = "6";
panel.again_btn.addEventListener(MouseEvent.MOUSE_DOWN, onButtonPress);
panel.again_btn.addEventListener(MouseEvent.CLICK, onQuickAgainClick);
panel.next_btn.addEventListener(MouseEvent.MOUSE_DOWN, onButtonPress);
panel.next_btn.addEventListener(MouseEvent.CLICK, onQuickNextClick);
panel.menu_btn.addEventListener(MouseEvent.MOUSE_DOWN, onButtonPress);
panel.menu_btn.addEventListener(MouseEvent.CLICK, onMenuClick);
addChild(panel);
addEventListener(Event.ENTER_FRAME, onLevelWinEnterFrame);
showLevelSelectPanel = false;
panelShowing = true;
stage.addEventListener(KeyboardEvent.KEY_DOWN, onQuickKeyDown);
}
private function onLevelWinTimer(_arg1:TimerEvent):void{
timer.removeEventListener(TimerEvent.TIMER_COMPLETE, onLevelWinTimer);
timer = null;
data.music.stop();
var _local2:ExtendedSound = Main.smSequencer.getSoundFromID("ThemeChorus");
var _local3:Sequence = new Sequence();
_local3.addStep(_local2, 0);
Main.smSequencer.playSequence(_local3);
}
private function onMenuClick(_arg1:MouseEvent):void{
dispatchEvent(new Event(EVENT_GOTO_TITLE));
}
private function onButtonPress(_arg1:MouseEvent):void{
Main.smSFX.getSoundFromID("ButtonPressSFX").play();
}
public function showLevelWin(_arg1:PanelData):void{
this.data = _arg1;
panel = (af.createDisplayObject("LevelWinPanelAsset") as MovieClip);
var _local2 = 1;
while (_local2 <= 8) {
winIcon = (panel.getChildByName((("level" + _local2) + "_mc")) as MovieClip);
winIcon.visible = (_local2 == _arg1.levelRef);
_local2++;
};
winIcon = (panel.getChildByName((("level" + _arg1.levelRef) + "_mc")) as MovieClip);
winIcon.uncompleted_btn.visible = false;
winIcon.completed_btn.enabled = false;
winIcon.petals.gotoAndStop("grow");
winIcon.scaleX = 0;
winIcon.scaleY = 0;
panel.next_btn.addEventListener(MouseEvent.MOUSE_DOWN, onButtonPress);
panel.next_btn.addEventListener(MouseEvent.CLICK, onNextLevelClick);
panel.menu_btn.addEventListener(MouseEvent.MOUSE_DOWN, onButtonPress);
panel.menu_btn.addEventListener(MouseEvent.CLICK, onMenuClick);
addChild(panel);
addEventListener(Event.ENTER_FRAME, onLevelWinEnterFrame);
showLevelSelectPanel = true;
panelShowing = true;
stage.addEventListener(KeyboardEvent.KEY_DOWN, onWinKeyDown);
}
private function onCarouselClose(_arg1:Event):void{
carousel.removeEventListener(Event.SELECT, onLevelSelect);
carousel.removeEventListener(Event.CLOSE, onCarouselClose);
removeChild(panel);
panel = null;
if (data.music){
data.music.fadeOut(1000);
};
panelShowing = false;
}
private function updateScoreDisplays(_arg1:MovieClip):Boolean{
var _local3:int;
var _local4:int;
var _local2:int;
if (_arg1.bonus){
if (_arg1.bonus.numBonus_txt){
_arg1.bonus.numBonus_txt.text = data.numBonus;
_local2++;
};
if (_arg1.bonus.totalBonus_txt){
_arg1.bonus.totalBonus_txt.text = data.totalBonus;
_local2++;
};
if (_arg1.bonus.bonusScore_txt){
_arg1.bonus.bonusScore_txt.text = data.bonusScore;
_local2++;
};
};
if (_arg1.flowers){
if (_arg1.flowers.numFlowers_txt){
_arg1.flowers.numFlowers_txt.text = data.numFlowers;
_local2++;
};
if (_arg1.flowers.totalFlowers_txt){
_arg1.flowers.totalFlowers_txt.text = data.totalFlowers;
_local2++;
};
if (_arg1.flowers.flowersScore_txt){
_arg1.flowers.flowersScore_txt.text = data.flowersScore;
_local2++;
};
};
if (_arg1.time){
if (_arg1.time.time_txt){
_local3 = (data.remainingTime / 60);
_local4 = (data.remainingTime - (60 * _local3));
_arg1.time.time_txt.text = ((_local3 + ":") + ((_local4 < 10)) ? ("0" + _local4) : _local4);
_local2++;
};
if (_arg1.time.timeScore_txt){
_arg1.time.timeScore_txt.text = data.timeScore;
_local2++;
};
};
if (_arg1.total){
_arg1.total.animation.score_txt.text = ("00000" + data.totalScore).substr(-5);
};
if (_arg1.levelScore){
_arg1.levelScore.animation.score_txt.text = "00000";
};
if (_arg1.bestScore){
_arg1.bestScore.animation.bestScore_txt.text = ("00000" + data.bestScore).substr(-5);
};
if (_arg1.level_txt){
_arg1.level_txt.text = (data.levelNum + 1);
};
return ((_local2 == 8));
}
private function onGameCompleteEnterFrame(_arg1:Event):void{
var _local2:Boolean = updateScoreDisplays(panel.animation);
if (panel.animation){
if (panel.animation.bestScoreLabel){
panel.animation.bestScoreLabel.gotoAndStop(Constants.lang);
};
if (panel.animation.levelScoreLabel){
panel.animation.levelScoreLabel.gotoAndStop(Constants.lang);
};
if (panel.animation.wellDone){
panel.animation.wellDone.gotoAndStop(Constants.lang);
};
if (panel.animation.gameComplete){
panel.animation.gameComplete.gotoAndStop(Constants.lang);
};
};
if (_local2){
removeEventListener(Event.ENTER_FRAME, onGameCompleteEnterFrame);
addEventListener(Event.ENTER_FRAME, onGameCompleteScoreEnterFrame);
};
if (panel.animation.bonus_btn){
panel.animation.bonus_btn.visible = Constants.bonusUnlocked;
};
if (panel.animation.bonusLabel_txt){
panel.animation.bonusLabel_txt.visible = Constants.bonusUnlocked;
};
}
public function showLevelSelect(_arg1:PanelData, _arg2:Boolean=true):void{
var _local5:int;
var _local6:MovieClip;
this.data = _arg1;
if (panel){
removeChild(panel);
panel = null;
};
panel = (af.createDisplayObject("LevelSelectPanelAsset") as MovieClip);
panel.total.animation.score_txt.text = ("00000" + _arg1.totalScore).substr(-5);
var _local3:Array = new Array();
var _local4:int = _arg1.levelNum;
while (_local4 < (_arg1.levelNum + 8)) {
_local5 = ((_local4 % 8) + 1);
_local6 = (panel.getChildByName((("level" + _local5) + "_mc")) as MovieClip);
_local3.push(_local6);
_local4++;
};
carousel = new LevelSelectCarousel(_arg1, _local3, panel.level_txt, panel.bestScore, _arg2, panel.bg);
carousel.addEventListener(Event.SELECT, onLevelSelect);
carousel.addEventListener(Event.CLOSE, onCarouselClose);
addChild(panel);
panelShowing = true;
}
private function onWinKeyDown(_arg1:KeyboardEvent):void{
if ((((_arg1.keyCode == 13)) || ((_arg1.keyCode == 32)))){
onNextLevelClick();
};
}
public function showGameComplete(_arg1:PanelData):void{
this.data = _arg1;
panel = (af.createDisplayObject("GameCompletePanelAsset") as MovieClip);
addChild(panel);
panel.animation.menu_btn.addEventListener(MouseEvent.MOUSE_DOWN, onButtonPress);
panel.animation.menu_btn.addEventListener(MouseEvent.CLICK, onMenuClick);
panel.animation.submit_btn.addEventListener(MouseEvent.MOUSE_DOWN, onButtonPress);
panel.animation.submit_btn.addEventListener(MouseEvent.CLICK, onSubmitHighScoreClick);
panel.animation.bonus_btn.addEventListener(MouseEvent.MOUSE_DOWN, onButtonPress);
panel.animation.bonus_btn.addEventListener(MouseEvent.CLICK, onBonusClick);
addEventListener(Event.ENTER_FRAME, onGameCompleteEnterFrame);
showLevelSelectPanel = true;
panelShowing = true;
}
private function onLevelQuitEnterFrame(_arg1:Event):void{
var _local2:Function;
var _local3:Tween;
if (panel.currentFrame == panel.totalFrames){
panel.stop();
removeEventListener(Event.ENTER_FRAME, onLevelQuitEnterFrame);
panel.menu_btn.removeEventListener(MouseEvent.MOUSE_DOWN, onButtonPress);
panel.menu_btn.removeEventListener(MouseEvent.CLICK, onMenuClick);
quickNumLevelSelected = data.levelNum;
dispatchEvent(new Event(Event.SELECT));
_local2 = Expo.easeIn;
_local3 = new Tween(panel, ["alpha"], 1, 0, 1000, _local2);
_local3.addEventListener(Tween.EVENT_TWEEN_COMPLETE, onCloseTweenComplete);
};
}
private function onCloseTweenComplete(_arg1:Event):void{
_arg1.target.removeEventListener(Tween.EVENT_TWEEN_COMPLETE, onCloseTweenComplete);
dispatchEvent(new Event(Event.CLOSE));
removeEventListener(Event.ENTER_FRAME, onLevelWinEnterFrame);
removeEventListener(Event.ENTER_FRAME, onLevelWinScoreEnterFrame);
if (panel){
removeChild(panel);
panel = null;
};
panelShowing = false;
}
private function onLoseKeyDown(_arg1:KeyboardEvent):void{
if ((((_arg1.keyCode == 13)) || ((_arg1.keyCode == 32)))){
onPlayAgainClick();
};
}
private function onGameCompleteAnimationEnterFrame(_arg1:Event):void{
if (panel.animation.emitter0){
if (!emitter0){
emitter0 = new ParticleEmitter(af, panel.animation.emitter0);
};
};
if (panel.animation.emitter1){
if (!emitter1){
emitter1 = new ParticleEmitter(af, panel.animation.emitter1);
};
};
if (panel.animation.emitter2){
if (!emitter2){
emitter2 = new ParticleEmitter(af, panel.animation.emitter2);
};
};
if (panel.animation.emitter3){
if (!emitter3){
emitter3 = new ParticleEmitter(af, panel.animation.emitter3);
};
};
if (panel.animation.currentFrame == panel.animation.totalFrames){
removeEventListener(Event.ENTER_FRAME, onGameCompleteAnimationEnterFrame);
};
if (panel.animation.bonus_btn){
panel.animation.bonus_btn.visible = Constants.bonusUnlocked;
};
if (panel.animation.bonusLabel_txt){
panel.animation.bonusLabel_txt.visible = Constants.bonusUnlocked;
};
}
private function onLevelWinScoreEnterFrame(_arg1:Event):void{
var _local2:Boolean = incrementScores(panel);
if (((_local2) && (showLevelSelectPanel))){
panel.bonus.visible = false;
panel.flowers.visible = false;
panel.time.visible = false;
removeEventListener(Event.ENTER_FRAME, onLevelWinScoreEnterFrame);
if (panel.total){
panel.total.animation.score_txt.text = ("00000" + data.totalScore).substr(-5);
panel.total.play();
};
};
}
private function onQuickKeyDown(_arg1:KeyboardEvent):void{
if ((((_arg1.keyCode == 32)) || ((_arg1.keyCode == 13)))){
onQuickNextClick();
};
}
public function showLevelQuit(_arg1:PanelData):void{
this.data = _arg1;
panel = (af.createDisplayObject("QuitLevelPanelAsset") as MovieClip);
panel.menu_btn.addEventListener(MouseEvent.MOUSE_DOWN, onButtonPress);
panel.menu_btn.addEventListener(MouseEvent.CLICK, onMenuClick);
panel.sony_btn.addEventListener(MouseEvent.MOUSE_DOWN, onButtonPress);
panel.sony_btn.addEventListener(MouseEvent.CLICK, onSonyClick);
addChild(panel);
addEventListener(Event.ENTER_FRAME, onLevelQuitEnterFrame);
panelShowing = true;
}
private function incrementScores(_arg1:MovieClip):Boolean{
var _local2:int = parseInt(_arg1.levelScore.animation.score_txt.text);
if (data.bonusScore > 0){
if (data.bonusScore >= BONUS_SCORE_STEP){
_local2 = (_local2 + BONUS_SCORE_STEP);
data.bonusScore = (data.bonusScore - BONUS_SCORE_STEP);
} else {
_local2 = (_local2 + data.bonusScore);
data.bonusScore = 0;
};
_arg1.bonus.bonusScore_txt.text = data.bonusScore;
_arg1.levelScore.animation.score_txt.text = ("00000" + _local2).substr(-5);
} else {
if (data.flowersScore > 0){
if (data.flowersScore >= FLOWER_SCORE_STEP){
_local2 = (_local2 + FLOWER_SCORE_STEP);
data.flowersScore = (data.flowersScore - FLOWER_SCORE_STEP);
} else {
_local2 = (_local2 + data.flowersScore);
data.flowersScore = 0;
};
_arg1.flowers.flowersScore_txt.text = data.flowersScore;
_arg1.levelScore.animation.score_txt.text = ("00000" + _local2).substr(-5);
} else {
if (data.timeScore > 0){
if (data.timeScore >= TIME_SCORE_STEP){
_local2 = (_local2 + TIME_SCORE_STEP);
data.timeScore = (data.timeScore - TIME_SCORE_STEP);
} else {
_local2 = (_local2 + data.timeScore);
data.timeScore = 0;
};
_arg1.time.timeScore_txt.text = data.timeScore;
_arg1.levelScore.animation.score_txt.text = ("00000" + _local2).substr(-5);
} else {
_arg1.levelScore.play();
if (_local2 > data.bestScore){
if (data.highScores){
data.highScores[data.levelNum] = _local2;
};
if (_arg1.bestScore){
_arg1.bestScore.animation.bestScore_txt.text = ("00000" + data.bestScore).substr(-5);
_arg1.bestScore.play();
};
};
return (true);
};
};
};
return (false);
}
public function showBonusComplete(_arg1:PanelData):void{
this.data = _arg1;
panel = (af.createDisplayObject("BonusCompletePanelAsset") as MovieClip);
addChild(panel);
panel.animation.menu_btn.addEventListener(MouseEvent.MOUSE_DOWN, onButtonPress);
panel.animation.menu_btn.addEventListener(MouseEvent.CLICK, onMenuClick);
addEventListener(Event.ENTER_FRAME, onGameCompleteEnterFrame);
showLevelSelectPanel = true;
panelShowing = true;
}
private function onQuickAgainClick(_arg1:MouseEvent):void{
Main.smSFX.getSoundFromID("ButtonReleaseSFX").play();
panel.again_btn.removeEventListener(MouseEvent.MOUSE_DOWN, onButtonPress);
panel.again_btn.removeEventListener(MouseEvent.MOUSE_DOWN, onQuickAgainClick);
panel.next_btn.removeEventListener(MouseEvent.MOUSE_DOWN, onButtonPress);
panel.next_btn.removeEventListener(MouseEvent.MOUSE_DOWN, onQuickNextClick);
panel.menu_btn.removeEventListener(MouseEvent.MOUSE_DOWN, onButtonPress);
panel.menu_btn.removeEventListener(MouseEvent.CLICK, onMenuClick);
removeEventListener(Event.ENTER_FRAME, onLevelWinScoreEnterFrame);
removeChild(panel);
panel = null;
showLevelQuit(data);
}
}
}//package uk.kerb.locoRoco.game
Section 131
//ParticleEmitter (uk.kerb.locoRoco.game.ParticleEmitter)
package uk.kerb.locoRoco.game {
import flash.events.*;
import uk.kerb.utils.game.*;
import flash.display.*;
import flash.geom.*;
public class ParticleEmitter {
private var numParticles:int;
private var lifeMax:int;
private var speedMin:Number;
private var angleMax:Number;
private var gravity:Number;
private var speedMax:Number;
private var mc:MovieClip;
private var colours:Array;
private var scaleMin:Number;
private var restitution:Number;
private var particles:Array;
private var firstParticle:MovieClip;
private var ct:ColorTransform;
private var lifeMin:int;
private var scaleMax:Number;
private var angleMin:Number;
public function ParticleEmitter(_arg1:AssetFactory, _arg2:MovieClip){
var _local4:MovieClip;
super();
numParticles = 50;
gravity = 0.4;
restitution = 0.98;
lifeMin = 65;
lifeMax = 75;
speedMin = 2.5;
speedMax = 9;
angleMin = ((-128 * Math.PI) / 180);
angleMax = ((-52 * Math.PI) / 180);
scaleMin = 0.4;
scaleMax = 0.65;
colours = [16730828, 0xFF3300, 16724787, 16724838, 16763170, 0xFFCC00, 0xFFFF00, 0xCC00, 10092390, 6750105, 6750207, 3394764, 0xFF, 6697932];
ct = new ColorTransform();
particles = new Array();
var _local3:int;
while (_local3 < numParticles) {
_local4 = (_arg1.createDisplayObject("ParticleAsset") as MovieClip);
resetParticle(_local4);
_local4.next = ((_local3)==0) ? null : particles[(_local3 - 1)];
_local4.alphaPoint = 20;
_local4.visiblePoint = lifeMin;
particles.push(_local4);
_arg2.addChild(_local4);
_local3++;
};
firstParticle = _local4;
_arg2.addEventListener(Event.ENTER_FRAME, onEnterFrame);
}
private function onEnterFrame(_arg1:Event):void{
var _local2:MovieClip = firstParticle;
while (_local2) {
if (_local2.life < _local2.visiblePoint){
_local2.x = (_local2.x + _local2.vx);
_local2.y = (_local2.y + _local2.vy);
_local2.vy = (_local2.vy + gravity);
_local2.vx = (_local2.vx * restitution);
_local2.vy = (_local2.vy * restitution);
};
if (_local2.life == _local2.visiblePoint){
_local2.visible = true;
};
if (_local2.life < _local2.alphaPoint){
_local2.alpha = (_local2.life / _local2.alphaPoint);
};
if (--_local2.life == 0){
resetParticle(_local2);
};
_local2 = _local2.next;
};
}
private function resetParticle(_arg1:MovieClip):void{
var _local2:Number;
var _local3:Number;
var _local4:Number;
var _local5:int;
var _local6:int;
_local2 = ((Math.random() * (speedMax - speedMin)) + speedMin);
_local3 = ((Math.random() * (angleMax - angleMin)) + angleMin);
_local4 = ((Math.random() * (scaleMax - scaleMin)) + scaleMin);
_local6 = ((Math.random() * (lifeMax - lifeMin)) + lifeMin);
_local5 = (Math.random() * colours.length);
ct.color = colours[_local5];
_arg1.transform.colorTransform = ct;
_arg1.x = 0;
_arg1.y = 0;
_arg1.vx = (_local2 * Math.cos(_local3));
_arg1.vy = (_local2 * Math.sin(_local3));
_arg1.life = _local6;
_arg1.scaleX = _local4;
_arg1.scaleY = _local4;
_arg1.rotation = (Math.random() * 360);
_arg1.alpha = 1;
_arg1.visible = false;
}
}
}//package uk.kerb.locoRoco.game
Section 132
//Powerup (uk.kerb.locoRoco.game.Powerup)
package uk.kerb.locoRoco.game {
import flash.display.*;
public class Powerup {
private var counter:Number;
public var taken:Boolean;
public var value:Number;
public var mc:MovieClip;
public var y:Number;
public var type:int;
public var mc2:MovieClip;
public var x:Number;
public static const TARGET_RADIUS:Number = 50;
public static const TARGET_RADIUS_SQUARED:Number = 2500;
public static const TYPE_TIME:int = 0;
public static const TYPE_POINTS:int = 1;
public function Powerup(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:int){
this.x = _arg1;
this.y = _arg2;
this.value = _arg3;
counter = (Math.random() * Math.PI);
taken = false;
if ((((_arg4 == TYPE_TIME)) || ((_arg4 == TYPE_POINTS)))){
this.type = _arg4;
} else {
throw (new Error("Powerup type must be Powerup.TYPE_TIME or Powerup.TYPE_POINTS"));
};
}
public function hitTest(_arg1:Number, _arg2:Number):Boolean{
var _local3:Number = (mc.x - _arg1);
var _local4:Number = (mc.y - _arg2);
var _local5:Number = ((_local3 * _local3) + (_local4 * _local4));
return ((_local5 < TARGET_RADIUS_SQUARED));
}
public function step():void{
counter = (counter + 0.15);
mc.y = ((6 * Math.sin(counter)) + y);
if (mc2){
mc2.y = mc.y;
};
}
}
}//package uk.kerb.locoRoco.game
Section 133
//Spring (uk.kerb.locoRoco.game.Spring)
package uk.kerb.locoRoco.game {
import de.polygonal.motor2.dynamics.*;
import de.polygonal.motor2.dynamics.forces.*;
public class Spring extends Spring2 {
private var initDamping:Number;
private var initStiffness:Number;
private static const JUMP_DAMPING:Number = 1000;
public function Spring(_arg1:RigidBody, _arg2:Number, _arg3:Number=0, _arg4:Number=0){
super(_arg1, _arg2, _arg3, _arg4);
if (_arg3 <= 0){
throw (new Error("Spring restLength values must be greater than zero"));
};
if (_arg4 <= 0){
throw (new Error("Spring damping values must be greater than zero"));
};
initDamping = _arg4;
initStiffness = _arg2;
}
public function jump():void{
damping = JUMP_DAMPING;
}
override public function evaluate(_arg1:RigidBody):void{
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;
_local4 = (_arg1.x - otherBody.x);
_local7 = (_arg1.y - otherBody.y);
_local9 = (Math.sqrt(((_local4 * _local4) + (_local7 * _local7))) + 1E-6);
_local8 = (-(stiffness) * (_local9 - restLength));
_local3 = (_local8 * (_local4 / _local9));
_local6 = (_local8 * (_local7 / _local9));
_local2 = (_arg1.vx - otherBody.vx);
_local5 = (_arg1.vy - otherBody.vy);
_local10 = ((-(damping) * ((_local2 * _local3) + (_local5 * _local6))) / ((_local3 * _local3) + (_local6 * _local6)));
_local3 = (_local3 + (_local3 * _local10));
_local6 = (_local6 + (_local6 * _local10));
_arg1.fx = (_arg1.fx + _local3);
_arg1.fy = (_arg1.fy + _local6);
otherBody.fx = (otherBody.fx - _local3);
otherBody.fy = (otherBody.fy - _local6);
if (damping != initDamping){
damping = (damping + (0.08 * (initDamping - damping)));
if ((damping - initDamping) < 0.5){
damping = initDamping;
};
};
}
}
}//package uk.kerb.locoRoco.game
Section 134
//Target (uk.kerb.locoRoco.game.Target)
package uk.kerb.locoRoco.game {
import flash.display.*;
import flash.geom.*;
public class Target {
public var id:String;
protected var pt:Point;
public var targetBlobs:int;
private var opened:Boolean;
public var colour:uint;
public var numBlobs:int;
public var flower:MovieClip;
private static const HIT_RADIUS:Number = 1600;
public function Target(_arg1:int, _arg2:MovieClip, _arg3:MovieClip, _arg4:String){
pt = new Point();
super();
this.targetBlobs = _arg1;
this.flower = _arg2;
this.id = _arg4;
colour = BaseLevel.ALL_COLOURS[_arg4];
var _local5:ColorTransform = new ColorTransform();
_local5.color = colour;
_arg3.transform.colorTransform = _local5;
numBlobs = 0;
opened = false;
}
public function updateFlower():void{
if (!opened){
flower.flower.colour = id;
flower.flower.play();
opened = true;
};
}
public function hitTest(_arg1:Number, _arg2:Number):Boolean{
pt.x = 0;
pt.y = 0;
pt = flower.flower.localToGlobal(pt);
var _local3:Number = (_arg1 - pt.x);
var _local4:Number = (_arg2 - pt.y);
var _local5:Number = ((_local3 * _local3) + (_local4 * _local4));
return ((_local5 < HIT_RADIUS));
}
}
}//package uk.kerb.locoRoco.game
Section 135
//BonusGame (uk.kerb.locoRoco.BonusGame)
package uk.kerb.locoRoco {
import flash.events.*;
import uk.co.stdio.sound.*;
import uk.kerb.locoRoco.game.*;
import uk.kerb.utils.game.*;
import flash.display.*;
import flash.utils.*;
import uk.kerb.locoRoco.game.level7.*;
import uk.kerb.locoRoco.game.level8.*;
import uk.kerb.tracking.*;
public class BonusGame extends AbstractSection {
private var helpPanel:MovieClip;
private var level:BaseLevel;
private var timer:Timer;
private var levelPoints:int;
private var panelManager:PanelManager;
private var Levels:Array;
private var score:int;
private var levelNum:int;
private var highScores:Array;
private var gameCompletePanelShown:Boolean;
private var levelTrackingFlags:Array;
public static const BONUS_POINTS_PER_SECOND:int = 10;
public static const POINTS_PER_TARGET:int = 200;
private function onLevelSelect(_arg1:Event):void{
levelNum = (_arg1.target as PanelManager).selectedLevel;
initLevel();
}
private function startLevel(_arg1:Event):void{
level.removeEventListener(Event.INIT, startLevel);
timer.start(level.levelTime);
addEventListener(Event.ENTER_FRAME, step);
}
private function step(_arg1:Event):void{
level.step();
mc.hud_mc.time_txt.text = timer.getTimeAsString(":", false);
mc.hud_mc.timeGlow.visible = (timer.totalTime < 30000);
}
override public function init(_arg1:Class):void{
super.init(_arg1);
addEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
}
private function onKeyDown(_arg1:KeyboardEvent):void{
if ((((_arg1.keyCode == 81)) && (level))){
quitLevel();
} else {
if (_arg1.keyCode == 72){
if (level){
pause();
};
showHelp();
} else {
if ((((_arg1.keyCode == 32)) || ((_arg1.keyCode == 13)))){
if (helpPanel){
hideHelp();
};
};
};
};
}
private function initLevel():void{
var _local1:int;
var _local2:Sequence;
Main.smSequencer.getSoundFromID("ThemeIntro").stop();
Main.smSequencer.getSoundFromID("ThemeVerse").stop();
Main.smSequencer.getSoundFromID("ThemeChorus").stop();
Main.smSequencer.getSoundFromID("ThemeMiddle8").stop();
if (level){
_local1 = 0;
while (_local1 < level.musicLoops.length) {
_local2 = level.musicLoops[_local1];
_local2.currSound.stop();
_local1++;
};
level.removeEventListener(BaseLevel.EVENT_WIN, onLevelWin);
level.removeEventListener(LevelEvent.TYPE_TIME, onLevelTime);
level.dispose();
mc.removeChild(level);
level = null;
};
removeEventListener(Event.ENTER_FRAME, resetDisplay);
levelPoints = 0;
level = new Levels[levelNum](assetFactory);
level.addEventListener(BaseLevel.EVENT_WIN, onLevelWin);
level.addEventListener(LevelEvent.TYPE_TIME, onLevelTime);
level.addEventListener(Event.INIT, startLevel);
mc.hud_mc.level_txt.text = (levelNum + 1);
mc.hud_mc.timeGlow.visible = false;
mc.addChild(level);
mc.setChildIndex(mc.hud_mc, (mc.numChildren - 1));
if (!levelTrackingFlags[levelNum]){
DoubleQuick.event((164 + levelNum));
levelTrackingFlags[levelNum] = true;
};
}
private function onGotoTitle(_arg1:Event):void{
NextSectionClass = Title;
gotoNextSection();
}
private function setScore(_arg1:int):void{
levelPoints = (levelPoints + _arg1);
score = (score + _arg1);
}
private function onLevelQuit(_arg1:MouseEvent):void{
Main.smSFX.getSoundFromID("ButtonReleaseSFX").play();
initLevel();
}
private function onGotoBonus(_arg1:Event):void{
NextSectionClass = BonusGame;
gotoNextSection();
}
override public function dispose():void{
if (level){
level.removeEventListener(BaseLevel.EVENT_WIN, onLevelWin);
level.removeEventListener(LevelEvent.TYPE_TIME, onLevelTime);
level.removeEventListener(Event.INIT, startLevel);
level.dispose();
mc.removeChild(level);
level = null;
};
if (timer){
timer.removeEventListener(Event.COMPLETE, onTimerComplete);
timer.dispose();
};
if (panelManager){
panelManager.removeEventListener(Event.SELECT, onLevelSelect);
panelManager.removeEventListener(PanelManager.EVENT_GOTO_TITLE, onGotoTitle);
panelManager.removeEventListener(PanelManager.EVENT_GOTO_BONUS, onGotoBonus);
};
if (((mc) && (mc.hud_mc))){
if (mc.hud_mc.quit_btn){
mc.hud_mc.quit_btn.removeEventListener(MouseEvent.MOUSE_DOWN, onButtonPress);
mc.hud_mc.quit_btn.removeEventListener(MouseEvent.CLICK, onLevelQuit);
};
};
if (stage){
stage.removeEventListener(KeyboardEvent.KEY_DOWN, onKeyDown);
};
removeEventListener(Event.ENTER_FRAME, step);
removeEventListener(Event.ENTER_FRAME, resetDisplay);
}
private function onQuitButtonRollOut(_arg1:MouseEvent):void{
mc.hud_mc.playAgainRollover.visible = false;
}
private function onLevelTime(_arg1:LevelEvent):void{
timer.addTime(_arg1.value);
}
private function showHelp():void{
panelManager.helpShowing = true;
helpPanel = (assetFactory.createDisplayObject("HelpPanelAsset") as MovieClip);
helpPanel.x = 275;
helpPanel.y = 200;
helpPanel.back_btn.addEventListener(MouseEvent.MOUSE_DOWN, onButtonPress);
helpPanel.back_btn.addEventListener(MouseEvent.CLICK, onHelpBackClick);
addChild(helpPanel);
}
private function onHelpClick(_arg1:MouseEvent):void{
Main.smSFX.getSoundFromID("ButtonReleaseSFX").play();
if (level){
pause();
};
showHelp();
}
private function onAddedToStage(_arg1:Event):void{
removeEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
mc = (assetFactory.createDisplayObject("GameSectionAsset") as MovieClip);
Levels = [Level, Level];
highScores = new Array();
levelTrackingFlags = new Array();
var _local2:int;
while (_local2 < Levels.length) {
highScores.push(0);
levelTrackingFlags.push(false);
_local2++;
};
levelNum = 0;
levelPoints = 0;
gameCompletePanelShown = false;
score = 0;
setScore(0);
timer = new Timer();
timer.addEventListener(Event.COMPLETE, onTimerComplete);
addChild(mc);
mc.hud_mc.quit_btn.addEventListener(MouseEvent.ROLL_OVER, onQuitButtonRollOver);
mc.hud_mc.quit_btn.addEventListener(MouseEvent.ROLL_OUT, onQuitButtonRollOut);
TextManager.getInstance().setText(mc.hud_mc.playAgainRollover.label_txt, "repeat");
mc.hud_mc.playAgainRollover.visible = false;
mc.hud_mc.quit_btn.addEventListener(MouseEvent.MOUSE_DOWN, onButtonPress);
mc.hud_mc.quit_btn.addEventListener(MouseEvent.CLICK, onLevelQuit);
mc.hud_mc.menu_btn.addEventListener(MouseEvent.MOUSE_DOWN, onButtonPress);
mc.hud_mc.menu_btn.addEventListener(MouseEvent.CLICK, onMenuButtonClick);
mc.hud_mc.miniPanel.numLevels_txt.text = "2";
panelManager = new PanelManager(assetFactory);
panelManager.addEventListener(Event.SELECT, onLevelSelect);
panelManager.addEventListener(PanelManager.EVENT_GOTO_TITLE, onGotoTitle);
panelManager.addEventListener(PanelManager.EVENT_GOTO_BONUS, onGotoBonus);
panelManager.x = (0.5 * stage.stageWidth);
panelManager.y = (0.5 * stage.stageHeight);
addChild(panelManager);
var _local3:ExtendedSound = Main.smSequencer.getSoundFromID("ThemeVerse");
var _local4:Sequence = new Sequence();
_local4.addStep(_local3, 0);
Main.smSequencer.playSequence(_local4, 0, false);
var _local5:SimpleButton = (assetFactory.createDisplayObject("HelpButtonAsset") as SimpleButton);
_local5.addEventListener(MouseEvent.MOUSE_DOWN, onButtonPress);
_local5.addEventListener(MouseEvent.CLICK, onHelpClick);
_local5.x = 44;
_local5.y = 18;
addChild(_local5);
stage.addEventListener(KeyboardEvent.KEY_DOWN, onKeyDown);
initLevel();
}
private function hideHelp():void{
helpPanel.back_btn.removeEventListener(MouseEvent.MOUSE_DOWN, onButtonPress);
helpPanel.back_btn.removeEventListener(MouseEvent.CLICK, onHelpBackClick);
removeChild(helpPanel);
helpPanel = null;
if (((level) && (!(panelManager.panelShowing)))){
resume();
};
panelManager.helpShowing = false;
stage.focus = stage;
}
private function resume():void{
addEventListener(Event.ENTER_FRAME, step);
timer.unpause();
if (level){
level.resume();
};
}
private function onHelpBackClick(_arg1:MouseEvent):void{
Main.smSFX.getSoundFromID("ButtonReleaseSFX").play();
hideHelp();
}
private function onQuitButtonRollOver(_arg1:MouseEvent):void{
mc.hud_mc.playAgainRollover.visible = true;
}
private function onButtonPress(_arg1:MouseEvent):void{
Main.smSFX.getSoundFromID("ButtonPressSFX").play();
}
private function quitLevel():void{
Main.smSequencer.stop();
var _local1:ExtendedSound = Main.smSequencer.getSoundFromID("ThemeVerse");
var _local2:Sequence = new Sequence();
_local2.addStep(_local1, 0);
Main.smSequencer.playSequence(_local2);
setScore(-(levelPoints));
pause();
_local2 = level.musicLoops[level.currMusicLoop];
var _local3:PanelData = new PanelData();
_local3.levelNum = levelNum;
_local3.highScores = highScores;
_local3.music = _local2.currSound;
panelManager.showLevelSelect(_local3, true);
}
private function pause():void{
removeEventListener(Event.ENTER_FRAME, step);
timer.pause();
if (level){
level.pause();
};
}
private function onLevelWin(_arg1:Event):void{
pause();
var _local2:Sequence = level.musicLoops[level.currMusicLoop];
var _local3:PanelData = new PanelData();
_local3.levelNum = levelNum;
_local3.highScores = highScores;
_local3.remainingTime = (timer.totalTime / 1000);
_local3.timeScore = (_local3.remainingTime * BONUS_POINTS_PER_SECOND);
_local3.numFlowers = level.numTargets;
_local3.totalFlowers = level.numTargets;
_local3.flowersScore = (POINTS_PER_TARGET * level.numTargets);
_local3.numBonus = level.numPointsPowerupsHit;
_local3.totalBonus = level.numPointsPowerups;
_local3.bonusScore = level.totalPowerupPoints;
_local3.music = _local2.currSound;
_local3.levelRef = parseInt(getQualifiedClassName(level).split("::")[0].substring(27));
var _local4 = (levelNum == (Levels.length - 1));
if (((_local4) && (!(gameCompletePanelShown)))){
gameCompletePanelShown = true;
panelManager.showBonusComplete(_local3);
} else {
panelManager.showLevelWin(_local3);
addEventListener(Event.ENTER_FRAME, resetDisplay);
};
}
private function onMenuButtonClick(_arg1:MouseEvent):void{
NextSectionClass = Title;
gotoNextSection();
}
private function resetDisplay(_arg1:Event):void{
level.resetDisplay();
}
private function onTimerComplete(_arg1:Event):void{
Main.smSequencer.stop();
var _local2:ExtendedSound = Main.smSequencer.getSoundFromID("ThemeIntro");
var _local3:Sequence = new Sequence();
_local3.addStep(_local2, 0);
Main.smSequencer.playSequence(_local3);
setScore(-(levelPoints));
pause();
var _local4:PanelData = new PanelData();
_local4.levelNum = levelNum;
_local4.highScores = highScores;
_local4.music = _local3.currSound;
panelManager.showLevelLose(_local4);
Main.smSFX.getSoundFromID("OutOfTimeSFX").play();
}
}
}//package uk.kerb.locoRoco
Section 136
//Constants (uk.kerb.locoRoco.Constants)
package uk.kerb.locoRoco {
public class Constants {
public static const DOWNLOAD_THIS_GAME_URL:String = "http://blog.kerb.co.uk/download.php?url=";
public static const SHOW_IDENT:Boolean = false;
public static const SHOW_PACKSHOT:Boolean = false;
public static const SUBMIT_SCORE_URL:String = "/highscores/savescore.php";
public static const GET_HIGH_SCORES_URL:String = "/highscores/getscores.php";
public static const PLAYSTATION_URL:String = "http://www.locoroco.com";
public static const KERB_SITE_URL:String = "http://www.kerb.co.uk";
public static const KERB_GAMES_URL:String = "http://www.kerbgames.com";
public static var useSystemFont:Boolean = false;
public static var name:String = "";
public static var score:int = 0;
public static var bonusUnlocked:Boolean = false;
public static var rank:int = -1;
public static var lang:String = "en_GB";
}
}//package uk.kerb.locoRoco
Section 137
//FullGame (uk.kerb.locoRoco.FullGame)
package uk.kerb.locoRoco {
import flash.events.*;
import uk.co.stdio.sound.*;
import uk.kerb.locoRoco.game.*;
import uk.kerb.utils.game.*;
import flash.display.*;
import uk.kerb.locoRoco.game.level2.*;
import flash.utils.*;
import uk.kerb.locoRoco.game.level3.*;
import uk.kerb.locoRoco.game.level4.*;
import uk.kerb.locoRoco.game.level5.*;
import uk.kerb.locoRoco.game.level6.*;
import uk.kerb.locoRoco.game.level1.*;
import uk.kerb.tracking.*;
public class FullGame extends AbstractSection {
private var level:BaseLevel;
private var levelPoints:int;
private var panelManager:PanelManager;
private var Levels:Array;
private var score:int;
private var gameCompletePanelShown:Boolean;
private var helpPanel:MovieClip;
private var timer:Timer;
private var levelNum:int;
private var highScores:Array;
private var levelTrackingFlags:Array;
public static const BONUS_POINTS_PER_SECOND:int = 10;
public static const MIN_BONUS_UNLOCK_SCORE:int = 6000;
public static const POINTS_PER_TARGET:int = 200;
private function onHelpBackClick(_arg1:MouseEvent):void{
Main.smSFX.getSoundFromID("ButtonReleaseSFX").play();
hideHelp();
}
override public function init(_arg1:Class):void{
super.init(_arg1);
addEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
}
private function onGotoTitle(_arg1:Event):void{
NextSectionClass = Title;
gotoNextSection();
}
private function onGotoScoreSubmit(_arg1:Event):void{
NextSectionClass = SubmitScore;
gotoNextSection();
}
override public function dispose():void{
if (level){
level.removeEventListener(BaseLevel.EVENT_WIN, onLevelWin);
level.removeEventListener(LevelEvent.TYPE_TIME, onLevelTime);
level.removeEventListener(Event.INIT, startLevel);
level.dispose();
mc.removeChild(level);
level = null;
};
if (timer){
timer.removeEventListener(Event.COMPLETE, onTimerComplete);
timer.dispose();
};
if (panelManager){
panelManager.removeEventListener(Event.SELECT, onLevelSelect);
panelManager.removeEventListener(PanelManager.EVENT_GOTO_TITLE, onGotoTitle);
panelManager.removeEventListener(PanelManager.EVENT_GOTO_BONUS, onGotoBonus);
panelManager.removeEventListener(PanelManager.EVENT_GOTO_SCORE_SUBMIT, onGotoScoreSubmit);
};
if (((mc) && (mc.hud_mc))){
if (mc.hud_mc.quit_btn){
mc.hud_mc.quit_btn.removeEventListener(MouseEvent.MOUSE_DOWN, onButtonPress);
mc.hud_mc.quit_btn.removeEventListener(MouseEvent.CLICK, onLevelQuit);
};
};
if (stage){
stage.removeEventListener(KeyboardEvent.KEY_DOWN, onKeyDown);
};
removeEventListener(Event.ENTER_FRAME, step);
removeEventListener(Event.ENTER_FRAME, resetDisplay);
}
private function onAddedToStage(_arg1:Event):void{
removeEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
mc = (assetFactory.createDisplayObject("GameSectionAsset") as MovieClip);
Levels = [Level, Level, Level, Level, Level, Level];
highScores = new Array();
levelTrackingFlags = new Array();
var _local2:int;
while (_local2 < Levels.length) {
highScores.push(0);
levelTrackingFlags.push(false);
_local2++;
};
levelNum = 0;
levelPoints = 0;
gameCompletePanelShown = false;
score = 0;
setScore(0);
timer = new Timer();
timer.addEventListener(Event.COMPLETE, onTimerComplete);
addChild(mc);
mc.hud_mc.quit_btn.addEventListener(MouseEvent.ROLL_OVER, onQuitButtonRollOver);
mc.hud_mc.quit_btn.addEventListener(MouseEvent.ROLL_OUT, onQuitButtonRollOut);
TextManager.getInstance().setText(mc.hud_mc.playAgainRollover.label_txt, "repeat");
mc.hud_mc.playAgainRollover.visible = false;
mc.hud_mc.quit_btn.addEventListener(MouseEvent.MOUSE_DOWN, onButtonPress);
mc.hud_mc.quit_btn.addEventListener(MouseEvent.CLICK, onLevelQuit);
mc.hud_mc.menu_btn.addEventListener(MouseEvent.MOUSE_DOWN, onButtonPress);
mc.hud_mc.menu_btn.addEventListener(MouseEvent.CLICK, onMenuButtonClick);
panelManager = new PanelManager(assetFactory);
panelManager.addEventListener(Event.SELECT, onLevelSelect);
panelManager.addEventListener(PanelManager.EVENT_GOTO_TITLE, onGotoTitle);
panelManager.addEventListener(PanelManager.EVENT_GOTO_BONUS, onGotoBonus);
panelManager.addEventListener(PanelManager.EVENT_GOTO_SCORE_SUBMIT, onGotoScoreSubmit);
panelManager.x = (0.5 * stage.stageWidth);
panelManager.y = (0.5 * stage.stageHeight);
addChild(panelManager);
var _local3:ExtendedSound = Main.smSequencer.getSoundFromID("ThemeVerse");
var _local4:Sequence = new Sequence();
_local4.addStep(_local3, 0);
Main.smSequencer.playSequence(_local4, 0, false);
var _local5:SimpleButton = (assetFactory.createDisplayObject("HelpButtonAsset") as SimpleButton);
_local5.addEventListener(MouseEvent.MOUSE_DOWN, onButtonPress);
_local5.addEventListener(MouseEvent.CLICK, onHelpClick);
_local5.x = 44;
_local5.y = 18;
addChild(_local5);
stage.addEventListener(KeyboardEvent.KEY_DOWN, onKeyDown);
initLevel();
}
private function hideHelp():void{
helpPanel.back_btn.removeEventListener(MouseEvent.MOUSE_DOWN, onButtonPress);
helpPanel.back_btn.removeEventListener(MouseEvent.CLICK, onHelpBackClick);
removeChild(helpPanel);
helpPanel = null;
if (((level) && (!(panelManager.panelShowing)))){
resume();
};
panelManager.helpShowing = false;
stage.focus = stage;
}
private function onHelpClick(_arg1:MouseEvent):void{
Main.smSFX.getSoundFromID("ButtonReleaseSFX").play();
if (level){
pause();
};
showHelp();
}
private function resume():void{
addEventListener(Event.ENTER_FRAME, step);
timer.unpause();
if (level){
level.resume();
};
}
private function onQuitButtonRollOver(_arg1:MouseEvent):void{
mc.hud_mc.playAgainRollover.visible = true;
}
private function onLevelWin(_arg1:Event):void{
var _local5:int;
pause();
var _local2:Sequence = level.musicLoops[level.currMusicLoop];
var _local3:PanelData = new PanelData();
_local3.levelNum = levelNum;
_local3.highScores = highScores;
_local3.remainingTime = (timer.totalTime / 1000);
_local3.timeScore = (_local3.remainingTime * BONUS_POINTS_PER_SECOND);
_local3.numFlowers = level.numTargets;
_local3.totalFlowers = level.numTargets;
_local3.flowersScore = (POINTS_PER_TARGET * level.numTargets);
_local3.numBonus = level.numPointsPowerupsHit;
_local3.totalBonus = level.numPointsPowerups;
_local3.bonusScore = level.totalPowerupPoints;
_local3.music = _local2.currSound;
_local3.levelRef = parseInt(getQualifiedClassName(level).split("::")[0].substring(27));
var _local4 = (levelNum == (Levels.length - 1));
if (_local4){
panelManager.showGameComplete(_local3);
_local5 = (((_local3.totalScore + _local3.timeScore) + _local3.bonusScore) + _local3.flowersScore);
Constants.bonusUnlocked = ((Constants.bonusUnlocked) || ((_local5 >= MIN_BONUS_UNLOCK_SCORE)));
} else {
panelManager.showLevelWin(_local3);
addEventListener(Event.ENTER_FRAME, resetDisplay);
};
}
private function onMenuButtonClick(_arg1:MouseEvent):void{
NextSectionClass = Title;
gotoNextSection();
}
private function onLevelSelect(_arg1:Event):void{
levelNum = (_arg1.target as PanelManager).selectedLevel;
initLevel();
}
private function startLevel(_arg1:Event):void{
level.removeEventListener(Event.INIT, startLevel);
timer.start(level.levelTime);
addEventListener(Event.ENTER_FRAME, step);
}
private function onKeyDown(_arg1:KeyboardEvent):void{
if ((((_arg1.keyCode == 81)) && (level))){
quitLevel();
} else {
if (_arg1.keyCode == 72){
if (level){
pause();
};
showHelp();
} else {
if ((((_arg1.keyCode == 32)) || ((_arg1.keyCode == 13)))){
if (helpPanel){
hideHelp();
};
};
};
};
}
private function step(_arg1:Event):void{
level.step();
mc.hud_mc.time_txt.text = timer.getTimeAsString(":", false);
mc.hud_mc.timeGlow.visible = (timer.totalTime < 30000);
}
private function setScore(_arg1:int):void{
levelPoints = (levelPoints + _arg1);
score = (score + _arg1);
}
private function onQuitButtonRollOut(_arg1:MouseEvent):void{
mc.hud_mc.playAgainRollover.visible = false;
}
private function onLevelTime(_arg1:LevelEvent):void{
timer.addTime(_arg1.value);
}
private function initLevel():void{
var _local1:int;
var _local2:Sequence;
Main.smSequencer.getSoundFromID("ThemeIntro").stop();
Main.smSequencer.getSoundFromID("ThemeVerse").stop();
Main.smSequencer.getSoundFromID("ThemeChorus").stop();
Main.smSequencer.getSoundFromID("ThemeMiddle8").stop();
if (level){
_local1 = 0;
while (_local1 < level.musicLoops.length) {
_local2 = level.musicLoops[_local1];
_local2.currSound.stop();
_local1++;
};
level.removeEventListener(BaseLevel.EVENT_WIN, onLevelWin);
level.removeEventListener(LevelEvent.TYPE_TIME, onLevelTime);
level.dispose();
mc.removeChild(level);
level = null;
};
removeEventListener(Event.ENTER_FRAME, resetDisplay);
levelPoints = 0;
level = new Levels[levelNum](assetFactory);
level.addEventListener(BaseLevel.EVENT_WIN, onLevelWin);
level.addEventListener(LevelEvent.TYPE_TIME, onLevelTime);
level.addEventListener(Event.INIT, startLevel);
mc.hud_mc.level_txt.text = (levelNum + 1);
mc.hud_mc.timeGlow.visible = false;
mc.addChild(level);
mc.setChildIndex(mc.hud_mc, (mc.numChildren - 1));
if (!levelTrackingFlags[levelNum]){
DoubleQuick.event((164 + levelNum));
levelTrackingFlags[levelNum] = true;
};
}
private function onButtonPress(_arg1:MouseEvent):void{
Main.smSFX.getSoundFromID("ButtonPressSFX").play();
}
private function onLevelQuit(_arg1:MouseEvent):void{
Main.smSFX.getSoundFromID("ButtonReleaseSFX").play();
initLevel();
}
private function onGotoBonus(_arg1:Event):void{
NextSectionClass = BonusGame;
gotoNextSection();
}
private function showHelp():void{
panelManager.helpShowing = true;
helpPanel = (assetFactory.createDisplayObject("HelpPanelAsset") as MovieClip);
helpPanel.x = 275;
helpPanel.y = 200;
helpPanel.back_btn.addEventListener(MouseEvent.MOUSE_DOWN, onButtonPress);
helpPanel.back_btn.addEventListener(MouseEvent.CLICK, onHelpBackClick);
addChild(helpPanel);
}
private function resetDisplay(_arg1:Event):void{
level.resetDisplay();
}
private function quitLevel():void{
Main.smSequencer.stop();
var _local1:ExtendedSound = Main.smSequencer.getSoundFromID("ThemeVerse");
var _local2:Sequence = new Sequence();
_local2.addStep(_local1, 0);
Main.smSequencer.playSequence(_local2);
setScore(-(levelPoints));
pause();
_local2 = level.musicLoops[level.currMusicLoop];
var _local3:PanelData = new PanelData();
_local3.levelNum = levelNum;
_local3.highScores = highScores;
_local3.music = _local2.currSound;
panelManager.showLevelSelect(_local3, true);
}
private function pause():void{
removeEventListener(Event.ENTER_FRAME, step);
timer.pause();
if (level){
level.pause();
};
}
private function onTimerComplete(_arg1:Event):void{
Main.smSequencer.stop();
var _local2:ExtendedSound = Main.smSequencer.getSoundFromID("ThemeIntro");
var _local3:Sequence = new Sequence();
_local3.addStep(_local2, 0);
Main.smSequencer.playSequence(_local3);
setScore(-(levelPoints));
pause();
var _local4:PanelData = new PanelData();
_local4.levelNum = levelNum;
_local4.highScores = highScores;
_local4.music = _local3.currSound;
panelManager.showLevelLose(_local4);
Main.smSFX.getSoundFromID("OutOfTimeSFX").play();
}
}
}//package uk.kerb.locoRoco
Section 138
//FullInstructions (uk.kerb.locoRoco.FullInstructions)
package uk.kerb.locoRoco {
import flash.events.*;
import uk.kerb.utils.game.*;
import flash.display.*;
public class FullInstructions extends AbstractSection {
private var numActiveTweens:int;
override public function init(_arg1:Class):void{
super.init(_arg1);
mc = (assetFactory.createDisplayObject("FullInstructionsSectionAsset") as MovieClip);
mc.x = 275;
mc.y = 200;
mc.play_btn.addEventListener(MouseEvent.MOUSE_DOWN, onButtonPress);
mc.play_btn.addEventListener(MouseEvent.CLICK, onPlayClick);
mc.repeat_btn.addEventListener(MouseEvent.MOUSE_DOWN, onButtonPress);
mc.repeat_btn.addEventListener(MouseEvent.CLICK, onRepeatClick);
addChild(mc);
numActiveTweens = 0;
addEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
}
private function onKeyDown(_arg1:KeyboardEvent):void{
if ((((_arg1.keyCode == 32)) || ((_arg1.keyCode == 13)))){
hide();
};
}
private function onAddedToStage(_arg1:Event):void{
removeEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
stage.addEventListener(KeyboardEvent.KEY_DOWN, onKeyDown);
stage.focus = stage;
}
private function onPlayClick(_arg1:MouseEvent):void{
Main.smSFX.getSoundFromID("ButtonReleaseSFX").play();
hide();
}
override public function dispose():void{
mc.play_btn.removeEventListener(MouseEvent.MOUSE_DOWN, onButtonPress);
mc.play_btn.removeEventListener(MouseEvent.CLICK, onPlayClick);
mc.repeat_btn.removeEventListener(MouseEvent.MOUSE_DOWN, onButtonPress);
mc.repeat_btn.removeEventListener(MouseEvent.CLICK, onRepeatClick);
}
private function onButtonPress(_arg1:MouseEvent):void{
Main.smSFX.getSoundFromID("ButtonPressSFX").play();
}
private function hide():void{
NextSectionClass = FullGame;
if (stage){
stage.removeEventListener(KeyboardEvent.KEY_DOWN, onKeyDown);
};
gotoNextSection();
}
private function onRepeatClick(_arg1:MouseEvent):void{
Main.smSFX.getSoundFromID("ButtonReleaseSFX").play();
mc.animation.gotoAndPlay(1);
}
}
}//package uk.kerb.locoRoco
Section 139
//HighScores (uk.kerb.locoRoco.HighScores)
package uk.kerb.locoRoco {
import flash.events.*;
import uk.kerb.utils.game.*;
import flash.display.*;
import flash.net.*;
public class HighScores extends AbstractSection {
private var urlLoader:URLLoader;
override public function init(_arg1:Class):void{
super.init(_arg1);
mc = (assetFactory.createDisplayObject("HighScoreAsset") as MovieClip);
mc.x = 275;
mc.y = 200;
mc.menu_btn.addEventListener(MouseEvent.MOUSE_DOWN, onButtonPress);
mc.menu_btn.addEventListener(MouseEvent.CLICK, onMenuClick);
mc.bonus_btn.visible = false;
mc.bonusLabel_txt.visible = false;
mc.userBG.visible = false;
mc.userFlag.visible = false;
addChild(mc);
addEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
urlLoader = new URLLoader();
urlLoader.addEventListener(Event.COMPLETE, onLoadComplete);
urlLoader.addEventListener(IOErrorEvent.IO_ERROR, onLoadError);
var _local2:String = ("?" + new Date().getTime());
var _local3:URLRequest = new URLRequest((Constants.GET_HIGH_SCORES_URL + _local2));
urlLoader.load(_local3);
mc.scrollbar.init(mc.content, mc.contentMask);
}
protected function onButtonPress(_arg1:MouseEvent):void{
Main.smSFX.getSoundFromID("ButtonPressSFX").play();
}
override public function dispose():void{
mc.menu_btn.removeEventListener(MouseEvent.MOUSE_DOWN, onButtonPress);
mc.menu_btn.removeEventListener(MouseEvent.CLICK, onMenuClick);
}
private function onAddedToStage(_arg1:Event):void{
removeEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
}
private function onMenuClick(_arg1:MouseEvent):void{
Main.smSFX.getSoundFromID("ButtonReleaseSFX").play();
NextSectionClass = Title;
gotoNextSection();
}
private function onLoadError(_arg1:IOErrorEvent):void{
trace(("A load error has occurred:\n" + _arg1.text));
urlLoader.removeEventListener(Event.COMPLETE, onLoadComplete);
urlLoader.removeEventListener(IOErrorEvent.IO_ERROR, onLoadError);
}
private function onLoadComplete(_arg1:Event):void{
var _local3:String;
var _local4:String;
var _local5:int;
var _local6:int;
var _local10:MovieClip;
urlLoader.removeEventListener(Event.COMPLETE, onLoadComplete);
urlLoader.removeEventListener(IOErrorEvent.IO_ERROR, onLoadError);
var _local2:XML = new XML(_arg1.target.data);
var _local7:Array = new Array();
_local6 = 0;
while (_local6 < _local2.children().length()) {
_local3 = _local2.children()[_local6].toString();
_local5 = parseInt(_local2.children()[_local6].@points);
_local4 = _local2.children()[_local6].@locale;
_local7.push({name:_local3, score:_local5, locale:_local4});
_local6++;
};
_local7.sortOn("score", (Array.NUMERIC | Array.DESCENDING));
var _local8:int = Math.min(100, _local7.length);
var _local9:Number = 0;
_local6 = 0;
while (_local6 < _local8) {
_local10 = (assetFactory.createDisplayObject("HighScoreEntryAsset") as MovieClip);
_local10.y = _local9;
_local10.rank_txt.text = (_local6 + 1);
_local10.name_txt.text = _local7[_local6].name;
_local10.score_txt.text = _local7[_local6].score;
_local10.flag.gotoAndStop(_local7[_local6].locale);
mc.content.addChild(_local10);
_local9 = (_local9 + 21.7);
_local6++;
};
if (((!((Constants.rank == -1))) && ((Constants.rank > 10)))){
mc.userRank_txt.text = Constants.rank;
mc.userName_txt.text = Constants.name;
mc.userScore_txt.text = Constants.score;
mc.userFlag.gotoAndStop(Constants.lang);
mc.userBG.visible = true;
mc.userFlag.visible = true;
} else {
mc.userBG.visible = false;
mc.userRank_txt.text = "";
mc.userName_txt.text = "";
mc.userScore_txt.text = "";
mc.userFlag.visible = false;
};
}
}
}//package uk.kerb.locoRoco
Section 140
//HighScoresUnlocked (uk.kerb.locoRoco.HighScoresUnlocked)
package uk.kerb.locoRoco {
import flash.events.*;
import uk.kerb.utils.game.*;
public class HighScoresUnlocked extends HighScores {
override public function init(_arg1:Class):void{
super.init(_arg1);
mc.bonus_btn.visible = true;
mc.bonusLabel_txt.text = "play unlocked levels";
mc.bonus_btn.addEventListener(MouseEvent.MOUSE_DOWN, onButtonPress);
mc.bonus_btn.addEventListener(MouseEvent.CLICK, onBonusClick);
}
private function onBonusClick(_arg1:MouseEvent):void{
Main.smSFX.getSoundFromID("ButtonReleaseSFX").play();
NextSectionClass = BonusGame;
gotoNextSection();
}
override public function dispose():void{
super.dispose();
mc.bonus_btn.removeEventListener(MouseEvent.MOUSE_DOWN, onButtonPress);
mc.bonus_btn.removeEventListener(MouseEvent.CLICK, onBonusClick);
}
}
}//package uk.kerb.locoRoco
Section 141
//Ident (uk.kerb.locoRoco.Ident)
package uk.kerb.locoRoco {
import flash.events.*;
import flash.display.*;
import uk.kerb.utils.game.*;
import flash.utils.*;
public class Ident extends Ident {
private static const APPLICATION_CLASS:String = "LocoRoco2Game";
override protected function showPreloader():void{
var _local1:Preload = new Preload();
_local1.addEventListener(Event.COMPLETE, onPreloadComplete);
addChild(_local1);
}
override protected function onAssetFactoryReady(_arg1:Event):void{
if (Constants.SHOW_IDENT){
super.onAssetFactoryReady(_arg1);
} else {
af.removeEventListener(AssetFactory.EVENT_ASSET_FACTORY_READY, onAssetFactoryReady);
af = null;
showPreloader();
};
}
override protected function onAddedToStage(_arg1:Event):void{
super.onAddedToStage(_arg1);
Setup.init(this);
}
override protected function showMainContent():void{
var _local1:Class = Class(getDefinitionByName(APPLICATION_CLASS));
if (_local1){
addChild((new (_local1) as Sprite));
} else {
throw (new Error("Application Class not found in Ident.showMainContent()"));
};
}
}
}//package uk.kerb.locoRoco
Section 142
//Main (uk.kerb.locoRoco.Main)
package uk.kerb.locoRoco {
import uk.co.stdio.sound.*;
import uk.kerb.utils.game.*;
import uk.kerb.utils.ui.*;
import mx.core.*;
public class Main extends Main {
private var soundControl:SoundControl;
public var text_en_GB:Class;
public static var smSequencer:Sequencer;
public function Main(_arg1:Class){
text_en_GB = Main_text_en_GB;
initText();
super(_arg1);
}
override protected function start():void{
gotoSection(Title);
var _local1:ExtendedSound = smSequencer.getSoundFromID("ThemeIntro");
var _local2:Sequence = new Sequence();
_local2.addStep(_local1, 0);
smSequencer.playSequence(_local2);
}
override protected function initSounds():void{
super.initSounds();
smSequencer = new Sequencer("smSequencer");
initSound("Africa1", smSequencer);
initSound("Africa2", smSequencer);
initSound("Africa3", smSequencer);
initSound("Africa4", smSequencer);
initSound("Star1", smSequencer);
initSound("Star2", smSequencer);
initSound("Star3", smSequencer);
initSound("Star4", smSequencer);
initSound("Jungle1", smSequencer);
initSound("Jungle2", smSequencer);
initSound("Jungle3", smSequencer);
initSound("Jungle4", smSequencer);
initSound("Jungle6", smSequencer);
initSound("Snow1And2", smSequencer);
initSound("Snow3", smSequencer);
initSound("Snow4", smSequencer);
initSound("Snow5", smSequencer);
initSound("Snow6", smSequencer);
initSound("Snow7And8", smSequencer);
initSound("ThemeIntro", smSequencer);
initSound("ThemeVerse", smSequencer);
initSound("ThemeChorus", smSequencer);
initSound("ThemeMiddle8", smSequencer);
initSound("HouseSFX", smSFX);
initSound("DrumSFX", smSFX);
initSound("SpikeSFX", smSFX);
initSound("YeahSFX", smSFX);
initSound("PointsBonusSFX", smSFX);
initSound("TimeBonusSFX", smSFX);
initSound("ButtonPressSFX", smSFX);
initSound("ButtonReleaseSFX", smSFX);
initSound("OutOfTimeSFX", smSFX);
initSound("NyokkiUpSFX", smSFX);
initSound("NyokkiDownSFX", smSFX);
soundControl = (assetFactory.createDisplayObject("SoundControlAsset") as SoundControl);
soundControl.x = 5.8;
soundControl.y = 6.8;
soundControl.scaleX = 0.548;
soundControl.scaleY = 0.548;
addChild(soundControl);
soundControl.init(smSequencer, smSFX);
}
override protected function gotoSection(_arg1:Class):void{
super.gotoSection(_arg1);
setChildIndex(soundControl, (numChildren - 1));
}
private function initText():void{
var _local4:XML;
var _local1:String = Constants.lang;
if ((((((_local1 == "en_AU")) || ((_local1 == "en_NZ")))) || ((_local1 == "en_IE")))){
_local1 = "en_GB";
};
if ((((Constants.lang == "pl_PL")) || ((Constants.lang == "ru_RU")))){
Constants.useSystemFont = true;
};
var _local2:Class = this[("text_" + _local1)];
var _local3:ByteArrayAsset = ByteArrayAsset(new (_local2));
var _local5:String = _local3.readUTFBytes(3);
if (_local5.length == 1){
_local4 = new XML(_local3.readUTFBytes((_local3.length - 3)));
} else {
_local4 = new XML((_local5 + _local3.readUTFBytes((_local3.length - 3))));
};
TextManager.getInstance().init(_local4);
}
}
}//package uk.kerb.locoRoco
Section 143
//Main_text_en_GB (uk.kerb.locoRoco.Main_text_en_GB)
package uk.kerb.locoRoco {
import mx.core.*;
public class Main_text_en_GB extends ByteArrayAsset {
}
}//package uk.kerb.locoRoco
Section 144
//Preload (uk.kerb.locoRoco.Preload)
package uk.kerb.locoRoco {
import flash.events.*;
import flash.display.*;
import uk.kerb.utils.game.*;
import uk.kerb.tracking.*;
public class Preload extends MovieClip {
private var af:AssetFactory;
private var mc:MovieClip;
private var SWFBytes:Class;
public function Preload(){
SWFBytes = Preload_SWFBytes;
super();
addEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
init();
}
private function init():void{
af = new AssetFactory();
af.addEventListener(AssetFactory.EVENT_ASSET_FACTORY_READY, onAssetFactoryReady);
af.initialize(SWFBytes);
}
private function onAddedToStage(_arg1:Event):void{
removeEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
DoubleQuick.init(root, 80);
}
private function onAssetFactoryReady(_arg1:Event):void{
af.removeEventListener(AssetFactory.EVENT_ASSET_FACTORY_READY, onAssetFactoryReady);
mc = (af.createDisplayObject("PreloaderAsset") as MovieClip);
mc.animation.stop();
mc.x = 275;
mc.y = 200;
addChild(mc);
af = null;
addEventListener(Event.ENTER_FRAME, onPreloadEnterFrame);
}
private function onPostloadEnterFrame(_arg1:Event):void{
mc.animation.nextFrame();
if (mc.animation.currentFrame == mc.animation.totalFrames){
removeEventListener(Event.ENTER_FRAME, onPostloadEnterFrame);
dispatchEvent(new Event(Event.COMPLETE));
};
}
private function onPreloadEnterFrame(_arg1:Event):void{
var _local2:int = root.loaderInfo.bytesLoaded;
var _local3:int = root.loaderInfo.bytesTotal;
var _local4:int = ((100 * _local2) / _local3);
mc.animation.percent_txt.text = _local4;
if (_local4 != mc.animation.currentFrame){
mc.animation.gotoAndStop(_local4);
};
if (_local4 == 100){
removeEventListener(Event.ENTER_FRAME, onPreloadEnterFrame);
addEventListener(Event.ENTER_FRAME, onPostloadEnterFrame);
};
}
}
}//package uk.kerb.locoRoco
Section 145
//Preload_SWFBytes (uk.kerb.locoRoco.Preload_SWFBytes)
package uk.kerb.locoRoco {
import mx.core.*;
public class Preload_SWFBytes extends ByteArrayAsset {
}
}//package uk.kerb.locoRoco
Section 146
//QuickGame (uk.kerb.locoRoco.QuickGame)
package uk.kerb.locoRoco {
import flash.events.*;
import uk.co.stdio.sound.*;
import uk.kerb.locoRoco.game.*;
import uk.kerb.utils.game.*;
import flash.display.*;
import uk.kerb.locoRoco.game.level2.*;
import flash.utils.*;
import uk.kerb.locoRoco.game.level3.*;
import uk.kerb.locoRoco.game.level4.*;
import uk.kerb.locoRoco.game.level5.*;
import uk.kerb.locoRoco.game.level6.*;
import uk.kerb.locoRoco.game.level1.*;
import uk.kerb.tracking.*;
public class QuickGame extends AbstractSection {
private var helpPanel:MovieClip;
private var level:BaseLevel;
private var timer:Timer;
private var levelPoints:int;
private var panelManager:PanelManager;
private var Levels:Array;
private var score:int;
private var help_btn:SimpleButton;
private var levelNum:int;
private var gameCompletePanelShown:Boolean;
private var levelTrackingFlags:Array;
public static const BONUS_POINTS_PER_SECOND:int = 10;
public static const POINTS_PER_TARGET:int = 200;
private function showHelp():void{
panelManager.helpShowing = true;
helpPanel = (assetFactory.createDisplayObject("HelpPanelAsset") as MovieClip);
helpPanel.x = 275;
helpPanel.y = 200;
helpPanel.back_btn.addEventListener(MouseEvent.MOUSE_DOWN, onButtonPress);
helpPanel.back_btn.addEventListener(MouseEvent.CLICK, onHelpBackClick);
addChild(helpPanel);
}
private function onLevelSelect(_arg1:Event):void{
levelNum = (_arg1.target as PanelManager).selectedLevel;
initLevel();
}
private function startLevel(_arg1:Event):void{
level.removeEventListener(Event.INIT, startLevel);
timer.start(level.levelTime);
addEventListener(Event.ENTER_FRAME, step);
}
private function step(_arg1:Event):void{
level.step();
mc.hud_mc.time_txt.text = timer.getTimeAsString(":", false);
mc.hud_mc.timeGlow.visible = (timer.totalTime < 30000);
}
override public function init(_arg1:Class):void{
super.init(_arg1);
addEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
}
private function onKeyDown(_arg1:KeyboardEvent):void{
if ((((_arg1.keyCode == 81)) && (level))){
quitLevel();
} else {
if (_arg1.keyCode == 72){
if (level){
pause();
};
showHelp();
} else {
if ((((_arg1.keyCode == 32)) || ((_arg1.keyCode == 13)))){
if (helpPanel){
hideHelp();
};
};
};
};
}
private function initLevel():void{
var _local1:int;
var _local2:Sequence;
Main.smSequencer.getSoundFromID("ThemeIntro").stop();
Main.smSequencer.getSoundFromID("ThemeVerse").stop();
Main.smSequencer.getSoundFromID("ThemeChorus").stop();
Main.smSequencer.getSoundFromID("ThemeMiddle8").stop();
if (level){
_local1 = 0;
while (_local1 < level.musicLoops.length) {
_local2 = level.musicLoops[_local1];
_local2.currSound.stop();
_local1++;
};
level.removeEventListener(BaseLevel.EVENT_WIN, onLevelEnd);
level.removeEventListener(LevelEvent.TYPE_TIME, onLevelTime);
level.dispose();
mc.removeChild(level);
level = null;
};
removeEventListener(Event.ENTER_FRAME, resetDisplay);
levelPoints = 0;
level = new Levels[levelNum](assetFactory);
level.addEventListener(BaseLevel.EVENT_WIN, onLevelEnd);
level.addEventListener(LevelEvent.TYPE_TIME, onLevelTime);
level.addEventListener(Event.INIT, startLevel);
mc.hud_mc.level_txt.text = (levelNum + 1);
mc.hud_mc.timeGlow.visible = false;
mc.addChild(level);
mc.setChildIndex(mc.hud_mc, (mc.numChildren - 1));
}
private function onGotoTitle(_arg1:Event):void{
NextSectionClass = Title;
gotoNextSection();
}
private function setScore(_arg1:int):void{
levelPoints = (levelPoints + _arg1);
score = (score + _arg1);
}
private function onLevelQuit(_arg1:MouseEvent):void{
DoubleQuick.event(208);
Main.smSFX.getSoundFromID("ButtonReleaseSFX").play();
var _local2:int = ((levelNum + 1) % Levels.length);
pause();
var _local3:Sequence = level.musicLoops[level.currMusicLoop];
var _local4:PanelData = new PanelData();
_local4.levelNum = _local2;
_local4.music = _local3.currSound;
panelManager.showLevelQuit(_local4);
}
override public function dispose():void{
if (level){
level.removeEventListener(BaseLevel.EVENT_WIN, onLevelEnd);
level.removeEventListener(LevelEvent.TYPE_TIME, onLevelTime);
level.removeEventListener(Event.INIT, startLevel);
level.dispose();
mc.removeChild(level);
level = null;
};
if (timer){
timer.removeEventListener(Event.COMPLETE, onLevelEnd);
timer.dispose();
};
if (panelManager){
panelManager.removeEventListener(Event.SELECT, onLevelSelect);
panelManager.removeEventListener(PanelManager.EVENT_GOTO_TITLE, onGotoTitle);
};
if (((mc) && (mc.hud_mc))){
if (mc.hud_mc.quit_btn){
mc.hud_mc.quit_btn.removeEventListener(MouseEvent.MOUSE_DOWN, onButtonPress);
mc.hud_mc.quit_btn.removeEventListener(MouseEvent.CLICK, onLevelQuit);
};
};
help_btn.removeEventListener(MouseEvent.MOUSE_DOWN, onButtonPress);
help_btn.removeEventListener(MouseEvent.CLICK, onHelpClick);
if (stage){
stage.removeEventListener(KeyboardEvent.KEY_DOWN, onKeyDown);
};
removeEventListener(Event.ENTER_FRAME, step);
removeEventListener(Event.ENTER_FRAME, resetDisplay);
}
private function onQuitButtonRollOut(_arg1:MouseEvent):void{
mc.hud_mc.playAgainRollover.visible = false;
}
private function onLevelTime(_arg1:LevelEvent):void{
timer.addTime(_arg1.value);
}
private function onHelpBackClick(_arg1:MouseEvent):void{
Main.smSFX.getSoundFromID("ButtonReleaseSFX").play();
hideHelp();
}
private function onHelpClick(_arg1:MouseEvent):void{
Main.smSFX.getSoundFromID("ButtonReleaseSFX").play();
if (level){
pause();
};
showHelp();
}
private function onAddedToStage(_arg1:Event):void{
removeEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
mc = (assetFactory.createDisplayObject("GameSectionAsset") as MovieClip);
Levels = [Level, Level, Level, Level, Level, Level];
levelNum = 0;
levelPoints = 0;
score = 0;
setScore(0);
timer = new Timer();
timer.addEventListener(Event.COMPLETE, onLevelEnd);
addChild(mc);
mc.hud_mc.miniPanel.numLevels_txt.text = Levels.length;
mc.hud_mc.quit_btn.addEventListener(MouseEvent.ROLL_OVER, onQuitButtonRollOver);
mc.hud_mc.quit_btn.addEventListener(MouseEvent.ROLL_OUT, onQuitButtonRollOut);
TextManager.getInstance().setText(mc.hud_mc.playAgainRollover.label_txt, "another");
mc.hud_mc.playAgainRollover.visible = false;
mc.hud_mc.quit_btn.addEventListener(MouseEvent.MOUSE_DOWN, onButtonPress);
mc.hud_mc.quit_btn.addEventListener(MouseEvent.CLICK, onLevelQuit);
mc.hud_mc.menu_btn.addEventListener(MouseEvent.MOUSE_DOWN, onButtonPress);
mc.hud_mc.menu_btn.addEventListener(MouseEvent.CLICK, onMenuButtonClick);
panelManager = new PanelManager(assetFactory);
panelManager.addEventListener(Event.SELECT, onLevelSelect);
panelManager.addEventListener(PanelManager.EVENT_GOTO_TITLE, onGotoTitle);
panelManager.x = (0.5 * stage.stageWidth);
panelManager.y = (0.5 * stage.stageHeight);
addChild(panelManager);
help_btn = (assetFactory.createDisplayObject("HelpButtonAsset") as SimpleButton);
help_btn.addEventListener(MouseEvent.MOUSE_DOWN, onButtonPress);
help_btn.addEventListener(MouseEvent.CLICK, onHelpClick);
help_btn.x = 44;
help_btn.y = 18;
addChild(help_btn);
stage.addEventListener(KeyboardEvent.KEY_DOWN, onKeyDown);
levelNum = 0;
initLevel();
}
private function hideHelp():void{
helpPanel.back_btn.removeEventListener(MouseEvent.MOUSE_DOWN, onButtonPress);
helpPanel.back_btn.removeEventListener(MouseEvent.CLICK, onHelpBackClick);
removeChild(helpPanel);
helpPanel = null;
if (((level) && (!(panelManager.panelShowing)))){
resume();
};
panelManager.helpShowing = false;
stage.focus = stage;
}
private function resume():void{
addEventListener(Event.ENTER_FRAME, step);
timer.unpause();
if (level){
level.resume();
};
}
private function onQuitButtonRollOver(_arg1:MouseEvent):void{
mc.hud_mc.playAgainRollover.visible = true;
}
private function onButtonPress(_arg1:MouseEvent):void{
Main.smSFX.getSoundFromID("ButtonPressSFX").play();
}
private function quitLevel():void{
Main.smSequencer.stop();
var _local1:ExtendedSound = Main.smSequencer.getSoundFromID("ThemeVerse");
var _local2:Sequence = new Sequence();
_local2.addStep(_local1, 0);
Main.smSequencer.playSequence(_local2);
setScore(-(levelPoints));
pause();
_local2 = level.musicLoops[level.currMusicLoop];
var _local3:PanelData = new PanelData();
_local3.levelNum = levelNum;
_local3.music = _local2.currSound;
panelManager.showLevelSelect(_local3, true);
}
private function pause():void{
removeEventListener(Event.ENTER_FRAME, step);
timer.pause();
if (level){
level.pause();
};
}
private function onMenuButtonClick(_arg1:MouseEvent):void{
NextSectionClass = Title;
gotoNextSection();
}
private function resetDisplay(_arg1:Event):void{
level.resetDisplay();
}
private function onLevelEnd(_arg1:Event):void{
pause();
var _local2:Sequence = level.musicLoops[level.currMusicLoop];
var _local3:PanelData = new PanelData();
_local3.levelNum = levelNum;
_local3.remainingTime = (timer.totalTime / 1000);
_local3.timeScore = (_local3.remainingTime * BONUS_POINTS_PER_SECOND);
_local3.numFlowers = level.getNumTargetsHit();
_local3.totalFlowers = level.numTargets;
_local3.flowersScore = (POINTS_PER_TARGET * _local3.numFlowers);
_local3.numBonus = level.numPointsPowerupsHit;
_local3.totalBonus = level.numPointsPowerups;
_local3.bonusScore = level.totalPowerupPoints;
_local3.music = _local2.currSound;
_local3.levelRef = parseInt(getQualifiedClassName(level).split("::")[0].substring(27));
_local3.nextLevelNum = ((_local3.levelNum + 1) % Levels.length);
panelManager.showQuickLevelEnd(_local3);
addEventListener(Event.ENTER_FRAME, resetDisplay);
}
}
}//package uk.kerb.locoRoco
Section 147
//QuickInstructions (uk.kerb.locoRoco.QuickInstructions)
package uk.kerb.locoRoco {
import flash.events.*;
import uk.kerb.utils.game.*;
import flash.display.*;
public class QuickInstructions extends AbstractSection {
private var numActiveTweens:int;
override public function init(_arg1:Class):void{
super.init(_arg1);
mc = (assetFactory.createDisplayObject("QuickInstructionsSectionAsset") as MovieClip);
mc.x = 275;
mc.y = 200;
mc.play_btn.addEventListener(MouseEvent.MOUSE_DOWN, onButtonPress);
mc.play_btn.addEventListener(MouseEvent.CLICK, onPlayClick);
mc.repeat_btn.addEventListener(MouseEvent.MOUSE_DOWN, onButtonPress);
mc.repeat_btn.addEventListener(MouseEvent.CLICK, onRepeatClick);
addChild(mc);
numActiveTweens = 0;
addEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
}
private function onKeyDown(_arg1:KeyboardEvent):void{
if ((((_arg1.keyCode == 32)) || ((_arg1.keyCode == 13)))){
hide();
};
}
private function onAddedToStage(_arg1:Event):void{
removeEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
stage.addEventListener(KeyboardEvent.KEY_DOWN, onKeyDown);
stage.focus = stage;
}
private function onPlayClick(_arg1:MouseEvent):void{
Main.smSFX.getSoundFromID("ButtonReleaseSFX").play();
hide();
}
override public function dispose():void{
mc.play_btn.removeEventListener(MouseEvent.MOUSE_DOWN, onButtonPress);
mc.play_btn.removeEventListener(MouseEvent.CLICK, onPlayClick);
mc.repeat_btn.removeEventListener(MouseEvent.MOUSE_DOWN, onButtonPress);
mc.repeat_btn.removeEventListener(MouseEvent.CLICK, onRepeatClick);
}
private function onButtonPress(_arg1:MouseEvent):void{
Main.smSFX.getSoundFromID("ButtonPressSFX").play();
}
private function hide():void{
NextSectionClass = QuickGame;
if (stage){
stage.removeEventListener(KeyboardEvent.KEY_DOWN, onKeyDown);
};
gotoNextSection();
}
private function onRepeatClick(_arg1:MouseEvent):void{
Main.smSFX.getSoundFromID("ButtonReleaseSFX").play();
mc.animation.gotoAndPlay(1);
}
}
}//package uk.kerb.locoRoco
Section 148
//Setup (uk.kerb.locoRoco.Setup)
package uk.kerb.locoRoco {
import flash.events.*;
import flash.display.*;
import flash.net.*;
import flash.ui.*;
public class Setup {
private static var stage:Stage;
private static var lowQualityItem:ContextMenuItem;
private static var url:String;
private static var highQualityItem:ContextMenuItem;
private static var setupComplete:Boolean = false;
private static var mediumQualityItem:ContextMenuItem;
private static function onKerbMenuItemSelect(_arg1:Event):void{
navigateToURL(new URLRequest(Constants.KERB_SITE_URL), "_blank");
}
private static function initTracking():void{
}
private static function initContextMenu(_arg1:MovieClip):void{
var _local2:ContextMenuItem;
_arg1.contextMenu = new ContextMenu();
_arg1.contextMenu.hideBuiltInItems();
url = _arg1.loaderInfo.url;
stage = _arg1.stage;
_local2 = new ContextMenuItem("Built by Kerb!", false);
_local2.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, onKerbMenuItemSelect);
_arg1.contextMenu.customItems.push(_local2);
lowQualityItem = new ContextMenuItem("Low Quality (fastest)", true);
lowQualityItem.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, onQualityMenuItemSelect);
_arg1.contextMenu.customItems.push(lowQualityItem);
mediumQualityItem = new ContextMenuItem("Medium Quality", false);
mediumQualityItem.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, onQualityMenuItemSelect);
_arg1.contextMenu.customItems.push(mediumQualityItem);
highQualityItem = new ContextMenuItem("• High Quality (slowest)", false);
highQualityItem.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, onQualityMenuItemSelect);
_arg1.contextMenu.customItems.push(highQualityItem);
_local2 = new ContextMenuItem("Download This Game", true);
_local2.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, onDownloadMenuItemSelect);
_arg1.contextMenu.customItems.push(_local2);
}
private static function initStage(_arg1:MovieClip):void{
_arg1.stage.scaleMode = StageScaleMode.NO_SCALE;
_arg1.stage.align = StageAlign.TOP_LEFT;
}
private static function onDownloadMenuItemSelect(_arg1:Event):void{
navigateToURL(new URLRequest((Constants.DOWNLOAD_THIS_GAME_URL + url)), "_blank");
}
public static function init(_arg1:MovieClip):void{
if (!setupComplete){
initStage(_arg1);
initContextMenu(_arg1);
initTracking();
setupComplete = true;
};
}
private static function onQualityMenuItemSelect(_arg1:Event):void{
lowQualityItem.caption = "Low Quality (fast)";
mediumQualityItem.caption = "Medium Quality";
highQualityItem.caption = "High Quality (slow)";
switch (_arg1.currentTarget){
case lowQualityItem:
lowQualityItem.caption = ("• " + lowQualityItem.caption);
stage.quality = StageQuality.LOW;
break;
case mediumQualityItem:
mediumQualityItem.caption = ("• " + mediumQualityItem.caption);
stage.quality = StageQuality.MEDIUM;
break;
case highQualityItem:
highQualityItem.caption = ("• " + highQualityItem.caption);
stage.quality = StageQuality.HIGH;
break;
};
}
}
}//package uk.kerb.locoRoco
Section 149
//SubmitScore (uk.kerb.locoRoco.SubmitScore)
package uk.kerb.locoRoco {
import flash.events.*;
import uk.kerb.utils.game.*;
import flash.display.*;
import flash.net.*;
public class SubmitScore extends AbstractSection {
private var loader:URLLoader;
private function showHighScores():void{
if (Constants.score >= FullGame.MIN_BONUS_UNLOCK_SCORE){
NextSectionClass = HighScoresUnlocked;
} else {
NextSectionClass = HighScores;
};
gotoNextSection();
}
private function submitScore(_arg1:String, _arg2:int, _arg3:String):void{
var name = _arg1;
var score = _arg2;
var locale = _arg3;
trace("submit score");
trace((("NAME[" + name) + "]"));
trace((("SCORE[" + score) + "]"));
trace((("LOCALE[" + locale) + "]"));
loader = new URLLoader();
loader.addEventListener(Event.COMPLETE, onSaveScoreSuccess);
loader.addEventListener(SecurityErrorEvent.SECURITY_ERROR, onSaveScoreFail);
loader.addEventListener(IOErrorEvent.IO_ERROR, onSaveScoreFail);
var vars:URLVariables = new URLVariables();
vars.name = name;
vars.score = score;
vars.locale = locale;
var request:URLRequest = new URLRequest(Constants.SUBMIT_SCORE_URL);
request.contentType = "application/x-www-form-urlencoded";
request.data = vars;
request.method = URLRequestMethod.POST;
try {
loader.load(request);
} catch(error:Error) {
showHighScores();
};
}
private function onAddedToStage(_arg1:Event):void{
removeEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
stage.focus = mc.userName_txt;
}
private function onMenuClick(_arg1:MouseEvent):void{
Main.smSFX.getSoundFromID("ButtonReleaseSFX").play();
NextSectionClass = Title;
gotoNextSection();
}
private function onSaveScoreSuccess(_arg1:Event):void{
var _local2:URLLoader = URLLoader(_arg1.target);
var _local3:URLVariables = new URLVariables(_local2.data);
var _local4:int = parseInt(_local3.result);
if (!isNaN(_local4)){
Constants.rank = _local4;
};
trace((("RANK[" + _local4) + "]"));
showHighScores();
}
override public function init(_arg1:Class):void{
super.init(_arg1);
mc = (assetFactory.createDisplayObject("SubmitScoreAsset") as MovieClip);
mc.x = 275;
mc.y = 200;
mc.menu_btn.addEventListener(MouseEvent.MOUSE_DOWN, onButtonPress);
mc.menu_btn.addEventListener(MouseEvent.CLICK, onMenuClick);
mc.submit_btn.addEventListener(MouseEvent.MOUSE_DOWN, onButtonPress);
mc.submit_btn.addEventListener(MouseEvent.CLICK, onSubmitClick);
addChild(mc);
addEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
}
private function onSubmitClick(_arg1:MouseEvent):void{
Main.smSFX.getSoundFromID("ButtonReleaseSFX").play();
Constants.name = mc.userName_txt.text;
if (Constants.name != ""){
mc.submit_btn.enabled = false;
submitScore(Constants.name, Constants.score, Constants.lang);
};
}
private function onButtonPress(_arg1:MouseEvent):void{
Main.smSFX.getSoundFromID("ButtonPressSFX").play();
}
private function onSaveScoreFail(_arg1:Event):void{
showHighScores();
}
override public function dispose():void{
mc.menu_btn.removeEventListener(MouseEvent.MOUSE_DOWN, onButtonPress);
mc.menu_btn.removeEventListener(MouseEvent.CLICK, onMenuClick);
loader.removeEventListener(Event.COMPLETE, onSaveScoreSuccess);
loader.removeEventListener(SecurityErrorEvent.SECURITY_ERROR, onSaveScoreFail);
loader.removeEventListener(IOErrorEvent.IO_ERROR, onSaveScoreFail);
}
}
}//package uk.kerb.locoRoco
Section 150
//TextManager (uk.kerb.locoRoco.TextManager)
package uk.kerb.locoRoco {
import flash.text.*;
public class TextManager {
private var xmlData:XML;
private static var instance:TextManager;
public function init(_arg1:XML):void{
xmlData = _arg1;
}
public function getTextById(_arg1:String):String{
var result:String;
var id = _arg1;
if (xmlData){
result = xmlData.text.(@id == id);
if (result){
return (result);
};
return ((("[text key missing : " + id) + "]"));
//unresolved jump
};
return (id);
}
public function setText(_arg1:TextField, _arg2:String, _arg3:Boolean=false):void{
var _local4:TextFormat;
var _local5:Number;
var _local6:Array;
var _local7:int;
_arg1.text = getTextById(_arg2);
if (Constants.useSystemFont){
_local4 = new TextFormat();
_local5 = parseFloat(_arg1.getTextFormat().size.toString());
_local4.font = "_sans";
_local4.bold = true;
_local4.size = ((_local5 * 20) / 23);
_arg1.embedFonts = false;
_arg1.setTextFormat(_local4);
};
if (_arg3){
_local6 = [12470533, 6649977, 7891557, 9927764, 14847816, 8739397, 7436041, 7241610, 11761688, 7305272, 9663861];
_local4 = new TextFormat();
_local7 = 0;
while (_local7 < _arg1.text.length) {
_local4.color = _local6[(_local7 % _local6.length)];
_arg1.setTextFormat(_local4, _local7, (_local7 + 1));
_local7++;
};
};
}
public static function getInstance():TextManager{
if (instance == null){
instance = new (TextManager);
};
return (instance);
}
}
}//package uk.kerb.locoRoco
Section 151
//Title (uk.kerb.locoRoco.Title)
package uk.kerb.locoRoco {
import flash.events.*;
import uk.kerb.utils.game.*;
import flash.display.*;
import uk.kerb.tracking.*;
public class Title extends AbstractSection {
private function onQuickClick(_arg1:MouseEvent):void{
Main.smSFX.getSoundFromID("ButtonReleaseSFX").play();
NextSectionClass = QuickInstructions;
startOutro();
}
private function onIntroEnterFrame(_arg1:Event):void{
localise();
}
private function onRollOver(_arg1:MouseEvent):void{
if (_arg1.currentTarget == mc.quick_btn){
TextManager.getInstance().setText(mc.rollOver_txt, "quickplay.description");
} else {
if (_arg1.currentTarget == mc.full_btn){
TextManager.getInstance().setText(mc.rollOver_txt, "challenge.description");
};
};
}
private function onOutroEnterFrame(_arg1:Event):void{
localise();
if (mc.currentFrame == mc.totalFrames){
removeEventListener(Event.ENTER_FRAME, onOutroEnterFrame);
gotoNextSection();
};
}
private function startOutro():void{
mc.gotoAndPlay("out");
removeEventListener(Event.ENTER_FRAME, onIntroEnterFrame);
addEventListener(Event.ENTER_FRAME, onOutroEnterFrame);
}
override public function init(_arg1:Class):void{
super.init(_arg1);
mc = (assetFactory.createDisplayObject("TitleSectionAsset") as MovieClip);
mc.x = 275;
mc.y = 200;
mc.quick_btn.addEventListener(MouseEvent.MOUSE_DOWN, onButtonPress);
mc.quick_btn.addEventListener(MouseEvent.ROLL_OVER, onRollOver);
mc.quick_btn.addEventListener(MouseEvent.ROLL_OUT, onRollOut);
mc.quick_btn.addEventListener(MouseEvent.CLICK, onQuickClick);
mc.full_btn.addEventListener(MouseEvent.MOUSE_DOWN, onButtonPress);
mc.full_btn.addEventListener(MouseEvent.ROLL_OVER, onRollOver);
mc.full_btn.addEventListener(MouseEvent.ROLL_OUT, onRollOut);
mc.full_btn.addEventListener(MouseEvent.CLICK, onFullClick);
mc.packshot_btn.addEventListener(MouseEvent.MOUSE_DOWN, onButtonPress);
mc.packshot_btn.addEventListener(MouseEvent.ROLL_OVER, onRollOver);
mc.packshot_btn.addEventListener(MouseEvent.ROLL_OUT, onRollOut);
mc.packshot_btn.addEventListener(MouseEvent.CLICK, onPackshotClick);
mc.highScore_btn.addEventListener(MouseEvent.MOUSE_DOWN, onButtonPress);
mc.highScore_btn.addEventListener(MouseEvent.CLICK, onHighScoreClick);
addEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
addEventListener(Event.ENTER_FRAME, onIntroEnterFrame);
addChild(mc);
DoubleQuick.event(211);
}
private function onAddedToStage(_arg1:Event):void{
removeEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
}
private function onButtonPress(_arg1:MouseEvent):void{
Main.smSFX.getSoundFromID("ButtonPressSFX").play();
}
private function onPackshotClick(_arg1:MouseEvent):void{
Main.smSFX.getSoundFromID("ButtonReleaseSFX").play();
DoubleQuick.click(215);
}
private function onHighScoreClick(_arg1:MouseEvent):void{
Main.smSFX.getSoundFromID("ButtonReleaseSFX").play();
NextSectionClass = HighScores;
startOutro();
}
private function onRollOut(_arg1:MouseEvent):void{
if (mc.rollOver_txt){
mc.rollOver_txt.text = "";
};
}
private function onFullClick(_arg1:MouseEvent):void{
Main.smSFX.getSoundFromID("ButtonReleaseSFX").play();
NextSectionClass = FullInstructions;
startOutro();
}
private function localise():void{
if (mc.packshot){
mc.packshot.gotoAndStop(Constants.lang);
};
}
override public function dispose():void{
mc.quick_btn.removeEventListener(MouseEvent.MOUSE_DOWN, onButtonPress);
mc.quick_btn.removeEventListener(MouseEvent.ROLL_OVER, onRollOver);
mc.quick_btn.removeEventListener(MouseEvent.ROLL_OUT, onRollOut);
mc.quick_btn.removeEventListener(MouseEvent.CLICK, onQuickClick);
mc.full_btn.removeEventListener(MouseEvent.MOUSE_DOWN, onButtonPress);
mc.full_btn.removeEventListener(MouseEvent.ROLL_OVER, onRollOver);
mc.full_btn.removeEventListener(MouseEvent.ROLL_OUT, onRollOut);
mc.full_btn.removeEventListener(MouseEvent.CLICK, onFullClick);
if (mc.packshot_btn){
mc.packshot_btn.removeEventListener(MouseEvent.MOUSE_DOWN, onButtonPress);
mc.packshot_btn.removeEventListener(MouseEvent.ROLL_OVER, onRollOver);
mc.packshot_btn.removeEventListener(MouseEvent.ROLL_OUT, onRollOut);
mc.packshot_btn.removeEventListener(MouseEvent.CLICK, onPackshotClick);
};
mc.highScore_btn.removeEventListener(MouseEvent.MOUSE_DOWN, onButtonPress);
mc.highScore_btn.removeEventListener(MouseEvent.CLICK, onHighScoreClick);
removeEventListener(Event.ENTER_FRAME, onIntroEnterFrame);
removeEventListener(Event.ENTER_FRAME, onOutroEnterFrame);
}
}
}//package uk.kerb.locoRoco
Section 152
//DoubleQuick (uk.kerb.tracking.DoubleQuick)
package uk.kerb.tracking {
import flash.events.*;
import flash.display.*;
import flash.net.*;
import flash.utils.*;
public class DoubleQuick {
private static const SO_SESSION_PROPERTY_NAME:String = "sessionkey";
private static const SO_NAME:String = "doublequick";
private static const TICKER_PERIOD:Number = 30000;
private static const TRACKER_SESSION_URL:String = "http://whodidit.co.uk/tracking/session.htm";
private static const TICKER_URL:String = "http://whodidit.co.uk/tracking/ticker.htm";
private static const TRACKER_URL:String = "http://whodidit.co.uk/tracking/trackflash.htm";
private static const SO_EXPIRY_PROPERTY_NAME:String = "expo";
private static var tickerURL:URLRequest = null;
private static var initialised:Boolean = false;
private static var queue:Array = new Array();
private static var projectId:Number;
private static var baseurl:String;
private static var dq:DoubleQuick;
public function startTimer():void{
var _local1:Timer = new Timer(TICKER_PERIOD, 0);
_local1.start();
_local1.addEventListener(TimerEvent.TIMER, pingProxy);
}
public function pingProxy(_arg1:TimerEvent):void{
DoubleQuick.ping();
}
private static function dummyListener(_arg1:Event):void{
}
public static function event(_arg1:Number):void{
var loader:URLLoader;
var request:URLRequest;
var watchId = _arg1;
if (!initialised){
trace(("Queueing event " + watchId));
queue.push(watchId);
} else {
trace(("Tracking event " + watchId));
loader = new URLLoader();
loader.dataFormat = URLLoaderDataFormat.VARIABLES;
loader.addEventListener(IOErrorEvent.IO_ERROR, dummyListener);
request = generateURL(watchId);
request.method = URLRequestMethod.GET;
try {
loader.load(request);
} catch(error:Error) {
};
};
}
public static function click(_arg1:Number):void{
trace(("Tracking clickThrough " + _arg1));
navigateToURL(generateURL(_arg1));
}
private static function onInit(_arg1:Event):void{
var _local4:Date;
var _local2:URLLoader = URLLoader(_arg1.target);
var _local3:SharedObject = SharedObject.getLocal(DoubleQuick.SO_NAME);
if (((!((_local2.data["sessionkey"] == ""))) && (!((_local2.data["sessionkey"] == null))))){
trace(("acquired session key " + _local2.data["sessionkey"]));
_local3.setProperty(DoubleQuick.SO_SESSION_PROPERTY_NAME, _local2.data["sessionkey"]);
_local4 = new Date((new Date().getTime() + ((_local2.data["timeout"] * 60) * 1000)));
_local3.setProperty(DoubleQuick.SO_EXPIRY_PROPERTY_NAME, _local4);
};
DoubleQuick.initialisationFinished();
}
public static function init(_arg1:DisplayObject, _arg2:Number):void{
var loader:URLLoader;
var request:URLRequest;
var root = _arg1;
var _projectId = _arg2;
projectId = _projectId;
baseurl = root.loaderInfo.url;
trace(((("Tracking initialised with project " + projectId) + " and baseurl ") + baseurl));
var so:SharedObject = SharedObject.getLocal(DoubleQuick.SO_NAME);
var isExpired:Boolean;
var currentDate:Date = new Date();
if (currentDate < so.data[DoubleQuick.SO_EXPIRY_PROPERTY_NAME]){
isExpired = false;
};
if ((((so.data[DoubleQuick.SO_SESSION_PROPERTY_NAME] == undefined)) || (isExpired))){
trace("requesting new session key");
loader = new URLLoader();
loader.dataFormat = URLLoaderDataFormat.VARIABLES;
loader.addEventListener(Event.COMPLETE, onInit);
loader.addEventListener(IOErrorEvent.IO_ERROR, dummyListener);
request = new URLRequest(((TRACKER_SESSION_URL + "?project=") + projectId));
request.method = URLRequestMethod.GET;
try {
loader.load(request);
} catch(error:Error) {
};
} else {
DoubleQuick.initialisationFinished();
};
}
public static function initialisationFinished():void{
trace("Tracking initialised");
initialised = true;
var _local1:int;
while (_local1 < queue.length) {
event(queue[_local1]);
_local1++;
};
queue = new Array();
var _local2:SharedObject = SharedObject.getLocal(DoubleQuick.SO_NAME);
tickerURL = new URLRequest(((((TICKER_URL + "?project=") + projectId) + "&session=") + _local2.data[DoubleQuick.SO_SESSION_PROPERTY_NAME]));
tickerURL.method = URLRequestMethod.GET;
dq = new (DoubleQuick);
dq.startTimer();
}
public static function ping():void{
var loader:URLLoader;
if (tickerURL != null){
loader = new URLLoader();
loader.dataFormat = URLLoaderDataFormat.VARIABLES;
loader.addEventListener(IOErrorEvent.IO_ERROR, dummyListener);
trace("Tracking ticker");
try {
loader.load(tickerURL);
} catch(error:Error) {
};
};
}
private static function generateURL(_arg1:Number):URLRequest{
var _local2:SharedObject = SharedObject.getLocal(DoubleQuick.SO_NAME);
var _local3:String = ((((((((TRACKER_URL + "?watch=") + _arg1) + "&project=") + projectId) + "&session=") + _local2.data[DoubleQuick.SO_SESSION_PROPERTY_NAME]) + "&baseurl=") + escape(baseurl));
return (new URLRequest(_local3));
}
}
}//package uk.kerb.tracking
Section 153
//AbstractSection (uk.kerb.utils.game.AbstractSection)
package uk.kerb.utils.game {
import flash.events.*;
import flash.display.*;
import uk.kerb.utils.ui.*;
public class AbstractSection extends MovieClip implements IDisposable {
protected var NextSectionClass:Class;
protected var PreviousSectionClass:Class;
protected var mc:MovieClip;
protected var assetFactory:AssetFactory;
public function AbstractSection(){
assetFactory = Main.assetFactory;
}
public function dispose():void{
}
protected function gotoNextSection():void{
dispatchEvent(new Event(Event.COMPLETE));
}
public function init(_arg1:Class):void{
this.PreviousSectionClass = _arg1;
}
public function getNextSection():Class{
return (NextSectionClass);
}
}
}//package uk.kerb.utils.game
Section 154
//AssetFactory (uk.kerb.utils.game.AssetFactory)
package uk.kerb.utils.game {
import flash.events.*;
import flash.display.*;
import uk.co.stdio.sound.*;
public final class AssetFactory extends EventDispatcher {
private var _loader:Loader;// = null
public static const EVENT_ASSET_FACTORY_READY:String = "EVENT_ASSET_FACTORY_READY";
public function initialize(_arg1:Class):void{
_loader = new Loader();
_loader.contentLoaderInfo.addEventListener(Event.INIT, _onLibraryReady);
_loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, _onIOError);
_loader.loadBytes(new (_arg1));
}
public function createDisplayObject(_arg1:String):DisplayObject{
var _local2:Class = Class(_loader.contentLoaderInfo.applicationDomain.getDefinition(_arg1));
return ((new (_local2) as DisplayObject));
}
private function _onLibraryReady(_arg1:Event):void{
_loader.contentLoaderInfo.removeEventListener(Event.INIT, _onLibraryReady);
dispatchEvent(new Event(EVENT_ASSET_FACTORY_READY));
}
public function createSound(_arg1:String):ExtendedSound{
var _local2:Class = Class(_loader.contentLoaderInfo.applicationDomain.getDefinition(_arg1));
return ((new (_local2) as ExtendedSound));
}
public function createBitmapDataObject(_arg1:String):BitmapData{
var _local2:Class = Class(_loader.contentLoaderInfo.applicationDomain.getDefinition(_arg1));
return ((new _local2(0, 0) as BitmapData));
}
private function _onIOError(_arg1:Event):void{
}
}
}//package uk.kerb.utils.game
Section 155
//Ident (uk.kerb.utils.game.Ident)
package uk.kerb.utils.game {
import flash.events.*;
import flash.display.*;
import flash.net.*;
import flash.utils.*;
public class Ident extends MovieClip {
protected var af:AssetFactory;
protected var preload:MovieClip;
protected var ident:MovieClip;
protected var SWFBytes:Class;
protected static const KERB_GAMES_URL:String = "http://www.kerbgames.com";
public function Ident(){
SWFBytes = Ident_SWFBytes;
super();
addEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
}
protected function onAddedToStage(_arg1:Event):void{
removeEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
stop();
stage.scaleMode = StageScaleMode.NO_SCALE;
stage.align = StageAlign.TOP_LEFT;
af = new AssetFactory();
af.addEventListener(AssetFactory.EVENT_ASSET_FACTORY_READY, onAssetFactoryReady);
af.initialize(SWFBytes);
}
protected function onPreloadComplete(_arg1:Event):void{
_arg1.target.removeEventListener(Event.COMPLETE, onPreloadComplete);
nextFrame();
showMainContent();
preload = (_arg1.target as MovieClip);
var _local2:Timer = new Timer(100, 1);
_local2.addEventListener(TimerEvent.TIMER_COMPLETE, onTimerComplete);
_local2.start();
}
protected function showPreloader():void{
}
protected function onAssetFactoryReady(_arg1:Event):void{
af.removeEventListener(AssetFactory.EVENT_ASSET_FACTORY_READY, onAssetFactoryReady);
ident = (af.createDisplayObject("IdentAsset") as MovieClip);
ident.x = (0.5 * stage.stageWidth);
ident.y = (0.5 * stage.stageHeight);
ident.bg_mc.width = (stage.stageWidth + 20);
ident.bg_mc.height = (stage.stageHeight + 20);
ident.addEventListener(MouseEvent.MOUSE_DOWN, onIdentClick);
ident.addEventListener(Event.ENTER_FRAME, onEnterFrame);
addChild(ident);
}
protected function onEnterFrame(_arg1:Event):void{
if (ident.currentFrame == ident.totalFrames){
ident.stop();
ident.removeEventListener(Event.ENTER_FRAME, onEnterFrame);
ident.removeEventListener(MouseEvent.MOUSE_DOWN, onIdentClick);
removeChild(ident);
ident = null;
showPreloader();
};
}
protected function onIdentClick(_arg1:MouseEvent):void{
navigateToURL(new URLRequest(KERB_GAMES_URL), "_blank");
}
protected function showMainContent():void{
}
protected function onTimerComplete(_arg1:TimerEvent):void{
_arg1.target.removeEventListener(TimerEvent.TIMER_COMPLETE, onTimerComplete);
removeChild(preload);
preload = null;
}
}
}//package uk.kerb.utils.game
Section 156
//Ident_SWFBytes (uk.kerb.utils.game.Ident_SWFBytes)
package uk.kerb.utils.game {
import mx.core.*;
public class Ident_SWFBytes extends ByteArrayAsset {
}
}//package uk.kerb.utils.game
Section 157
//Main (uk.kerb.utils.game.Main)
package uk.kerb.utils.game {
import flash.events.*;
import uk.co.stdio.sound.*;
import flash.display.*;
public class Main extends Sprite {
protected var PreviousSectionClass:Class;
protected var currentSection:AbstractSection;
public static var smSFX:SoundManager;
public static var assetFactory:AssetFactory;
public static var smMusic:SoundManager;
public function Main(_arg1:Class){
assetFactory = new AssetFactory();
assetFactory.addEventListener(AssetFactory.EVENT_ASSET_FACTORY_READY, onAssetFactoryReady);
assetFactory.initialize(_arg1);
}
protected function init():void{
initSounds();
start();
}
protected function gotoSection(_arg1:Class):void{
if (currentSection != null){
currentSection.removeEventListener(Event.COMPLETE, onSectionComplete);
currentSection.dispose();
removeChild(currentSection);
};
currentSection = new (_arg1);
currentSection.init(PreviousSectionClass);
currentSection.addEventListener(Event.COMPLETE, onSectionComplete);
addChild(currentSection);
PreviousSectionClass = _arg1;
}
protected function initSound(_arg1:String, _arg2:SoundManager):void{
var _local3:ExtendedSound = (assetFactory.createSound(_arg1) as ExtendedSound);
_arg2.registerSound(_local3, _arg1);
}
protected function start():void{
}
protected function onAssetFactoryReady(_arg1:Event):void{
assetFactory.removeEventListener(AssetFactory.EVENT_ASSET_FACTORY_READY, onAssetFactoryReady);
init();
}
protected function initSounds():void{
Main.smMusic = new SoundManager("music");
Main.smSFX = new SoundManager("sfx");
}
protected function onSectionComplete(_arg1:Event):void{
gotoSection(currentSection.getNextSection());
}
}
}//package uk.kerb.utils.game
Section 158
//Timer (uk.kerb.utils.game.Timer)
package uk.kerb.utils.game {
import flash.events.*;
import uk.kerb.utils.ui.*;
import flash.utils.*;
public class Timer extends EventDispatcher implements IDisposable {
protected var _countdownTimer:Timer;
protected var _paused:Boolean;
protected var _stopTime:int;
protected var _startTime:int;
protected var _pauseStartTime:int;
protected var _countdownTime:int;
protected var _pauseTotalTime:int;
public function Timer(){
reset();
}
public function stop():void{
if (_startTime != -1){
if (_paused){
unpause();
};
_stopTime = getTimer();
};
}
public function getTimeAsString(_arg1:String=":", _arg2:Boolean=true, _arg3:Boolean=true):String{
var _local4:int = (totalTime / 1000);
var _local5:int = (_local4 / 60);
var _local6:int = (_local4 % 60);
var _local7 = "";
var _local8:int = Math.abs(_local5);
var _local9:int = Math.abs(_local6);
if (_local4 < 0){
_local7 = (_local7 + "-");
};
if (((_arg2) && ((_local8 < 10)))){
_local7 = (_local7 + "0");
};
_local7 = (_local7 + _local8.toString());
_local7 = (_local7 + _arg1);
if (((_arg3) && ((_local9 < 10)))){
_local7 = (_local7 + "0");
};
_local7 = (_local7 + _local9.toString());
return (_local7);
}
public function get startTime():int{
return (_startTime);
}
public function addTime(_arg1:int):void{
var _local2:Boolean;
if (_countdownTimer){
if (_countdownTime == -1){
_startTime = (_startTime + _arg1);
} else {
_local2 = paused;
start((totalTime + _arg1));
if (_local2){
pause();
};
};
};
}
public function reset():void{
_startTime = -1;
_stopTime = -1;
_countdownTime = -1;
_pauseStartTime = 0;
_pauseTotalTime = 0;
_paused = false;
dispose();
}
public function get countdownTime():int{
return (_countdownTime);
}
public function start(_arg1:int=-1):void{
reset();
if (_arg1 != -1){
_countdownTime = _arg1;
_countdownTimer = new Timer(_arg1, 1);
_countdownTimer.addEventListener(TimerEvent.TIMER_COMPLETE, onTimerComplete);
_countdownTimer.start();
};
_startTime = getTimer();
}
public function get paused():Boolean{
return (_paused);
}
public function get stopTime():int{
return (_stopTime);
}
public function get totalTime():int{
var _local2:int;
var _local1:int = _pauseTotalTime;
if (_paused){
_local1 = (_local1 + (getTimer() - _pauseStartTime));
};
if (_startTime == -1){
_local2 = 0;
} else {
if (_stopTime == -1){
_local2 = ((getTimer() - _startTime) - _local1);
} else {
_local2 = ((_stopTime - _startTime) - _local1);
};
};
if (_countdownTime != -1){
_local2 = (_countdownTime - _local2);
if (_local2 < 0){
_local2 = 0;
};
};
return (_local2);
}
public function pause():void{
if (((((!(_paused)) && ((_stopTime == -1)))) && (!((_startTime == -1))))){
_paused = true;
_pauseStartTime = getTimer();
if (_countdownTimer){
_countdownTimer.stop();
};
};
}
public function dispose():void{
if (_countdownTimer){
_countdownTimer.removeEventListener(TimerEvent.TIMER_COMPLETE, onTimerComplete);
};
_countdownTimer = null;
}
public function unpause():void{
if (((((_paused) && ((_stopTime == -1)))) && (!((_startTime == -1))))){
_paused = false;
_pauseTotalTime = (_pauseTotalTime + (getTimer() - _pauseStartTime));
if (_countdownTimer){
_countdownTimer.start();
};
};
}
protected function onTimerComplete(_arg1:TimerEvent):void{
stop();
_countdownTimer.stop();
_countdownTimer.removeEventListener(TimerEvent.TIMER_COMPLETE, onTimerComplete);
_countdownTimer = null;
dispatchEvent(new Event(Event.COMPLETE));
}
}
}//package uk.kerb.utils.game
Section 159
//DynamicButton (uk.kerb.utils.ui.DynamicButton)
package uk.kerb.utils.ui {
import flash.display.*;
public dynamic class DynamicButton extends SimpleButton {
}
}//package uk.kerb.utils.ui
Section 160
//IDisposable (uk.kerb.utils.ui.IDisposable)
package uk.kerb.utils.ui {
public interface IDisposable {
function dispose():void;
}
}//package uk.kerb.utils.ui
Section 161
//SoundControl (uk.kerb.utils.ui.SoundControl)
package uk.kerb.utils.ui {
import flash.events.*;
import uk.co.stdio.sound.*;
import flash.display.*;
public class SoundControl extends MovieClip implements IDisposable {
protected var _musicSoundManager:SoundManager;
protected var _sfxSoundManager:SoundManager;
protected var propagateMasterChange:Boolean;
public function SoundControl(){
propagateMasterChange = true;
}
public function get musicSoundManager():SoundManager{
return (_musicSoundManager);
}
protected function onSFXChange(_arg1:Event):void{
var _local2:Toggle = (getChildByName("music_btn") as Toggle);
var _local3:Toggle = (getChildByName("sfx_btn") as Toggle);
var _local4:Toggle = (getChildByName("master_btn") as Toggle);
propagateMasterChange = false;
if (_local3.isOn){
if (_sfxSoundManager.muted){
_sfxSoundManager.unmute();
};
_local4.isOn = true;
} else {
if (!_sfxSoundManager.muted){
_sfxSoundManager.mute();
};
if (!_local2.isOn){
_local4.isOn = false;
};
};
propagateMasterChange = true;
}
public function set musicSoundManager(_arg1:SoundManager):void{
this._musicSoundManager = _arg1;
}
public function get sfxSoundManager():SoundManager{
return (_sfxSoundManager);
}
public function set sfxSoundManager(_arg1:SoundManager):void{
this._sfxSoundManager = _arg1;
}
public function dispose():void{
var _local1:Toggle = (getChildByName("music_btn") as Toggle);
var _local2:Toggle = (getChildByName("sfx_btn") as Toggle);
var _local3:Toggle = (getChildByName("master_btn") as Toggle);
removeEventListener(MouseEvent.ROLL_OUT, onRollOut);
_local3.removeEventListener(MouseEvent.ROLL_OVER, onRollOver);
_local3.removeEventListener(Event.CHANGE, onMasterChange);
if (_local1 != null){
_local1.removeEventListener(Event.CHANGE, onMusicChange);
};
if (_local2 != null){
_local2.removeEventListener(Event.CHANGE, onSFXChange);
};
}
public function init(_arg1:SoundManager, _arg2:SoundManager):void{
var _local4:int;
var _local5:int;
var _local3:Toggle = (getChildByName("master_btn") as Toggle);
_local3.isOn = true;
this.musicSoundManager = _arg1;
this.sfxSoundManager = _arg2;
_local3.addEventListener(Event.CHANGE, onMasterChange);
_local3.addEventListener(MouseEvent.ROLL_OVER, onRollOver);
addEventListener(MouseEvent.ROLL_OUT, onRollOut);
_local4 = 0;
while (_local4 < currentLabels.length) {
if (currentLabels[_local4].name == "open"){
_local5 = (currentLabels[_local4].frame - 1);
addFrameScript(_local5, initButtons);
break;
};
_local4++;
};
}
protected function initButtons():void{
var _local1:Toggle = (getChildByName("music_btn") as Toggle);
var _local2:Toggle = (getChildByName("sfx_btn") as Toggle);
_local1.isOn = !(_musicSoundManager.muted);
_local1.addEventListener(Event.CHANGE, onMusicChange);
_local2.isOn = !(_sfxSoundManager.muted);
_local2.addEventListener(Event.CHANGE, onSFXChange);
}
protected function onRollOut(_arg1:MouseEvent):void{
var _local2:Toggle = (getChildByName("music_btn") as Toggle);
var _local3:Toggle = (getChildByName("sfx_btn") as Toggle);
if (_local2 != null){
_local2.removeEventListener(Event.CHANGE, onMusicChange);
};
if (_local3 != null){
_local3.removeEventListener(Event.CHANGE, onSFXChange);
};
gotoAndStop("closed");
}
protected function onRollOver(_arg1:MouseEvent):void{
gotoAndStop("open");
}
protected function onMasterChange(_arg1:Event):void{
var _local2:Toggle = (getChildByName("music_btn") as Toggle);
var _local3:Toggle = (getChildByName("sfx_btn") as Toggle);
var _local4:Toggle = (getChildByName("master_btn") as Toggle);
if (propagateMasterChange){
if (_local4.isOn){
if (_musicSoundManager.muted){
_musicSoundManager.unmute();
};
if (_sfxSoundManager.muted){
_sfxSoundManager.unmute();
};
} else {
if (!_musicSoundManager.muted){
_musicSoundManager.mute();
};
if (!_sfxSoundManager.muted){
_sfxSoundManager.mute();
};
};
if (_local2 != null){
_local2.isOn = _local4.isOn;
};
if (_local3 != null){
_local3.isOn = _local4.isOn;
};
};
}
protected function onMusicChange(_arg1:Event):void{
var _local2:Toggle = (getChildByName("music_btn") as Toggle);
var _local3:Toggle = (getChildByName("sfx_btn") as Toggle);
var _local4:Toggle = (getChildByName("master_btn") as Toggle);
propagateMasterChange = false;
if (_local2.isOn){
if (_musicSoundManager.muted){
_musicSoundManager.unmute();
};
_local4.isOn = true;
} else {
if (!_musicSoundManager.muted){
_musicSoundManager.mute();
};
if (!_local3.isOn){
_local4.isOn = false;
};
};
propagateMasterChange = true;
}
}
}//package uk.kerb.utils.ui
Section 162
//Toggle (uk.kerb.utils.ui.Toggle)
package uk.kerb.utils.ui {
import flash.events.*;
import flash.text.*;
import flash.display.*;
public class Toggle extends MovieClip implements IDisposable {
protected var _isOn:Boolean;
protected var _state:int;
protected var _label:String;
public static const STATE_DOWN:int = 2;
public static const STATE_UP:int = 0;
public static const STATE_OVER:int = 1;
protected static var stateLabels:Array = ["upOff", "overOff", "downOff", "upOn", "overOn", "downOn"];
public function Toggle(){
addEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
}
protected function onMouseDown(_arg1:MouseEvent):void{
_state = STATE_DOWN;
update();
}
protected function onMouseUp(_arg1:MouseEvent):void{
_state = STATE_OVER;
isOn = !(_isOn);
}
protected function onAddedToStage(_arg1:Event):void{
removeEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
init();
}
public function get isOn():Boolean{
return (_isOn);
}
protected function onRollOut(_arg1:MouseEvent):void{
_state = STATE_UP;
update();
}
public function set label(_arg1:String):void{
this._label = _arg1;
updateLabel();
}
public function get state():int{
return (_state);
}
public function get label():String{
return (_label);
}
protected function init():void{
var _local2:int;
_state = STATE_UP;
_label = "";
isOn = false;
buttonMode = true;
mouseChildren = false;
var _local1:int;
while (_local1 < numChildren) {
if ((getChildAt(_local1) is TextField)){
_local2 = 0;
while (_local2 < totalFrames) {
addFrameScript(_local2, updateLabel);
_local2++;
};
break;
};
_local1++;
};
addEventListener(MouseEvent.MOUSE_DOWN, onMouseDown);
addEventListener(MouseEvent.MOUSE_UP, onMouseUp);
addEventListener(MouseEvent.ROLL_OVER, onRollOver);
addEventListener(MouseEvent.ROLL_OUT, onRollOut);
}
protected function update():void{
gotoAndStop(stateLabels[((_isOn) ? 3 : 0 + state)]);
}
public function set isOn(_arg1:Boolean):void{
this._isOn = _arg1;
update();
dispatchEvent(new Event(Event.CHANGE));
}
protected function updateLabel():void{
var _local1:int;
while (_local1 < numChildren) {
if ((getChildAt(_local1) is TextField)){
(getChildAt(_local1) as TextField).text = _label;
break;
};
_local1++;
};
}
protected function onRollOver(_arg1:MouseEvent):void{
_state = STATE_OVER;
update();
}
public function dispose():void{
removeEventListener(MouseEvent.MOUSE_DOWN, onMouseDown);
removeEventListener(MouseEvent.MOUSE_UP, onMouseUp);
removeEventListener(MouseEvent.ROLL_OVER, onRollOver);
removeEventListener(MouseEvent.ROLL_OUT, onRollOut);
}
}
}//package uk.kerb.utils.ui
Section 163
//Tween (uk.kerb.utils.Tween)
package uk.kerb.utils {
import flash.events.*;
import flash.utils.*;
public final class Tween extends EventDispatcher {
private var _timer:Timer;// = null
private var _fn:Function;// = null
private var _startValue:Number;// = 0
private var _props:Array;// = null
private var _duration:uint;// = 0
private var _endValue:Number;// = 0
private var _obj:Object;// = null
private var _t0:uint;// = 0
public static const EVENT_TWEEN_COMPLETE:String = "EVENT_TWEEN_COMPLETE";
public function Tween(_arg1:Object, _arg2:Array, _arg3:Number, _arg4:Number, _arg5:uint, _arg6:Function){
_obj = _arg1;
_props = _arg2;
_startValue = _arg3;
_endValue = _arg4;
_duration = _arg5;
_fn = _arg6;
_startTimer();
}
public function get object():Object{
return (_obj);
}
private function _stopTimer():void{
if (_timer){
_timer.stop();
_timer = null;
};
}
private function _startTimer():void{
_stopTimer();
_timer = new Timer(10);
_timer.addEventListener(TimerEvent.TIMER, _onTimer);
_timer.start();
_t0 = getTimer();
}
public function dispose():void{
_stopTimer();
}
private function _onTimer(_arg1:TimerEvent):void{
var _local2:Number = 0;
var _local3:Number = (getTimer() - _t0);
if (_local3 >= _duration){
_local2 = _endValue;
_stopTimer();
dispatchEvent(new Event(EVENT_TWEEN_COMPLETE));
} else {
_local2 = _fn(_local3, _startValue, (_endValue - _startValue), _duration);
};
var _local4:uint;
while (_local4 < _props.length) {
_obj[_props[_local4]] = _local2;
_local4++;
};
}
}
}//package uk.kerb.utils
Section 164
//LocoRoco2Game (LocoRoco2Game)
package {
import uk.kerb.locoRoco.*;
import flash.display.*;
public class LocoRoco2Game extends Sprite {
private var SWFBytes:Class;
public function LocoRoco2Game(){
SWFBytes = LocoRoco2Game_SWFBytes;
super();
addChild(new Main(SWFBytes));
}
}
}//package
Section 165
//LocoRoco2Game_SWFBytes (LocoRoco2Game_SWFBytes)
package {
import mx.core.*;
public class LocoRoco2Game_SWFBytes extends ByteArrayAsset {
}
}//package