Section 1
//b2CircleDef (Box2D.Collision.Shapes.b2CircleDef)
package Box2D.Collision.Shapes {
import Box2D.Common.Math.*;
public class b2CircleDef extends b2ShapeDef {
public var radius:Number;
public var localPosition:b2Vec2;
public function b2CircleDef(){
localPosition = new b2Vec2(0, 0);
super();
type = b2Shape.e_circleShape;
radius = 1;
}
}
}//package Box2D.Collision.Shapes
Section 2
//b2CircleShape (Box2D.Collision.Shapes.b2CircleShape)
package Box2D.Collision.Shapes {
import Box2D.Common.Math.*;
import Box2D.Collision.*;
import Box2D.Dynamics.*;
import Box2D.Common.*;
public class b2CircleShape extends b2Shape {
public var m_localPosition:b2Vec2;
public var m_radius:Number;
public function b2CircleShape(_arg1:b2ShapeDef){
m_localPosition = new b2Vec2();
super(_arg1);
var _local2:b2CircleDef = (_arg1 as b2CircleDef);
m_type = e_circleShape;
m_localPosition.SetV(_local2.localPosition);
m_radius = _local2.radius;
}
override public function TestSegment(_arg1:b2XForm, _arg2:Array, _arg3:b2Vec2, _arg4:b2Segment, _arg5:Number):int{
var _local10:Number;
var _local6:b2Mat22 = _arg1.R;
var _local7:Number = (_arg1.position.x + ((_local6.col1.x * m_localPosition.x) + (_local6.col2.x * m_localPosition.y)));
var _local8:Number = (_arg1.position.y + ((_local6.col1.y * m_localPosition.x) + (_local6.col2.y * m_localPosition.y)));
var _local9:Number = (_arg4.p1.x - _local7);
_local10 = (_arg4.p1.y - _local8);
var _local11:Number = (((_local9 * _local9) + (_local10 * _local10)) - (m_radius * m_radius));
if (_local11 < 0){
_arg2[0] = 0;
return (e_startsInsideCollide);
};
var _local12:Number = (_arg4.p2.x - _arg4.p1.x);
var _local13:Number = (_arg4.p2.y - _arg4.p1.y);
var _local14:Number = ((_local9 * _local12) + (_local10 * _local13));
var _local15:Number = ((_local12 * _local12) + (_local13 * _local13));
var _local16:Number = ((_local14 * _local14) - (_local15 * _local11));
if ((((_local16 < 0)) || ((_local15 < Number.MIN_VALUE)))){
return (e_missCollide);
};
var _local17:Number = -((_local14 + Math.sqrt(_local16)));
if ((((0 <= _local17)) && ((_local17 <= (_arg5 * _local15))))){
_local17 = (_local17 / _local15);
_arg2[0] = _local17;
_arg3.x = (_local9 + (_local17 * _local12));
_arg3.y = (_local10 + (_local17 * _local13));
_arg3.Normalize();
return (e_hitCollide);
};
return (e_missCollide);
}
public function GetLocalPosition():b2Vec2{
return (m_localPosition);
}
public function GetRadius():Number{
return (m_radius);
}
override public function ComputeSweptAABB(_arg1:b2AABB, _arg2:b2XForm, _arg3:b2XForm):void{
var _local4:b2Mat22;
_local4 = _arg2.R;
var _local5:Number = (_arg2.position.x + ((_local4.col1.x * m_localPosition.x) + (_local4.col2.x * m_localPosition.y)));
var _local6:Number = (_arg2.position.y + ((_local4.col1.y * m_localPosition.x) + (_local4.col2.y * m_localPosition.y)));
_local4 = _arg3.R;
var _local7:Number = (_arg3.position.x + ((_local4.col1.x * m_localPosition.x) + (_local4.col2.x * m_localPosition.y)));
var _local8:Number = (_arg3.position.y + ((_local4.col1.y * m_localPosition.x) + (_local4.col2.y * m_localPosition.y)));
_arg1.lowerBound.Set((((_local5 < _local7)) ? _local5 : _local7 - m_radius), (((_local6 < _local8)) ? _local6 : _local8 - m_radius));
_arg1.upperBound.Set((((_local5 > _local7)) ? _local5 : _local7 + m_radius), (((_local6 > _local8)) ? _local6 : _local8 + m_radius));
}
override public function ComputeMass(_arg1:b2MassData):void{
_arg1.mass = (((m_density * b2Settings.b2_pi) * m_radius) * m_radius);
_arg1.center.SetV(m_localPosition);
_arg1.I = (_arg1.mass * (((0.5 * m_radius) * m_radius) + ((m_localPosition.x * m_localPosition.x) + (m_localPosition.y * m_localPosition.y))));
}
override public function UpdateSweepRadius(_arg1:b2Vec2):void{
var _local2:Number = (m_localPosition.x - _arg1.x);
var _local3:Number = (m_localPosition.y - _arg1.y);
_local2 = Math.sqrt(((_local2 * _local2) + (_local3 * _local3)));
m_sweepRadius = ((_local2 + m_radius) - b2Settings.b2_toiSlop);
}
override public function ComputeAABB(_arg1:b2AABB, _arg2:b2XForm):void{
var _local3:b2Mat22 = _arg2.R;
var _local4:Number = (_arg2.position.x + ((_local3.col1.x * m_localPosition.x) + (_local3.col2.x * m_localPosition.y)));
var _local5:Number = (_arg2.position.y + ((_local3.col1.y * m_localPosition.x) + (_local3.col2.y * m_localPosition.y)));
_arg1.lowerBound.Set((_local4 - m_radius), (_local5 - m_radius));
_arg1.upperBound.Set((_local4 + m_radius), (_local5 + m_radius));
}
override public function TestPoint(_arg1:b2XForm, _arg2:b2Vec2):Boolean{
var _local3:b2Mat22 = _arg1.R;
var _local4:Number = (_arg1.position.x + ((_local3.col1.x * m_localPosition.x) + (_local3.col2.x * m_localPosition.y)));
var _local5:Number = (_arg1.position.y + ((_local3.col1.y * m_localPosition.x) + (_local3.col2.y * m_localPosition.y)));
_local4 = (_arg2.x - _local4);
_local5 = (_arg2.y - _local5);
return ((((_local4 * _local4) + (_local5 * _local5)) <= (m_radius * m_radius)));
}
}
}//package Box2D.Collision.Shapes
Section 3
//b2FilterData (Box2D.Collision.Shapes.b2FilterData)
package Box2D.Collision.Shapes {
public class b2FilterData {
public var maskBits:uint;// = 0xFFFF
public var groupIndex:int;// = 0
public var categoryBits:uint;// = 1
public function Copy():b2FilterData{
var _local1:b2FilterData = new b2FilterData();
_local1.categoryBits = categoryBits;
_local1.maskBits = maskBits;
_local1.groupIndex = groupIndex;
return (_local1);
}
}
}//package Box2D.Collision.Shapes
Section 4
//b2MassData (Box2D.Collision.Shapes.b2MassData)
package Box2D.Collision.Shapes {
import Box2D.Common.Math.*;
public class b2MassData {
public var mass:Number;// = 0
public var center:b2Vec2;
public var I:Number;// = 0
public function b2MassData(){
center = new b2Vec2(0, 0);
super();
}
}
}//package Box2D.Collision.Shapes
Section 5
//b2PolygonDef (Box2D.Collision.Shapes.b2PolygonDef)
package Box2D.Collision.Shapes {
import Box2D.Common.Math.*;
import Box2D.Common.*;
public class b2PolygonDef extends b2ShapeDef {
public var vertices:Array;
public var vertexCount:int;
private static var s_mat:b2Mat22 = new b2Mat22();
public function b2PolygonDef(){
vertices = new Array(b2Settings.b2_maxPolygonVertices);
super();
type = b2Shape.e_polygonShape;
vertexCount = 0;
var _local1:int;
while (_local1 < b2Settings.b2_maxPolygonVertices) {
vertices[_local1] = new b2Vec2();
_local1++;
};
}
public function SetAsOrientedBox(_arg1:Number, _arg2:Number, _arg3:b2Vec2=null, _arg4:Number=0):void{
var _local5:b2Vec2;
var _local6:b2Mat22;
var _local7:int;
vertexCount = 4;
vertices[0].Set(-(_arg1), -(_arg2));
vertices[1].Set(_arg1, -(_arg2));
vertices[2].Set(_arg1, _arg2);
vertices[3].Set(-(_arg1), _arg2);
if (_arg3){
_local5 = _arg3;
_local6 = s_mat;
_local6.Set(_arg4);
_local7 = 0;
while (_local7 < vertexCount) {
_arg3 = vertices[_local7];
_arg1 = (_local5.x + ((_local6.col1.x * _arg3.x) + (_local6.col2.x * _arg3.y)));
_arg3.y = (_local5.y + ((_local6.col1.y * _arg3.x) + (_local6.col2.y * _arg3.y)));
_arg3.x = _arg1;
_local7++;
};
};
}
public function SetAsBox(_arg1:Number, _arg2:Number):void{
vertexCount = 4;
vertices[0].Set(-(_arg1), -(_arg2));
vertices[1].Set(_arg1, -(_arg2));
vertices[2].Set(_arg1, _arg2);
vertices[3].Set(-(_arg1), _arg2);
}
}
}//package Box2D.Collision.Shapes
Section 6
//b2PolygonShape (Box2D.Collision.Shapes.b2PolygonShape)
package Box2D.Collision.Shapes {
import Box2D.Common.Math.*;
import Box2D.Collision.*;
import Box2D.Dynamics.*;
import Box2D.Common.*;
public class b2PolygonShape extends b2Shape {
public var m_coreVertices:Array;
public var m_vertices:Array;
private var s_supportVec:b2Vec2;
public var m_centroid:b2Vec2;
public var m_normals:Array;
public var m_obb:b2OBB;
public var m_vertexCount:int;
private static var s_computeMat:b2Mat22 = new b2Mat22();
private static var s_sweptAABB1:b2AABB = new b2AABB();
private static var s_sweptAABB2:b2AABB = new b2AABB();
public function b2PolygonShape(_arg1:b2ShapeDef){
var _local3:int;
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;
s_supportVec = new b2Vec2();
m_obb = new b2OBB();
m_vertices = new Array(b2Settings.b2_maxPolygonVertices);
m_normals = new Array(b2Settings.b2_maxPolygonVertices);
m_coreVertices = new Array(b2Settings.b2_maxPolygonVertices);
super(_arg1);
m_type = e_polygonShape;
var _local2:b2PolygonDef = (_arg1 as b2PolygonDef);
m_vertexCount = _local2.vertexCount;
var _local4:int = _local3;
var _local5:int = _local3;
_local3 = 0;
while (_local3 < m_vertexCount) {
m_vertices[_local3] = _local2.vertices[_local3].Copy();
_local3++;
};
_local3 = 0;
while (_local3 < m_vertexCount) {
_local4 = _local3;
_local5 = (((_local3 + 1) < m_vertexCount)) ? (_local3 + 1) : 0;
_local6 = (m_vertices[_local5].x - m_vertices[_local4].x);
_local7 = (m_vertices[_local5].y - m_vertices[_local4].y);
_local8 = Math.sqrt(((_local6 * _local6) + (_local7 * _local7)));
m_normals[_local3] = new b2Vec2((_local7 / _local8), (-(_local6) / _local8));
_local3++;
};
m_centroid = ComputeCentroid(_local2.vertices, _local2.vertexCount);
ComputeOBB(m_obb, m_vertices, m_vertexCount);
_local3 = 0;
while (_local3 < m_vertexCount) {
_local4 = (((_local3 - 1) >= 0)) ? (_local3 - 1) : (m_vertexCount - 1);
_local5 = _local3;
_local9 = m_normals[_local4].x;
_local10 = m_normals[_local4].y;
_local11 = m_normals[_local5].x;
_local12 = m_normals[_local5].y;
_local13 = (m_vertices[_local3].x - m_centroid.x);
_local14 = (m_vertices[_local3].y - m_centroid.y);
_local15 = (((_local9 * _local13) + (_local10 * _local14)) - b2Settings.b2_toiSlop);
_local16 = (((_local11 * _local13) + (_local12 * _local14)) - b2Settings.b2_toiSlop);
_local17 = (1 / ((_local9 * _local12) - (_local10 * _local11)));
m_coreVertices[_local3] = new b2Vec2(((_local17 * ((_local12 * _local15) - (_local10 * _local16))) + m_centroid.x), ((_local17 * ((_local9 * _local16) - (_local11 * _local15))) + m_centroid.y));
_local3++;
};
}
override public function ComputeSweptAABB(_arg1:b2AABB, _arg2:b2XForm, _arg3:b2XForm):void{
var _local4:b2AABB = s_sweptAABB1;
var _local5:b2AABB = s_sweptAABB2;
ComputeAABB(_local4, _arg2);
ComputeAABB(_local5, _arg3);
_arg1.lowerBound.Set(((_local4.lowerBound.x < _local5.lowerBound.x)) ? _local4.lowerBound.x : _local5.lowerBound.x, ((_local4.lowerBound.y < _local5.lowerBound.y)) ? _local4.lowerBound.y : _local5.lowerBound.y);
_arg1.upperBound.Set(((_local4.upperBound.x > _local5.upperBound.x)) ? _local4.upperBound.x : _local5.upperBound.x, ((_local4.upperBound.y > _local5.upperBound.y)) ? _local4.upperBound.y : _local5.upperBound.y);
}
public function GetVertices():Array{
return (m_vertices);
}
public function GetCoreVertices():Array{
return (m_coreVertices);
}
public function GetCentroid():b2Vec2{
return (m_centroid);
}
public function GetOBB():b2OBB{
return (m_obb);
}
public function GetFirstVertex(_arg1:b2XForm):b2Vec2{
return (b2Math.b2MulX(_arg1, m_coreVertices[0]));
}
public function Centroid(_arg1:b2XForm):b2Vec2{
return (b2Math.b2MulX(_arg1, m_centroid));
}
override public function TestSegment(_arg1:b2XForm, _arg2:Array, _arg3:b2Vec2, _arg4:b2Segment, _arg5:Number):int{
var _local8:Number;
var _local9:Number;
var _local10:b2Mat22;
var _local11:b2Vec2;
var _local20:Number;
var _local21:Number;
var _local6:Number = 0;
var _local7:Number = _arg5;
_local8 = (_arg4.p1.x - _arg1.position.x);
_local9 = (_arg4.p1.y - _arg1.position.y);
_local10 = _arg1.R;
var _local12:Number = ((_local8 * _local10.col1.x) + (_local9 * _local10.col1.y));
var _local13:Number = ((_local8 * _local10.col2.x) + (_local9 * _local10.col2.y));
_local8 = (_arg4.p2.x - _arg1.position.x);
_local9 = (_arg4.p2.y - _arg1.position.y);
_local10 = _arg1.R;
var _local14:Number = ((_local8 * _local10.col1.x) + (_local9 * _local10.col1.y));
var _local15:Number = ((_local8 * _local10.col2.x) + (_local9 * _local10.col2.y));
var _local16:Number = (_local14 - _local12);
var _local17:Number = (_local15 - _local13);
var _local18 = -1;
var _local19:int;
while (_local19 < m_vertexCount) {
_local11 = m_vertices[_local19];
_local8 = (_local11.x - _local12);
_local9 = (_local11.y - _local13);
_local11 = m_normals[_local19];
_local20 = ((_local11.x * _local8) + (_local11.y * _local9));
_local21 = ((_local11.x * _local16) + (_local11.y * _local17));
if ((((_local21 < 0)) && ((_local20 < (_local6 * _local21))))){
_local6 = (_local20 / _local21);
_local18 = _local19;
} else {
if ((((_local21 > 0)) && ((_local20 < (_local7 * _local21))))){
_local7 = (_local20 / _local21);
};
};
if (_local7 < _local6){
return (e_missCollide);
};
_local19++;
};
if (_local18 >= 0){
_arg2[0] = _local6;
_local10 = _arg1.R;
_local11 = m_normals[_local18];
_arg3.x = ((_local10.col1.x * _local11.x) + (_local10.col2.x * _local11.y));
_arg3.y = ((_local10.col1.y * _local11.x) + (_local10.col2.y * _local11.y));
return (e_hitCollide);
};
_arg2[0] = 0;
return (e_startsInsideCollide);
}
override public function ComputeMass(_arg1:b2MassData):void{
var _local10:b2Vec2;
var _local11:b2Vec2;
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 _local2:Number = 0;
var _local3:Number = 0;
var _local4:Number = 0;
var _local5:Number = 0;
var _local6:Number = 0;
var _local7:Number = 0;
var _local8:Number = (1 / 3);
var _local9:int;
while (_local9 < m_vertexCount) {
_local10 = m_vertices[_local9];
_local11 = (((_local9 + 1) < m_vertexCount)) ? m_vertices[int((_local9 + 1))] : m_vertices[0];
_local12 = (_local10.x - _local6);
_local13 = (_local10.y - _local7);
_local14 = (_local11.x - _local6);
_local15 = (_local11.y - _local7);
_local16 = ((_local12 * _local15) - (_local13 * _local14));
_local17 = (0.5 * _local16);
_local4 = (_local4 + _local17);
_local2 = (_local2 + ((_local17 * _local8) * ((_local6 + _local10.x) + _local11.x)));
_local3 = (_local3 + ((_local17 * _local8) * ((_local7 + _local10.y) + _local11.y)));
_local18 = _local6;
_local19 = _local7;
_local20 = _local12;
_local21 = _local13;
_local22 = _local14;
_local23 = _local15;
_local24 = ((_local8 * ((0.25 * (((_local20 * _local20) + (_local22 * _local20)) + (_local22 * _local22))) + ((_local18 * _local20) + (_local18 * _local22)))) + ((0.5 * _local18) * _local18));
_local25 = ((_local8 * ((0.25 * (((_local21 * _local21) + (_local23 * _local21)) + (_local23 * _local23))) + ((_local19 * _local21) + (_local19 * _local23)))) + ((0.5 * _local19) * _local19));
_local5 = (_local5 + (_local16 * (_local24 + _local25)));
_local9++;
};
_arg1.mass = (m_density * _local4);
_local2 = (_local2 * (1 / _local4));
_local3 = (_local3 * (1 / _local4));
_arg1.center.Set(_local2, _local3);
_arg1.I = (m_density * _local5);
}
public function GetNormals():Array{
return (m_normals);
}
public function Support(_arg1:b2XForm, _arg2:Number, _arg3:Number):b2Vec2{
var _local4:b2Vec2;
var _local5:b2Mat22;
var _local11:Number;
_local5 = _arg1.R;
var _local6:Number = ((_arg2 * _local5.col1.x) + (_arg3 * _local5.col1.y));
var _local7:Number = ((_arg2 * _local5.col2.x) + (_arg3 * _local5.col2.y));
var _local8:int;
_local4 = m_coreVertices[0];
var _local9:Number = ((_local4.x * _local6) + (_local4.y * _local7));
var _local10 = 1;
while (_local10 < m_vertexCount) {
_local4 = m_coreVertices[_local10];
_local11 = ((_local4.x * _local6) + (_local4.y * _local7));
if (_local11 > _local9){
_local8 = _local10;
_local9 = _local11;
};
_local10++;
};
_local5 = _arg1.R;
_local4 = m_coreVertices[_local8];
s_supportVec.x = (_arg1.position.x + ((_local5.col1.x * _local4.x) + (_local5.col2.x * _local4.y)));
s_supportVec.y = (_arg1.position.y + ((_local5.col1.y * _local4.x) + (_local5.col2.y * _local4.y)));
return (s_supportVec);
}
public function GetVertexCount():int{
return (m_vertexCount);
}
override public function ComputeAABB(_arg1:b2AABB, _arg2:b2XForm):void{
var _local3:b2Mat22;
var _local4:b2Vec2;
var _local5:b2Mat22 = s_computeMat;
_local3 = _arg2.R;
_local4 = m_obb.R.col1;
_local5.col1.x = ((_local3.col1.x * _local4.x) + (_local3.col2.x * _local4.y));
_local5.col1.y = ((_local3.col1.y * _local4.x) + (_local3.col2.y * _local4.y));
_local4 = m_obb.R.col2;
_local5.col2.x = ((_local3.col1.x * _local4.x) + (_local3.col2.x * _local4.y));
_local5.col2.y = ((_local3.col1.y * _local4.x) + (_local3.col2.y * _local4.y));
_local5.Abs();
var _local6:b2Mat22 = _local5;
_local4 = m_obb.extents;
var _local7:Number = ((_local6.col1.x * _local4.x) + (_local6.col2.x * _local4.y));
var _local8:Number = ((_local6.col1.y * _local4.x) + (_local6.col2.y * _local4.y));
_local3 = _arg2.R;
_local4 = m_obb.center;
var _local9:Number = (_arg2.position.x + ((_local3.col1.x * _local4.x) + (_local3.col2.x * _local4.y)));
var _local10:Number = (_arg2.position.y + ((_local3.col1.y * _local4.x) + (_local3.col2.y * _local4.y)));
_arg1.lowerBound.Set((_local9 - _local7), (_local10 - _local8));
_arg1.upperBound.Set((_local9 + _local7), (_local10 + _local8));
}
override public function UpdateSweepRadius(_arg1:b2Vec2):void{
var _local2:b2Vec2;
var _local4:Number;
var _local5:Number;
m_sweepRadius = 0;
var _local3:int;
while (_local3 < m_vertexCount) {
_local2 = m_coreVertices[_local3];
_local4 = (_local2.x - _arg1.x);
_local5 = (_local2.y - _arg1.y);
_local4 = Math.sqrt(((_local4 * _local4) + (_local5 * _local5)));
if (_local4 > m_sweepRadius){
m_sweepRadius = _local4;
};
_local3++;
};
}
override public function TestPoint(_arg1:b2XForm, _arg2:b2Vec2):Boolean{
var _local3:b2Vec2;
var _local10:Number;
var _local4:b2Mat22 = _arg1.R;
var _local5:Number = (_arg2.x - _arg1.position.x);
var _local6:Number = (_arg2.y - _arg1.position.y);
var _local7:Number = ((_local5 * _local4.col1.x) + (_local6 * _local4.col1.y));
var _local8:Number = ((_local5 * _local4.col2.x) + (_local6 * _local4.col2.y));
var _local9:int;
while (_local9 < m_vertexCount) {
_local3 = m_vertices[_local9];
_local5 = (_local7 - _local3.x);
_local6 = (_local8 - _local3.y);
_local3 = m_normals[_local9];
_local10 = ((_local3.x * _local5) + (_local3.y * _local6));
if (_local10 > 0){
return (false);
};
_local9++;
};
return (true);
}
public static function ComputeCentroid(_arg1:Array, _arg2:int):b2Vec2{
var _local3:b2Vec2;
var _local7:Number;
var _local9:b2Vec2;
var _local10:b2Vec2;
var _local11:Number;
var _local12:Number;
var _local13:Number;
var _local14:Number;
var _local15:Number;
var _local16:Number;
_local3 = new b2Vec2();
var _local4:Number = 0;
var _local5:Number = 0;
var _local6:Number = 0;
_local7 = (1 / 3);
var _local8:int;
while (_local8 < _arg2) {
_local9 = _arg1[_local8];
_local10 = (((_local8 + 1) < _arg2)) ? _arg1[int((_local8 + 1))] : _arg1[0];
_local11 = (_local9.x - _local5);
_local12 = (_local9.y - _local6);
_local13 = (_local10.x - _local5);
_local14 = (_local10.y - _local6);
_local15 = ((_local11 * _local14) - (_local12 * _local13));
_local16 = (0.5 * _local15);
_local4 = (_local4 + _local16);
_local3.x = (_local3.x + ((_local16 * _local7) * ((_local5 + _local9.x) + _local10.x)));
_local3.y = (_local3.y + ((_local16 * _local7) * ((_local6 + _local9.y) + _local10.y)));
_local8++;
};
_local3.x = (_local3.x * (1 / _local4));
_local3.y = (_local3.y * (1 / _local4));
return (_local3);
}
public static function ComputeOBB(_arg1:b2OBB, _arg2:Array, _arg3:int):void{
var _local4:int;
var _local7:b2Vec2;
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:int;
var _local18:Number;
var _local19:Number;
var _local20:Number;
var _local21:Number;
var _local22:Number;
var _local23:Number;
var _local24:Number;
var _local25:b2Mat22;
var _local5:Array = new Array((b2Settings.b2_maxPolygonVertices + 1));
_local4 = 0;
while (_local4 < _arg3) {
_local5[_local4] = _arg2[_local4];
_local4++;
};
_local5[_arg3] = _local5[0];
var _local6:Number = Number.MAX_VALUE;
_local4 = 1;
while (_local4 <= _arg3) {
_local7 = _local5[int((_local4 - 1))];
_local8 = (_local5[_local4].x - _local7.x);
_local9 = (_local5[_local4].y - _local7.y);
_local10 = Math.sqrt(((_local8 * _local8) + (_local9 * _local9)));
_local8 = (_local8 / _local10);
_local9 = (_local9 / _local10);
_local11 = -(_local9);
_local12 = _local8;
_local13 = Number.MAX_VALUE;
_local14 = Number.MAX_VALUE;
_local15 = -(Number.MAX_VALUE);
_local16 = -(Number.MAX_VALUE);
_local17 = 0;
while (_local17 < _arg3) {
_local19 = (_local5[_local17].x - _local7.x);
_local20 = (_local5[_local17].y - _local7.y);
_local21 = ((_local8 * _local19) + (_local9 * _local20));
_local22 = ((_local11 * _local19) + (_local12 * _local20));
if (_local21 < _local13){
_local13 = _local21;
};
if (_local22 < _local14){
_local14 = _local22;
};
if (_local21 > _local15){
_local15 = _local21;
};
if (_local22 > _local16){
_local16 = _local22;
};
_local17++;
};
_local18 = ((_local15 - _local13) * (_local16 - _local14));
if (_local18 < (0.95 * _local6)){
_local6 = _local18;
_arg1.R.col1.x = _local8;
_arg1.R.col1.y = _local9;
_arg1.R.col2.x = _local11;
_arg1.R.col2.y = _local12;
_local23 = (0.5 * (_local13 + _local15));
_local24 = (0.5 * (_local14 + _local16));
_local25 = _arg1.R;
_arg1.center.x = (_local7.x + ((_local25.col1.x * _local23) + (_local25.col2.x * _local24)));
_arg1.center.y = (_local7.y + ((_local25.col1.y * _local23) + (_local25.col2.y * _local24)));
_arg1.extents.x = (0.5 * (_local15 - _local13));
_arg1.extents.y = (0.5 * (_local16 - _local14));
};
_local4++;
};
}
}
}//package Box2D.Collision.Shapes
Section 7
//b2Shape (Box2D.Collision.Shapes.b2Shape)
package Box2D.Collision.Shapes {
import Box2D.Common.Math.*;
import Box2D.Collision.*;
import Box2D.Dynamics.*;
public class b2Shape {
public var m_next:b2Shape;
public var m_type:int;
public var m_sweepRadius:Number;
public var m_density:Number;
public var m_filter:b2FilterData;
public var m_friction:Number;
public var m_isSensor:Boolean;
public var m_restitution:Number;
public var m_userData;
public var m_proxyId:uint;
public var m_body:b2Body;
public static const e_polygonShape:int = 1;
public static const e_hitCollide:int = 1;
public static const e_missCollide:int = 0;
public static const e_unknownShape:int = -1;
public static const e_circleShape:int = 0;
public static const e_shapeTypeCount:int = 2;
public static const e_startsInsideCollide:int = -1;
private static var s_resetAABB:b2AABB = new b2AABB();
private static var s_syncAABB:b2AABB = new b2AABB();
private static var s_proxyAABB:b2AABB = new b2AABB();
public function b2Shape(_arg1:b2ShapeDef){
m_userData = _arg1.userData;
m_friction = _arg1.friction;
m_restitution = _arg1.restitution;
m_density = _arg1.density;
m_body = null;
m_sweepRadius = 0;
m_next = null;
m_proxyId = b2Pair.b2_nullProxy;
m_filter = _arg1.filter.Copy();
m_isSensor = _arg1.isSensor;
}
public function SetUserData(_arg1):void{
m_userData = _arg1;
}
public function GetSweepRadius():Number{
return (m_sweepRadius);
}
public function GetNext():b2Shape{
return (m_next);
}
public function ComputeSweptAABB(_arg1:b2AABB, _arg2:b2XForm, _arg3:b2XForm):void{
}
public function GetType():int{
return (m_type);
}
public function GetRestitution():Number{
return (m_restitution);
}
public function GetFriction():Number{
return (m_friction);
}
public function GetFilterData():b2FilterData{
return (m_filter.Copy());
}
public function TestSegment(_arg1:b2XForm, _arg2:Array, _arg3:b2Vec2, _arg4:b2Segment, _arg5:Number):int{
return (e_missCollide);
}
public function RefilterProxy(_arg1:b2BroadPhase, _arg2:b2XForm):void{
if (m_proxyId == b2Pair.b2_nullProxy){
return;
};
_arg1.DestroyProxy(m_proxyId);
var _local3:b2AABB = s_resetAABB;
ComputeAABB(_local3, _arg2);
var _local4:Boolean = _arg1.InRange(_local3);
if (_local4){
m_proxyId = _arg1.CreateProxy(_local3, this);
} else {
m_proxyId = b2Pair.b2_nullProxy;
};
}
public function SetFilterData(_arg1:b2FilterData):void{
m_filter = _arg1.Copy();
}
public function GetUserData(){
return (m_userData);
}
public function Synchronize(_arg1:b2BroadPhase, _arg2:b2XForm, _arg3:b2XForm):Boolean{
if (m_proxyId == b2Pair.b2_nullProxy){
return (false);
};
var _local4:b2AABB = s_syncAABB;
ComputeSweptAABB(_local4, _arg2, _arg3);
if (_arg1.InRange(_local4)){
_arg1.MoveProxy(m_proxyId, _local4);
return (true);
};
return (false);
}
public function ComputeMass(_arg1:b2MassData):void{
}
public function IsSensor():Boolean{
return (m_isSensor);
}
public function DestroyProxy(_arg1:b2BroadPhase):void{
if (m_proxyId != b2Pair.b2_nullProxy){
_arg1.DestroyProxy(m_proxyId);
m_proxyId = b2Pair.b2_nullProxy;
};
}
public function UpdateSweepRadius(_arg1:b2Vec2):void{
}
public function ComputeAABB(_arg1:b2AABB, _arg2:b2XForm):void{
}
public function GetBody():b2Body{
return (m_body);
}
public function CreateProxy(_arg1:b2BroadPhase, _arg2:b2XForm):void{
var _local3:b2AABB = s_proxyAABB;
ComputeAABB(_local3, _arg2);
var _local4:Boolean = _arg1.InRange(_local3);
if (_local4){
m_proxyId = _arg1.CreateProxy(_local3, this);
} else {
m_proxyId = b2Pair.b2_nullProxy;
};
}
public function TestPoint(_arg1:b2XForm, _arg2:b2Vec2):Boolean{
return (false);
}
public static function Destroy(_arg1:b2Shape, _arg2):void{
}
public static function Create(_arg1:b2ShapeDef, _arg2):b2Shape{
switch (_arg1.type){
case e_circleShape:
return (new b2CircleShape(_arg1));
case e_polygonShape:
return (new b2PolygonShape(_arg1));
default:
return (null);
};
}
}
}//package Box2D.Collision.Shapes
Section 8
//b2ShapeDef (Box2D.Collision.Shapes.b2ShapeDef)
package Box2D.Collision.Shapes {
public class b2ShapeDef {
public var friction:Number;// = 0.2
public var isSensor:Boolean;// = false
public var density:Number;// = 0
public var restitution:Number;// = 0
public var userData;// = null
public var filter:b2FilterData;
public var type:int;// = -1
public function b2ShapeDef(){
filter = new b2FilterData();
super();
}
}
}//package Box2D.Collision.Shapes
Section 9
//b2AABB (Box2D.Collision.b2AABB)
package Box2D.Collision {
import Box2D.Common.Math.*;
public class b2AABB {
public var upperBound:b2Vec2;
public var lowerBound:b2Vec2;
public function b2AABB(){
lowerBound = new b2Vec2();
upperBound = new b2Vec2();
super();
}
public function IsValid():Boolean{
var _local1:Number = (upperBound.x - lowerBound.x);
var _local2:Number = (upperBound.y - lowerBound.y);
var _local3:Boolean = (((_local1 >= 0)) && ((_local2 >= 0)));
_local3 = ((((_local3) && (lowerBound.IsValid()))) && (upperBound.IsValid()));
return (_local3);
}
}
}//package Box2D.Collision
Section 10
//b2Bound (Box2D.Collision.b2Bound)
package Box2D.Collision {
public class b2Bound {
public var value:uint;
public var proxyId:uint;
public var stabbingCount:uint;
public function Swap(_arg1:b2Bound):void{
var _local2:uint = value;
var _local3:uint = proxyId;
var _local4:uint = stabbingCount;
value = _arg1.value;
proxyId = _arg1.proxyId;
stabbingCount = _arg1.stabbingCount;
_arg1.value = _local2;
_arg1.proxyId = _local3;
_arg1.stabbingCount = _local4;
}
public function IsLower():Boolean{
return (((value & 1) == 0));
}
public function IsUpper():Boolean{
return (((value & 1) == 1));
}
}
}//package Box2D.Collision
Section 11
//b2BoundValues (Box2D.Collision.b2BoundValues)
package Box2D.Collision {
public class b2BoundValues {
public var lowerValues:Array;
public var upperValues:Array;
public function b2BoundValues(){
lowerValues = [0, 0];
upperValues = [0, 0];
super();
}
}
}//package Box2D.Collision
Section 12
//b2BroadPhase (Box2D.Collision.b2BroadPhase)
package Box2D.Collision {
import Box2D.Common.Math.*;
import Box2D.Common.*;
public class b2BroadPhase {
public var m_bounds:Array;
public var m_worldAABB:b2AABB;
public var m_querySortKeys:Array;
public var m_freeProxy:uint;
public var m_quantizationFactor:b2Vec2;
public var m_proxyCount:int;
public var m_proxyPool:Array;
public var m_queryResultCount:int;
public var m_pairManager:b2PairManager;
public var m_timeStamp:uint;
public var m_queryResults:Array;
public static const b2_nullEdge:uint = b2Settings.USHRT_MAX;
public static const b2_invalid:uint = b2Settings.USHRT_MAX;
public static var s_validate:Boolean = false;
public function b2BroadPhase(_arg1:b2AABB, _arg2:b2PairCallback){
var _local3:int;
var _local6:b2Proxy;
var _local7:int;
m_pairManager = new b2PairManager();
m_proxyPool = new Array(b2Settings.b2_maxPairs);
m_bounds = new Array((2 * b2Settings.b2_maxProxies));
m_querySortKeys = new Array(b2Settings.b2_maxProxies);
m_queryResults = new Array(b2Settings.b2_maxProxies);
m_quantizationFactor = new b2Vec2();
super();
m_pairManager.Initialize(this, _arg2);
m_worldAABB = _arg1;
m_proxyCount = 0;
_local3 = 0;
while (_local3 < b2Settings.b2_maxProxies) {
m_queryResults[_local3] = 0;
m_querySortKeys[_local3] = 0;
_local3++;
};
m_bounds = new Array(2);
_local3 = 0;
while (_local3 < 2) {
m_bounds[_local3] = new Array((2 * b2Settings.b2_maxProxies));
_local7 = 0;
while (_local7 < (2 * b2Settings.b2_maxProxies)) {
m_bounds[_local3][_local7] = new b2Bound();
_local7++;
};
_local3++;
};
var _local4:Number = (_arg1.upperBound.x - _arg1.lowerBound.x);
var _local5:Number = (_arg1.upperBound.y - _arg1.lowerBound.y);
m_quantizationFactor.x = (b2Settings.USHRT_MAX / _local4);
m_quantizationFactor.y = (b2Settings.USHRT_MAX / _local5);
_local3 = 0;
while (_local3 < (b2Settings.b2_maxProxies - 1)) {
_local6 = new b2Proxy();
m_proxyPool[_local3] = _local6;
_local6.SetNext((_local3 + 1));
_local6.timeStamp = 0;
_local6.overlapCount = b2_invalid;
_local6.userData = null;
_local3++;
};
_local6 = new b2Proxy();
m_proxyPool[int((b2Settings.b2_maxProxies - 1))] = _local6;
_local6.SetNext(b2Pair.b2_nullProxy);
_local6.timeStamp = 0;
_local6.overlapCount = b2_invalid;
_local6.userData = null;
m_freeProxy = 0;
m_timeStamp = 1;
m_queryResultCount = 0;
}
public function QueryAABB(_arg1:b2AABB, _arg2, _arg3:int):int{
var _local6:uint;
var _local7:uint;
var _local12:b2Proxy;
var _local4:Array = new Array();
var _local5:Array = new Array();
ComputeBounds(_local4, _local5, _arg1);
var _local8:Array = [_local6];
var _local9:Array = [_local7];
Query(_local8, _local9, _local4[0], _local5[0], m_bounds[0], (2 * m_proxyCount), 0);
Query(_local8, _local9, _local4[1], _local5[1], m_bounds[1], (2 * m_proxyCount), 1);
var _local10:int;
var _local11:int;
while ((((_local11 < m_queryResultCount)) && ((_local10 < _arg3)))) {
_local12 = m_proxyPool[m_queryResults[_local11]];
_arg2[_local11] = _local12.userData;
_local11++;
_local10++;
};
m_queryResultCount = 0;
IncrementTimeStamp();
return (_local10);
}
public function Commit():void{
m_pairManager.Commit();
}
public function GetProxy(_arg1:int):b2Proxy{
var _local2:b2Proxy = m_proxyPool[_arg1];
if ((((_arg1 == b2Pair.b2_nullProxy)) || ((_local2.IsValid() == false)))){
return (null);
};
return (_local2);
}
private function IncrementTimeStamp():void{
var _local1:uint;
if (m_timeStamp == b2Settings.USHRT_MAX){
_local1 = 0;
while (_local1 < b2Settings.b2_maxProxies) {
(m_proxyPool[_local1] as b2Proxy).timeStamp = 0;
_local1++;
};
m_timeStamp = 1;
} else {
m_timeStamp++;
};
}
private function Query(_arg1:Array, _arg2:Array, _arg3:uint, _arg4:uint, _arg5:Array, _arg6:uint, _arg7:int):void{
var _local10:b2Bound;
var _local12:int;
var _local13:int;
var _local14:b2Proxy;
var _local8:uint = BinarySearch(_arg5, _arg6, _arg3);
var _local9:uint = BinarySearch(_arg5, _arg6, _arg4);
var _local11:uint = _local8;
while (_local11 < _local9) {
_local10 = _arg5[_local11];
if (_local10.IsLower()){
IncrementOverlapCount(_local10.proxyId);
};
_local11++;
};
if (_local8 > 0){
_local12 = (_local8 - 1);
_local10 = _arg5[_local12];
_local13 = _local10.stabbingCount;
while (_local13) {
_local10 = _arg5[_local12];
if (_local10.IsLower()){
_local14 = m_proxyPool[_local10.proxyId];
if (_local8 <= _local14.upperBounds[_arg7]){
IncrementOverlapCount(_local10.proxyId);
_local13--;
};
};
_local12--;
};
};
_arg1[0] = _local8;
_arg2[0] = _local9;
}
private function AddProxyResult(_arg1:uint, _arg2:b2Proxy, _arg3:Number, _arg4:Function):void{
var _local9:Number;
var _local10:uint;
var _local5:Number = _arg4(_arg2.userData);
if (_local5 < 0){
return;
};
var _local6:Number = 0;
while ((((_local6 < m_queryResultCount)) && ((m_querySortKeys[_local6] < _local5)))) {
_local6++;
};
var _local7:Number = _local5;
var _local8:uint = _arg1;
m_queryResultCount = (m_queryResultCount + 1);
if (m_queryResultCount > _arg3){
m_queryResultCount = _arg3;
};
while (_local6 < m_queryResultCount) {
_local9 = m_querySortKeys[_local6];
_local10 = m_queryResults[_local6];
m_querySortKeys[_local6] = _local7;
m_queryResults[_local6] = _local8;
_local7 = _local9;
_local8 = _local10;
_local6++;
};
}
private function TestOverlapValidate(_arg1:b2Proxy, _arg2:b2Proxy):Boolean{
var _local4:Array;
var _local5:b2Bound;
var _local6:b2Bound;
var _local3:int;
while (_local3 < 2) {
_local4 = m_bounds[_local3];
_local5 = _local4[_arg1.lowerBounds[_local3]];
_local6 = _local4[_arg2.upperBounds[_local3]];
if (_local5.value > _local6.value){
return (false);
};
_local5 = _local4[_arg1.upperBounds[_local3]];
_local6 = _local4[_arg2.lowerBounds[_local3]];
if (_local5.value < _local6.value){
return (false);
};
_local3++;
};
return (true);
}
private function ComputeBounds(_arg1:Array, _arg2:Array, _arg3:b2AABB):void{
var _local4:Number = _arg3.lowerBound.x;
var _local5:Number = _arg3.lowerBound.y;
_local4 = b2Math.b2Min(_local4, m_worldAABB.upperBound.x);
_local5 = b2Math.b2Min(_local5, m_worldAABB.upperBound.y);
_local4 = b2Math.b2Max(_local4, m_worldAABB.lowerBound.x);
_local5 = b2Math.b2Max(_local5, m_worldAABB.lowerBound.y);
var _local6:Number = _arg3.upperBound.x;
var _local7:Number = _arg3.upperBound.y;
_local6 = b2Math.b2Min(_local6, m_worldAABB.upperBound.x);
_local7 = b2Math.b2Min(_local7, m_worldAABB.upperBound.y);
_local6 = b2Math.b2Max(_local6, m_worldAABB.lowerBound.x);
_local7 = b2Math.b2Max(_local7, m_worldAABB.lowerBound.y);
_arg1[0] = (uint((m_quantizationFactor.x * (_local4 - m_worldAABB.lowerBound.x))) & (b2Settings.USHRT_MAX - 1));
_arg2[0] = ((uint((m_quantizationFactor.x * (_local6 - m_worldAABB.lowerBound.x))) & 0xFFFF) | 1);
_arg1[1] = (uint((m_quantizationFactor.y * (_local5 - m_worldAABB.lowerBound.y))) & (b2Settings.USHRT_MAX - 1));
_arg2[1] = ((uint((m_quantizationFactor.y * (_local7 - m_worldAABB.lowerBound.y))) & 0xFFFF) | 1);
}
public function CreateProxy(_arg1:b2AABB, _arg2):uint{
var _local3:uint;
var _local4:b2Proxy;
var _local11:Array;
var _local12:uint;
var _local13:uint;
var _local14:Array;
var _local15:Array;
var _local16:Array;
var _local17:int;
var _local18:int;
var _local19:b2Bound;
var _local20:b2Bound;
var _local21:b2Bound;
var _local22:int;
var _local23:b2Proxy;
var _local5:uint = m_freeProxy;
_local4 = m_proxyPool[_local5];
m_freeProxy = _local4.GetNext();
_local4.overlapCount = 0;
_local4.userData = _arg2;
var _local6:uint = (2 * m_proxyCount);
var _local7:Array = new Array();
var _local8:Array = new Array();
ComputeBounds(_local7, _local8, _arg1);
var _local9:int;
while (_local9 < 2) {
_local11 = m_bounds[_local9];
_local14 = [_local12];
_local15 = [_local13];
Query(_local14, _local15, _local7[_local9], _local8[_local9], _local11, _local6, _local9);
_local12 = _local14[0];
_local13 = _local15[0];
_local16 = new Array();
_local18 = (_local6 - _local13);
_local17 = 0;
while (_local17 < _local18) {
_local16[_local17] = new b2Bound();
_local19 = _local16[_local17];
_local20 = _local11[int((_local13 + _local17))];
_local19.value = _local20.value;
_local19.proxyId = _local20.proxyId;
_local19.stabbingCount = _local20.stabbingCount;
_local17++;
};
_local18 = _local16.length;
_local22 = (_local13 + 2);
_local17 = 0;
while (_local17 < _local18) {
_local20 = _local16[_local17];
_local19 = _local11[int((_local22 + _local17))];
_local19.value = _local20.value;
_local19.proxyId = _local20.proxyId;
_local19.stabbingCount = _local20.stabbingCount;
_local17++;
};
_local16 = new Array();
_local18 = (_local13 - _local12);
_local17 = 0;
while (_local17 < _local18) {
_local16[_local17] = new b2Bound();
_local19 = _local16[_local17];
_local20 = _local11[int((_local12 + _local17))];
_local19.value = _local20.value;
_local19.proxyId = _local20.proxyId;
_local19.stabbingCount = _local20.stabbingCount;
_local17++;
};
_local18 = _local16.length;
_local22 = (_local12 + 1);
_local17 = 0;
while (_local17 < _local18) {
_local20 = _local16[_local17];
_local19 = _local11[int((_local22 + _local17))];
_local19.value = _local20.value;
_local19.proxyId = _local20.proxyId;
_local19.stabbingCount = _local20.stabbingCount;
_local17++;
};
_local13++;
_local19 = _local11[_local12];
_local20 = _local11[_local13];
_local19.value = _local7[_local9];
_local19.proxyId = _local5;
_local20.value = _local8[_local9];
_local20.proxyId = _local5;
_local21 = _local11[int((_local12 - 1))];
_local19.stabbingCount = ((_local12 == 0)) ? 0 : _local21.stabbingCount;
_local21 = _local11[int((_local13 - 1))];
_local20.stabbingCount = _local21.stabbingCount;
_local3 = _local12;
while (_local3 < _local13) {
_local21 = _local11[_local3];
_local21.stabbingCount++;
_local3++;
};
_local3 = _local12;
while (_local3 < (_local6 + 2)) {
_local19 = _local11[_local3];
_local23 = m_proxyPool[_local19.proxyId];
if (_local19.IsLower()){
_local23.lowerBounds[_local9] = _local3;
} else {
_local23.upperBounds[_local9] = _local3;
};
_local3++;
};
_local9++;
};
m_proxyCount++;
var _local10:int;
while (_local10 < m_queryResultCount) {
m_pairManager.AddBufferedPair(_local5, m_queryResults[_local10]);
_local10++;
};
m_pairManager.Commit();
m_queryResultCount = 0;
IncrementTimeStamp();
return (_local5);
}
public function DestroyProxy(_arg1:uint):void{
var _local2:b2Bound;
var _local3:b2Bound;
var _local8:Array;
var _local9:uint;
var _local10:uint;
var _local11:uint;
var _local12:uint;
var _local13:Array;
var _local14:int;
var _local15:int;
var _local16:int;
var _local17:uint;
var _local18:int;
var _local19:b2Proxy;
var _local4:b2Proxy = m_proxyPool[_arg1];
var _local5:int = (2 * m_proxyCount);
var _local6:int;
while (_local6 < 2) {
_local8 = m_bounds[_local6];
_local9 = _local4.lowerBounds[_local6];
_local10 = _local4.upperBounds[_local6];
_local2 = _local8[_local9];
_local11 = _local2.value;
_local3 = _local8[_local10];
_local12 = _local3.value;
_local13 = new Array();
_local15 = ((_local10 - _local9) - 1);
_local14 = 0;
while (_local14 < _local15) {
_local13[_local14] = new b2Bound();
_local2 = _local13[_local14];
_local3 = _local8[int(((_local9 + 1) + _local14))];
_local2.value = _local3.value;
_local2.proxyId = _local3.proxyId;
_local2.stabbingCount = _local3.stabbingCount;
_local14++;
};
_local15 = _local13.length;
_local16 = _local9;
_local14 = 0;
while (_local14 < _local15) {
_local3 = _local13[_local14];
_local2 = _local8[int((_local16 + _local14))];
_local2.value = _local3.value;
_local2.proxyId = _local3.proxyId;
_local2.stabbingCount = _local3.stabbingCount;
_local14++;
};
_local13 = new Array();
_local15 = ((_local5 - _local10) - 1);
_local14 = 0;
while (_local14 < _local15) {
_local13[_local14] = new b2Bound();
_local2 = _local13[_local14];
_local3 = _local8[int(((_local10 + 1) + _local14))];
_local2.value = _local3.value;
_local2.proxyId = _local3.proxyId;
_local2.stabbingCount = _local3.stabbingCount;
_local14++;
};
_local15 = _local13.length;
_local16 = (_local10 - 1);
_local14 = 0;
while (_local14 < _local15) {
_local3 = _local13[_local14];
_local2 = _local8[int((_local16 + _local14))];
_local2.value = _local3.value;
_local2.proxyId = _local3.proxyId;
_local2.stabbingCount = _local3.stabbingCount;
_local14++;
};
_local15 = (_local5 - 2);
_local17 = _local9;
while (_local17 < _local15) {
_local2 = _local8[_local17];
_local19 = m_proxyPool[_local2.proxyId];
if (_local2.IsLower()){
_local19.lowerBounds[_local6] = _local17;
} else {
_local19.upperBounds[_local6] = _local17;
};
_local17++;
};
_local15 = (_local10 - 1);
_local18 = _local9;
while (_local18 < _local15) {
_local2 = _local8[_local18];
_local2.stabbingCount--;
_local18++;
};
Query([0], [0], _local11, _local12, _local8, (_local5 - 2), _local6);
_local6++;
};
var _local7:int;
while (_local7 < m_queryResultCount) {
m_pairManager.RemoveBufferedPair(_arg1, m_queryResults[_local7]);
_local7++;
};
m_pairManager.Commit();
m_queryResultCount = 0;
IncrementTimeStamp();
_local4.userData = null;
_local4.overlapCount = b2_invalid;
_local4.lowerBounds[0] = b2_invalid;
_local4.lowerBounds[1] = b2_invalid;
_local4.upperBounds[0] = b2_invalid;
_local4.upperBounds[1] = b2_invalid;
_local4.SetNext(m_freeProxy);
m_freeProxy = _arg1;
m_proxyCount--;
}
public function TestOverlap(_arg1:b2BoundValues, _arg2:b2Proxy):Boolean{
var _local4:Array;
var _local5:b2Bound;
var _local3:int;
while (_local3 < 2) {
_local4 = m_bounds[_local3];
_local5 = _local4[_arg2.upperBounds[_local3]];
if (_arg1.lowerValues[_local3] > _local5.value){
return (false);
};
_local5 = _local4[_arg2.lowerBounds[_local3]];
if (_arg1.upperValues[_local3] < _local5.value){
return (false);
};
_local3++;
};
return (true);
}
public function Validate():void{
var _local1:b2Pair;
var _local2:b2Proxy;
var _local3:b2Proxy;
var _local4:Boolean;
var _local6:b2Bound;
var _local7:uint;
var _local8:uint;
var _local9:uint;
var _local10:b2Bound;
var _local5:int;
while (_local5 < 2) {
_local6 = m_bounds[_local5];
_local7 = (2 * m_proxyCount);
_local8 = 0;
_local9 = 0;
while (_local9 < _local7) {
_local10 = _local6[_local9];
if (_local10.IsLower() == true){
_local8++;
} else {
_local8--;
};
_local9++;
};
_local5++;
};
}
private function IncrementOverlapCount(_arg1:uint):void{
var _local2:b2Proxy = m_proxyPool[_arg1];
if (_local2.timeStamp < m_timeStamp){
_local2.timeStamp = m_timeStamp;
_local2.overlapCount = 1;
} else {
_local2.overlapCount = 2;
m_queryResults[m_queryResultCount] = _arg1;
m_queryResultCount++;
};
}
public function InRange(_arg1:b2AABB):Boolean{
var _local2:Number;
var _local3:Number;
var _local4:Number;
var _local5:Number;
_local2 = _arg1.lowerBound.x;
_local3 = _arg1.lowerBound.y;
_local2 = (_local2 - m_worldAABB.upperBound.x);
_local3 = (_local3 - m_worldAABB.upperBound.y);
_local4 = m_worldAABB.lowerBound.x;
_local5 = m_worldAABB.lowerBound.y;
_local4 = (_local4 - _arg1.upperBound.x);
_local5 = (_local5 - _arg1.upperBound.y);
_local2 = b2Math.b2Max(_local2, _local4);
_local3 = b2Math.b2Max(_local3, _local5);
return ((b2Math.b2Max(_local2, _local3) < 0));
}
public function QuerySegment(_arg1:b2Segment, _arg2, _arg3:int, _arg4:Function):int{
var _local15:int;
var _local16:int;
var _local17:uint;
var _local18:b2Proxy;
var _local19:uint;
var _local20:uint;
var _local24:Number;
var _local25:Number;
var _local27:Number;
var _local28:Number;
var _local29:Number;
var _local30:uint;
var _local5:Number = 1;
var _local6:Number = ((_arg1.p2.x - _arg1.p1.x) * m_quantizationFactor.x);
var _local7:Number = ((_arg1.p2.y - _arg1.p1.y) * m_quantizationFactor.y);
var _local8:int = ((_local6 < -(Number.MIN_VALUE))) ? -1 : ((_local6 > Number.MIN_VALUE)) ? 1 : 0;
var _local9:int = ((_local7 < -(Number.MIN_VALUE))) ? -1 : ((_local7 > Number.MIN_VALUE)) ? 1 : 0;
var _local10:Number = (m_quantizationFactor.x * (_arg1.p1.x - m_worldAABB.lowerBound.x));
var _local11:Number = (m_quantizationFactor.y * (_arg1.p1.y - m_worldAABB.lowerBound.y));
var _local12:Array = new Array();
var _local13:Array = new Array();
_local12[0] = (uint(_local10) & (b2Settings.USHRT_MAX - 1));
_local12[1] = (uint(_local11) & (b2Settings.USHRT_MAX - 1));
_local13[0] = (_local12[0] + 1);
_local13[1] = (_local12[1] + 1);
var _local14:Array = new Array();
var _local21:Array = [_local19];
var _local22:Array = [_local20];
Query(_local21, _local22, _local12[0], _local13[0], m_bounds[0], (2 * m_proxyCount), 0);
if (_local8 >= 0){
_local15 = (_local22[0] - 1);
} else {
_local15 = _local21[0];
};
Query(_local21, _local22, _local12[1], _local13[1], m_bounds[1], (2 * m_proxyCount), 1);
if (_local9 >= 0){
_local16 = (_local22[0] - 1);
} else {
_local16 = _local21[0];
};
if (_arg4 != null){
_local27 = 0;
while (_local27 < m_queryResultCount) {
m_querySortKeys[_local27] = _arg4(m_proxyPool[m_queryResults[_local27]].userData);
_local27++;
};
_local27 = 0;
while (_local27 < (m_queryResultCount - 1)) {
_local28 = m_querySortKeys[_local27];
_local29 = m_querySortKeys[(_local27 + 1)];
if (((_local28)<0) ? (_local29 >= 0) : (((_local28 > _local29)) && ((_local29 >= 0)))){
m_querySortKeys[(_local27 + 1)] = _local28;
m_querySortKeys[_local27] = _local29;
_local30 = m_queryResults[(_local27 + 1)];
m_queryResults[(_local27 + 1)] = m_queryResults[_local27];
m_queryResults[_local27] = _local30;
--_local27;
if (_local27 == -1){
_local27 = 1;
};
} else {
_local27++;
};
};
while ((((m_queryResultCount > 0)) && ((m_querySortKeys[(m_queryResultCount - 1)] < 0)))) {
m_queryResultCount--;
};
};
var _local23:Boolean;
if ((((_local15 < 0)) || ((_local15 >= (m_proxyCount * 2))))){
_local23 = false;
};
if ((((_local16 < 0)) || ((_local16 >= (m_proxyCount * 2))))){
_local23 = false;
};
if (_local23){
if (_local8 != 0){
if (_local8 > 0){
_local15++;
if (_local15 == (m_proxyCount * 2)){
_local23 = false;
};
} else {
--_local15;
if (_local15 < 0){
_local23 = false;
};
};
_local24 = ((m_bounds[0][_local15].value - _local10) / _local6);
};
if (_local9 != 0){
if (_local9 > 0){
_local16++;
if (_local16 == (m_proxyCount * 2)){
_local23 = false;
};
} else {
--_local16;
if (_local16 < 0){
_local23 = false;
};
};
_local25 = ((m_bounds[1][_local16].value - _local11) / _local7);
};
};
while (_local23) {
if ((((_local9 == 0)) || (((!((_local8 == 0))) && ((_local24 < _local25)))))){
if (_local24 > _local5){
break;
};
if (((_local8 > 0)) ? m_bounds[0][_local15].IsLower() : m_bounds[0][_local15].IsUpper()){
_local17 = m_bounds[0][_local15].proxyId;
_local18 = m_proxyPool[_local17];
if (_local9 >= 0){
if ((((_local18.lowerBounds[1] <= (_local16 - 1))) && ((_local18.upperBounds[1] >= _local16)))){
if (_arg4 != null){
AddProxyResult(_local17, _local18, _arg3, _arg4);
} else {
m_queryResults[m_queryResultCount] = _local17;
m_queryResultCount++;
};
};
} else {
if ((((_local18.lowerBounds[1] <= _local16)) && ((_local18.upperBounds[1] >= (_local16 + 1))))){
if (_arg4 != null){
AddProxyResult(_local17, _local18, _arg3, _arg4);
} else {
m_queryResults[m_queryResultCount] = _local17;
m_queryResultCount++;
};
};
};
};
if (((((((!((_arg4 == null))) && ((m_queryResultCount == _arg3)))) && ((m_queryResultCount > 0)))) && ((_local24 > m_querySortKeys[(m_queryResultCount - 1)])))){
break;
};
if (_local8 > 0){
_local15++;
if (_local15 == (m_proxyCount * 2)){
break;
};
} else {
--_local15;
if (_local15 < 0){
break;
};
};
_local24 = ((m_bounds[0][_local15].value - _local10) / _local6);
} else {
if (_local25 > _local5){
break;
};
if (((_local9 > 0)) ? m_bounds[1][_local16].IsLower() : m_bounds[1][_local16].IsUpper()){
_local17 = m_bounds[1][_local16].proxyId;
_local18 = m_proxyPool[_local17];
if (_local8 >= 0){
if ((((_local18.lowerBounds[0] <= (_local15 - 1))) && ((_local18.upperBounds[0] >= _local15)))){
if (_arg4 != null){
AddProxyResult(_local17, _local18, _arg3, _arg4);
} else {
m_queryResults[m_queryResultCount] = _local17;
m_queryResultCount++;
};
};
} else {
if ((((_local18.lowerBounds[0] <= _local15)) && ((_local18.upperBounds[0] >= (_local15 + 1))))){
if (_arg4 != null){
AddProxyResult(_local17, _local18, _arg3, _arg4);
} else {
m_queryResults[m_queryResultCount] = _local17;
m_queryResultCount++;
};
};
};
};
if (((((((!((_arg4 == null))) && ((m_queryResultCount == _arg3)))) && ((m_queryResultCount > 0)))) && ((_local25 > m_querySortKeys[(m_queryResultCount - 1)])))){
break;
};
if (_local9 > 0){
_local16++;
if (_local16 == (m_proxyCount * 2)){
break;
};
} else {
--_local16;
if (_local16 < 0){
break;
};
};
_local25 = ((m_bounds[1][_local16].value - _local11) / _local7);
};
};
var _local26:int;
_local27 = 0;
while ((((_local27 < m_queryResultCount)) && ((_local26 < _arg3)))) {
_local18 = m_proxyPool[m_queryResults[_local27]];
_arg2[_local27] = _local18.userData;
_local27++;
_local26++;
};
m_queryResultCount = 0;
IncrementTimeStamp();
return (_local26);
}
public function MoveProxy(_arg1:uint, _arg2:b2AABB):void{
var _local3:Array;
var _local4:int;
var _local5:uint;
var _local6:uint;
var _local7:b2Bound;
var _local8:b2Bound;
var _local9:b2Bound;
var _local10:uint;
var _local11:b2Proxy;
var _local16:Array;
var _local17:uint;
var _local18:uint;
var _local19:uint;
var _local20:uint;
var _local21:int;
var _local22:int;
var _local23:uint;
var _local24:b2Proxy;
if ((((_arg1 == b2Pair.b2_nullProxy)) || ((b2Settings.b2_maxProxies <= _arg1)))){
return;
};
if (_arg2.IsValid() == false){
return;
};
var _local12:uint = (2 * m_proxyCount);
var _local13:b2Proxy = m_proxyPool[_arg1];
var _local14:b2BoundValues = new b2BoundValues();
ComputeBounds(_local14.lowerValues, _local14.upperValues, _arg2);
var _local15:b2BoundValues = new b2BoundValues();
_local5 = 0;
while (_local5 < 2) {
_local7 = m_bounds[_local5][_local13.lowerBounds[_local5]];
_local15.lowerValues[_local5] = _local7.value;
_local7 = m_bounds[_local5][_local13.upperBounds[_local5]];
_local15.upperValues[_local5] = _local7.value;
_local5++;
};
_local5 = 0;
while (_local5 < 2) {
_local16 = m_bounds[_local5];
_local17 = _local13.lowerBounds[_local5];
_local18 = _local13.upperBounds[_local5];
_local19 = _local14.lowerValues[_local5];
_local20 = _local14.upperValues[_local5];
_local7 = _local16[_local17];
_local21 = (_local19 - _local7.value);
_local7.value = _local19;
_local7 = _local16[_local18];
_local22 = (_local20 - _local7.value);
_local7.value = _local20;
if (_local21 < 0){
_local6 = _local17;
while ((((_local6 > 0)) && ((_local19 < (_local16[int((_local6 - 1))] as b2Bound).value)))) {
_local7 = _local16[_local6];
_local8 = _local16[int((_local6 - 1))];
_local23 = _local8.proxyId;
_local24 = m_proxyPool[_local8.proxyId];
_local8.stabbingCount++;
if (_local8.IsUpper() == true){
if (TestOverlap(_local14, _local24)){
m_pairManager.AddBufferedPair(_arg1, _local23);
};
_local3 = _local24.upperBounds;
_local4 = _local3[_local5];
_local4++;
_local3[_local5] = _local4;
_local7.stabbingCount++;
} else {
_local3 = _local24.lowerBounds;
_local4 = _local3[_local5];
_local4++;
_local3[_local5] = _local4;
_local7.stabbingCount--;
};
_local3 = _local13.lowerBounds;
_local4 = _local3[_local5];
_local4--;
_local3[_local5] = _local4;
_local7.Swap(_local8);
_local6--;
};
};
if (_local22 > 0){
_local6 = _local18;
while ((((_local6 < (_local12 - 1))) && (((_local16[int((_local6 + 1))] as b2Bound).value <= _local20)))) {
_local7 = _local16[_local6];
_local9 = _local16[int((_local6 + 1))];
_local10 = _local9.proxyId;
_local11 = m_proxyPool[_local10];
_local9.stabbingCount++;
if (_local9.IsLower() == true){
if (TestOverlap(_local14, _local11)){
m_pairManager.AddBufferedPair(_arg1, _local10);
};
_local3 = _local11.lowerBounds;
_local4 = _local3[_local5];
_local4--;
_local3[_local5] = _local4;
_local7.stabbingCount++;
} else {
_local3 = _local11.upperBounds;
_local4 = _local3[_local5];
_local4--;
_local3[_local5] = _local4;
_local7.stabbingCount--;
};
_local3 = _local13.upperBounds;
_local4 = _local3[_local5];
_local4++;
_local3[_local5] = _local4;
_local7.Swap(_local9);
_local6++;
};
};
if (_local21 > 0){
_local6 = _local17;
while ((((_local6 < (_local12 - 1))) && (((_local16[int((_local6 + 1))] as b2Bound).value <= _local19)))) {
_local7 = _local16[_local6];
_local9 = _local16[int((_local6 + 1))];
_local10 = _local9.proxyId;
_local11 = m_proxyPool[_local10];
_local9.stabbingCount--;
if (_local9.IsUpper()){
if (TestOverlap(_local15, _local11)){
m_pairManager.RemoveBufferedPair(_arg1, _local10);
};
_local3 = _local11.upperBounds;
_local4 = _local3[_local5];
_local4--;
_local3[_local5] = _local4;
_local7.stabbingCount--;
} else {
_local3 = _local11.lowerBounds;
_local4 = _local3[_local5];
_local4--;
_local3[_local5] = _local4;
_local7.stabbingCount++;
};
_local3 = _local13.lowerBounds;
_local4 = _local3[_local5];
_local4++;
_local3[_local5] = _local4;
_local7.Swap(_local9);
_local6++;
};
};
if (_local22 < 0){
_local6 = _local18;
while ((((_local6 > 0)) && ((_local20 < (_local16[int((_local6 - 1))] as b2Bound).value)))) {
_local7 = _local16[_local6];
_local8 = _local16[int((_local6 - 1))];
_local23 = _local8.proxyId;
_local24 = m_proxyPool[_local23];
_local8.stabbingCount--;
if (_local8.IsLower() == true){
if (TestOverlap(_local15, _local24)){
m_pairManager.RemoveBufferedPair(_arg1, _local23);
};
_local3 = _local24.lowerBounds;
_local4 = _local3[_local5];
_local4++;
_local3[_local5] = _local4;
_local7.stabbingCount--;
} else {
_local3 = _local24.upperBounds;
_local4 = _local3[_local5];
_local4++;
_local3[_local5] = _local4;
_local7.stabbingCount++;
};
_local3 = _local13.upperBounds;
_local4 = _local3[_local5];
_local4--;
_local3[_local5] = _local4;
_local7.Swap(_local8);
_local6--;
};
};
_local5++;
};
}
public static function BinarySearch(_arg1:Array, _arg2:int, _arg3:uint):uint{
var _local6:int;
var _local7:b2Bound;
var _local4:int;
var _local5:int = (_arg2 - 1);
while (_local4 <= _local5) {
_local6 = ((_local4 + _local5) / 2);
_local7 = _arg1[_local6];
if (_local7.value > _arg3){
_local5 = (_local6 - 1);
} else {
if (_local7.value < _arg3){
_local4 = (_local6 + 1);
} else {
return (uint(_local6));
};
};
};
return (uint(_local4));
}
}
}//package Box2D.Collision
Section 13
//b2BufferedPair (Box2D.Collision.b2BufferedPair)
package Box2D.Collision {
public class b2BufferedPair {
public var proxyId1:uint;
public var proxyId2:uint;
}
}//package Box2D.Collision
Section 14
//b2Collision (Box2D.Collision.b2Collision)
package Box2D.Collision {
import Box2D.Common.Math.*;
import Box2D.Collision.Shapes.*;
import Box2D.Common.*;
public class b2Collision {
public static const b2_nullFeature:uint = 0xFF;
private static var b2CollidePolyTempVec:b2Vec2 = new b2Vec2();
public static function EdgeSeparation(_arg1:b2PolygonShape, _arg2:b2XForm, _arg3:int, _arg4:b2PolygonShape, _arg5:b2XForm):Number{
var _local11:b2Mat22;
var _local12:b2Vec2;
var _local25:Number;
var _local6:int = _arg1.m_vertexCount;
var _local7:Array = _arg1.m_vertices;
var _local8:Array = _arg1.m_normals;
var _local9:int = _arg4.m_vertexCount;
var _local10:Array = _arg4.m_vertices;
_local11 = _arg2.R;
_local12 = _local8[_arg3];
var _local13:Number = ((_local11.col1.x * _local12.x) + (_local11.col2.x * _local12.y));
var _local14:Number = ((_local11.col1.y * _local12.x) + (_local11.col2.y * _local12.y));
_local11 = _arg5.R;
var _local15:Number = ((_local11.col1.x * _local13) + (_local11.col1.y * _local14));
var _local16:Number = ((_local11.col2.x * _local13) + (_local11.col2.y * _local14));
var _local17:int;
var _local18:Number = Number.MAX_VALUE;
var _local19:int;
while (_local19 < _local9) {
_local12 = _local10[_local19];
_local25 = ((_local12.x * _local15) + (_local12.y * _local16));
if (_local25 < _local18){
_local18 = _local25;
_local17 = _local19;
};
_local19++;
};
_local12 = _local7[_arg3];
_local11 = _arg2.R;
var _local20:Number = (_arg2.position.x + ((_local11.col1.x * _local12.x) + (_local11.col2.x * _local12.y)));
var _local21:Number = (_arg2.position.y + ((_local11.col1.y * _local12.x) + (_local11.col2.y * _local12.y)));
_local12 = _local10[_local17];
_local11 = _arg5.R;
var _local22:Number = (_arg5.position.x + ((_local11.col1.x * _local12.x) + (_local11.col2.x * _local12.y)));
var _local23:Number = (_arg5.position.y + ((_local11.col1.y * _local12.x) + (_local11.col2.y * _local12.y)));
_local22 = (_local22 - _local20);
_local23 = (_local23 - _local21);
var _local24:Number = ((_local22 * _local13) + (_local23 * _local14));
return (_local24);
}
public static function b2TestOverlap(_arg1:b2AABB, _arg2:b2AABB):Boolean{
var _local3:b2Vec2 = _arg2.lowerBound;
var _local4:b2Vec2 = _arg1.upperBound;
var _local5:Number = (_local3.x - _local4.x);
var _local6:Number = (_local3.y - _local4.y);
_local3 = _arg1.lowerBound;
_local4 = _arg2.upperBound;
var _local7:Number = (_local3.x - _local4.x);
var _local8:Number = (_local3.y - _local4.y);
if ((((_local5 > 0)) || ((_local6 > 0)))){
return (false);
};
if ((((_local7 > 0)) || ((_local8 > 0)))){
return (false);
};
return (true);
}
public static function FindIncidentEdge(_arg1:Array, _arg2:b2PolygonShape, _arg3:b2XForm, _arg4:int, _arg5:b2PolygonShape, _arg6:b2XForm):void{
var _local12:b2Mat22;
var _local13:b2Vec2;
var _local20:ClipVertex;
var _local23:Number;
var _local7:int = _arg2.m_vertexCount;
var _local8:Array = _arg2.m_normals;
var _local9:int = _arg5.m_vertexCount;
var _local10:Array = _arg5.m_vertices;
var _local11:Array = _arg5.m_normals;
_local12 = _arg3.R;
_local13 = _local8[_arg4];
var _local14:Number = ((_local12.col1.x * _local13.x) + (_local12.col2.x * _local13.y));
var _local15:Number = ((_local12.col1.y * _local13.x) + (_local12.col2.y * _local13.y));
_local12 = _arg6.R;
var _local16:Number = ((_local12.col1.x * _local14) + (_local12.col1.y * _local15));
_local15 = ((_local12.col2.x * _local14) + (_local12.col2.y * _local15));
_local14 = _local16;
var _local17:int;
var _local18:Number = Number.MAX_VALUE;
var _local19:int;
while (_local19 < _local9) {
_local13 = _local11[_local19];
_local23 = ((_local14 * _local13.x) + (_local15 * _local13.y));
if (_local23 < _local18){
_local18 = _local23;
_local17 = _local19;
};
_local19++;
};
var _local21:int = _local17;
var _local22:int = (((_local21 + 1) < _local9)) ? (_local21 + 1) : 0;
_local20 = _arg1[0];
_local13 = _local10[_local21];
_local12 = _arg6.R;
_local20.v.x = (_arg6.position.x + ((_local12.col1.x * _local13.x) + (_local12.col2.x * _local13.y)));
_local20.v.y = (_arg6.position.y + ((_local12.col1.y * _local13.x) + (_local12.col2.y * _local13.y)));
_local20.id.features.referenceEdge = _arg4;
_local20.id.features.incidentEdge = _local21;
_local20.id.features.incidentVertex = 0;
_local20 = _arg1[1];
_local13 = _local10[_local22];
_local12 = _arg6.R;
_local20.v.x = (_arg6.position.x + ((_local12.col1.x * _local13.x) + (_local12.col2.x * _local13.y)));
_local20.v.y = (_arg6.position.y + ((_local12.col1.y * _local13.x) + (_local12.col2.y * _local13.y)));
_local20.id.features.referenceEdge = _arg4;
_local20.id.features.incidentEdge = _local22;
_local20.id.features.incidentVertex = 1;
}
public static function b2CollidePolygons(_arg1:b2Manifold, _arg2:b2PolygonShape, _arg3:b2XForm, _arg4:b2PolygonShape, _arg5:b2XForm):void{
var _local6:ClipVertex;
var _local13:b2PolygonShape;
var _local14:b2PolygonShape;
var _local17:int;
var _local18:uint;
var _local34:int;
var _local37:b2Vec2;
var _local38:Number;
var _local39:b2ManifoldPoint;
_arg1.pointCount = 0;
var _local7:int;
var _local8:Array = [_local7];
var _local9:Number = FindMaxSeparation(_local8, _arg2, _arg3, _arg4, _arg5);
_local7 = _local8[0];
if (_local9 > 0){
return;
};
var _local10:int;
var _local11:Array = [_local10];
var _local12:Number = FindMaxSeparation(_local11, _arg4, _arg5, _arg2, _arg3);
_local10 = _local11[0];
if (_local12 > 0){
return;
};
var _local15:b2XForm = new b2XForm();
var _local16:b2XForm = new b2XForm();
var _local19:Number = 0.98;
var _local20:Number = 0.001;
if (_local12 > ((_local19 * _local9) + _local20)){
_local13 = _arg4;
_local14 = _arg2;
_local15.Set(_arg5);
_local16.Set(_arg3);
_local17 = _local10;
_local18 = 1;
} else {
_local13 = _arg2;
_local14 = _arg4;
_local15.Set(_arg3);
_local16.Set(_arg5);
_local17 = _local7;
_local18 = 0;
};
var _local21:Array = [new ClipVertex(), new ClipVertex()];
FindIncidentEdge(_local21, _local13, _local15, _local17, _local14, _local16);
var _local22:int = _local13.m_vertexCount;
var _local23:Array = _local13.m_vertices;
var _local24:b2Vec2 = _local23[_local17];
var _local25:b2Vec2 = _local24.Copy();
if ((_local17 + 1) < _local22){
_local24 = _local23[int((_local17 + 1))];
_local37 = _local24.Copy();
} else {
_local24 = _local23[0];
_local37 = _local24.Copy();
};
var _local26:b2Vec2 = b2Math.SubtractVV(_local37, _local25);
var _local27:b2Vec2 = b2Math.b2MulMV(_local15.R, b2Math.SubtractVV(_local37, _local25));
_local27.Normalize();
var _local28:b2Vec2 = b2Math.b2CrossVF(_local27, 1);
_local25 = b2Math.b2MulX(_local15, _local25);
_local37 = b2Math.b2MulX(_local15, _local37);
var _local29:Number = b2Math.b2Dot(_local28, _local25);
var _local30:Number = -(b2Math.b2Dot(_local27, _local25));
var _local31:Number = b2Math.b2Dot(_local27, _local37);
var _local32:Array = [new ClipVertex(), new ClipVertex()];
var _local33:Array = [new ClipVertex(), new ClipVertex()];
_local34 = ClipSegmentToLine(_local32, _local21, _local27.Negative(), _local30);
if (_local34 < 2){
return;
};
_local34 = ClipSegmentToLine(_local33, _local32, _local27, _local31);
if (_local34 < 2){
return;
};
_arg1.normal = (_local18) ? _local28.Negative() : _local28.Copy();
var _local35:int;
var _local36:int;
while (_local36 < b2Settings.b2_maxManifoldPoints) {
_local6 = _local33[_local36];
_local38 = (b2Math.b2Dot(_local28, _local6.v) - _local29);
if (_local38 <= 0){
_local39 = _arg1.points[_local35];
_local39.separation = _local38;
_local39.localPoint1 = b2Math.b2MulXT(_arg3, _local6.v);
_local39.localPoint2 = b2Math.b2MulXT(_arg5, _local6.v);
_local39.id.key = _local6.id._key;
_local39.id.features.flip = _local18;
_local35++;
};
_local36++;
};
_arg1.pointCount = _local35;
}
public static function FindMaxSeparation(_arg1:Array, _arg2:b2PolygonShape, _arg3:b2XForm, _arg4:b2PolygonShape, _arg5:b2XForm):Number{
var _local8:b2Vec2;
var _local9:b2Mat22;
var _local22:int;
var _local23:Number;
var _local24:int;
var _local25:Number;
var _local6:int = _arg2.m_vertexCount;
var _local7:Array = _arg2.m_normals;
_local9 = _arg5.R;
_local8 = _arg4.m_centroid;
var _local10:Number = (_arg5.position.x + ((_local9.col1.x * _local8.x) + (_local9.col2.x * _local8.y)));
var _local11:Number = (_arg5.position.y + ((_local9.col1.y * _local8.x) + (_local9.col2.y * _local8.y)));
_local9 = _arg3.R;
_local8 = _arg2.m_centroid;
_local10 = (_local10 - (_arg3.position.x + ((_local9.col1.x * _local8.x) + (_local9.col2.x * _local8.y))));
_local11 = (_local11 - (_arg3.position.y + ((_local9.col1.y * _local8.x) + (_local9.col2.y * _local8.y))));
var _local12:Number = ((_local10 * _arg3.R.col1.x) + (_local11 * _arg3.R.col1.y));
var _local13:Number = ((_local10 * _arg3.R.col2.x) + (_local11 * _arg3.R.col2.y));
var _local14:int;
var _local15:Number = -(Number.MAX_VALUE);
var _local16:int;
while (_local16 < _local6) {
_local8 = _local7[_local16];
_local25 = ((_local8.x * _local12) + (_local8.y * _local13));
if (_local25 > _local15){
_local15 = _local25;
_local14 = _local16;
};
_local16++;
};
var _local17:Number = EdgeSeparation(_arg2, _arg3, _local14, _arg4, _arg5);
if (_local17 > 0){
return (_local17);
};
var _local18:int = (((_local14 - 1) >= 0)) ? (_local14 - 1) : (_local6 - 1);
var _local19:Number = EdgeSeparation(_arg2, _arg3, _local18, _arg4, _arg5);
if (_local19 > 0){
return (_local19);
};
var _local20:int = (((_local14 + 1) < _local6)) ? (_local14 + 1) : 0;
var _local21:Number = EdgeSeparation(_arg2, _arg3, _local20, _arg4, _arg5);
if (_local21 > 0){
return (_local21);
};
if ((((_local19 > _local17)) && ((_local19 > _local21)))){
_local24 = -1;
_local22 = _local18;
_local23 = _local19;
} else {
if (_local21 > _local17){
_local24 = 1;
_local22 = _local20;
_local23 = _local21;
} else {
_arg1[0] = _local14;
return (_local17);
};
};
while (true) {
if (_local24 == -1){
_local14 = (((_local22 - 1) >= 0)) ? (_local22 - 1) : (_local6 - 1);
} else {
_local14 = (((_local22 + 1) < _local6)) ? (_local22 + 1) : 0;
};
_local17 = EdgeSeparation(_arg2, _arg3, _local14, _arg4, _arg5);
if (_local17 > 0){
return (_local17);
};
if (_local17 > _local23){
_local22 = _local14;
_local23 = _local17;
} else {
break;
};
};
_arg1[0] = _local22;
return (_local23);
}
public static function ClipSegmentToLine(_arg1:Array, _arg2:Array, _arg3:b2Vec2, _arg4:Number):int{
var _local5:ClipVertex;
var _local6:int;
var _local7:b2Vec2;
var _local8:b2Vec2;
var _local9:Number;
var _local11:Number;
var _local12:b2Vec2;
var _local13:ClipVertex;
_local6 = 0;
_local5 = _arg2[0];
_local7 = _local5.v;
_local5 = _arg2[1];
_local8 = _local5.v;
_local9 = (b2Math.b2Dot(_arg3, _local7) - _arg4);
var _local10:Number = (b2Math.b2Dot(_arg3, _local8) - _arg4);
if (_local9 <= 0){
var _temp1 = _local6;
_local6 = (_local6 + 1);
var _local14 = _temp1;
_arg1[_local14] = _arg2[0];
};
if (_local10 <= 0){
var _temp2 = _local6;
_local6 = (_local6 + 1);
_local14 = _temp2;
_arg1[_local14] = _arg2[1];
};
if ((_local9 * _local10) < 0){
_local11 = (_local9 / (_local9 - _local10));
_local5 = _arg1[_local6];
_local12 = _local5.v;
_local12.x = (_local7.x + (_local11 * (_local8.x - _local7.x)));
_local12.y = (_local7.y + (_local11 * (_local8.y - _local7.y)));
_local5 = _arg1[_local6];
if (_local9 > 0){
_local13 = _arg2[0];
_local5.id = _local13.id;
} else {
_local13 = _arg2[1];
_local5.id = _local13.id;
};
_local6++;
};
return (_local6);
}
public static function b2CollideCircles(_arg1:b2Manifold, _arg2:b2CircleShape, _arg3:b2XForm, _arg4:b2CircleShape, _arg5:b2XForm):void{
var _local6:b2Mat22;
var _local7:b2Vec2;
var _local18:Number;
var _local24:Number;
var _local25:Number;
_arg1.pointCount = 0;
_local6 = _arg3.R;
_local7 = _arg2.m_localPosition;
var _local8:Number = (_arg3.position.x + ((_local6.col1.x * _local7.x) + (_local6.col2.x * _local7.y)));
var _local9:Number = (_arg3.position.y + ((_local6.col1.y * _local7.x) + (_local6.col2.y * _local7.y)));
_local6 = _arg5.R;
_local7 = _arg4.m_localPosition;
var _local10:Number = (_arg5.position.x + ((_local6.col1.x * _local7.x) + (_local6.col2.x * _local7.y)));
var _local11:Number = (_arg5.position.y + ((_local6.col1.y * _local7.x) + (_local6.col2.y * _local7.y)));
var _local12:Number = (_local10 - _local8);
var _local13:Number = (_local11 - _local9);
var _local14:Number = ((_local12 * _local12) + (_local13 * _local13));
var _local15:Number = _arg2.m_radius;
var _local16:Number = _arg4.m_radius;
var _local17:Number = (_local15 + _local16);
if (_local14 > (_local17 * _local17)){
return;
};
if (_local14 < Number.MIN_VALUE){
_local18 = -(_local17);
_arg1.normal.Set(0, 1);
} else {
_local24 = Math.sqrt(_local14);
_local18 = (_local24 - _local17);
_local25 = (1 / _local24);
_arg1.normal.x = (_local25 * _local12);
_arg1.normal.y = (_local25 * _local13);
};
_arg1.pointCount = 1;
var _local19:b2ManifoldPoint = _arg1.points[0];
_local19.id.key = 0;
_local19.separation = _local18;
_local8 = (_local8 + (_local15 * _arg1.normal.x));
_local9 = (_local9 + (_local15 * _arg1.normal.y));
_local10 = (_local10 - (_local16 * _arg1.normal.x));
_local11 = (_local11 - (_local16 * _arg1.normal.y));
var _local20:Number = (0.5 * (_local8 + _local10));
var _local21:Number = (0.5 * (_local9 + _local11));
var _local22:Number = (_local20 - _arg3.position.x);
var _local23:Number = (_local21 - _arg3.position.y);
_local19.localPoint1.x = ((_local22 * _arg3.R.col1.x) + (_local23 * _arg3.R.col1.y));
_local19.localPoint1.y = ((_local22 * _arg3.R.col2.x) + (_local23 * _arg3.R.col2.y));
_local22 = (_local20 - _arg5.position.x);
_local23 = (_local21 - _arg5.position.y);
_local19.localPoint2.x = ((_local22 * _arg5.R.col1.x) + (_local23 * _arg5.R.col1.y));
_local19.localPoint2.y = ((_local22 * _arg5.R.col2.x) + (_local23 * _arg5.R.col2.y));
}
public static function b2CollidePolygonAndCircle(_arg1:b2Manifold, _arg2:b2PolygonShape, _arg3:b2XForm, _arg4:b2CircleShape, _arg5:b2XForm):void{
var _local6:b2ManifoldPoint;
var _local7:Number;
var _local8:Number;
var _local9:Number;
var _local10:Number;
var _local11:b2Vec2;
var _local12:b2Mat22;
var _local17:Number;
var _local32:Number;
var _local33:Number;
var _local34:Number;
_arg1.pointCount = 0;
_local12 = _arg5.R;
_local11 = _arg4.m_localPosition;
var _local13:Number = (_arg5.position.x + ((_local12.col1.x * _local11.x) + (_local12.col2.x * _local11.y)));
var _local14:Number = (_arg5.position.y + ((_local12.col1.y * _local11.x) + (_local12.col2.y * _local11.y)));
_local7 = (_local13 - _arg3.position.x);
_local8 = (_local14 - _arg3.position.y);
_local12 = _arg3.R;
var _local15:Number = ((_local7 * _local12.col1.x) + (_local8 * _local12.col1.y));
var _local16:Number = ((_local7 * _local12.col2.x) + (_local8 * _local12.col2.y));
var _local18:int;
var _local19:Number = -(Number.MAX_VALUE);
var _local20:Number = _arg4.m_radius;
var _local21:int = _arg2.m_vertexCount;
var _local22:Array = _arg2.m_vertices;
var _local23:Array = _arg2.m_normals;
var _local24:int;
while (_local24 < _local21) {
_local11 = _local22[_local24];
_local7 = (_local15 - _local11.x);
_local8 = (_local16 - _local11.y);
_local11 = _local23[_local24];
_local34 = ((_local11.x * _local7) + (_local11.y * _local8));
if (_local34 > _local20){
return;
};
if (_local34 > _local19){
_local19 = _local34;
_local18 = _local24;
};
_local24++;
};
if (_local19 < Number.MIN_VALUE){
_arg1.pointCount = 1;
_local11 = _local23[_local18];
_local12 = _arg3.R;
_arg1.normal.x = ((_local12.col1.x * _local11.x) + (_local12.col2.x * _local11.y));
_arg1.normal.y = ((_local12.col1.y * _local11.x) + (_local12.col2.y * _local11.y));
_local6 = _arg1.points[0];
_local6.id.features.incidentEdge = _local18;
_local6.id.features.incidentVertex = b2_nullFeature;
_local6.id.features.referenceEdge = 0;
_local6.id.features.flip = 0;
_local9 = (_local13 - (_local20 * _arg1.normal.x));
_local10 = (_local14 - (_local20 * _arg1.normal.y));
_local7 = (_local9 - _arg3.position.x);
_local8 = (_local10 - _arg3.position.y);
_local12 = _arg3.R;
_local6.localPoint1.x = ((_local7 * _local12.col1.x) + (_local8 * _local12.col1.y));
_local6.localPoint1.y = ((_local7 * _local12.col2.x) + (_local8 * _local12.col2.y));
_local7 = (_local9 - _arg5.position.x);
_local8 = (_local10 - _arg5.position.y);
_local12 = _arg5.R;
_local6.localPoint2.x = ((_local7 * _local12.col1.x) + (_local8 * _local12.col1.y));
_local6.localPoint2.y = ((_local7 * _local12.col2.x) + (_local8 * _local12.col2.y));
_local6.separation = (_local19 - _local20);
return;
};
var _local25:int = _local18;
var _local26:int = (((_local25 + 1) < _local21)) ? (_local25 + 1) : 0;
_local11 = _local22[_local25];
var _local27:b2Vec2 = _local22[_local26];
var _local28:Number = (_local27.x - _local11.x);
var _local29:Number = (_local27.y - _local11.y);
var _local30:Number = Math.sqrt(((_local28 * _local28) + (_local29 * _local29)));
_local28 = (_local28 / _local30);
_local29 = (_local29 / _local30);
_local7 = (_local15 - _local11.x);
_local8 = (_local16 - _local11.y);
var _local31:Number = ((_local7 * _local28) + (_local8 * _local29));
_local6 = _arg1.points[0];
if (_local31 <= 0){
_local32 = _local11.x;
_local33 = _local11.y;
_local6.id.features.incidentEdge = b2_nullFeature;
_local6.id.features.incidentVertex = _local25;
} else {
if (_local31 >= _local30){
_local32 = _local27.x;
_local33 = _local27.y;
_local6.id.features.incidentEdge = b2_nullFeature;
_local6.id.features.incidentVertex = _local26;
} else {
_local32 = ((_local28 * _local31) + _local11.x);
_local33 = ((_local29 * _local31) + _local11.y);
_local6.id.features.incidentEdge = _local18;
_local6.id.features.incidentVertex = 0;
};
};
_local7 = (_local15 - _local32);
_local8 = (_local16 - _local33);
_local17 = Math.sqrt(((_local7 * _local7) + (_local8 * _local8)));
_local7 = (_local7 / _local17);
_local8 = (_local8 / _local17);
if (_local17 > _local20){
return;
};
_arg1.pointCount = 1;
_local12 = _arg3.R;
_arg1.normal.x = ((_local12.col1.x * _local7) + (_local12.col2.x * _local8));
_arg1.normal.y = ((_local12.col1.y * _local7) + (_local12.col2.y * _local8));
_local9 = (_local13 - (_local20 * _arg1.normal.x));
_local10 = (_local14 - (_local20 * _arg1.normal.y));
_local7 = (_local9 - _arg3.position.x);
_local8 = (_local10 - _arg3.position.y);
_local12 = _arg3.R;
_local6.localPoint1.x = ((_local7 * _local12.col1.x) + (_local8 * _local12.col1.y));
_local6.localPoint1.y = ((_local7 * _local12.col2.x) + (_local8 * _local12.col2.y));
_local7 = (_local9 - _arg5.position.x);
_local8 = (_local10 - _arg5.position.y);
_local12 = _arg5.R;
_local6.localPoint2.x = ((_local7 * _local12.col1.x) + (_local8 * _local12.col1.y));
_local6.localPoint2.y = ((_local7 * _local12.col2.x) + (_local8 * _local12.col2.y));
_local6.separation = (_local17 - _local20);
_local6.id.features.referenceEdge = 0;
_local6.id.features.flip = 0;
}
}
}//package Box2D.Collision
Section 15
//b2ContactID (Box2D.Collision.b2ContactID)
package Box2D.Collision {
public class b2ContactID {
public var _key:uint;
public var features:Features;
public function b2ContactID(){
features = new Features();
super();
features._m_id = this;
}
public function Set(_arg1:b2ContactID):void{
key = _arg1._key;
}
public function Copy():b2ContactID{
var _local1:b2ContactID = new b2ContactID();
_local1.key = key;
return (_local1);
}
public function set key(_arg1:uint):void{
_key = _arg1;
features._referenceEdge = (_key & 0xFF);
features._incidentEdge = (((_key & 0xFF00) >> 8) & 0xFF);
features._incidentVertex = (((_key & 0xFF0000) >> 16) & 0xFF);
features._flip = (((_key & 4278190080) >> 24) & 0xFF);
}
public function get key():uint{
return (_key);
}
}
}//package Box2D.Collision
Section 16
//b2ContactPoint (Box2D.Collision.b2ContactPoint)
package Box2D.Collision {
import Box2D.Common.Math.*;
import Box2D.Collision.Shapes.*;
public class b2ContactPoint {
public var friction:Number;
public var separation:Number;
public var normal:b2Vec2;
public var position:b2Vec2;
public var restitution:Number;
public var shape1:b2Shape;
public var shape2:b2Shape;
public var id:b2ContactID;
public var velocity:b2Vec2;
public function b2ContactPoint(){
position = new b2Vec2();
velocity = new b2Vec2();
normal = new b2Vec2();
id = new b2ContactID();
super();
}
}
}//package Box2D.Collision
Section 17
//b2Distance (Box2D.Collision.b2Distance)
package Box2D.Collision {
import Box2D.Common.Math.*;
import Box2D.Collision.Shapes.*;
import Box2D.Common.*;
public class b2Distance {
private static var s_p2s:Array = [new b2Vec2(), new b2Vec2(), new b2Vec2()];
private static var s_p1s:Array = [new b2Vec2(), new b2Vec2(), new b2Vec2()];
private static var s_points:Array = [new b2Vec2(), new b2Vec2(), new b2Vec2()];
private static var gPoint:b2Point = new b2Point();
public static var g_GJK_Iterations:int = 0;
public static function InPoints(_arg1:b2Vec2, _arg2:Array, _arg3:int):Boolean{
var _local6:b2Vec2;
var _local7:Number;
var _local8:Number;
var _local9:Number;
var _local10:Number;
var _local4:Number = (100 * Number.MIN_VALUE);
var _local5:int;
while (_local5 < _arg3) {
_local6 = _arg2[_local5];
_local7 = Math.abs((_arg1.x - _local6.x));
_local8 = Math.abs((_arg1.y - _local6.y));
_local9 = Math.max(Math.abs(_arg1.x), Math.abs(_local6.x));
_local10 = Math.max(Math.abs(_arg1.y), Math.abs(_local6.y));
if ((((_local7 < (_local4 * (_local9 + 1)))) && ((_local8 < (_local4 * (_local10 + 1)))))){
return (true);
};
_local5++;
};
return (false);
}
public static function DistanceGeneric(_arg1:b2Vec2, _arg2:b2Vec2, _arg3, _arg4:b2XForm, _arg5, _arg6:b2XForm):Number{
var _local7:b2Vec2;
var _local15:Number;
var _local16:Number;
var _local17:b2Vec2;
var _local18:b2Vec2;
var _local19:Number;
var _local20:Number;
var _local21:Number;
var _local22:Number;
var _local23:int;
var _local8:Array = s_p1s;
var _local9:Array = s_p2s;
var _local10:Array = s_points;
var _local11:int;
_arg1.SetV(_arg3.GetFirstVertex(_arg4));
_arg2.SetV(_arg5.GetFirstVertex(_arg6));
var _local12:Number = 0;
var _local13 = 20;
var _local14:int;
while (_local14 < _local13) {
_local15 = (_arg2.x - _arg1.x);
_local16 = (_arg2.y - _arg1.y);
_local17 = _arg3.Support(_arg4, _local15, _local16);
_local18 = _arg5.Support(_arg6, -(_local15), -(_local16));
_local12 = ((_local15 * _local15) + (_local16 * _local16));
_local19 = (_local18.x - _local17.x);
_local20 = (_local18.y - _local17.y);
_local21 = ((_local15 * _local19) + (_local16 * _local20));
if ((_local12 - ((_local15 * _local19) + (_local16 * _local20))) <= (0.01 * _local12)){
if (_local11 == 0){
_arg1.SetV(_local17);
_arg2.SetV(_local18);
};
g_GJK_Iterations = _local14;
return (Math.sqrt(_local12));
};
switch (_local11){
case 0:
_local7 = _local8[0];
_local7.SetV(_local17);
_local7 = _local9[0];
_local7.SetV(_local18);
_local7 = _local10[0];
_local7.x = _local19;
_local7.y = _local20;
_arg1.SetV(_local8[0]);
_arg2.SetV(_local9[0]);
_local11++;
break;
case 1:
_local7 = _local8[1];
_local7.SetV(_local17);
_local7 = _local9[1];
_local7.SetV(_local18);
_local7 = _local10[1];
_local7.x = _local19;
_local7.y = _local20;
_local11 = ProcessTwo(_arg1, _arg2, _local8, _local9, _local10);
break;
case 2:
_local7 = _local8[2];
_local7.SetV(_local17);
_local7 = _local9[2];
_local7.SetV(_local18);
_local7 = _local10[2];
_local7.x = _local19;
_local7.y = _local20;
_local11 = ProcessThree(_arg1, _arg2, _local8, _local9, _local10);
break;
};
if (_local11 == 3){
g_GJK_Iterations = _local14;
return (0);
};
_local22 = -(Number.MAX_VALUE);
_local23 = 0;
while (_local23 < _local11) {
_local7 = _local10[_local23];
_local22 = b2Math.b2Max(_local22, ((_local7.x * _local7.x) + (_local7.y * _local7.y)));
_local23++;
};
if ((((_local11 == 3)) || ((_local12 <= ((100 * Number.MIN_VALUE) * _local22))))){
g_GJK_Iterations = _local14;
_local15 = (_arg2.x - _arg1.x);
_local16 = (_arg2.y - _arg1.y);
_local12 = ((_local15 * _local15) + (_local16 * _local16));
return (Math.sqrt(_local12));
};
_local14++;
};
g_GJK_Iterations = _local13;
return (Math.sqrt(_local12));
}
public static function DistanceCC(_arg1:b2Vec2, _arg2:b2Vec2, _arg3:b2CircleShape, _arg4:b2XForm, _arg5:b2CircleShape, _arg6:b2XForm):Number{
var _local7:b2Mat22;
var _local8:b2Vec2;
var _local19:Number;
var _local20:Number;
_local7 = _arg4.R;
_local8 = _arg3.m_localPosition;
var _local9:Number = (_arg4.position.x + ((_local7.col1.x * _local8.x) + (_local7.col2.x * _local8.y)));
var _local10:Number = (_arg4.position.y + ((_local7.col1.y * _local8.x) + (_local7.col2.y * _local8.y)));
_local7 = _arg6.R;
_local8 = _arg5.m_localPosition;
var _local11:Number = (_arg6.position.x + ((_local7.col1.x * _local8.x) + (_local7.col2.x * _local8.y)));
var _local12:Number = (_arg6.position.y + ((_local7.col1.y * _local8.x) + (_local7.col2.y * _local8.y)));
var _local13:Number = (_local11 - _local9);
var _local14:Number = (_local12 - _local10);
var _local15:Number = ((_local13 * _local13) + (_local14 * _local14));
var _local16:Number = (_arg3.m_radius - b2Settings.b2_toiSlop);
var _local17:Number = (_arg5.m_radius - b2Settings.b2_toiSlop);
var _local18:Number = (_local16 + _local17);
if (_local15 > (_local18 * _local18)){
_local19 = Math.sqrt(((_local13 * _local13) + (_local14 * _local14)));
_local13 = (_local13 / _local19);
_local14 = (_local14 / _local19);
_local20 = (_local19 - _local18);
_arg1.x = (_local9 + (_local16 * _local13));
_arg1.y = (_local10 + (_local16 * _local14));
_arg2.x = (_local11 - (_local17 * _local13));
_arg2.y = (_local12 - (_local17 * _local14));
return (_local20);
};
if (_local15 > (Number.MIN_VALUE * Number.MIN_VALUE)){
_local19 = Math.sqrt(((_local13 * _local13) + (_local14 * _local14)));
_local13 = (_local13 / _local19);
_local14 = (_local14 / _local19);
_arg1.x = (_local9 + (_local16 * _local13));
_arg1.y = (_local10 + (_local16 * _local14));
_arg2.x = _arg1.x;
_arg2.y = _arg1.y;
return (0);
};
_arg1.x = _local9;
_arg1.y = _local10;
_arg2.x = _arg1.x;
_arg2.y = _arg1.y;
return (0);
}
public static function ProcessThree(_arg1:b2Vec2, _arg2:b2Vec2, _arg3:Array, _arg4:Array, _arg5:Array):int{
var _local6:b2Vec2;
var _local7:b2Vec2;
var _local8:b2Vec2;
var _local9:b2Vec2;
var _local10:b2Vec2;
var _local11:b2Vec2;
var _local12:b2Vec2;
var _local13:b2Vec2;
var _local35:Number;
_local6 = _arg5[0];
_local7 = _arg5[1];
_local8 = _arg5[2];
_local9 = _arg3[0];
_local10 = _arg3[1];
_local11 = _arg3[2];
_local12 = _arg4[0];
_local13 = _arg4[1];
var _local14:b2Vec2 = _arg4[2];
var _local15:Number = _local6.x;
var _local16:Number = _local6.y;
var _local17:Number = _local7.x;
var _local18:Number = _local7.y;
var _local19:Number = _local8.x;
var _local20:Number = _local8.y;
var _local21:Number = (_local17 - _local15);
var _local22:Number = (_local18 - _local16);
var _local23:Number = (_local19 - _local15);
var _local24:Number = (_local20 - _local16);
var _local25:Number = (_local19 - _local17);
var _local26:Number = (_local20 - _local18);
var _local27:Number = -(((_local15 * _local21) + (_local16 * _local22)));
var _local28:Number = ((_local17 * _local21) + (_local18 * _local22));
var _local29:Number = -(((_local15 * _local23) + (_local16 * _local24)));
var _local30:Number = ((_local19 * _local23) + (_local20 * _local24));
var _local31:Number = -(((_local17 * _local25) + (_local18 * _local26)));
var _local32:Number = ((_local19 * _local25) + (_local20 * _local26));
if ((((_local30 <= 0)) && ((_local32 <= 0)))){
_arg1.SetV(_local11);
_arg2.SetV(_local14);
_local9.SetV(_local11);
_local12.SetV(_local14);
_local6.SetV(_local8);
return (1);
};
var _local33:Number = ((_local21 * _local24) - (_local22 * _local23));
var _local34:Number = (_local33 * ((_local15 * _local18) - (_local16 * _local17)));
var _local36:Number = (_local33 * ((_local17 * _local20) - (_local18 * _local19)));
if ((((((((_local36 <= 0)) && ((_local31 >= 0)))) && ((_local32 >= 0)))) && (((_local31 + _local32) > 0)))){
_local35 = (_local31 / (_local31 + _local32));
_arg1.x = (_local10.x + (_local35 * (_local11.x - _local10.x)));
_arg1.y = (_local10.y + (_local35 * (_local11.y - _local10.y)));
_arg2.x = (_local13.x + (_local35 * (_local14.x - _local13.x)));
_arg2.y = (_local13.y + (_local35 * (_local14.y - _local13.y)));
_local9.SetV(_local11);
_local12.SetV(_local14);
_local6.SetV(_local8);
return (2);
};
var _local37:Number = (_local33 * ((_local19 * _local16) - (_local20 * _local15)));
if ((((((((_local37 <= 0)) && ((_local29 >= 0)))) && ((_local30 >= 0)))) && (((_local29 + _local30) > 0)))){
_local35 = (_local29 / (_local29 + _local30));
_arg1.x = (_local9.x + (_local35 * (_local11.x - _local9.x)));
_arg1.y = (_local9.y + (_local35 * (_local11.y - _local9.y)));
_arg2.x = (_local12.x + (_local35 * (_local14.x - _local12.x)));
_arg2.y = (_local12.y + (_local35 * (_local14.y - _local12.y)));
_local10.SetV(_local11);
_local13.SetV(_local14);
_local7.SetV(_local8);
return (2);
};
var _local38:Number = ((_local36 + _local37) + _local34);
_local38 = (1 / _local38);
var _local39:Number = (_local36 * _local38);
var _local40:Number = (_local37 * _local38);
var _local41:Number = ((1 - _local39) - _local40);
_arg1.x = (((_local39 * _local9.x) + (_local40 * _local10.x)) + (_local41 * _local11.x));
_arg1.y = (((_local39 * _local9.y) + (_local40 * _local10.y)) + (_local41 * _local11.y));
_arg2.x = (((_local39 * _local12.x) + (_local40 * _local13.x)) + (_local41 * _local14.x));
_arg2.y = (((_local39 * _local12.y) + (_local40 * _local13.y)) + (_local41 * _local14.y));
return (3);
}
public static function DistancePC(_arg1:b2Vec2, _arg2:b2Vec2, _arg3:b2PolygonShape, _arg4:b2XForm, _arg5:b2CircleShape, _arg6:b2XForm):Number{
var _local7:b2Mat22;
var _local8:b2Vec2;
var _local12:Number;
var _local13:Number;
var _local14:Number;
var _local9:b2Point = gPoint;
_local8 = _arg5.m_localPosition;
_local7 = _arg6.R;
_local9.p.x = (_arg6.position.x + ((_local7.col1.x * _local8.x) + (_local7.col2.x * _local8.y)));
_local9.p.y = (_arg6.position.y + ((_local7.col1.y * _local8.x) + (_local7.col2.y * _local8.y)));
var _local10:Number = DistanceGeneric(_arg1, _arg2, _arg3, _arg4, _local9, b2Math.b2XForm_identity);
var _local11:Number = (_arg5.m_radius - b2Settings.b2_toiSlop);
if (_local10 > _local11){
_local10 = (_local10 - _local11);
_local12 = (_arg2.x - _arg1.x);
_local13 = (_arg2.y - _arg1.y);
_local14 = Math.sqrt(((_local12 * _local12) + (_local13 * _local13)));
_local12 = (_local12 / _local14);
_local13 = (_local13 / _local14);
_arg2.x = (_arg2.x - (_local11 * _local12));
_arg2.y = (_arg2.y - (_local11 * _local13));
} else {
_local10 = 0;
_arg2.x = _arg1.x;
_arg2.y = _arg1.y;
};
return (_local10);
}
public static function Distance(_arg1:b2Vec2, _arg2:b2Vec2, _arg3:b2Shape, _arg4:b2XForm, _arg5:b2Shape, _arg6:b2XForm):Number{
var _local7:int = _arg3.m_type;
var _local8:int = _arg5.m_type;
if ((((_local7 == b2Shape.e_circleShape)) && ((_local8 == b2Shape.e_circleShape)))){
return (DistanceCC(_arg1, _arg2, (_arg3 as b2CircleShape), _arg4, (_arg5 as b2CircleShape), _arg6));
};
if ((((_local7 == b2Shape.e_polygonShape)) && ((_local8 == b2Shape.e_circleShape)))){
return (DistancePC(_arg1, _arg2, (_arg3 as b2PolygonShape), _arg4, (_arg5 as b2CircleShape), _arg6));
};
if ((((_local7 == b2Shape.e_circleShape)) && ((_local8 == b2Shape.e_polygonShape)))){
return (DistancePC(_arg2, _arg1, (_arg5 as b2PolygonShape), _arg6, (_arg3 as b2CircleShape), _arg4));
};
if ((((_local7 == b2Shape.e_polygonShape)) && ((_local8 == b2Shape.e_polygonShape)))){
return (DistanceGeneric(_arg1, _arg2, (_arg3 as b2PolygonShape), _arg4, (_arg5 as b2PolygonShape), _arg6));
};
return (0);
}
public static function ProcessTwo(_arg1:b2Vec2, _arg2:b2Vec2, _arg3:Array, _arg4:Array, _arg5:Array):int{
var _local9:b2Vec2;
var _local10:b2Vec2;
var _local11:b2Vec2;
var _local17:Number;
var _local6:b2Vec2 = _arg5[0];
var _local7:b2Vec2 = _arg5[1];
var _local8:b2Vec2 = _arg3[0];
_local9 = _arg3[1];
_local10 = _arg4[0];
_local11 = _arg4[1];
var _local12:Number = -(_local7.x);
var _local13:Number = -(_local7.y);
var _local14:Number = (_local6.x - _local7.x);
var _local15:Number = (_local6.y - _local7.y);
var _local16:Number = Math.sqrt(((_local14 * _local14) + (_local15 * _local15)));
_local14 = (_local14 / _local16);
_local15 = (_local15 / _local16);
_local17 = ((_local12 * _local14) + (_local13 * _local15));
if ((((_local17 <= 0)) || ((_local16 < Number.MIN_VALUE)))){
_arg1.SetV(_local9);
_arg2.SetV(_local11);
_local8.SetV(_local9);
_local10.SetV(_local11);
_local6.SetV(_local7);
return (1);
};
_local17 = (_local17 / _local16);
_arg1.x = (_local9.x + (_local17 * (_local8.x - _local9.x)));
_arg1.y = (_local9.y + (_local17 * (_local8.y - _local9.y)));
_arg2.x = (_local11.x + (_local17 * (_local10.x - _local11.x)));
_arg2.y = (_local11.y + (_local17 * (_local10.y - _local11.y)));
return (2);
}
}
}//package Box2D.Collision
Section 18
//b2Manifold (Box2D.Collision.b2Manifold)
package Box2D.Collision {
import Box2D.Common.Math.*;
import Box2D.Common.*;
public class b2Manifold {
public var pointCount:int;// = 0
public var normal:b2Vec2;
public var points:Array;
public function b2Manifold(){
points = new Array(b2Settings.b2_maxManifoldPoints);
var _local1:int;
while (_local1 < b2Settings.b2_maxManifoldPoints) {
points[_local1] = new b2ManifoldPoint();
_local1++;
};
normal = new b2Vec2();
}
public function Set(_arg1:b2Manifold):void{
pointCount = _arg1.pointCount;
var _local2:int;
while (_local2 < b2Settings.b2_maxManifoldPoints) {
(points[_local2] as b2ManifoldPoint).Set(_arg1.points[_local2]);
_local2++;
};
normal.SetV(_arg1.normal);
}
public function Reset():void{
var _local1:int;
while (_local1 < b2Settings.b2_maxManifoldPoints) {
(points[_local1] as b2ManifoldPoint).Reset();
_local1++;
};
normal.SetZero();
pointCount = 0;
}
}
}//package Box2D.Collision
Section 19
//b2ManifoldPoint (Box2D.Collision.b2ManifoldPoint)
package Box2D.Collision {
import Box2D.Common.Math.*;
public class b2ManifoldPoint {
public var separation:Number;
public var localPoint2:b2Vec2;
public var normalImpulse:Number;
public var tangentImpulse:Number;
public var localPoint1:b2Vec2;
public var id:b2ContactID;
public function b2ManifoldPoint(){
localPoint1 = new b2Vec2();
localPoint2 = new b2Vec2();
id = new b2ContactID();
super();
}
public function Set(_arg1:b2ManifoldPoint):void{
localPoint1.SetV(_arg1.localPoint1);
localPoint2.SetV(_arg1.localPoint2);
separation = _arg1.separation;
normalImpulse = _arg1.normalImpulse;
tangentImpulse = _arg1.tangentImpulse;
id.key = _arg1.id.key;
}
public function Reset():void{
localPoint1.SetZero();
localPoint2.SetZero();
separation = 0;
normalImpulse = 0;
tangentImpulse = 0;
id.key = 0;
}
}
}//package Box2D.Collision
Section 20
//b2OBB (Box2D.Collision.b2OBB)
package Box2D.Collision {
import Box2D.Common.Math.*;
public class b2OBB {
public var R:b2Mat22;
public var center:b2Vec2;
public var extents:b2Vec2;
public function b2OBB(){
R = new b2Mat22();
center = new b2Vec2();
extents = new b2Vec2();
super();
}
}
}//package Box2D.Collision
Section 21
//b2Pair (Box2D.Collision.b2Pair)
package Box2D.Collision {
import Box2D.Common.*;
public class b2Pair {
public var proxyId1:uint;
public var userData;// = null
public var proxyId2:uint;
public var status:uint;
public var next:uint;
public static var e_pairFinal:uint = 4;
public static var b2_tableMask:int = (b2_tableCapacity - 1);
public static var e_pairRemoved:uint = 2;
public static var b2_nullPair:uint = b2Settings.USHRT_MAX;
public static var e_pairBuffered:uint = 1;
public static var b2_nullProxy:uint = b2Settings.USHRT_MAX;
public static var b2_tableCapacity:int = b2Settings.b2_maxPairs;
public function SetBuffered():void{
status = (status | e_pairBuffered);
}
public function IsBuffered():Boolean{
return (((status & e_pairBuffered) == e_pairBuffered));
}
public function IsFinal():Boolean{
return (((status & e_pairFinal) == e_pairFinal));
}
public function ClearRemoved():void{
status = (status & ~(e_pairRemoved));
}
public function SetFinal():void{
status = (status | e_pairFinal);
}
public function IsRemoved():Boolean{
return (((status & e_pairRemoved) == e_pairRemoved));
}
public function ClearBuffered():void{
status = (status & ~(e_pairBuffered));
}
public function SetRemoved():void{
status = (status | e_pairRemoved);
}
}
}//package Box2D.Collision
Section 22
//b2PairCallback (Box2D.Collision.b2PairCallback)
package Box2D.Collision {
public class b2PairCallback {
public function PairRemoved(_arg1, _arg2, _arg3):void{
}
public function PairAdded(_arg1, _arg2){
return (null);
}
}
}//package Box2D.Collision
Section 23
//b2PairManager (Box2D.Collision.b2PairManager)
package Box2D.Collision {
import Box2D.Common.Math.*;
import Box2D.Common.*;
public class b2PairManager {
public var m_pairCount:int;
public var m_pairBuffer:Array;
public var m_hashTable:Array;
public var m_callback:b2PairCallback;
public var m_pairs:Array;
public var m_pairBufferCount:int;
public var m_broadPhase:b2BroadPhase;
public var m_freePair:uint;
public function b2PairManager(){
var _local1:uint;
super();
m_hashTable = new Array(b2Pair.b2_tableCapacity);
_local1 = 0;
while (_local1 < b2Pair.b2_tableCapacity) {
m_hashTable[_local1] = b2Pair.b2_nullPair;
_local1++;
};
m_pairs = new Array(b2Settings.b2_maxPairs);
_local1 = 0;
while (_local1 < b2Settings.b2_maxPairs) {
m_pairs[_local1] = new b2Pair();
_local1++;
};
m_pairBuffer = new Array(b2Settings.b2_maxPairs);
_local1 = 0;
while (_local1 < b2Settings.b2_maxPairs) {
m_pairBuffer[_local1] = new b2BufferedPair();
_local1++;
};
_local1 = 0;
while (_local1 < b2Settings.b2_maxPairs) {
m_pairs[_local1].proxyId1 = b2Pair.b2_nullProxy;
m_pairs[_local1].proxyId2 = b2Pair.b2_nullProxy;
m_pairs[_local1].userData = null;
m_pairs[_local1].status = 0;
m_pairs[_local1].next = (_local1 + 1);
_local1++;
};
m_pairs[int((b2Settings.b2_maxPairs - 1))].next = b2Pair.b2_nullPair;
m_pairCount = 0;
m_pairBufferCount = 0;
}
private function FindHash(_arg1:uint, _arg2:uint, _arg3:uint):b2Pair{
var _local4:b2Pair;
var _local5:uint = m_hashTable[_arg3];
_local4 = m_pairs[_local5];
while (((!((_local5 == b2Pair.b2_nullPair))) && ((Equals(_local4, _arg1, _arg2) == false)))) {
_local5 = _local4.next;
_local4 = m_pairs[_local5];
};
if (_local5 == b2Pair.b2_nullPair){
return (null);
};
return (_local4);
}
private function Find(_arg1:uint, _arg2:uint):b2Pair{
var _local4:uint;
if (_arg1 > _arg2){
_local4 = _arg1;
_arg1 = _arg2;
_arg2 = _local4;
};
var _local3:uint = (Hash(_arg1, _arg2) & b2Pair.b2_tableMask);
return (FindHash(_arg1, _arg2, _local3));
}
private function ValidateBuffer():void{
}
public function Commit():void{
var _local1:b2BufferedPair;
var _local2:int;
var _local5:b2Pair;
var _local6:b2Proxy;
var _local7:b2Proxy;
var _local3:int;
var _local4:Array = m_broadPhase.m_proxyPool;
_local2 = 0;
while (_local2 < m_pairBufferCount) {
_local1 = m_pairBuffer[_local2];
_local5 = Find(_local1.proxyId1, _local1.proxyId2);
_local5.ClearBuffered();
_local6 = _local4[_local5.proxyId1];
_local7 = _local4[_local5.proxyId2];
if (_local5.IsRemoved()){
if (_local5.IsFinal() == true){
m_callback.PairRemoved(_local6.userData, _local7.userData, _local5.userData);
};
_local1 = m_pairBuffer[_local3];
_local1.proxyId1 = _local5.proxyId1;
_local1.proxyId2 = _local5.proxyId2;
_local3++;
} else {
if (_local5.IsFinal() == false){
_local5.userData = m_callback.PairAdded(_local6.userData, _local7.userData);
_local5.SetFinal();
};
};
_local2++;
};
_local2 = 0;
while (_local2 < _local3) {
_local1 = m_pairBuffer[_local2];
RemovePair(_local1.proxyId1, _local1.proxyId2);
_local2++;
};
m_pairBufferCount = 0;
if (b2BroadPhase.s_validate){
ValidateTable();
};
}
public function RemoveBufferedPair(_arg1:int, _arg2:int):void{
var _local3:b2BufferedPair;
var _local4:b2Pair = Find(_arg1, _arg2);
if (_local4 == null){
return;
};
if (_local4.IsBuffered() == false){
_local4.SetBuffered();
_local3 = m_pairBuffer[m_pairBufferCount];
_local3.proxyId1 = _local4.proxyId1;
_local3.proxyId2 = _local4.proxyId2;
m_pairBufferCount++;
};
_local4.SetRemoved();
if (b2BroadPhase.s_validate){
ValidateBuffer();
};
}
private function RemovePair(_arg1:uint, _arg2:uint){
var _local3:b2Pair;
var _local7:uint;
var _local8:uint;
var _local9:*;
if (_arg1 > _arg2){
_local7 = _arg1;
_arg1 = _arg2;
_arg2 = _local7;
};
var _local4:uint = (Hash(_arg1, _arg2) & b2Pair.b2_tableMask);
var _local5:uint = m_hashTable[_local4];
var _local6:b2Pair;
while (_local5 != b2Pair.b2_nullPair) {
if (Equals(m_pairs[_local5], _arg1, _arg2)){
_local8 = _local5;
_local3 = m_pairs[_local5];
if (_local6){
_local6.next = _local3.next;
} else {
m_hashTable[_local4] = _local3.next;
};
_local3 = m_pairs[_local8];
_local9 = _local3.userData;
_local3.next = m_freePair;
_local3.proxyId1 = b2Pair.b2_nullProxy;
_local3.proxyId2 = b2Pair.b2_nullProxy;
_local3.userData = null;
_local3.status = 0;
m_freePair = _local8;
m_pairCount--;
return (_local9);
} else {
_local6 = m_pairs[_local5];
_local5 = _local6.next;
};
};
return (null);
}
public function Initialize(_arg1:b2BroadPhase, _arg2:b2PairCallback):void{
m_broadPhase = _arg1;
m_callback = _arg2;
}
public function AddBufferedPair(_arg1:int, _arg2:int):void{
var _local3:b2BufferedPair;
var _local4:b2Pair = AddPair(_arg1, _arg2);
if (_local4.IsBuffered() == false){
_local4.SetBuffered();
_local3 = m_pairBuffer[m_pairBufferCount];
_local3.proxyId1 = _local4.proxyId1;
_local3.proxyId2 = _local4.proxyId2;
m_pairBufferCount++;
};
_local4.ClearRemoved();
if (b2BroadPhase.s_validate){
ValidateBuffer();
};
}
private function AddPair(_arg1:uint, _arg2:uint):b2Pair{
var _local6:uint;
if (_arg1 > _arg2){
_local6 = _arg1;
_arg1 = _arg2;
_arg2 = _local6;
};
var _local3:uint = (Hash(_arg1, _arg2) & b2Pair.b2_tableMask);
var _local4 = FindHash(_arg1, _arg2, _local3);
if (_local4 != null){
return (_local4);
};
var _local5:uint = m_freePair;
_local4 = m_pairs[_local5];
m_freePair = _local4.next;
_local4.proxyId1 = _arg1;
_local4.proxyId2 = _arg2;
_local4.status = 0;
_local4.userData = null;
_local4.next = m_hashTable[_local3];
m_hashTable[_local3] = _local5;
m_pairCount++;
return (_local4);
}
private function ValidateTable():void{
}
public static function EqualsPair(_arg1:b2BufferedPair, _arg2:b2BufferedPair):Boolean{
return ((((_arg1.proxyId1 == _arg2.proxyId1)) && ((_arg1.proxyId2 == _arg2.proxyId2))));
}
public static function Hash(_arg1:uint, _arg2:uint):uint{
var _local3:uint = (((_arg2 << 16) & 4294901760) | _arg1);
_local3 = (~(_local3) + ((_local3 << 15) & 4294934528));
_local3 = (_local3 ^ ((_local3 >> 12) & 1048575));
_local3 = (_local3 + ((_local3 << 2) & 4294967292));
_local3 = (_local3 ^ ((_local3 >> 4) & 268435455));
_local3 = (_local3 * 2057);
_local3 = (_local3 ^ ((_local3 >> 16) & 0xFFFF));
return (_local3);
}
public static function Equals(_arg1:b2Pair, _arg2:uint, _arg3:uint):Boolean{
return ((((_arg1.proxyId1 == _arg2)) && ((_arg1.proxyId2 == _arg3))));
}
}
}//package Box2D.Collision
Section 24
//b2Point (Box2D.Collision.b2Point)
package Box2D.Collision {
import Box2D.Common.Math.*;
public class b2Point {
public var p:b2Vec2;
public function b2Point(){
p = new b2Vec2();
super();
}
public function GetFirstVertex(_arg1:b2XForm):b2Vec2{
return (p);
}
public function Support(_arg1:b2XForm, _arg2:Number, _arg3:Number):b2Vec2{
return (p);
}
}
}//package Box2D.Collision
Section 25
//b2Proxy (Box2D.Collision.b2Proxy)
package Box2D.Collision {
public class b2Proxy {
public var overlapCount:uint;
public var userData;// = null
public var lowerBounds:Array;
public var upperBounds:Array;
public var timeStamp:uint;
public function b2Proxy(){
lowerBounds = [uint(0), uint(0)];
upperBounds = [uint(0), uint(0)];
super();
}
public function GetNext():uint{
return (lowerBounds[0]);
}
public function IsValid():Boolean{
return (!((overlapCount == b2BroadPhase.b2_invalid)));
}
public function SetNext(_arg1:uint):void{
lowerBounds[0] = (_arg1 & 0xFFFF);
}
}
}//package Box2D.Collision
Section 26
//b2Segment (Box2D.Collision.b2Segment)
package Box2D.Collision {
import Box2D.Common.Math.*;
import Box2D.Common.*;
public class b2Segment {
public var p1:b2Vec2;
public var p2:b2Vec2;
public function b2Segment(){
p1 = new b2Vec2();
p2 = new b2Vec2();
super();
}
public function TestSegment(_arg1:Array, _arg2:b2Vec2, _arg3:b2Segment, _arg4:Number):Boolean{
var _local14:Number;
var _local15:Number;
var _local16:Number;
var _local17:Number;
var _local18:Number;
var _local5:b2Vec2 = _arg3.p1;
var _local6:Number = (_arg3.p2.x - _local5.x);
var _local7:Number = (_arg3.p2.y - _local5.y);
var _local8:Number = (p2.x - p1.x);
var _local9:Number = (p2.y - p1.y);
var _local10:Number = _local9;
var _local11:Number = -(_local8);
var _local12:Number = (100 * Number.MIN_VALUE);
var _local13:Number = -(((_local6 * _local10) + (_local7 * _local11)));
if (_local13 > _local12){
_local14 = (_local5.x - p1.x);
_local15 = (_local5.y - p1.y);
_local16 = ((_local14 * _local10) + (_local15 * _local11));
if ((((0 <= _local16)) && ((_local16 <= (_arg4 * _local13))))){
_local17 = ((-(_local7) * _local15) + (_local7 * _local14));
if (((((-(_local12) * _local13) <= _local17)) && ((_local17 <= (_local13 * (1 + _local12)))))){
_local16 = (_local16 / _local13);
_local18 = Math.sqrt(((_local10 * _local10) + (_local11 * _local11)));
_local10 = (_local10 / _local18);
_local11 = (_local11 / _local18);
_arg1[0] = _local16;
_arg2.Set(_local10, _local11);
return (true);
};
};
};
return (false);
}
public function Extend(_arg1:b2AABB):void{
ExtendForward(_arg1);
ExtendBackward(_arg1);
}
public function ExtendForward(_arg1:b2AABB):void{
var aabb = _arg1;
var dX:Number = (p2.x - p1.x);
var dY:Number = (p2.y - p1.y);
var greaterthan0:* = function (_arg1){
return ((_arg1 > 0));
};
var lambda:Number = Math.min(((dX > 0)) ? ((aabb.upperBound.x - p1.x) / dX) : ((dX < 0)) ? ((aabb.lowerBound.x - p1.x) / dX) : Number.POSITIVE_INFINITY, ((dY > 0)) ? ((aabb.upperBound.y - p1.y) / dY) : ((dY < 0)) ? ((aabb.lowerBound.y - p1.y) / dY) : Number.POSITIVE_INFINITY);
p2.x = (p1.x + (dX * lambda));
p2.y = (p1.y + (dY * lambda));
}
public function ExtendBackward(_arg1:b2AABB):void{
var dY:Number;
var lambda:Number;
var aabb = _arg1;
var dX:Number = (-(p2.x) + p1.x);
dY = (-(p2.y) + p1.y);
var greaterthan0:* = function (_arg1){
return ((_arg1 > 0));
};
lambda = Math.min(((dX > 0)) ? ((aabb.upperBound.x - p2.x) / dX) : ((dX < 0)) ? ((aabb.lowerBound.x - p2.x) / dX) : Number.POSITIVE_INFINITY, ((dY > 0)) ? ((aabb.upperBound.y - p2.y) / dY) : ((dY < 0)) ? ((aabb.lowerBound.y - p2.y) / dY) : Number.POSITIVE_INFINITY);
p1.x = (p2.x + (dX * lambda));
p1.y = (p2.y + (dY * lambda));
}
}
}//package Box2D.Collision
Section 27
//b2TimeOfImpact (Box2D.Collision.b2TimeOfImpact)
package Box2D.Collision {
import Box2D.Common.Math.*;
import Box2D.Collision.Shapes.*;
import Box2D.Common.*;
public class b2TimeOfImpact {
public static var s_xf1:b2XForm = new b2XForm();
public static var s_xf2:b2XForm = new b2XForm();
public static var s_p1:b2Vec2 = new b2Vec2();
public static var s_p2:b2Vec2 = new b2Vec2();
public static function TimeOfImpact(_arg1:b2Shape, _arg2:b2Sweep, _arg3:b2Shape, _arg4:b2Sweep):Number{
var _local5:Number;
var _local6:Number;
var _local25:Number;
var _local26:b2XForm;
var _local27:b2XForm;
var _local28:Number;
var _local29:Number;
var _local30:Number;
var _local31:Number;
var _local7:Number = _arg1.m_sweepRadius;
var _local8:Number = _arg3.m_sweepRadius;
var _local9:Number = _arg2.t0;
var _local10:Number = (_arg2.c.x - _arg2.c0.x);
var _local11:Number = (_arg2.c.y - _arg2.c0.y);
var _local12:Number = (_arg4.c.x - _arg4.c0.x);
var _local13:Number = (_arg4.c.y - _arg4.c0.y);
var _local14:Number = (_arg2.a - _arg2.a0);
var _local15:Number = (_arg4.a - _arg4.a0);
var _local16:Number = 0;
var _local17:b2Vec2 = s_p1;
var _local18:b2Vec2 = s_p2;
var _local19 = 20;
var _local20:int;
var _local21:Number = 0;
var _local22:Number = 0;
var _local23:Number = 0;
var _local24:Number = 0;
while (true) {
_local25 = (((1 - _local16) * _local9) + _local16);
_local26 = s_xf1;
_local27 = s_xf2;
_arg2.GetXForm(_local26, _local25);
_arg4.GetXForm(_local27, _local25);
_local23 = b2Distance.Distance(_local17, _local18, _arg1, _local26, _arg3, _local27);
if (_local20 == 0){
if (_local23 > (2 * b2Settings.b2_toiSlop)){
_local24 = (1.5 * b2Settings.b2_toiSlop);
} else {
_local5 = (0.05 * b2Settings.b2_toiSlop);
_local6 = (_local23 - (0.5 * b2Settings.b2_toiSlop));
_local24 = ((_local5 > _local6)) ? _local5 : _local6;
};
};
if (((((_local23 - _local24) < (0.05 * b2Settings.b2_toiSlop))) || ((_local20 == _local19)))){
break;
};
_local21 = (_local18.x - _local17.x);
_local22 = (_local18.y - _local17.y);
_local28 = Math.sqrt(((_local21 * _local21) + (_local22 * _local22)));
_local21 = (_local21 / _local28);
_local22 = (_local22 / _local28);
_local29 = ((((_local21 * (_local10 - _local12)) + (_local22 * (_local11 - _local13))) + (((_local14 < 0)) ? -(_local14) : _local14 * _local7)) + (((_local15 < 0)) ? -(_local15) : _local15 * _local8));
if (_local29 == 0){
_local16 = 1;
break;
};
_local30 = ((_local23 - _local24) / _local29);
_local31 = (_local16 + _local30);
if ((((_local31 < 0)) || ((1 < _local31)))){
_local16 = 1;
break;
};
if (_local31 < ((1 + (100 * Number.MIN_VALUE)) * _local16)){
break;
};
_local16 = _local31;
_local20++;
};
return (_local16);
}
}
}//package Box2D.Collision
Section 28
//ClipVertex (Box2D.Collision.ClipVertex)
package Box2D.Collision {
import Box2D.Common.Math.*;
public class ClipVertex {
public var id:b2ContactID;
public var v:b2Vec2;
public function ClipVertex(){
v = new b2Vec2();
id = new b2ContactID();
super();
}
}
}//package Box2D.Collision
Section 29
//Features (Box2D.Collision.Features)
package Box2D.Collision {
public class Features {
public var _referenceEdge:int;
public var _incidentEdge:int;
public var _flip:int;
public var _incidentVertex:int;
public var _m_id:b2ContactID;
public function get referenceEdge():int{
return (_referenceEdge);
}
public function set incidentVertex(_arg1:int):void{
_incidentVertex = _arg1;
_m_id._key = ((_m_id._key & 4278255615) | ((_incidentVertex << 16) & 0xFF0000));
}
public function get flip():int{
return (_flip);
}
public function get incidentEdge():int{
return (_incidentEdge);
}
public function set referenceEdge(_arg1:int):void{
_referenceEdge = _arg1;
_m_id._key = ((_m_id._key & 4294967040) | (_referenceEdge & 0xFF));
}
public function get incidentVertex():int{
return (_incidentVertex);
}
public function set flip(_arg1:int):void{
_flip = _arg1;
_m_id._key = ((_m_id._key & 0xFFFFFF) | ((_flip << 24) & 4278190080));
}
public function set incidentEdge(_arg1:int):void{
_incidentEdge = _arg1;
_m_id._key = ((_m_id._key & 4294902015) | ((_incidentEdge << 8) & 0xFF00));
}
}
}//package Box2D.Collision
Section 30
//b2Mat22 (Box2D.Common.Math.b2Mat22)
package Box2D.Common.Math {
public class b2Mat22 {
public var col1:b2Vec2;
public var col2:b2Vec2;
public function b2Mat22(_arg1:Number=0, _arg2:b2Vec2=null, _arg3:b2Vec2=null){
var _local4:Number;
var _local5:Number;
col1 = new b2Vec2();
col2 = new b2Vec2();
super();
if (((!((_arg2 == null))) && (!((_arg3 == null))))){
col1.SetV(_arg2);
col2.SetV(_arg3);
} else {
_local4 = Math.cos(_arg1);
_local5 = Math.sin(_arg1);
col1.x = _local4;
col2.x = -(_local5);
col1.y = _local5;
col2.y = _local4;
};
}
public function SetIdentity():void{
col1.x = 1;
col2.x = 0;
col1.y = 0;
col2.y = 1;
}
public function SetVV(_arg1:b2Vec2, _arg2:b2Vec2):void{
col1.SetV(_arg1);
col2.SetV(_arg2);
}
public function Set(_arg1:Number):void{
var _local2:Number;
_local2 = Math.cos(_arg1);
var _local3:Number = Math.sin(_arg1);
col1.x = _local2;
col2.x = -(_local3);
col1.y = _local3;
col2.y = _local2;
}
public function SetZero():void{
col1.x = 0;
col2.x = 0;
col1.y = 0;
col2.y = 0;
}
public function SetM(_arg1:b2Mat22):void{
col1.SetV(_arg1.col1);
col2.SetV(_arg1.col2);
}
public function AddM(_arg1:b2Mat22):void{
col1.x = (col1.x + _arg1.col1.x);
col1.y = (col1.y + _arg1.col1.y);
col2.x = (col2.x + _arg1.col2.x);
col2.y = (col2.y + _arg1.col2.y);
}
public function Abs():void{
col1.Abs();
col2.Abs();
}
public function Copy():b2Mat22{
return (new b2Mat22(0, col1, col2));
}
public function Invert(_arg1:b2Mat22):b2Mat22{
var _local2:Number;
var _local4:Number;
var _local6:Number;
_local2 = col1.x;
var _local3:Number = col2.x;
_local4 = col1.y;
var _local5:Number = col2.y;
_local6 = ((_local2 * _local5) - (_local3 * _local4));
_local6 = (1 / _local6);
_arg1.col1.x = (_local6 * _local5);
_arg1.col2.x = (-(_local6) * _local3);
_arg1.col1.y = (-(_local6) * _local4);
_arg1.col2.y = (_local6 * _local2);
return (_arg1);
}
public function GetAngle():Number{
return (Math.atan2(col1.y, col1.x));
}
public function Solve(_arg1:b2Vec2, _arg2:Number, _arg3:Number):b2Vec2{
var _local4:Number = col1.x;
var _local5:Number = col2.x;
var _local6:Number = col1.y;
var _local7:Number = col2.y;
var _local8:Number = ((_local4 * _local7) - (_local5 * _local6));
_local8 = (1 / _local8);
_arg1.x = (_local8 * ((_local7 * _arg2) - (_local5 * _arg3)));
_arg1.y = (_local8 * ((_local4 * _arg3) - (_local6 * _arg2)));
return (_arg1);
}
}
}//package Box2D.Common.Math
Section 31
//b2Math (Box2D.Common.Math.b2Math)
package Box2D.Common.Math {
public class b2Math {
public static const b2Mat22_identity:b2Mat22 = new b2Mat22(0, new b2Vec2(1, 0), new b2Vec2(0, 1));
public static const b2XForm_identity:b2XForm = new b2XForm(b2Vec2_zero, b2Mat22_identity);
public static const b2Vec2_zero:b2Vec2 = new b2Vec2(0, 0);
public static function b2CrossVF(_arg1:b2Vec2, _arg2:Number):b2Vec2{
var _local3:b2Vec2 = new b2Vec2((_arg2 * _arg1.y), (-(_arg2) * _arg1.x));
return (_local3);
}
public static function AddVV(_arg1:b2Vec2, _arg2:b2Vec2):b2Vec2{
var _local3:b2Vec2 = new b2Vec2((_arg1.x + _arg2.x), (_arg1.y + _arg2.y));
return (_local3);
}
public static function b2IsValid(_arg1:Number):Boolean{
return (isFinite(_arg1));
}
public static function b2MinV(_arg1:b2Vec2, _arg2:b2Vec2):b2Vec2{
var _local3:b2Vec2 = new b2Vec2(b2Min(_arg1.x, _arg2.x), b2Min(_arg1.y, _arg2.y));
return (_local3);
}
public static function b2MulX(_arg1:b2XForm, _arg2:b2Vec2):b2Vec2{
var _local3:b2Vec2;
_local3 = b2MulMV(_arg1.R, _arg2);
_local3.x = (_local3.x + _arg1.position.x);
_local3.y = (_local3.y + _arg1.position.y);
return (_local3);
}
public static function b2DistanceSquared(_arg1:b2Vec2, _arg2:b2Vec2):Number{
var _local3:Number = (_arg1.x - _arg2.x);
var _local4:Number = (_arg1.y - _arg2.y);
return (((_local3 * _local3) + (_local4 * _local4)));
}
public static function b2Swap(_arg1:Array, _arg2:Array):void{
var _local3:* = _arg1[0];
_arg1[0] = _arg2[0];
_arg2[0] = _local3;
}
public static function b2AbsM(_arg1:b2Mat22):b2Mat22{
var _local2:b2Mat22 = new b2Mat22(0, b2AbsV(_arg1.col1), b2AbsV(_arg1.col2));
return (_local2);
}
public static function SubtractVV(_arg1:b2Vec2, _arg2:b2Vec2):b2Vec2{
var _local3:b2Vec2 = new b2Vec2((_arg1.x - _arg2.x), (_arg1.y - _arg2.y));
return (_local3);
}
public static function b2MulXT(_arg1:b2XForm, _arg2:b2Vec2):b2Vec2{
var _local3:b2Vec2;
var _local4:Number;
_local3 = SubtractVV(_arg2, _arg1.position);
_local4 = ((_local3.x * _arg1.R.col1.x) + (_local3.y * _arg1.R.col1.y));
_local3.y = ((_local3.x * _arg1.R.col2.x) + (_local3.y * _arg1.R.col2.y));
_local3.x = _local4;
return (_local3);
}
public static function b2Abs(_arg1:Number):Number{
return (((_arg1 > 0)) ? _arg1 : -(_arg1));
}
public static function b2Clamp(_arg1:Number, _arg2:Number, _arg3:Number):Number{
return (b2Max(_arg2, b2Min(_arg1, _arg3)));
}
public static function b2AbsV(_arg1:b2Vec2):b2Vec2{
var _local2:b2Vec2 = new b2Vec2(b2Abs(_arg1.x), b2Abs(_arg1.y));
return (_local2);
}
public static function MulFV(_arg1:Number, _arg2:b2Vec2):b2Vec2{
var _local3:b2Vec2 = new b2Vec2((_arg1 * _arg2.x), (_arg1 * _arg2.y));
return (_local3);
}
public static function b2CrossVV(_arg1:b2Vec2, _arg2:b2Vec2):Number{
return (((_arg1.x * _arg2.y) - (_arg1.y * _arg2.x)));
}
public static function b2Dot(_arg1:b2Vec2, _arg2:b2Vec2):Number{
return (((_arg1.x * _arg2.x) + (_arg1.y * _arg2.y)));
}
public static function b2CrossFV(_arg1:Number, _arg2:b2Vec2):b2Vec2{
var _local3:b2Vec2 = new b2Vec2((-(_arg1) * _arg2.y), (_arg1 * _arg2.x));
return (_local3);
}
public static function AddMM(_arg1:b2Mat22, _arg2:b2Mat22):b2Mat22{
var _local3:b2Mat22 = new b2Mat22(0, AddVV(_arg1.col1, _arg2.col1), AddVV(_arg1.col2, _arg2.col2));
return (_local3);
}
public static function b2Distance(_arg1:b2Vec2, _arg2:b2Vec2):Number{
var _local3:Number = (_arg1.x - _arg2.x);
var _local4:Number = (_arg1.y - _arg2.y);
return (Math.sqrt(((_local3 * _local3) + (_local4 * _local4))));
}
public static function b2MulTMM(_arg1:b2Mat22, _arg2:b2Mat22):b2Mat22{
var _local3:b2Vec2 = new b2Vec2(b2Dot(_arg1.col1, _arg2.col1), b2Dot(_arg1.col2, _arg2.col1));
var _local4:b2Vec2 = new b2Vec2(b2Dot(_arg1.col1, _arg2.col2), b2Dot(_arg1.col2, _arg2.col2));
var _local5:b2Mat22 = new b2Mat22(0, _local3, _local4);
return (_local5);
}
public static function b2MaxV(_arg1:b2Vec2, _arg2:b2Vec2):b2Vec2{
var _local3:b2Vec2 = new b2Vec2(b2Max(_arg1.x, _arg2.x), b2Max(_arg1.y, _arg2.y));
return (_local3);
}
public static function b2IsPowerOfTwo(_arg1:uint):Boolean{
var _local2:Boolean = (((_arg1 > 0)) && (((_arg1 & (_arg1 - 1)) == 0)));
return (_local2);
}
public static function b2ClampV(_arg1:b2Vec2, _arg2:b2Vec2, _arg3:b2Vec2):b2Vec2{
return (b2MaxV(_arg2, b2MinV(_arg1, _arg3)));
}
public static function b2RandomRange(_arg1:Number, _arg2:Number):Number{
var _local3:Number = Math.random();
_local3 = (((_arg2 - _arg1) * _local3) + _arg1);
return (_local3);
}
public static function b2MulTMV(_arg1:b2Mat22, _arg2:b2Vec2):b2Vec2{
var _local3:b2Vec2 = new b2Vec2(b2Dot(_arg2, _arg1.col1), b2Dot(_arg2, _arg1.col2));
return (_local3);
}
public static function b2Min(_arg1:Number, _arg2:Number):Number{
return (((_arg1 < _arg2)) ? _arg1 : _arg2);
}
public static function b2Random():Number{
return (((Math.random() * 2) - 1));
}
public static function b2MulMM(_arg1:b2Mat22, _arg2:b2Mat22):b2Mat22{
var _local3:b2Mat22 = new b2Mat22(0, b2MulMV(_arg1, _arg2.col1), b2MulMV(_arg1, _arg2.col2));
return (_local3);
}
public static function b2NextPowerOfTwo(_arg1:uint):uint{
_arg1 = (_arg1 | ((_arg1 >> 1) & 2147483647));
_arg1 = (_arg1 | ((_arg1 >> 2) & 1073741823));
_arg1 = (_arg1 | ((_arg1 >> 4) & 268435455));
_arg1 = (_arg1 | ((_arg1 >> 8) & 0xFFFFFF));
_arg1 = (_arg1 | ((_arg1 >> 16) & 0xFFFF));
return ((_arg1 + 1));
}
public static function b2Max(_arg1:Number, _arg2:Number):Number{
return (((_arg1 > _arg2)) ? _arg1 : _arg2);
}
public static function b2MulMV(_arg1:b2Mat22, _arg2:b2Vec2):b2Vec2{
var _local3:b2Vec2 = new b2Vec2(((_arg1.col1.x * _arg2.x) + (_arg1.col2.x * _arg2.y)), ((_arg1.col1.y * _arg2.x) + (_arg1.col2.y * _arg2.y)));
return (_local3);
}
}
}//package Box2D.Common.Math
Section 32
//b2Sweep (Box2D.Common.Math.b2Sweep)
package Box2D.Common.Math {
public class b2Sweep {
public var localCenter:b2Vec2;
public var a:Number;
public var c:b2Vec2;
public var a0:Number;
public var c0:b2Vec2;
public var t0:Number;
public function b2Sweep(){
localCenter = new b2Vec2();
c0 = new b2Vec2();
c = new b2Vec2();
super();
}
public function Advance(_arg1:Number):void{
var _local2:Number;
if ((((t0 < _arg1)) && (((1 - t0) > Number.MIN_VALUE)))){
_local2 = ((_arg1 - t0) / (1 - t0));
c0.x = (((1 - _local2) * c0.x) + (_local2 * c.x));
c0.y = (((1 - _local2) * c0.y) + (_local2 * c.y));
a0 = (((1 - _local2) * a0) + (_local2 * a));
t0 = _arg1;
};
}
public function GetXForm(_arg1:b2XForm, _arg2:Number):void{
var _local4:Number;
var _local5:Number;
if ((1 - t0) > Number.MIN_VALUE){
_local4 = ((_arg2 - t0) / (1 - t0));
_arg1.position.x = (((1 - _local4) * c0.x) + (_local4 * c.x));
_arg1.position.y = (((1 - _local4) * c0.y) + (_local4 * c.y));
_local5 = (((1 - _local4) * a0) + (_local4 * a));
_arg1.R.Set(_local5);
} else {
_arg1.position.SetV(c);
_arg1.R.Set(a);
};
var _local3:b2Mat22 = _arg1.R;
_arg1.position.x = (_arg1.position.x - ((_local3.col1.x * localCenter.x) + (_local3.col2.x * localCenter.y)));
_arg1.position.y = (_arg1.position.y - ((_local3.col1.y * localCenter.x) + (_local3.col2.y * localCenter.y)));
}
}
}//package Box2D.Common.Math
Section 33
//b2Vec2 (Box2D.Common.Math.b2Vec2)
package Box2D.Common.Math {
public class b2Vec2 {
public var y:Number;
public var x:Number;
public function b2Vec2(_arg1:Number=0, _arg2:Number=0):void{
x = _arg1;
y = _arg2;
}
public function Add(_arg1:b2Vec2):void{
x = (x + _arg1.x);
y = (y + _arg1.y);
}
public function Set(_arg1:Number=0, _arg2:Number=0):void{
x = _arg1;
y = _arg2;
}
public function Multiply(_arg1:Number):void{
x = (x * _arg1);
y = (y * _arg1);
}
public function Length():Number{
return (Math.sqrt(((x * x) + (y * y))));
}
public function LengthSquared():Number{
return (((x * x) + (y * y)));
}
public function MulM(_arg1:b2Mat22):void{
var _local2:Number = x;
x = ((_arg1.col1.x * _local2) + (_arg1.col2.x * y));
y = ((_arg1.col1.y * _local2) + (_arg1.col2.y * y));
}
public function SetZero():void{
x = 0;
y = 0;
}
public function MinV(_arg1:b2Vec2):void{
x = ((x < _arg1.x)) ? x : _arg1.x;
y = ((y < _arg1.y)) ? y : _arg1.y;
}
public function Normalize():Number{
var _local1:Number = Math.sqrt(((x * x) + (y * y)));
if (_local1 < Number.MIN_VALUE){
return (0);
};
var _local2:Number = (1 / _local1);
x = (x * _local2);
y = (y * _local2);
return (_local1);
}
public function CrossVF(_arg1:Number):void{
var _local2:Number = x;
x = (_arg1 * y);
y = (-(_arg1) * _local2);
}
public function MaxV(_arg1:b2Vec2):void{
x = ((x > _arg1.x)) ? x : _arg1.x;
y = ((y > _arg1.y)) ? y : _arg1.y;
}
public function SetV(_arg1:b2Vec2):void{
x = _arg1.x;
y = _arg1.y;
}
public function Negative():b2Vec2{
return (new b2Vec2(-(x), -(y)));
}
public function CrossFV(_arg1:Number):void{
var _local2:Number = x;
x = (-(_arg1) * y);
y = (_arg1 * _local2);
}
public function Abs():void{
if (x < 0){
x = -(x);
};
if (y < 0){
y = -(y);
};
}
public function Subtract(_arg1:b2Vec2):void{
x = (x - _arg1.x);
y = (y - _arg1.y);
}
public function Copy():b2Vec2{
return (new b2Vec2(x, y));
}
public function MulTM(_arg1:b2Mat22):void{
var _local2:Number = b2Math.b2Dot(this, _arg1.col1);
y = b2Math.b2Dot(this, _arg1.col2);
x = _local2;
}
public function IsValid():Boolean{
return (((b2Math.b2IsValid(x)) && (b2Math.b2IsValid(y))));
}
public static function Make(_arg1:Number, _arg2:Number):b2Vec2{
return (new b2Vec2(_arg1, _arg2));
}
}
}//package Box2D.Common.Math
Section 34
//b2XForm (Box2D.Common.Math.b2XForm)
package Box2D.Common.Math {
public class b2XForm {
public var position:b2Vec2;
public var R:b2Mat22;
public function b2XForm(_arg1:b2Vec2=null, _arg2:b2Mat22=null):void{
position = new b2Vec2();
R = new b2Mat22();
super();
if (_arg1){
position.SetV(_arg1);
R.SetM(_arg2);
};
}
public function Initialize(_arg1:b2Vec2, _arg2:b2Mat22):void{
position.SetV(_arg1);
R.SetM(_arg2);
}
public function Set(_arg1:b2XForm):void{
position.SetV(_arg1.position);
R.SetM(_arg1.R);
}
public function SetIdentity():void{
position.SetZero();
R.SetIdentity();
}
}
}//package Box2D.Common.Math
Section 35
//b2Color (Box2D.Common.b2Color)
package Box2D.Common {
import Box2D.Common.Math.*;
public class b2Color {
private var _r:uint;// = 0
private var _g:uint;// = 0
private var _b:uint;// = 0
public function b2Color(_arg1:Number, _arg2:Number, _arg3:Number){
_r = uint((0xFF * b2Math.b2Clamp(_arg1, 0, 1)));
_g = uint((0xFF * b2Math.b2Clamp(_arg2, 0, 1)));
_b = uint((0xFF * b2Math.b2Clamp(_arg3, 0, 1)));
}
public function Set(_arg1:Number, _arg2:Number, _arg3:Number):void{
_r = uint((0xFF * b2Math.b2Clamp(_arg1, 0, 1)));
_g = uint((0xFF * b2Math.b2Clamp(_arg2, 0, 1)));
_b = uint((0xFF * b2Math.b2Clamp(_arg3, 0, 1)));
}
public function set b(_arg1:Number):void{
_b = uint((0xFF * b2Math.b2Clamp(_arg1, 0, 1)));
}
public function get color():uint{
return (((_r | (_g << 8)) | (_b << 16)));
}
public function set r(_arg1:Number):void{
_r = uint((0xFF * b2Math.b2Clamp(_arg1, 0, 1)));
}
public function set g(_arg1:Number):void{
_g = uint((0xFF * b2Math.b2Clamp(_arg1, 0, 1)));
}
}
}//package Box2D.Common
Section 36
//b2Settings (Box2D.Common.b2Settings)
package Box2D.Common {
import Box2D.Common.Math.*;
public class b2Settings {
public static const b2_angularSleepTolerance:Number = 0.0111111111111111;
public static const b2_linearSleepTolerance:Number = 0.01;
public static const b2_angularSlop:Number = 0.0349065850398866;
public static const b2_linearSlop:Number = 0.005;
public static const b2_pi:Number = 3.14159265358979;
public static const b2_maxProxies:int = 0x0400;
public static const b2_maxAngularVelocitySquared:Number = 62500;
public static const b2_maxPolygonVertices:int = 16;
public static const b2_velocityThreshold:Number = 1;
public static const b2_contactBaumgarte:Number = 0.2;
public static const b2_maxPairs:int = 8192;
public static const b2_maxTOIContactsPerIsland:int = 32;
public static const b2_timeToSleep:Number = 0.5;
public static const b2_maxManifoldPoints:int = 2;
public static const b2_maxAngularVelocity:Number = 250;
public static const b2_maxAngularCorrection:Number = 0.139626340159546;
public static const USHRT_MAX:int = 0xFFFF;
public static const b2_maxLinearVelocity:Number = 200;
public static const b2_maxLinearCorrection:Number = 0.2;
public static const b2_toiSlop:Number = 0.04;
public static const b2_maxLinearVelocitySquared:Number = 40000;
public static function b2Assert(_arg1:Boolean):void{
var _local2:b2Vec2;
if (!_arg1){
_local2.x++;
};
}
}
}//package Box2D.Common
Section 37
//b2CircleContact (Box2D.Dynamics.Contacts.b2CircleContact)
package Box2D.Dynamics.Contacts {
import Box2D.Common.Math.*;
import Box2D.Collision.*;
import Box2D.Dynamics.*;
import Box2D.Collision.Shapes.*;
import Box2D.Common.*;
public class b2CircleContact extends b2Contact {
private var m_manifolds:Array;
public var m_manifold:b2Manifold;
private var m0:b2Manifold;
private static const s_evalCP:b2ContactPoint = new b2ContactPoint();
public function b2CircleContact(_arg1:b2Shape, _arg2:b2Shape){
m_manifolds = [new b2Manifold()];
m0 = new b2Manifold();
super(_arg1, _arg2);
m_manifold = m_manifolds[0];
m_manifold.pointCount = 0;
var _local3:b2ManifoldPoint = m_manifold.points[0];
_local3.normalImpulse = 0;
_local3.tangentImpulse = 0;
}
override public function Evaluate(_arg1:b2ContactListener):void{
var _local2:b2Vec2;
var _local3:b2Vec2;
var _local4:b2ManifoldPoint;
var _local8:b2ManifoldPoint;
var _local5:b2Body = m_shape1.m_body;
var _local6:b2Body = m_shape2.m_body;
m0.Set(m_manifold);
b2Collision.b2CollideCircles(m_manifold, (m_shape1 as b2CircleShape), _local5.m_xf, (m_shape2 as b2CircleShape), _local6.m_xf);
var _local7:b2ContactPoint = s_evalCP;
_local7.shape1 = m_shape1;
_local7.shape2 = m_shape2;
_local7.friction = m_friction;
_local7.restitution = m_restitution;
if (m_manifold.pointCount > 0){
m_manifoldCount = 1;
_local8 = m_manifold.points[0];
if (m0.pointCount == 0){
_local8.normalImpulse = 0;
_local8.tangentImpulse = 0;
if (_arg1){
_local7.position = _local5.GetWorldPoint(_local8.localPoint1);
_local2 = _local5.GetLinearVelocityFromLocalPoint(_local8.localPoint1);
_local3 = _local6.GetLinearVelocityFromLocalPoint(_local8.localPoint2);
_local7.velocity.Set((_local3.x - _local2.x), (_local3.y - _local2.y));
_local7.normal.SetV(m_manifold.normal);
_local7.separation = _local8.separation;
_local7.id.key = _local8.id._key;
_arg1.Add(_local7);
};
} else {
_local4 = m0.points[0];
_local8.normalImpulse = _local4.normalImpulse;
_local8.tangentImpulse = _local4.tangentImpulse;
if (_arg1){
_local7.position = _local5.GetWorldPoint(_local8.localPoint1);
_local2 = _local5.GetLinearVelocityFromLocalPoint(_local8.localPoint1);
_local3 = _local6.GetLinearVelocityFromLocalPoint(_local8.localPoint2);
_local7.velocity.Set((_local3.x - _local2.x), (_local3.y - _local2.y));
_local7.normal.SetV(m_manifold.normal);
_local7.separation = _local8.separation;
_local7.id.key = _local8.id._key;
_arg1.Persist(_local7);
};
};
} else {
m_manifoldCount = 0;
if ((((m0.pointCount > 0)) && (_arg1))){
_local4 = m0.points[0];
_local7.position = _local5.GetWorldPoint(_local4.localPoint1);
_local2 = _local5.GetLinearVelocityFromLocalPoint(_local4.localPoint1);
_local3 = _local6.GetLinearVelocityFromLocalPoint(_local4.localPoint2);
_local7.velocity.Set((_local3.x - _local2.x), (_local3.y - _local2.y));
_local7.normal.SetV(m0.normal);
_local7.separation = _local4.separation;
_local7.id.key = _local4.id._key;
_arg1.Remove(_local7);
};
};
}
override public function GetManifolds():Array{
return (m_manifolds);
}
public static function Destroy(_arg1:b2Contact, _arg2):void{
}
public static function Create(_arg1:b2Shape, _arg2:b2Shape, _arg3):b2Contact{
return (new b2CircleContact(_arg1, _arg2));
}
}
}//package Box2D.Dynamics.Contacts
Section 38
//b2Contact (Box2D.Dynamics.Contacts.b2Contact)
package Box2D.Dynamics.Contacts {
import Box2D.Common.Math.*;
import Box2D.Collision.*;
import Box2D.Dynamics.*;
import Box2D.Collision.Shapes.*;
import Box2D.Common.*;
public class b2Contact {
public var m_shape1:b2Shape;
public var m_shape2:b2Shape;
public var m_prev:b2Contact;
public var m_toi:Number;
public var m_next:b2Contact;
public var m_friction:Number;
public var m_manifoldCount:int;
public var m_node1:b2ContactEdge;
public var m_node2:b2ContactEdge;
public var m_restitution:Number;
public var m_flags:uint;
public static var e_toiFlag:uint = 8;
public static var e_nonSolidFlag:uint = 1;
public static var e_slowFlag:uint = 2;
public static var e_islandFlag:uint = 4;
public static var s_registers:Array;
public static var s_initialized:Boolean = false;
public function b2Contact(_arg1:b2Shape=null, _arg2:b2Shape=null){
m_node1 = new b2ContactEdge();
m_node2 = new b2ContactEdge();
super();
m_flags = 0;
if (((!(_arg1)) || (!(_arg2)))){
m_shape1 = null;
m_shape2 = null;
return;
};
if (((_arg1.IsSensor()) || (_arg2.IsSensor()))){
m_flags = (m_flags | e_nonSolidFlag);
};
m_shape1 = _arg1;
m_shape2 = _arg2;
m_manifoldCount = 0;
m_friction = Math.sqrt((m_shape1.m_friction * m_shape2.m_friction));
m_restitution = b2Math.b2Max(m_shape1.m_restitution, m_shape2.m_restitution);
m_prev = null;
m_next = null;
m_node1.contact = null;
m_node1.prev = null;
m_node1.next = null;
m_node1.other = null;
m_node2.contact = null;
m_node2.prev = null;
m_node2.next = null;
m_node2.other = null;
}
public function IsSolid():Boolean{
return (((m_flags & e_nonSolidFlag) == 0));
}
public function GetShape1():b2Shape{
return (m_shape1);
}
public function GetShape2():b2Shape{
return (m_shape2);
}
public function GetNext():b2Contact{
return (m_next);
}
public function GetManifoldCount():int{
return (m_manifoldCount);
}
public function GetManifolds():Array{
return (null);
}
public function Update(_arg1:b2ContactListener):void{
var _local2:int = m_manifoldCount;
Evaluate(_arg1);
var _local3:int = m_manifoldCount;
var _local4:b2Body = m_shape1.m_body;
var _local5:b2Body = m_shape2.m_body;
if ((((_local3 == 0)) && ((_local2 > 0)))){
_local4.WakeUp();
_local5.WakeUp();
};
if (((((((_local4.IsStatic()) || (_local4.IsBullet()))) || (_local5.IsStatic()))) || (_local5.IsBullet()))){
m_flags = (m_flags & ~(e_slowFlag));
} else {
m_flags = (m_flags | e_slowFlag);
};
}
public function Evaluate(_arg1:b2ContactListener):void{
}
public static function InitializeRegisters():void{
var _local2:int;
s_registers = new Array(b2Shape.e_shapeTypeCount);
var _local1:int;
while (_local1 < b2Shape.e_shapeTypeCount) {
s_registers[_local1] = new Array(b2Shape.e_shapeTypeCount);
_local2 = 0;
while (_local2 < b2Shape.e_shapeTypeCount) {
s_registers[_local1][_local2] = new b2ContactRegister();
_local2++;
};
_local1++;
};
AddType(b2CircleContact.Create, b2CircleContact.Destroy, b2Shape.e_circleShape, b2Shape.e_circleShape);
AddType(b2PolyAndCircleContact.Create, b2PolyAndCircleContact.Destroy, b2Shape.e_polygonShape, b2Shape.e_circleShape);
AddType(b2PolygonContact.Create, b2PolygonContact.Destroy, b2Shape.e_polygonShape, b2Shape.e_polygonShape);
}
public static function Destroy(_arg1:b2Contact, _arg2):void{
if (_arg1.m_manifoldCount > 0){
_arg1.m_shape1.m_body.WakeUp();
_arg1.m_shape2.m_body.WakeUp();
};
var _local3:int = _arg1.m_shape1.m_type;
var _local4:int = _arg1.m_shape2.m_type;
var _local5:b2ContactRegister = s_registers[_local3][_local4];
var _local6:Function = _local5.destroyFcn;
_local6(_arg1, _arg2);
}
public static function AddType(_arg1:Function, _arg2:Function, _arg3:int, _arg4:int):void{
s_registers[_arg3][_arg4].createFcn = _arg1;
s_registers[_arg3][_arg4].destroyFcn = _arg2;
s_registers[_arg3][_arg4].primary = true;
if (_arg3 != _arg4){
s_registers[_arg4][_arg3].createFcn = _arg1;
s_registers[_arg4][_arg3].destroyFcn = _arg2;
s_registers[_arg4][_arg3].primary = false;
};
}
public static function Create(_arg1:b2Shape, _arg2:b2Shape, _arg3):b2Contact{
var _local8:b2Contact;
var _local9:int;
var _local10:b2Manifold;
if (s_initialized == false){
InitializeRegisters();
s_initialized = true;
};
var _local4:int = _arg1.m_type;
var _local5:int = _arg2.m_type;
var _local6:b2ContactRegister = s_registers[_local4][_local5];
var _local7:Function = _local6.createFcn;
if (_local7 != null){
if (_local6.primary){
return (_local7(_arg1, _arg2, _arg3));
};
_local8 = _local7(_arg2, _arg1, _arg3);
_local9 = 0;
while (_local9 < _local8.m_manifoldCount) {
_local10 = _local8.GetManifolds()[_local9];
_local8.GetManifolds()[_local9].normal = _local10.normal.Negative();
_local9++;
};
return (_local8);
//unresolved jump
};
return (null);
}
}
}//package Box2D.Dynamics.Contacts
Section 39
//b2ContactConstraint (Box2D.Dynamics.Contacts.b2ContactConstraint)
package Box2D.Dynamics.Contacts {
import Box2D.Common.Math.*;
import Box2D.Collision.*;
import Box2D.Dynamics.*;
import Box2D.Common.*;
public class b2ContactConstraint {
public var points:Array;
public var normal:b2Vec2;
public var restitution:Number;
public var body1:b2Body;
public var manifold:b2Manifold;
public var body2:b2Body;
public var friction:Number;
public var pointCount:int;
public function b2ContactConstraint(){
normal = new b2Vec2();
super();
points = new Array(b2Settings.b2_maxManifoldPoints);
var _local1:int;
while (_local1 < b2Settings.b2_maxManifoldPoints) {
points[_local1] = new b2ContactConstraintPoint();
_local1++;
};
}
}
}//package Box2D.Dynamics.Contacts
Section 40
//b2ContactConstraintPoint (Box2D.Dynamics.Contacts.b2ContactConstraintPoint)
package Box2D.Dynamics.Contacts {
import Box2D.Common.Math.*;
public class b2ContactConstraintPoint {
public var r2:b2Vec2;
public var separation:Number;
public var positionImpulse:Number;
public var normalImpulse:Number;
public var tangentMass:Number;
public var equalizedMass:Number;
public var tangentImpulse:Number;
public var localAnchor1:b2Vec2;
public var localAnchor2:b2Vec2;
public var normalMass:Number;
public var velocityBias:Number;
public var r1:b2Vec2;
public function b2ContactConstraintPoint(){
localAnchor1 = new b2Vec2();
localAnchor2 = new b2Vec2();
r1 = new b2Vec2();
r2 = new b2Vec2();
super();
}
}
}//package Box2D.Dynamics.Contacts
Section 41
//b2ContactEdge (Box2D.Dynamics.Contacts.b2ContactEdge)
package Box2D.Dynamics.Contacts {
import Box2D.Dynamics.*;
public class b2ContactEdge {
public var other:b2Body;
public var prev:b2ContactEdge;
public var contact:b2Contact;
public var next:b2ContactEdge;
}
}//package Box2D.Dynamics.Contacts
Section 42
//b2ContactRegister (Box2D.Dynamics.Contacts.b2ContactRegister)
package Box2D.Dynamics.Contacts {
public class b2ContactRegister {
public var primary:Boolean;
public var createFcn:Function;
public var destroyFcn:Function;
}
}//package Box2D.Dynamics.Contacts
Section 43
//b2ContactResult (Box2D.Dynamics.Contacts.b2ContactResult)
package Box2D.Dynamics.Contacts {
import Box2D.Common.Math.*;
import Box2D.Collision.*;
import Box2D.Collision.Shapes.*;
public class b2ContactResult {
public var position:b2Vec2;
public var shape1:b2Shape;
public var shape2:b2Shape;
public var normalImpulse:Number;
public var normal:b2Vec2;
public var tangentImpulse:Number;
public var id:b2ContactID;
public function b2ContactResult(){
position = new b2Vec2();
normal = new b2Vec2();
id = new b2ContactID();
super();
}
}
}//package Box2D.Dynamics.Contacts
Section 44
//b2ContactSolver (Box2D.Dynamics.Contacts.b2ContactSolver)
package Box2D.Dynamics.Contacts {
import Box2D.Common.Math.*;
import Box2D.Collision.*;
import Box2D.Dynamics.*;
import Box2D.Common.*;
public class b2ContactSolver {
public var m_constraintCount:int;
public var m_constraints:Array;
public var m_allocator;
public var m_step:b2TimeStep;
public function b2ContactSolver(_arg1:b2TimeStep, _arg2:Array, _arg3:int, _arg4){
var _local5:b2Contact;
var _local6:int;
var _local7:b2Vec2;
var _local8:b2Mat22;
var _local10:b2Body;
var _local11:b2Body;
var _local12:int;
var _local13:Array;
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:int;
var _local23:b2Manifold;
var _local24:Number;
var _local25:Number;
var _local26:b2ContactConstraint;
var _local27:uint;
var _local28:b2ManifoldPoint;
var _local29:b2ContactConstraintPoint;
var _local30:Number;
var _local31:Number;
var _local32:Number;
var _local33:Number;
var _local34:Number;
var _local35:Number;
var _local36:Number;
var _local37:Number;
var _local38:Number;
var _local39:Number;
var _local40:Number;
var _local41:Number;
var _local42:Number;
var _local43:Number;
var _local44:Number;
var _local45:Number;
var _local46:Number;
var _local47:Number;
m_step = new b2TimeStep();
m_constraints = new Array();
super();
m_step.dt = _arg1.dt;
m_step.inv_dt = _arg1.inv_dt;
m_step.maxIterations = _arg1.maxIterations;
m_allocator = _arg4;
m_constraintCount = 0;
_local6 = 0;
while (_local6 < _arg3) {
_local5 = _arg2[_local6];
m_constraintCount = (m_constraintCount + _local5.m_manifoldCount);
_local6++;
};
_local6 = 0;
while (_local6 < m_constraintCount) {
m_constraints[_local6] = new b2ContactConstraint();
_local6++;
};
var _local9:int;
_local6 = 0;
while (_local6 < _arg3) {
_local5 = _arg2[_local6];
_local10 = _local5.m_shape1.m_body;
_local11 = _local5.m_shape2.m_body;
_local12 = _local5.m_manifoldCount;
_local13 = _local5.GetManifolds();
_local14 = _local5.m_friction;
_local15 = _local5.m_restitution;
_local16 = _local10.m_linearVelocity.x;
_local17 = _local10.m_linearVelocity.y;
_local18 = _local11.m_linearVelocity.x;
_local19 = _local11.m_linearVelocity.y;
_local20 = _local10.m_angularVelocity;
_local21 = _local11.m_angularVelocity;
_local22 = 0;
while (_local22 < _local12) {
_local23 = _local13[_local22];
_local24 = _local23.normal.x;
_local25 = _local23.normal.y;
_local26 = m_constraints[_local9];
_local26.body1 = _local10;
_local26.body2 = _local11;
_local26.manifold = _local23;
_local26.normal.x = _local24;
_local26.normal.y = _local25;
_local26.pointCount = _local23.pointCount;
_local26.friction = _local14;
_local26.restitution = _local15;
_local27 = 0;
while (_local27 < _local26.pointCount) {
_local28 = _local23.points[_local27];
_local29 = _local26.points[_local27];
_local29.normalImpulse = _local28.normalImpulse;
_local29.tangentImpulse = _local28.tangentImpulse;
_local29.separation = _local28.separation;
_local29.positionImpulse = 0;
_local29.localAnchor1.SetV(_local28.localPoint1);
_local29.localAnchor2.SetV(_local28.localPoint2);
_local8 = _local10.m_xf.R;
_local32 = (_local28.localPoint1.x - _local10.m_sweep.localCenter.x);
_local33 = (_local28.localPoint1.y - _local10.m_sweep.localCenter.y);
_local30 = ((_local8.col1.x * _local32) + (_local8.col2.x * _local33));
_local33 = ((_local8.col1.y * _local32) + (_local8.col2.y * _local33));
_local32 = _local30;
_local29.r1.Set(_local32, _local33);
_local8 = _local11.m_xf.R;
_local34 = (_local28.localPoint2.x - _local11.m_sweep.localCenter.x);
_local35 = (_local28.localPoint2.y - _local11.m_sweep.localCenter.y);
_local30 = ((_local8.col1.x * _local34) + (_local8.col2.x * _local35));
_local35 = ((_local8.col1.y * _local34) + (_local8.col2.y * _local35));
_local34 = _local30;
_local29.r2.Set(_local34, _local35);
_local36 = ((_local32 * _local32) + (_local33 * _local33));
_local37 = ((_local34 * _local34) + (_local35 * _local35));
_local38 = ((_local32 * _local24) + (_local33 * _local25));
_local39 = ((_local34 * _local24) + (_local35 * _local25));
_local40 = (_local10.m_invMass + _local11.m_invMass);
_local40 = (_local40 + ((_local10.m_invI * (_local36 - (_local38 * _local38))) + (_local11.m_invI * (_local37 - (_local39 * _local39)))));
_local29.normalMass = (1 / _local40);
_local41 = ((_local10.m_mass * _local10.m_invMass) + (_local11.m_mass * _local11.m_invMass));
_local41 = (_local41 + (((_local10.m_mass * _local10.m_invI) * (_local36 - (_local38 * _local38))) + ((_local11.m_mass * _local11.m_invI) * (_local37 - (_local39 * _local39)))));
_local29.equalizedMass = (1 / _local41);
_local42 = _local25;
_local43 = -(_local24);
_local44 = ((_local32 * _local42) + (_local33 * _local43));
_local45 = ((_local34 * _local42) + (_local35 * _local43));
_local46 = (_local10.m_invMass + _local11.m_invMass);
_local46 = (_local46 + ((_local10.m_invI * (_local36 - (_local44 * _local44))) + (_local11.m_invI * (_local37 - (_local45 * _local45)))));
_local29.tangentMass = (1 / _local46);
_local29.velocityBias = 0;
if (_local29.separation > 0){
_local29.velocityBias = (-60 * _local29.separation);
};
_local30 = (((_local18 + (-(_local21) * _local35)) - _local16) - (-(_local20) * _local33));
_local31 = (((_local19 + (_local21 * _local34)) - _local17) - (_local20 * _local32));
_local47 = ((_local26.normal.x * _local30) + (_local26.normal.y * _local31));
if (_local47 < -(b2Settings.b2_velocityThreshold)){
_local29.velocityBias = (_local29.velocityBias + (-(_local26.restitution) * _local47));
};
_local27++;
};
_local9++;
_local22++;
};
_local6++;
};
}
public function InitVelocityConstraints(_arg1:b2TimeStep):void{
var _local2:b2Vec2;
var _local3:b2Vec2;
var _local4:b2Mat22;
var _local6:b2ContactConstraint;
var _local7:b2Body;
var _local8:b2Body;
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:int;
var _local19:int;
var _local20:b2ContactConstraintPoint;
var _local21:Number;
var _local22:Number;
var _local23:b2ContactConstraintPoint;
var _local5:int;
while (_local5 < m_constraintCount) {
_local6 = m_constraints[_local5];
_local7 = _local6.body1;
_local8 = _local6.body2;
_local9 = _local7.m_invMass;
_local10 = _local7.m_invI;
_local11 = _local8.m_invMass;
_local12 = _local8.m_invI;
_local13 = _local6.normal.x;
_local14 = _local6.normal.y;
_local15 = _local14;
_local16 = -(_local13);
if (_arg1.warmStarting){
_local19 = _local6.pointCount;
_local18 = 0;
while (_local18 < _local19) {
_local20 = _local6.points[_local18];
_local6.points[_local18].normalImpulse = (_local20.normalImpulse * _arg1.dtRatio);
_local20.tangentImpulse = (_local20.tangentImpulse * _arg1.dtRatio);
_local21 = ((_local20.normalImpulse * _local13) + (_local20.tangentImpulse * _local15));
_local22 = ((_local20.normalImpulse * _local14) + (_local20.tangentImpulse * _local16));
_local7.m_angularVelocity = (_local7.m_angularVelocity - (_local10 * ((_local20.r1.x * _local22) - (_local20.r1.y * _local21))));
_local7.m_linearVelocity.x = (_local7.m_linearVelocity.x - (_local9 * _local21));
_local7.m_linearVelocity.y = (_local7.m_linearVelocity.y - (_local9 * _local22));
_local8.m_angularVelocity = (_local8.m_angularVelocity + (_local12 * ((_local20.r2.x * _local22) - (_local20.r2.y * _local21))));
_local8.m_linearVelocity.x = (_local8.m_linearVelocity.x + (_local11 * _local21));
_local8.m_linearVelocity.y = (_local8.m_linearVelocity.y + (_local11 * _local22));
_local18++;
};
} else {
_local19 = _local6.pointCount;
_local18 = 0;
while (_local18 < _local19) {
_local23 = _local6.points[_local18];
_local23.normalImpulse = 0;
_local23.tangentImpulse = 0;
_local18++;
};
};
_local5++;
};
}
public function SolvePositionConstraints(_arg1:Number):Boolean{
var _local3:b2Mat22;
var _local4:b2Vec2;
var _local6:b2ContactConstraint;
var _local7:b2Body;
var _local8:b2Body;
var _local9:b2Vec2;
var _local10:Number;
var _local11:b2Vec2;
var _local12:Number;
var _local13:Number;
var _local14:Number;
var _local15:Number;
var _local16:Number;
var _local17:Number;
var _local18:Number;
var _local19:int;
var _local20:int;
var _local21:b2ContactConstraintPoint;
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;
var _local32:Number;
var _local33:Number;
var _local34:Number;
var _local35:Number;
var _local36:Number;
var _local37:Number;
var _local38:Number;
var _local2:Number = 0;
var _local5:int;
while (_local5 < m_constraintCount) {
_local6 = m_constraints[_local5];
_local7 = _local6.body1;
_local8 = _local6.body2;
_local9 = _local7.m_sweep.c;
_local10 = _local7.m_sweep.a;
_local11 = _local8.m_sweep.c;
_local12 = _local8.m_sweep.a;
_local13 = (_local7.m_mass * _local7.m_invMass);
_local14 = (_local7.m_mass * _local7.m_invI);
_local15 = (_local8.m_mass * _local8.m_invMass);
_local16 = (_local8.m_mass * _local8.m_invI);
_local17 = _local6.normal.x;
_local18 = _local6.normal.y;
_local19 = _local6.pointCount;
_local20 = 0;
while (_local20 < _local19) {
_local21 = _local6.points[_local20];
_local3 = _local7.m_xf.R;
_local4 = _local7.m_sweep.localCenter;
_local22 = (_local21.localAnchor1.x - _local4.x);
_local23 = (_local21.localAnchor1.y - _local4.y);
_local26 = ((_local3.col1.x * _local22) + (_local3.col2.x * _local23));
_local23 = ((_local3.col1.y * _local22) + (_local3.col2.y * _local23));
_local22 = _local26;
_local3 = _local8.m_xf.R;
_local4 = _local8.m_sweep.localCenter;
_local24 = (_local21.localAnchor2.x - _local4.x);
_local25 = (_local21.localAnchor2.y - _local4.y);
_local26 = ((_local3.col1.x * _local24) + (_local3.col2.x * _local25));
_local25 = ((_local3.col1.y * _local24) + (_local3.col2.y * _local25));
_local24 = _local26;
_local27 = (_local9.x + _local22);
_local28 = (_local9.y + _local23);
_local29 = (_local11.x + _local24);
_local30 = (_local11.y + _local25);
_local31 = (_local29 - _local27);
_local32 = (_local30 - _local28);
_local33 = (((_local31 * _local17) + (_local32 * _local18)) + _local21.separation);
_local2 = b2Math.b2Min(_local2, _local33);
_local34 = (_arg1 * b2Math.b2Clamp((_local33 + b2Settings.b2_linearSlop), -(b2Settings.b2_maxLinearCorrection), 0));
_local35 = (-(_local21.equalizedMass) * _local34);
_local36 = _local21.positionImpulse;
_local21.positionImpulse = b2Math.b2Max((_local36 + _local35), 0);
_local35 = (_local21.positionImpulse - _local36);
_local37 = (_local35 * _local17);
_local38 = (_local35 * _local18);
_local9.x = (_local9.x - (_local13 * _local37));
_local9.y = (_local9.y - (_local13 * _local38));
_local10 = (_local10 - (_local14 * ((_local22 * _local38) - (_local23 * _local37))));
_local7.m_sweep.a = _local10;
_local7.SynchronizeTransform();
_local11.x = (_local11.x + (_local15 * _local37));
_local11.y = (_local11.y + (_local15 * _local38));
_local12 = (_local12 + (_local16 * ((_local24 * _local38) - (_local25 * _local37))));
_local8.m_sweep.a = _local12;
_local8.SynchronizeTransform();
_local20++;
};
_local5++;
};
return ((_local2 >= (-1.5 * b2Settings.b2_linearSlop)));
}
public function SolveVelocityConstraints():void{
var _local1:int;
var _local2:b2ContactConstraintPoint;
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:b2Mat22;
var _local18:b2Vec2;
var _local20:b2ContactConstraint;
var _local21:b2Body;
var _local22:b2Body;
var _local23:Number;
var _local24:Number;
var _local25:b2Vec2;
var _local26:b2Vec2;
var _local27:Number;
var _local28:Number;
var _local29:Number;
var _local30:Number;
var _local31:Number;
var _local32:Number;
var _local33:Number;
var _local34:Number;
var _local35:Number;
var _local36:Number;
var _local37:int;
var _local38:Number;
var _local19:int;
while (_local19 < m_constraintCount) {
_local20 = m_constraints[_local19];
_local21 = _local20.body1;
_local22 = _local20.body2;
_local23 = _local21.m_angularVelocity;
_local24 = _local22.m_angularVelocity;
_local25 = _local21.m_linearVelocity;
_local26 = _local22.m_linearVelocity;
_local27 = _local21.m_invMass;
_local28 = _local21.m_invI;
_local29 = _local22.m_invMass;
_local30 = _local22.m_invI;
_local31 = _local20.normal.x;
_local32 = _local20.normal.y;
_local33 = _local32;
_local34 = -(_local31);
_local35 = _local20.friction;
_local37 = _local20.pointCount;
_local1 = 0;
while (_local1 < _local37) {
_local2 = _local20.points[_local1];
_local7 = (((_local26.x + (-(_local24) * _local2.r2.y)) - _local25.x) - (-(_local23) * _local2.r1.y));
_local8 = (((_local26.y + (_local24 * _local2.r2.x)) - _local25.y) - (_local23 * _local2.r1.x));
_local9 = ((_local7 * _local31) + (_local8 * _local32));
_local11 = (-(_local2.normalMass) * (_local9 - _local2.velocityBias));
_local10 = ((_local7 * _local33) + (_local8 * _local34));
_local12 = (_local2.tangentMass * -(_local10));
_local13 = b2Math.b2Max((_local2.normalImpulse + _local11), 0);
_local11 = (_local13 - _local2.normalImpulse);
_local38 = (_local35 * _local2.normalImpulse);
_local14 = b2Math.b2Clamp((_local2.tangentImpulse + _local12), -(_local38), _local38);
_local12 = (_local14 - _local2.tangentImpulse);
_local15 = ((_local11 * _local31) + (_local12 * _local33));
_local16 = ((_local11 * _local32) + (_local12 * _local34));
_local25.x = (_local25.x - (_local27 * _local15));
_local25.y = (_local25.y - (_local27 * _local16));
_local23 = (_local23 - (_local28 * ((_local2.r1.x * _local16) - (_local2.r1.y * _local15))));
_local26.x = (_local26.x + (_local29 * _local15));
_local26.y = (_local26.y + (_local29 * _local16));
_local24 = (_local24 + (_local30 * ((_local2.r2.x * _local16) - (_local2.r2.y * _local15))));
_local2.normalImpulse = _local13;
_local2.tangentImpulse = _local14;
_local1++;
};
_local21.m_angularVelocity = _local23;
_local22.m_angularVelocity = _local24;
_local19++;
};
}
public function FinalizeVelocityConstraints():void{
var _local2:b2ContactConstraint;
var _local3:b2Manifold;
var _local4:int;
var _local5:b2ManifoldPoint;
var _local6:b2ContactConstraintPoint;
var _local1:int;
while (_local1 < m_constraintCount) {
_local2 = m_constraints[_local1];
_local3 = _local2.manifold;
_local4 = 0;
while (_local4 < _local2.pointCount) {
_local5 = _local3.points[_local4];
_local6 = _local2.points[_local4];
_local5.normalImpulse = _local6.normalImpulse;
_local5.tangentImpulse = _local6.tangentImpulse;
_local4++;
};
_local1++;
};
}
}
}//package Box2D.Dynamics.Contacts
Section 45
//b2NullContact (Box2D.Dynamics.Contacts.b2NullContact)
package Box2D.Dynamics.Contacts {
import Box2D.Dynamics.*;
public class b2NullContact extends b2Contact {
override public function Evaluate(_arg1:b2ContactListener):void{
}
override public function GetManifolds():Array{
return (null);
}
}
}//package Box2D.Dynamics.Contacts
Section 46
//b2PolyAndCircleContact (Box2D.Dynamics.Contacts.b2PolyAndCircleContact)
package Box2D.Dynamics.Contacts {
import Box2D.Common.Math.*;
import Box2D.Collision.*;
import Box2D.Dynamics.*;
import Box2D.Collision.Shapes.*;
import Box2D.Common.*;
public class b2PolyAndCircleContact extends b2Contact {
private var m_manifolds:Array;
public var m_manifold:b2Manifold;
private var m0:b2Manifold;
private static const s_evalCP:b2ContactPoint = new b2ContactPoint();
public function b2PolyAndCircleContact(_arg1:b2Shape, _arg2:b2Shape){
m_manifolds = [new b2Manifold()];
m0 = new b2Manifold();
super(_arg1, _arg2);
m_manifold = m_manifolds[0];
b2Settings.b2Assert((m_shape1.m_type == b2Shape.e_polygonShape));
b2Settings.b2Assert((m_shape2.m_type == b2Shape.e_circleShape));
m_manifold.pointCount = 0;
var _local3:b2ManifoldPoint = m_manifold.points[0];
_local3.normalImpulse = 0;
_local3.tangentImpulse = 0;
}
override public function Evaluate(_arg1:b2ContactListener):void{
var _local2:int;
var _local3:b2Vec2;
var _local4:b2Vec2;
var _local5:b2ManifoldPoint;
var _local10:b2ManifoldPoint;
var _local11:Boolean;
var _local12:uint;
var _local13:int;
var _local6:b2Body = m_shape1.m_body;
var _local7:b2Body = m_shape2.m_body;
m0.Set(m_manifold);
b2Collision.b2CollidePolygonAndCircle(m_manifold, (m_shape1 as b2PolygonShape), _local6.m_xf, (m_shape2 as b2CircleShape), _local7.m_xf);
var _local8:Array = [false, false];
var _local9:b2ContactPoint = s_evalCP;
_local9.shape1 = m_shape1;
_local9.shape2 = m_shape2;
_local9.friction = m_friction;
_local9.restitution = m_restitution;
if (m_manifold.pointCount > 0){
_local2 = 0;
while (_local2 < m_manifold.pointCount) {
_local10 = m_manifold.points[_local2];
_local10.normalImpulse = 0;
_local10.tangentImpulse = 0;
_local11 = false;
_local12 = _local10.id._key;
_local13 = 0;
while (_local13 < m0.pointCount) {
if (_local8[_local13] == true){
} else {
_local5 = m0.points[_local13];
if (_local5.id._key == _local12){
_local8[_local13] = true;
_local10.normalImpulse = _local5.normalImpulse;
_local10.tangentImpulse = _local5.tangentImpulse;
_local11 = true;
if (_arg1 != null){
_local9.position = _local6.GetWorldPoint(_local10.localPoint1);
_local3 = _local6.GetLinearVelocityFromLocalPoint(_local10.localPoint1);
_local4 = _local7.GetLinearVelocityFromLocalPoint(_local10.localPoint2);
_local9.velocity.Set((_local4.x - _local3.x), (_local4.y - _local3.y));
_local9.normal.SetV(m_manifold.normal);
_local9.separation = _local10.separation;
_local9.id.key = _local12;
_arg1.Persist(_local9);
};
break;
};
};
_local13++;
};
if ((((_local11 == false)) && (!((_arg1 == null))))){
_local9.position = _local6.GetWorldPoint(_local10.localPoint1);
_local3 = _local6.GetLinearVelocityFromLocalPoint(_local10.localPoint1);
_local4 = _local7.GetLinearVelocityFromLocalPoint(_local10.localPoint2);
_local9.velocity.Set((_local4.x - _local3.x), (_local4.y - _local3.y));
_local9.normal.SetV(m_manifold.normal);
_local9.separation = _local10.separation;
_local9.id.key = _local12;
_arg1.Add(_local9);
};
_local2++;
};
m_manifoldCount = 1;
} else {
m_manifoldCount = 0;
};
if (_arg1 == null){
return;
};
_local2 = 0;
while (_local2 < m0.pointCount) {
if (_local8[_local2]){
} else {
_local5 = m0.points[_local2];
_local9.position = _local6.GetWorldPoint(_local5.localPoint1);
_local3 = _local6.GetLinearVelocityFromLocalPoint(_local5.localPoint1);
_local4 = _local7.GetLinearVelocityFromLocalPoint(_local5.localPoint2);
_local9.velocity.Set((_local4.x - _local3.x), (_local4.y - _local3.y));
_local9.normal.SetV(m0.normal);
_local9.separation = _local5.separation;
_local9.id.key = _local5.id._key;
_arg1.Remove(_local9);
};
_local2++;
};
}
override public function GetManifolds():Array{
return (m_manifolds);
}
public static function Destroy(_arg1:b2Contact, _arg2):void{
}
public static function Create(_arg1:b2Shape, _arg2:b2Shape, _arg3):b2Contact{
return (new b2PolyAndCircleContact(_arg1, _arg2));
}
}
}//package Box2D.Dynamics.Contacts
Section 47
//b2PolygonContact (Box2D.Dynamics.Contacts.b2PolygonContact)
package Box2D.Dynamics.Contacts {
import Box2D.Common.Math.*;
import Box2D.Collision.*;
import Box2D.Dynamics.*;
import Box2D.Collision.Shapes.*;
import Box2D.Common.*;
public class b2PolygonContact extends b2Contact {
private var m_manifolds:Array;
private var m0:b2Manifold;
public var m_manifold:b2Manifold;
private static const s_evalCP:b2ContactPoint = new b2ContactPoint();
public function b2PolygonContact(_arg1:b2Shape, _arg2:b2Shape):void{
m0 = new b2Manifold();
m_manifolds = [new b2Manifold()];
super(_arg1, _arg2);
m_manifold = m_manifolds[0];
m_manifold.pointCount = 0;
}
override public function Evaluate(_arg1:b2ContactListener):void{
var _local2:b2Vec2;
var _local3:b2Vec2;
var _local4:b2ManifoldPoint;
var _local7:b2ContactPoint;
var _local8:int;
var _local10:b2ManifoldPoint;
var _local11:Boolean;
var _local12:uint;
var _local13:int;
var _local5:b2Body = m_shape1.m_body;
var _local6:b2Body = m_shape2.m_body;
m0.Set(m_manifold);
b2Collision.b2CollidePolygons(m_manifold, (m_shape1 as b2PolygonShape), _local5.m_xf, (m_shape2 as b2PolygonShape), _local6.m_xf);
var _local9:Array = [false, false];
_local7 = s_evalCP;
_local7.shape1 = m_shape1;
_local7.shape2 = m_shape2;
_local7.friction = m_friction;
_local7.restitution = m_restitution;
if (m_manifold.pointCount > 0){
_local8 = 0;
while (_local8 < m_manifold.pointCount) {
_local10 = m_manifold.points[_local8];
_local10.normalImpulse = 0;
_local10.tangentImpulse = 0;
_local11 = false;
_local12 = _local10.id._key;
_local13 = 0;
while (_local13 < m0.pointCount) {
if (_local9[_local13] == true){
} else {
_local4 = m0.points[_local13];
if (_local4.id._key == _local12){
_local9[_local13] = true;
_local10.normalImpulse = _local4.normalImpulse;
_local10.tangentImpulse = _local4.tangentImpulse;
_local11 = true;
if (_arg1 != null){
_local7.position = _local5.GetWorldPoint(_local10.localPoint1);
_local2 = _local5.GetLinearVelocityFromLocalPoint(_local10.localPoint1);
_local3 = _local6.GetLinearVelocityFromLocalPoint(_local10.localPoint2);
_local7.velocity.Set((_local3.x - _local2.x), (_local3.y - _local2.y));
_local7.normal.SetV(m_manifold.normal);
_local7.separation = _local10.separation;
_local7.id.key = _local12;
_arg1.Persist(_local7);
};
break;
};
};
_local13++;
};
if ((((_local11 == false)) && (!((_arg1 == null))))){
_local7.position = _local5.GetWorldPoint(_local10.localPoint1);
_local2 = _local5.GetLinearVelocityFromLocalPoint(_local10.localPoint1);
_local3 = _local6.GetLinearVelocityFromLocalPoint(_local10.localPoint2);
_local7.velocity.Set((_local3.x - _local2.x), (_local3.y - _local2.y));
_local7.normal.SetV(m_manifold.normal);
_local7.separation = _local10.separation;
_local7.id.key = _local12;
_arg1.Add(_local7);
};
_local8++;
};
m_manifoldCount = 1;
} else {
m_manifoldCount = 0;
};
if (_arg1 == null){
return;
};
_local8 = 0;
while (_local8 < m0.pointCount) {
if (_local9[_local8]){
} else {
_local4 = m0.points[_local8];
_local7.position = _local5.GetWorldPoint(_local4.localPoint1);
_local2 = _local5.GetLinearVelocityFromLocalPoint(_local4.localPoint1);
_local3 = _local6.GetLinearVelocityFromLocalPoint(_local4.localPoint2);
_local7.velocity.Set((_local3.x - _local2.x), (_local3.y - _local2.y));
_local7.normal.SetV(m0.normal);
_local7.separation = _local4.separation;
_local7.id.key = _local4.id._key;
_arg1.Remove(_local7);
};
_local8++;
};
}
override public function GetManifolds():Array{
return (m_manifolds);
}
public static function Destroy(_arg1:b2Contact, _arg2):void{
}
public static function Create(_arg1:b2Shape, _arg2:b2Shape, _arg3):b2Contact{
return (new b2PolygonContact(_arg1, _arg2));
}
}
}//package Box2D.Dynamics.Contacts
Section 48
//b2DistanceJoint (Box2D.Dynamics.Joints.b2DistanceJoint)
package Box2D.Dynamics.Joints {
import Box2D.Common.Math.*;
import Box2D.Dynamics.*;
import Box2D.Common.*;
public class b2DistanceJoint extends b2Joint {
public var m_localAnchor1:b2Vec2;
public var m_localAnchor2:b2Vec2;
public var m_bias:Number;
public var m_gamma:Number;
public var m_u:b2Vec2;
public var m_mass:Number;
public var m_impulse:Number;
public var m_dampingRatio:Number;
public var m_frequencyHz:Number;
public var m_length:Number;
public function b2DistanceJoint(_arg1:b2DistanceJointDef){
var _local2:b2Mat22;
var _local3:Number;
var _local4:Number;
m_localAnchor1 = new b2Vec2();
m_localAnchor2 = new b2Vec2();
m_u = new b2Vec2();
super(_arg1);
m_localAnchor1.SetV(_arg1.localAnchor1);
m_localAnchor2.SetV(_arg1.localAnchor2);
m_length = _arg1.length;
m_frequencyHz = _arg1.frequencyHz;
m_dampingRatio = _arg1.dampingRatio;
m_impulse = 0;
m_gamma = 0;
m_bias = 0;
m_inv_dt = 0;
}
override public function GetAnchor1():b2Vec2{
return (m_body1.GetWorldPoint(m_localAnchor1));
}
override public function GetAnchor2():b2Vec2{
return (m_body2.GetWorldPoint(m_localAnchor2));
}
override public function InitVelocityConstraints(_arg1:b2TimeStep):void{
var _local2:b2Mat22;
var _local3:Number;
var _local4:b2Body;
var _local5:b2Body;
var _local6:Number;
var _local8:Number;
var _local14:Number;
var _local15:Number;
var _local16:Number;
var _local17:Number;
var _local18:Number;
var _local19:Number;
m_inv_dt = _arg1.inv_dt;
_local4 = m_body1;
_local5 = m_body2;
_local2 = _local4.m_xf.R;
_local6 = (m_localAnchor1.x - _local4.m_sweep.localCenter.x);
var _local7:Number = (m_localAnchor1.y - _local4.m_sweep.localCenter.y);
_local3 = ((_local2.col1.x * _local6) + (_local2.col2.x * _local7));
_local7 = ((_local2.col1.y * _local6) + (_local2.col2.y * _local7));
_local6 = _local3;
_local2 = _local5.m_xf.R;
_local8 = (m_localAnchor2.x - _local5.m_sweep.localCenter.x);
var _local9:Number = (m_localAnchor2.y - _local5.m_sweep.localCenter.y);
_local3 = ((_local2.col1.x * _local8) + (_local2.col2.x * _local9));
_local9 = ((_local2.col1.y * _local8) + (_local2.col2.y * _local9));
_local8 = _local3;
m_u.x = (((_local5.m_sweep.c.x + _local8) - _local4.m_sweep.c.x) - _local6);
m_u.y = (((_local5.m_sweep.c.y + _local9) - _local4.m_sweep.c.y) - _local7);
var _local10:Number = Math.sqrt(((m_u.x * m_u.x) + (m_u.y * m_u.y)));
if (_local10 > b2Settings.b2_linearSlop){
m_u.Multiply((1 / _local10));
} else {
m_u.SetZero();
};
var _local11:Number = ((_local6 * m_u.y) - (_local7 * m_u.x));
var _local12:Number = ((_local8 * m_u.y) - (_local9 * m_u.x));
var _local13:Number = (((_local4.m_invMass + ((_local4.m_invI * _local11) * _local11)) + _local5.m_invMass) + ((_local5.m_invI * _local12) * _local12));
m_mass = (1 / _local13);
if (m_frequencyHz > 0){
_local14 = (_local10 - m_length);
_local15 = ((2 * Math.PI) * m_frequencyHz);
_local16 = (((2 * m_mass) * m_dampingRatio) * _local15);
_local17 = ((m_mass * _local15) * _local15);
m_gamma = (1 / (_arg1.dt * (_local16 + (_arg1.dt * _local17))));
m_bias = (((_local14 * _arg1.dt) * _local17) * m_gamma);
m_mass = (1 / (_local13 + m_gamma));
};
if (_arg1.warmStarting){
m_impulse = (m_impulse * _arg1.dtRatio);
_local18 = (m_impulse * m_u.x);
_local19 = (m_impulse * m_u.y);
_local4.m_linearVelocity.x = (_local4.m_linearVelocity.x - (_local4.m_invMass * _local18));
_local4.m_linearVelocity.y = (_local4.m_linearVelocity.y - (_local4.m_invMass * _local19));
_local4.m_angularVelocity = (_local4.m_angularVelocity - (_local4.m_invI * ((_local6 * _local19) - (_local7 * _local18))));
_local5.m_linearVelocity.x = (_local5.m_linearVelocity.x + (_local5.m_invMass * _local18));
_local5.m_linearVelocity.y = (_local5.m_linearVelocity.y + (_local5.m_invMass * _local19));
_local5.m_angularVelocity = (_local5.m_angularVelocity + (_local5.m_invI * ((_local8 * _local19) - (_local9 * _local18))));
} else {
m_impulse = 0;
};
}
override public function GetReactionTorque():Number{
return (0);
}
override public function GetReactionForce():b2Vec2{
var _local1:b2Vec2 = new b2Vec2();
_local1.SetV(m_u);
_local1.Multiply((m_inv_dt * m_impulse));
return (_local1);
}
override public function SolvePositionConstraints():Boolean{
var _local1:b2Mat22;
if (m_frequencyHz > 0){
return (true);
};
var _local2:b2Body = m_body1;
var _local3:b2Body = m_body2;
_local1 = _local2.m_xf.R;
var _local4:Number = (m_localAnchor1.x - _local2.m_sweep.localCenter.x);
var _local5:Number = (m_localAnchor1.y - _local2.m_sweep.localCenter.y);
var _local6:Number = ((_local1.col1.x * _local4) + (_local1.col2.x * _local5));
_local5 = ((_local1.col1.y * _local4) + (_local1.col2.y * _local5));
_local4 = _local6;
_local1 = _local3.m_xf.R;
var _local7:Number = (m_localAnchor2.x - _local3.m_sweep.localCenter.x);
var _local8:Number = (m_localAnchor2.y - _local3.m_sweep.localCenter.y);
_local6 = ((_local1.col1.x * _local7) + (_local1.col2.x * _local8));
_local8 = ((_local1.col1.y * _local7) + (_local1.col2.y * _local8));
_local7 = _local6;
var _local9:Number = (((_local3.m_sweep.c.x + _local7) - _local2.m_sweep.c.x) - _local4);
var _local10:Number = (((_local3.m_sweep.c.y + _local8) - _local2.m_sweep.c.y) - _local5);
var _local11:Number = Math.sqrt(((_local9 * _local9) + (_local10 * _local10)));
_local9 = (_local9 / _local11);
_local10 = (_local10 / _local11);
var _local12:Number = (_local11 - m_length);
_local12 = b2Math.b2Clamp(_local12, -(b2Settings.b2_maxLinearCorrection), b2Settings.b2_maxLinearCorrection);
var _local13:Number = (-(m_mass) * _local12);
m_u.Set(_local9, _local10);
var _local14:Number = (_local13 * m_u.x);
var _local15:Number = (_local13 * m_u.y);
_local2.m_sweep.c.x = (_local2.m_sweep.c.x - (_local2.m_invMass * _local14));
_local2.m_sweep.c.y = (_local2.m_sweep.c.y - (_local2.m_invMass * _local15));
_local2.m_sweep.a = (_local2.m_sweep.a - (_local2.m_invI * ((_local4 * _local15) - (_local5 * _local14))));
_local3.m_sweep.c.x = (_local3.m_sweep.c.x + (_local3.m_invMass * _local14));
_local3.m_sweep.c.y = (_local3.m_sweep.c.y + (_local3.m_invMass * _local15));
_local3.m_sweep.a = (_local3.m_sweep.a + (_local3.m_invI * ((_local7 * _local15) - (_local8 * _local14))));
_local2.SynchronizeTransform();
_local3.SynchronizeTransform();
return ((b2Math.b2Abs(_local12) < b2Settings.b2_linearSlop));
}
override public function SolveVelocityConstraints(_arg1:b2TimeStep):void{
var _local2:b2Mat22;
var _local3:b2Body = m_body1;
var _local4:b2Body = m_body2;
_local2 = _local3.m_xf.R;
var _local5:Number = (m_localAnchor1.x - _local3.m_sweep.localCenter.x);
var _local6:Number = (m_localAnchor1.y - _local3.m_sweep.localCenter.y);
var _local7:Number = ((_local2.col1.x * _local5) + (_local2.col2.x * _local6));
_local6 = ((_local2.col1.y * _local5) + (_local2.col2.y * _local6));
_local5 = _local7;
_local2 = _local4.m_xf.R;
var _local8:Number = (m_localAnchor2.x - _local4.m_sweep.localCenter.x);
var _local9:Number = (m_localAnchor2.y - _local4.m_sweep.localCenter.y);
_local7 = ((_local2.col1.x * _local8) + (_local2.col2.x * _local9));
_local9 = ((_local2.col1.y * _local8) + (_local2.col2.y * _local9));
_local8 = _local7;
var _local10:Number = (_local3.m_linearVelocity.x + (-(_local3.m_angularVelocity) * _local6));
var _local11:Number = (_local3.m_linearVelocity.y + (_local3.m_angularVelocity * _local5));
var _local12:Number = (_local4.m_linearVelocity.x + (-(_local4.m_angularVelocity) * _local9));
var _local13:Number = (_local4.m_linearVelocity.y + (_local4.m_angularVelocity * _local8));
var _local14:Number = ((m_u.x * (_local12 - _local10)) + (m_u.y * (_local13 - _local11)));
var _local15:Number = (-(m_mass) * ((_local14 + m_bias) + (m_gamma * m_impulse)));
m_impulse = (m_impulse + _local15);
var _local16:Number = (_local15 * m_u.x);
var _local17:Number = (_local15 * m_u.y);
_local3.m_linearVelocity.x = (_local3.m_linearVelocity.x - (_local3.m_invMass * _local16));
_local3.m_linearVelocity.y = (_local3.m_linearVelocity.y - (_local3.m_invMass * _local17));
_local3.m_angularVelocity = (_local3.m_angularVelocity - (_local3.m_invI * ((_local5 * _local17) - (_local6 * _local16))));
_local4.m_linearVelocity.x = (_local4.m_linearVelocity.x + (_local4.m_invMass * _local16));
_local4.m_linearVelocity.y = (_local4.m_linearVelocity.y + (_local4.m_invMass * _local17));
_local4.m_angularVelocity = (_local4.m_angularVelocity + (_local4.m_invI * ((_local8 * _local17) - (_local9 * _local16))));
}
}
}//package Box2D.Dynamics.Joints
Section 49
//b2DistanceJointDef (Box2D.Dynamics.Joints.b2DistanceJointDef)
package Box2D.Dynamics.Joints {
import Box2D.Common.Math.*;
import Box2D.Dynamics.*;
public class b2DistanceJointDef extends b2JointDef {
public var localAnchor1:b2Vec2;
public var length:Number;
public var dampingRatio:Number;
public var localAnchor2:b2Vec2;
public var frequencyHz:Number;
public function b2DistanceJointDef(){
localAnchor1 = new b2Vec2();
localAnchor2 = new b2Vec2();
super();
type = b2Joint.e_distanceJoint;
length = 1;
frequencyHz = 0;
dampingRatio = 0;
}
public function Initialize(_arg1:b2Body, _arg2:b2Body, _arg3:b2Vec2, _arg4:b2Vec2):void{
body1 = _arg1;
body2 = _arg2;
localAnchor1.SetV(body1.GetLocalPoint(_arg3));
localAnchor2.SetV(body2.GetLocalPoint(_arg4));
var _local5:Number = (_arg4.x - _arg3.x);
var _local6:Number = (_arg4.y - _arg3.y);
length = Math.sqrt(((_local5 * _local5) + (_local6 * _local6)));
frequencyHz = 0;
dampingRatio = 0;
}
}
}//package Box2D.Dynamics.Joints
Section 50
//b2GearJoint (Box2D.Dynamics.Joints.b2GearJoint)
package Box2D.Dynamics.Joints {
import Box2D.Common.Math.*;
import Box2D.Dynamics.*;
import Box2D.Common.*;
public class b2GearJoint extends b2Joint {
public var m_ground2:b2Body;
public var m_groundAnchor1:b2Vec2;
public var m_groundAnchor2:b2Vec2;
public var m_localAnchor1:b2Vec2;
public var m_localAnchor2:b2Vec2;
public var m_ratio:Number;
public var m_revolute2:b2RevoluteJoint;
public var m_force:Number;
public var m_mass:Number;
public var m_prismatic2:b2PrismaticJoint;
public var m_ground1:b2Body;
public var m_revolute1:b2RevoluteJoint;
public var m_prismatic1:b2PrismaticJoint;
public var m_constant:Number;
public var m_J:b2Jacobian;
public function b2GearJoint(_arg1:b2GearJointDef){
var _local4:Number;
var _local5:Number;
m_groundAnchor1 = new b2Vec2();
m_groundAnchor2 = new b2Vec2();
m_localAnchor1 = new b2Vec2();
m_localAnchor2 = new b2Vec2();
m_J = new b2Jacobian();
super(_arg1);
var _local2:int = _arg1.joint1.m_type;
var _local3:int = _arg1.joint2.m_type;
m_revolute1 = null;
m_prismatic1 = null;
m_revolute2 = null;
m_prismatic2 = null;
m_ground1 = _arg1.joint1.m_body1;
m_body1 = _arg1.joint1.m_body2;
if (_local2 == b2Joint.e_revoluteJoint){
m_revolute1 = (_arg1.joint1 as b2RevoluteJoint);
m_groundAnchor1.SetV(m_revolute1.m_localAnchor1);
m_localAnchor1.SetV(m_revolute1.m_localAnchor2);
_local4 = m_revolute1.GetJointAngle();
} else {
m_prismatic1 = (_arg1.joint1 as b2PrismaticJoint);
m_groundAnchor1.SetV(m_prismatic1.m_localAnchor1);
m_localAnchor1.SetV(m_prismatic1.m_localAnchor2);
_local4 = m_prismatic1.GetJointTranslation();
};
m_ground2 = _arg1.joint2.m_body1;
m_body2 = _arg1.joint2.m_body2;
if (_local3 == b2Joint.e_revoluteJoint){
m_revolute2 = (_arg1.joint2 as b2RevoluteJoint);
m_groundAnchor2.SetV(m_revolute2.m_localAnchor1);
m_localAnchor2.SetV(m_revolute2.m_localAnchor2);
_local5 = m_revolute2.GetJointAngle();
} else {
m_prismatic2 = (_arg1.joint2 as b2PrismaticJoint);
m_groundAnchor2.SetV(m_prismatic2.m_localAnchor1);
m_localAnchor2.SetV(m_prismatic2.m_localAnchor2);
_local5 = m_prismatic2.GetJointTranslation();
};
m_ratio = _arg1.ratio;
m_constant = (_local4 + (m_ratio * _local5));
m_force = 0;
}
override public function GetAnchor1():b2Vec2{
return (m_body1.GetWorldPoint(m_localAnchor1));
}
override public function GetAnchor2():b2Vec2{
return (m_body2.GetWorldPoint(m_localAnchor2));
}
override public function InitVelocityConstraints(_arg1:b2TimeStep):void{
var _local6:Number;
var _local7:Number;
var _local8:Number;
var _local9:Number;
var _local10:b2Mat22;
var _local11:b2Vec2;
var _local12:Number;
var _local13:Number;
var _local15:Number;
var _local2:b2Body = m_ground1;
var _local3:b2Body = m_ground2;
var _local4:b2Body = m_body1;
var _local5:b2Body = m_body2;
var _local14:Number = 0;
m_J.SetZero();
if (m_revolute1){
m_J.angular1 = -1;
_local14 = (_local14 + _local4.m_invI);
} else {
_local10 = _local2.m_xf.R;
_local11 = m_prismatic1.m_localXAxis1;
_local6 = ((_local10.col1.x * _local11.x) + (_local10.col2.x * _local11.y));
_local7 = ((_local10.col1.y * _local11.x) + (_local10.col2.y * _local11.y));
_local10 = _local4.m_xf.R;
_local8 = (m_localAnchor1.x - _local4.m_sweep.localCenter.x);
_local9 = (m_localAnchor1.y - _local4.m_sweep.localCenter.y);
_local13 = ((_local10.col1.x * _local8) + (_local10.col2.x * _local9));
_local9 = ((_local10.col1.y * _local8) + (_local10.col2.y * _local9));
_local8 = _local13;
_local12 = ((_local8 * _local7) - (_local9 * _local6));
m_J.linear1.Set(-(_local6), -(_local7));
m_J.angular1 = -(_local12);
_local14 = (_local14 + (_local4.m_invMass + ((_local4.m_invI * _local12) * _local12)));
};
if (m_revolute2){
m_J.angular2 = -(m_ratio);
_local14 = (_local14 + ((m_ratio * m_ratio) * _local5.m_invI));
} else {
_local10 = _local3.m_xf.R;
_local11 = m_prismatic2.m_localXAxis1;
_local6 = ((_local10.col1.x * _local11.x) + (_local10.col2.x * _local11.y));
_local7 = ((_local10.col1.y * _local11.x) + (_local10.col2.y * _local11.y));
_local10 = _local5.m_xf.R;
_local8 = (m_localAnchor2.x - _local5.m_sweep.localCenter.x);
_local9 = (m_localAnchor2.y - _local5.m_sweep.localCenter.y);
_local13 = ((_local10.col1.x * _local8) + (_local10.col2.x * _local9));
_local9 = ((_local10.col1.y * _local8) + (_local10.col2.y * _local9));
_local8 = _local13;
_local12 = ((_local8 * _local7) - (_local9 * _local6));
m_J.linear2.Set((-(m_ratio) * _local6), (-(m_ratio) * _local7));
m_J.angular2 = (-(m_ratio) * _local12);
_local14 = (_local14 + ((m_ratio * m_ratio) * (_local5.m_invMass + ((_local5.m_invI * _local12) * _local12))));
};
m_mass = (1 / _local14);
if (_arg1.warmStarting){
_local15 = (_arg1.dt * m_force);
_local4.m_linearVelocity.x = (_local4.m_linearVelocity.x + ((_local4.m_invMass * _local15) * m_J.linear1.x));
_local4.m_linearVelocity.y = (_local4.m_linearVelocity.y + ((_local4.m_invMass * _local15) * m_J.linear1.y));
_local4.m_angularVelocity = (_local4.m_angularVelocity + ((_local4.m_invI * _local15) * m_J.angular1));
_local5.m_linearVelocity.x = (_local5.m_linearVelocity.x + ((_local5.m_invMass * _local15) * m_J.linear2.x));
_local5.m_linearVelocity.y = (_local5.m_linearVelocity.y + ((_local5.m_invMass * _local15) * m_J.linear2.y));
_local5.m_angularVelocity = (_local5.m_angularVelocity + ((_local5.m_invI * _local15) * m_J.angular2));
} else {
m_force = 0;
};
}
override public function GetReactionTorque():Number{
var _local1:b2Mat22 = m_body2.m_xf.R;
var _local2:Number = (m_localAnchor1.x - m_body2.m_sweep.localCenter.x);
var _local3:Number = (m_localAnchor1.y - m_body2.m_sweep.localCenter.y);
var _local4:Number = ((_local1.col1.x * _local2) + (_local1.col2.x * _local3));
_local3 = ((_local1.col1.y * _local2) + (_local1.col2.y * _local3));
_local2 = _local4;
_local4 = ((m_force * m_J.angular2) - ((_local2 * (m_force * m_J.linear2.y)) - (_local3 * (m_force * m_J.linear2.x))));
return (_local4);
}
override public function GetReactionForce():b2Vec2{
var _local1:b2Vec2 = new b2Vec2((m_force * m_J.linear2.x), (m_force * m_J.linear2.y));
return (_local1);
}
override public function SolvePositionConstraints():Boolean{
var _local4:Number;
var _local5:Number;
var _local1:Number = 0;
var _local2:b2Body = m_body1;
var _local3:b2Body = m_body2;
if (m_revolute1){
_local4 = m_revolute1.GetJointAngle();
} else {
_local4 = m_prismatic1.GetJointTranslation();
};
if (m_revolute2){
_local5 = m_revolute2.GetJointAngle();
} else {
_local5 = m_prismatic2.GetJointTranslation();
};
var _local6:Number = (m_constant - (_local4 + (m_ratio * _local5)));
var _local7:Number = (-(m_mass) * _local6);
_local2.m_sweep.c.x = (_local2.m_sweep.c.x + ((_local2.m_invMass * _local7) * m_J.linear1.x));
_local2.m_sweep.c.y = (_local2.m_sweep.c.y + ((_local2.m_invMass * _local7) * m_J.linear1.y));
_local2.m_sweep.a = (_local2.m_sweep.a + ((_local2.m_invI * _local7) * m_J.angular1));
_local3.m_sweep.c.x = (_local3.m_sweep.c.x + ((_local3.m_invMass * _local7) * m_J.linear2.x));
_local3.m_sweep.c.y = (_local3.m_sweep.c.y + ((_local3.m_invMass * _local7) * m_J.linear2.y));
_local3.m_sweep.a = (_local3.m_sweep.a + ((_local3.m_invI * _local7) * m_J.angular2));
_local2.SynchronizeTransform();
_local3.SynchronizeTransform();
return ((_local1 < b2Settings.b2_linearSlop));
}
public function GetRatio():Number{
return (m_ratio);
}
override public function SolveVelocityConstraints(_arg1:b2TimeStep):void{
var _local2:b2Body = m_body1;
var _local3:b2Body = m_body2;
var _local4:Number = m_J.Compute(_local2.m_linearVelocity, _local2.m_angularVelocity, _local3.m_linearVelocity, _local3.m_angularVelocity);
var _local5:Number = ((-(_arg1.inv_dt) * m_mass) * _local4);
m_force = (m_force + _local5);
var _local6:Number = (_arg1.dt * _local5);
_local2.m_linearVelocity.x = (_local2.m_linearVelocity.x + ((_local2.m_invMass * _local6) * m_J.linear1.x));
_local2.m_linearVelocity.y = (_local2.m_linearVelocity.y + ((_local2.m_invMass * _local6) * m_J.linear1.y));
_local2.m_angularVelocity = (_local2.m_angularVelocity + ((_local2.m_invI * _local6) * m_J.angular1));
_local3.m_linearVelocity.x = (_local3.m_linearVelocity.x + ((_local3.m_invMass * _local6) * m_J.linear2.x));
_local3.m_linearVelocity.y = (_local3.m_linearVelocity.y + ((_local3.m_invMass * _local6) * m_J.linear2.y));
_local3.m_angularVelocity = (_local3.m_angularVelocity + ((_local3.m_invI * _local6) * m_J.angular2));
}
}
}//package Box2D.Dynamics.Joints
Section 51
//b2GearJointDef (Box2D.Dynamics.Joints.b2GearJointDef)
package Box2D.Dynamics.Joints {
public class b2GearJointDef extends b2JointDef {
public var joint1:b2Joint;
public var joint2:b2Joint;
public var ratio:Number;
public function b2GearJointDef(){
type = b2Joint.e_gearJoint;
joint1 = null;
joint2 = null;
ratio = 1;
}
}
}//package Box2D.Dynamics.Joints
Section 52
//b2Jacobian (Box2D.Dynamics.Joints.b2Jacobian)
package Box2D.Dynamics.Joints {
import Box2D.Common.Math.*;
public class b2Jacobian {
public var linear1:b2Vec2;
public var linear2:b2Vec2;
public var angular1:Number;
public var angular2:Number;
public function b2Jacobian(){
linear1 = new b2Vec2();
linear2 = new b2Vec2();
super();
}
public function Set(_arg1:b2Vec2, _arg2:Number, _arg3:b2Vec2, _arg4:Number):void{
linear1.SetV(_arg1);
angular1 = _arg2;
linear2.SetV(_arg3);
angular2 = _arg4;
}
public function SetZero():void{
linear1.SetZero();
angular1 = 0;
linear2.SetZero();
angular2 = 0;
}
public function Compute(_arg1:b2Vec2, _arg2:Number, _arg3:b2Vec2, _arg4:Number):Number{
return ((((((linear1.x * _arg1.x) + (linear1.y * _arg1.y)) + (angular1 * _arg2)) + ((linear2.x * _arg3.x) + (linear2.y * _arg3.y))) + (angular2 * _arg4)));
}
}
}//package Box2D.Dynamics.Joints
Section 53
//b2Joint (Box2D.Dynamics.Joints.b2Joint)
package Box2D.Dynamics.Joints {
import Box2D.Common.Math.*;
import Box2D.Dynamics.*;
public class b2Joint {
public var m_islandFlag:Boolean;
public var m_body1:b2Body;
public var m_prev:b2Joint;
public var m_next:b2Joint;
public var m_type:int;
public var m_collideConnected:Boolean;
public var m_node1:b2JointEdge;
public var m_node2:b2JointEdge;
public var m_inv_dt:Number;
public var m_userData;
public var m_body2:b2Body;
public static const e_unknownJoint:int = 0;
public static const e_inactiveLimit:int = 0;
public static const e_atUpperLimit:int = 2;
public static const e_atLowerLimit:int = 1;
public static const e_gearJoint:int = 6;
public static const e_revoluteJoint:int = 1;
public static const e_equalLimits:int = 3;
public static const e_distanceJoint:int = 3;
public static const e_pulleyJoint:int = 4;
public static const e_prismaticJoint:int = 2;
public static const e_mouseJoint:int = 5;
public function b2Joint(_arg1:b2JointDef){
m_node1 = new b2JointEdge();
m_node2 = new b2JointEdge();
super();
m_type = _arg1.type;
m_prev = null;
m_next = null;
m_body1 = _arg1.body1;
m_body2 = _arg1.body2;
m_collideConnected = _arg1.collideConnected;
m_islandFlag = false;
m_userData = _arg1.userData;
}
public function GetBody2():b2Body{
return (m_body2);
}
public function GetAnchor1():b2Vec2{
return (null);
}
public function GetAnchor2():b2Vec2{
return (null);
}
public function GetNext():b2Joint{
return (m_next);
}
public function GetType():int{
return (m_type);
}
public function InitVelocityConstraints(_arg1:b2TimeStep):void{
}
public function GetReactionTorque():Number{
return (0);
}
public function GetUserData(){
return (m_userData);
}
public function GetReactionForce():b2Vec2{
return (null);
}
public function SolvePositionConstraints():Boolean{
return (false);
}
public function SetUserData(_arg1):void{
m_userData = _arg1;
}
public function GetBody1():b2Body{
return (m_body1);
}
public function SolveVelocityConstraints(_arg1:b2TimeStep):void{
}
public function InitPositionConstraints():void{
}
public static function Destroy(_arg1:b2Joint, _arg2):void{
}
public static function Create(_arg1:b2JointDef, _arg2):b2Joint{
var _local3:b2Joint;
switch (_arg1.type){
case e_distanceJoint:
_local3 = new b2DistanceJoint((_arg1 as b2DistanceJointDef));
break;
case e_mouseJoint:
_local3 = new b2MouseJoint((_arg1 as b2MouseJointDef));
break;
case e_prismaticJoint:
_local3 = new b2PrismaticJoint((_arg1 as b2PrismaticJointDef));
break;
case e_revoluteJoint:
_local3 = new b2RevoluteJoint((_arg1 as b2RevoluteJointDef));
break;
case e_pulleyJoint:
_local3 = new b2PulleyJoint((_arg1 as b2PulleyJointDef));
break;
case e_gearJoint:
_local3 = new b2GearJoint((_arg1 as b2GearJointDef));
break;
default:
break;
};
return (_local3);
}
}
}//package Box2D.Dynamics.Joints
Section 54
//b2JointDef (Box2D.Dynamics.Joints.b2JointDef)
package Box2D.Dynamics.Joints {
import Box2D.Dynamics.*;
public class b2JointDef {
public var body2:b2Body;
public var type:int;
public var userData;
public var collideConnected:Boolean;
public var body1:b2Body;
public function b2JointDef(){
type = b2Joint.e_unknownJoint;
userData = null;
body1 = null;
body2 = null;
collideConnected = false;
}
}
}//package Box2D.Dynamics.Joints
Section 55
//b2JointEdge (Box2D.Dynamics.Joints.b2JointEdge)
package Box2D.Dynamics.Joints {
import Box2D.Dynamics.*;
public class b2JointEdge {
public var other:b2Body;
public var next:b2JointEdge;
public var prev:b2JointEdge;
public var joint:b2Joint;
}
}//package Box2D.Dynamics.Joints
Section 56
//b2MouseJoint (Box2D.Dynamics.Joints.b2MouseJoint)
package Box2D.Dynamics.Joints {
import Box2D.Common.Math.*;
import Box2D.Dynamics.*;
import Box2D.Common.*;
public class b2MouseJoint extends b2Joint {
private var K1:b2Mat22;
private var K:b2Mat22;
public var m_beta:Number;
public var m_mass:b2Mat22;
private var K2:b2Mat22;
public var m_target:b2Vec2;
public var m_gamma:Number;
public var m_impulse:b2Vec2;
public var m_C:b2Vec2;
public var m_localAnchor:b2Vec2;
public var m_maxForce:Number;
public function b2MouseJoint(_arg1:b2MouseJointDef){
var _local3:Number;
K = new b2Mat22();
K1 = new b2Mat22();
K2 = new b2Mat22();
m_localAnchor = new b2Vec2();
m_target = new b2Vec2();
m_impulse = new b2Vec2();
m_mass = new b2Mat22();
m_C = new b2Vec2();
super(_arg1);
m_target.SetV(_arg1.target);
var _local2:Number = (m_target.x - m_body2.m_xf.position.x);
_local3 = (m_target.y - m_body2.m_xf.position.y);
var _local4:b2Mat22 = m_body2.m_xf.R;
m_localAnchor.x = ((_local2 * _local4.col1.x) + (_local3 * _local4.col1.y));
m_localAnchor.y = ((_local2 * _local4.col2.x) + (_local3 * _local4.col2.y));
m_maxForce = _arg1.maxForce;
m_impulse.SetZero();
var _local5:Number = m_body2.m_mass;
var _local6:Number = ((2 * b2Settings.b2_pi) * _arg1.frequencyHz);
var _local7:Number = (((2 * _local5) * _arg1.dampingRatio) * _local6);
var _local8:Number = ((_arg1.timeStep * _local5) * (_local6 * _local6));
m_gamma = (1 / (_local7 + _local8));
m_beta = (_local8 / (_local7 + _local8));
}
public function SetTarget(_arg1:b2Vec2):void{
if (m_body2.IsSleeping()){
m_body2.WakeUp();
};
m_target = _arg1;
}
override public function GetAnchor2():b2Vec2{
return (m_body2.GetWorldPoint(m_localAnchor));
}
override public function InitVelocityConstraints(_arg1:b2TimeStep):void{
var _local2:b2Body;
var _local3:b2Mat22;
var _local4:Number;
var _local5:Number;
var _local7:Number;
var _local8:Number;
_local2 = m_body2;
_local3 = _local2.m_xf.R;
_local4 = (m_localAnchor.x - _local2.m_sweep.localCenter.x);
_local5 = (m_localAnchor.y - _local2.m_sweep.localCenter.y);
var _local6:Number = ((_local3.col1.x * _local4) + (_local3.col2.x * _local5));
_local5 = ((_local3.col1.y * _local4) + (_local3.col2.y * _local5));
_local4 = _local6;
_local7 = _local2.m_invMass;
_local8 = _local2.m_invI;
K1.col1.x = _local7;
K1.col2.x = 0;
K1.col1.y = 0;
K1.col2.y = _local7;
K2.col1.x = ((_local8 * _local5) * _local5);
K2.col2.x = ((-(_local8) * _local4) * _local5);
K2.col1.y = ((-(_local8) * _local4) * _local5);
K2.col2.y = ((_local8 * _local4) * _local4);
K.SetM(K1);
K.AddM(K2);
K.col1.x = (K.col1.x + m_gamma);
K.col2.y = (K.col2.y + m_gamma);
K.Invert(m_mass);
m_C.x = ((_local2.m_sweep.c.x + _local4) - m_target.x);
m_C.y = ((_local2.m_sweep.c.y + _local5) - m_target.y);
_local2.m_angularVelocity = (_local2.m_angularVelocity * 0.98);
var _local9:Number = (_arg1.dt * m_impulse.x);
var _local10:Number = (_arg1.dt * m_impulse.y);
_local2.m_linearVelocity.x = (_local2.m_linearVelocity.x + (_local7 * _local9));
_local2.m_linearVelocity.y = (_local2.m_linearVelocity.y + (_local7 * _local10));
_local2.m_angularVelocity = (_local2.m_angularVelocity + (_local8 * ((_local4 * _local10) - (_local5 * _local9))));
}
override public function GetAnchor1():b2Vec2{
return (m_target);
}
override public function GetReactionTorque():Number{
return (0);
}
override public function GetReactionForce():b2Vec2{
return (m_impulse);
}
override public function SolvePositionConstraints():Boolean{
return (true);
}
override public function SolveVelocityConstraints(_arg1:b2TimeStep):void{
var _local3:b2Mat22;
var _local4:Number;
var _local5:Number;
var _local2:b2Body = m_body2;
_local3 = _local2.m_xf.R;
var _local6:Number = (m_localAnchor.x - _local2.m_sweep.localCenter.x);
var _local7:Number = (m_localAnchor.y - _local2.m_sweep.localCenter.y);
_local4 = ((_local3.col1.x * _local6) + (_local3.col2.x * _local7));
_local7 = ((_local3.col1.y * _local6) + (_local3.col2.y * _local7));
_local6 = _local4;
var _local8:Number = (_local2.m_linearVelocity.x + (-(_local2.m_angularVelocity) * _local7));
var _local9:Number = (_local2.m_linearVelocity.y + (_local2.m_angularVelocity * _local6));
_local3 = m_mass;
_local4 = ((_local8 + ((m_beta * _arg1.inv_dt) * m_C.x)) + ((m_gamma * _arg1.dt) * m_impulse.x));
_local5 = ((_local9 + ((m_beta * _arg1.inv_dt) * m_C.y)) + ((m_gamma * _arg1.dt) * m_impulse.y));
var _local10:Number = (-(_arg1.inv_dt) * ((_local3.col1.x * _local4) + (_local3.col2.x * _local5)));
var _local11:Number = (-(_arg1.inv_dt) * ((_local3.col1.y * _local4) + (_local3.col2.y * _local5)));
var _local12:Number = m_impulse.x;
var _local13:Number = m_impulse.y;
m_impulse.x = (m_impulse.x + _local10);
m_impulse.y = (m_impulse.y + _local11);
var _local14:Number = m_impulse.Length();
if (_local14 > m_maxForce){
m_impulse.Multiply((m_maxForce / _local14));
};
_local10 = (m_impulse.x - _local12);
_local11 = (m_impulse.y - _local13);
var _local15:Number = (_arg1.dt * _local10);
var _local16:Number = (_arg1.dt * _local11);
_local2.m_linearVelocity.x = (_local2.m_linearVelocity.x + (_local2.m_invMass * _local15));
_local2.m_linearVelocity.y = (_local2.m_linearVelocity.y + (_local2.m_invMass * _local16));
_local2.m_angularVelocity = (_local2.m_angularVelocity + (_local2.m_invI * ((_local6 * _local16) - (_local7 * _local15))));
}
}
}//package Box2D.Dynamics.Joints
Section 57
//b2MouseJointDef (Box2D.Dynamics.Joints.b2MouseJointDef)
package Box2D.Dynamics.Joints {
import Box2D.Common.Math.*;
public class b2MouseJointDef extends b2JointDef {
public var timeStep:Number;
public var target:b2Vec2;
public var maxForce:Number;
public var dampingRatio:Number;
public var frequencyHz:Number;
public function b2MouseJointDef(){
target = new b2Vec2();
super();
type = b2Joint.e_mouseJoint;
maxForce = 0;
frequencyHz = 5;
dampingRatio = 0.7;
timeStep = (1 / 60);
}
}
}//package Box2D.Dynamics.Joints
Section 58
//b2PrismaticJoint (Box2D.Dynamics.Joints.b2PrismaticJoint)
package Box2D.Dynamics.Joints {
import Box2D.Common.Math.*;
import Box2D.Dynamics.*;
import Box2D.Common.*;
public class b2PrismaticJoint extends b2Joint {
public var m_limitForce:Number;
public var m_lowerTranslation:Number;
public var m_localXAxis1:b2Vec2;
public var m_refAngle:Number;
public var m_torque:Number;
public var m_motorForce:Number;
public var m_enableLimit:Boolean;
public var m_angularMass:Number;
public var m_maxMotorForce:Number;
public var m_localYAxis1:b2Vec2;
public var m_force:Number;
public var m_motorMass:Number;
public var m_upperTranslation:Number;
public var m_localAnchor1:b2Vec2;
public var m_localAnchor2:b2Vec2;
public var m_limitState:int;
public var m_linearMass:Number;
public var m_motorJacobian:b2Jacobian;
public var m_limitPositionImpulse:Number;
public var m_motorSpeed:Number;
public var m_enableMotor:Boolean;
public var m_linearJacobian:b2Jacobian;
public function b2PrismaticJoint(_arg1:b2PrismaticJointDef){
var _local2:b2Mat22;
var _local3:Number;
var _local4:Number;
m_localAnchor1 = new b2Vec2();
m_localAnchor2 = new b2Vec2();
m_localXAxis1 = new b2Vec2();
m_localYAxis1 = new b2Vec2();
m_linearJacobian = new b2Jacobian();
m_motorJacobian = new b2Jacobian();
super(_arg1);
m_localAnchor1.SetV(_arg1.localAnchor1);
m_localAnchor2.SetV(_arg1.localAnchor2);
m_localXAxis1.SetV(_arg1.localAxis1);
m_localYAxis1.x = -(m_localXAxis1.y);
m_localYAxis1.y = m_localXAxis1.x;
m_refAngle = _arg1.referenceAngle;
m_linearJacobian.SetZero();
m_linearMass = 0;
m_force = 0;
m_angularMass = 0;
m_torque = 0;
m_motorJacobian.SetZero();
m_motorMass = 0;
m_motorForce = 0;
m_limitForce = 0;
m_limitPositionImpulse = 0;
m_lowerTranslation = _arg1.lowerTranslation;
m_upperTranslation = _arg1.upperTranslation;
m_maxMotorForce = _arg1.maxMotorForce;
m_motorSpeed = _arg1.motorSpeed;
m_enableLimit = _arg1.enableLimit;
m_enableMotor = _arg1.enableMotor;
}
override public function SolveVelocityConstraints(_arg1:b2TimeStep):void{
var _local8:Number;
var _local15:Number;
var _local16:Number;
var _local17:Number;
var _local18:Number;
var _local19:Number;
var _local2:b2Body = m_body1;
var _local3:b2Body = m_body2;
var _local4:Number = _local2.m_invMass;
var _local5:Number = _local3.m_invMass;
var _local6:Number = _local2.m_invI;
var _local7:Number = _local3.m_invI;
var _local9:Number = m_linearJacobian.Compute(_local2.m_linearVelocity, _local2.m_angularVelocity, _local3.m_linearVelocity, _local3.m_angularVelocity);
var _local10:Number = ((-(_arg1.inv_dt) * m_linearMass) * _local9);
m_force = (m_force + _local10);
var _local11:Number = (_arg1.dt * _local10);
_local2.m_linearVelocity.x = (_local2.m_linearVelocity.x + ((_local4 * _local11) * m_linearJacobian.linear1.x));
_local2.m_linearVelocity.y = (_local2.m_linearVelocity.y + ((_local4 * _local11) * m_linearJacobian.linear1.y));
_local2.m_angularVelocity = (_local2.m_angularVelocity + ((_local6 * _local11) * m_linearJacobian.angular1));
_local3.m_linearVelocity.x = (_local3.m_linearVelocity.x + ((_local5 * _local11) * m_linearJacobian.linear2.x));
_local3.m_linearVelocity.y = (_local3.m_linearVelocity.y + ((_local5 * _local11) * m_linearJacobian.linear2.y));
_local3.m_angularVelocity = (_local3.m_angularVelocity + ((_local7 * _local11) * m_linearJacobian.angular2));
var _local12:Number = (_local3.m_angularVelocity - _local2.m_angularVelocity);
var _local13:Number = ((-(_arg1.inv_dt) * m_angularMass) * _local12);
m_torque = (m_torque + _local13);
var _local14:Number = (_arg1.dt * _local13);
_local2.m_angularVelocity = (_local2.m_angularVelocity - (_local6 * _local14));
_local3.m_angularVelocity = (_local3.m_angularVelocity + (_local7 * _local14));
if (((m_enableMotor) && (!((m_limitState == e_equalLimits))))){
_local15 = (m_motorJacobian.Compute(_local2.m_linearVelocity, _local2.m_angularVelocity, _local3.m_linearVelocity, _local3.m_angularVelocity) - m_motorSpeed);
_local16 = ((-(_arg1.inv_dt) * m_motorMass) * _local15);
_local17 = m_motorForce;
m_motorForce = b2Math.b2Clamp((m_motorForce + _local16), -(m_maxMotorForce), m_maxMotorForce);
_local16 = (m_motorForce - _local17);
_local11 = (_arg1.dt * _local16);
_local2.m_linearVelocity.x = (_local2.m_linearVelocity.x + ((_local4 * _local11) * m_motorJacobian.linear1.x));
_local2.m_linearVelocity.y = (_local2.m_linearVelocity.y + ((_local4 * _local11) * m_motorJacobian.linear1.y));
_local2.m_angularVelocity = (_local2.m_angularVelocity + ((_local6 * _local11) * m_motorJacobian.angular1));
_local3.m_linearVelocity.x = (_local3.m_linearVelocity.x + ((_local5 * _local11) * m_motorJacobian.linear2.x));
_local3.m_linearVelocity.y = (_local3.m_linearVelocity.y + ((_local5 * _local11) * m_motorJacobian.linear2.y));
_local3.m_angularVelocity = (_local3.m_angularVelocity + ((_local7 * _local11) * m_motorJacobian.angular2));
};
if (((m_enableLimit) && (!((m_limitState == e_inactiveLimit))))){
_local18 = m_motorJacobian.Compute(_local2.m_linearVelocity, _local2.m_angularVelocity, _local3.m_linearVelocity, _local3.m_angularVelocity);
_local19 = ((-(_arg1.inv_dt) * m_motorMass) * _local18);
if (m_limitState == e_equalLimits){
m_limitForce = (m_limitForce + _local19);
} else {
if (m_limitState == e_atLowerLimit){
_local8 = m_limitForce;
m_limitForce = b2Math.b2Max((m_limitForce + _local19), 0);
_local19 = (m_limitForce - _local8);
} else {
if (m_limitState == e_atUpperLimit){
_local8 = m_limitForce;
m_limitForce = b2Math.b2Min((m_limitForce + _local19), 0);
_local19 = (m_limitForce - _local8);
};
};
};
_local11 = (_arg1.dt * _local19);
_local2.m_linearVelocity.x = (_local2.m_linearVelocity.x + ((_local4 * _local11) * m_motorJacobian.linear1.x));
_local2.m_linearVelocity.y = (_local2.m_linearVelocity.y + ((_local4 * _local11) * m_motorJacobian.linear1.y));
_local2.m_angularVelocity = (_local2.m_angularVelocity + ((_local6 * _local11) * m_motorJacobian.angular1));
_local3.m_linearVelocity.x = (_local3.m_linearVelocity.x + ((_local5 * _local11) * m_motorJacobian.linear2.x));
_local3.m_linearVelocity.y = (_local3.m_linearVelocity.y + ((_local5 * _local11) * m_motorJacobian.linear2.y));
_local3.m_angularVelocity = (_local3.m_angularVelocity + ((_local7 * _local11) * m_motorJacobian.angular2));
};
}
override public function GetAnchor1():b2Vec2{
return (m_body1.GetWorldPoint(m_localAnchor1));
}
override public function GetAnchor2():b2Vec2{
return (m_body2.GetWorldPoint(m_localAnchor2));
}
public function GetUpperLimit():Number{
return (m_upperTranslation);
}
public function GetLowerLimit():Number{
return (m_lowerTranslation);
}
public function EnableMotor(_arg1:Boolean):void{
m_enableMotor = _arg1;
}
public function GetJointTranslation():Number{
var _local3:b2Mat22;
var _local1:b2Body = m_body1;
var _local2:b2Body = m_body2;
var _local4:b2Vec2 = _local1.GetWorldPoint(m_localAnchor1);
var _local5:b2Vec2 = _local2.GetWorldPoint(m_localAnchor2);
var _local6:Number = (_local5.x - _local4.x);
var _local7:Number = (_local5.y - _local4.y);
var _local8:b2Vec2 = _local1.GetWorldVector(m_localXAxis1);
var _local9:Number = ((_local8.x * _local6) + (_local8.y * _local7));
return (_local9);
}
public function GetMotorSpeed():Number{
return (m_motorSpeed);
}
override public function GetReactionForce():b2Vec2{
var _local1:b2Mat22 = m_body1.m_xf.R;
var _local2:Number = (m_limitForce * ((_local1.col1.x * m_localXAxis1.x) + (_local1.col2.x * m_localXAxis1.y)));
var _local3:Number = (m_limitForce * ((_local1.col1.y * m_localXAxis1.x) + (_local1.col2.y * m_localXAxis1.y)));
var _local4:Number = (m_force * ((_local1.col1.x * m_localYAxis1.x) + (_local1.col2.x * m_localYAxis1.y)));
var _local5:Number = (m_force * ((_local1.col1.y * m_localYAxis1.x) + (_local1.col2.y * m_localYAxis1.y)));
return (new b2Vec2(((m_limitForce * _local2) + (m_force * _local4)), ((m_limitForce * _local3) + (m_force * _local5))));
}
override public function SolvePositionConstraints():Boolean{
var _local1:Number;
var _local2:Number;
var _local9:b2Mat22;
var _local10:Number;
var _local29:Number;
var _local30:Number;
var _local31:Number;
var _local32:Number;
var _local3:b2Body = m_body1;
var _local4:b2Body = m_body2;
var _local5:Number = _local3.m_invMass;
var _local6:Number = _local4.m_invMass;
var _local7:Number = _local3.m_invI;
var _local8:Number = _local4.m_invI;
_local9 = _local3.m_xf.R;
var _local11:Number = (m_localAnchor1.x - _local3.m_sweep.localCenter.x);
var _local12:Number = (m_localAnchor1.y - _local3.m_sweep.localCenter.y);
_local10 = ((_local9.col1.x * _local11) + (_local9.col2.x * _local12));
_local12 = ((_local9.col1.y * _local11) + (_local9.col2.y * _local12));
_local11 = _local10;
_local9 = _local4.m_xf.R;
var _local13:Number = (m_localAnchor2.x - _local4.m_sweep.localCenter.x);
var _local14:Number = (m_localAnchor2.y - _local4.m_sweep.localCenter.y);
_local10 = ((_local9.col1.x * _local13) + (_local9.col2.x * _local14));
_local14 = ((_local9.col1.y * _local13) + (_local9.col2.y * _local14));
_local13 = _local10;
var _local15:Number = (_local3.m_sweep.c.x + _local11);
var _local16:Number = (_local3.m_sweep.c.y + _local12);
var _local17:Number = (_local4.m_sweep.c.x + _local13);
var _local18:Number = (_local4.m_sweep.c.y + _local14);
var _local19:Number = (_local17 - _local15);
var _local20:Number = (_local18 - _local16);
_local9 = _local3.m_xf.R;
var _local21:Number = ((_local9.col1.x * m_localYAxis1.x) + (_local9.col2.x * m_localYAxis1.y));
var _local22:Number = ((_local9.col1.y * m_localYAxis1.x) + (_local9.col2.y * m_localYAxis1.y));
var _local23:Number = ((_local21 * _local19) + (_local22 * _local20));
_local23 = b2Math.b2Clamp(_local23, -(b2Settings.b2_maxLinearCorrection), b2Settings.b2_maxLinearCorrection);
var _local24:Number = (-(m_linearMass) * _local23);
_local3.m_sweep.c.x = (_local3.m_sweep.c.x + ((_local5 * _local24) * m_linearJacobian.linear1.x));
_local3.m_sweep.c.y = (_local3.m_sweep.c.y + ((_local5 * _local24) * m_linearJacobian.linear1.y));
_local3.m_sweep.a = (_local3.m_sweep.a + ((_local7 * _local24) * m_linearJacobian.angular1));
_local4.m_sweep.c.x = (_local4.m_sweep.c.x + ((_local6 * _local24) * m_linearJacobian.linear2.x));
_local4.m_sweep.c.y = (_local4.m_sweep.c.y + ((_local6 * _local24) * m_linearJacobian.linear2.y));
_local4.m_sweep.a = (_local4.m_sweep.a + ((_local8 * _local24) * m_linearJacobian.angular2));
var _local25:Number = b2Math.b2Abs(_local23);
var _local26:Number = ((_local4.m_sweep.a - _local3.m_sweep.a) - m_refAngle);
_local26 = b2Math.b2Clamp(_local26, -(b2Settings.b2_maxAngularCorrection), b2Settings.b2_maxAngularCorrection);
var _local27:Number = (-(m_angularMass) * _local26);
_local3.m_sweep.a = (_local3.m_sweep.a - (_local3.m_invI * _local27));
_local4.m_sweep.a = (_local4.m_sweep.a + (_local4.m_invI * _local27));
_local3.SynchronizeTransform();
_local4.SynchronizeTransform();
var _local28:Number = b2Math.b2Abs(_local26);
if (((m_enableLimit) && (!((m_limitState == e_inactiveLimit))))){
_local9 = _local3.m_xf.R;
_local11 = (m_localAnchor1.x - _local3.m_sweep.localCenter.x);
_local12 = (m_localAnchor1.y - _local3.m_sweep.localCenter.y);
_local10 = ((_local9.col1.x * _local11) + (_local9.col2.x * _local12));
_local12 = ((_local9.col1.y * _local11) + (_local9.col2.y * _local12));
_local11 = _local10;
_local9 = _local4.m_xf.R;
_local13 = (m_localAnchor2.x - _local4.m_sweep.localCenter.x);
_local14 = (m_localAnchor2.y - _local4.m_sweep.localCenter.y);
_local10 = ((_local9.col1.x * _local13) + (_local9.col2.x * _local14));
_local14 = ((_local9.col1.y * _local13) + (_local9.col2.y * _local14));
_local13 = _local10;
_local15 = (_local3.m_sweep.c.x + _local11);
_local16 = (_local3.m_sweep.c.y + _local12);
_local17 = (_local4.m_sweep.c.x + _local13);
_local18 = (_local4.m_sweep.c.y + _local14);
_local19 = (_local17 - _local15);
_local20 = (_local18 - _local16);
_local9 = _local3.m_xf.R;
_local29 = ((_local9.col1.x * m_localXAxis1.x) + (_local9.col2.x * m_localXAxis1.y));
_local30 = ((_local9.col1.y * m_localXAxis1.x) + (_local9.col2.y * m_localXAxis1.y));
_local31 = ((_local29 * _local19) + (_local30 * _local20));
_local32 = 0;
if (m_limitState == e_equalLimits){
_local1 = b2Math.b2Clamp(_local31, -(b2Settings.b2_maxLinearCorrection), b2Settings.b2_maxLinearCorrection);
_local32 = (-(m_motorMass) * _local1);
_local25 = b2Math.b2Max(_local25, b2Math.b2Abs(_local26));
} else {
if (m_limitState == e_atLowerLimit){
_local1 = (_local31 - m_lowerTranslation);
_local25 = b2Math.b2Max(_local25, -(_local1));
_local1 = b2Math.b2Clamp((_local1 + b2Settings.b2_linearSlop), -(b2Settings.b2_maxLinearCorrection), 0);
_local32 = (-(m_motorMass) * _local1);
_local2 = m_limitPositionImpulse;
m_limitPositionImpulse = b2Math.b2Max((m_limitPositionImpulse + _local32), 0);
_local32 = (m_limitPositionImpulse - _local2);
} else {
if (m_limitState == e_atUpperLimit){
_local1 = (_local31 - m_upperTranslation);
_local25 = b2Math.b2Max(_local25, _local1);
_local1 = b2Math.b2Clamp((_local1 - b2Settings.b2_linearSlop), 0, b2Settings.b2_maxLinearCorrection);
_local32 = (-(m_motorMass) * _local1);
_local2 = m_limitPositionImpulse;
m_limitPositionImpulse = b2Math.b2Min((m_limitPositionImpulse + _local32), 0);
_local32 = (m_limitPositionImpulse - _local2);
};
};
};
_local3.m_sweep.c.x = (_local3.m_sweep.c.x + ((_local5 * _local32) * m_motorJacobian.linear1.x));
_local3.m_sweep.c.y = (_local3.m_sweep.c.y + ((_local5 * _local32) * m_motorJacobian.linear1.y));
_local3.m_sweep.a = (_local3.m_sweep.a + ((_local7 * _local32) * m_motorJacobian.angular1));
_local4.m_sweep.c.x = (_local4.m_sweep.c.x + ((_local6 * _local32) * m_motorJacobian.linear2.x));
_local4.m_sweep.c.y = (_local4.m_sweep.c.y + ((_local6 * _local32) * m_motorJacobian.linear2.y));
_local4.m_sweep.a = (_local4.m_sweep.a + ((_local8 * _local32) * m_motorJacobian.angular2));
_local3.SynchronizeTransform();
_local4.SynchronizeTransform();
};
return ((((_local25 <= b2Settings.b2_linearSlop)) && ((_local28 <= b2Settings.b2_angularSlop))));
}
public function SetMotorSpeed(_arg1:Number):void{
m_motorSpeed = _arg1;
}
public function GetJointSpeed():Number{
var _local3:b2Mat22;
var _local1:b2Body = m_body1;
var _local2:b2Body = m_body2;
_local3 = _local1.m_xf.R;
var _local4:Number = (m_localAnchor1.x - _local1.m_sweep.localCenter.x);
var _local5:Number = (m_localAnchor1.y - _local1.m_sweep.localCenter.y);
var _local6:Number = ((_local3.col1.x * _local4) + (_local3.col2.x * _local5));
_local5 = ((_local3.col1.y * _local4) + (_local3.col2.y * _local5));
_local4 = _local6;
_local3 = _local2.m_xf.R;
var _local7:Number = (m_localAnchor2.x - _local2.m_sweep.localCenter.x);
var _local8:Number = (m_localAnchor2.y - _local2.m_sweep.localCenter.y);
_local6 = ((_local3.col1.x * _local7) + (_local3.col2.x * _local8));
_local8 = ((_local3.col1.y * _local7) + (_local3.col2.y * _local8));
_local7 = _local6;
var _local9:Number = (_local1.m_sweep.c.x + _local4);
var _local10:Number = (_local1.m_sweep.c.y + _local5);
var _local11:Number = (_local2.m_sweep.c.x + _local7);
var _local12:Number = (_local2.m_sweep.c.y + _local8);
var _local13:Number = (_local11 - _local9);
var _local14:Number = (_local12 - _local10);
var _local15:b2Vec2 = _local1.GetWorldVector(m_localXAxis1);
var _local16:b2Vec2 = _local1.m_linearVelocity;
var _local17:b2Vec2 = _local2.m_linearVelocity;
var _local18:Number = _local1.m_angularVelocity;
var _local19:Number = _local2.m_angularVelocity;
var _local20:Number = (((_local13 * (-(_local18) * _local15.y)) + (_local14 * (_local18 * _local15.x))) + ((_local15.x * (((_local17.x + (-(_local19) * _local8)) - _local16.x) - (-(_local18) * _local5))) + (_local15.y * (((_local17.y + (_local19 * _local7)) - _local16.y) - (_local18 * _local4)))));
return (_local20);
}
override public function InitVelocityConstraints(_arg1:b2TimeStep):void{
var _local4:b2Mat22;
var _local5: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 _local2:b2Body = m_body1;
var _local3:b2Body = m_body2;
_local4 = _local2.m_xf.R;
var _local6:Number = (m_localAnchor1.x - _local2.m_sweep.localCenter.x);
var _local7:Number = (m_localAnchor1.y - _local2.m_sweep.localCenter.y);
_local5 = ((_local4.col1.x * _local6) + (_local4.col2.x * _local7));
_local7 = ((_local4.col1.y * _local6) + (_local4.col2.y * _local7));
_local6 = _local5;
_local4 = _local3.m_xf.R;
var _local8:Number = (m_localAnchor2.x - _local3.m_sweep.localCenter.x);
var _local9:Number = (m_localAnchor2.y - _local3.m_sweep.localCenter.y);
_local5 = ((_local4.col1.x * _local8) + (_local4.col2.x * _local9));
_local9 = ((_local4.col1.y * _local8) + (_local4.col2.y * _local9));
_local8 = _local5;
var _local10:Number = _local2.m_invMass;
var _local11:Number = _local3.m_invMass;
var _local12:Number = _local2.m_invI;
var _local13:Number = _local3.m_invI;
_local4 = _local2.m_xf.R;
var _local14:Number = ((_local4.col1.x * m_localYAxis1.x) + (_local4.col2.x * m_localYAxis1.y));
var _local15:Number = ((_local4.col1.y * m_localYAxis1.x) + (_local4.col2.y * m_localYAxis1.y));
var _local16:Number = ((_local3.m_sweep.c.x + _local8) - _local2.m_sweep.c.x);
var _local17:Number = ((_local3.m_sweep.c.y + _local9) - _local2.m_sweep.c.y);
m_linearJacobian.linear1.x = -(_local14);
m_linearJacobian.linear1.y = -(_local15);
m_linearJacobian.linear2.x = _local14;
m_linearJacobian.linear2.y = _local15;
m_linearJacobian.angular1 = -(((_local16 * _local15) - (_local17 * _local14)));
m_linearJacobian.angular2 = ((_local8 * _local15) - (_local9 * _local14));
m_linearMass = (((_local10 + ((_local12 * m_linearJacobian.angular1) * m_linearJacobian.angular1)) + _local11) + ((_local13 * m_linearJacobian.angular2) * m_linearJacobian.angular2));
m_linearMass = (1 / m_linearMass);
m_angularMass = (_local12 + _local13);
if (m_angularMass > Number.MIN_VALUE){
m_angularMass = (1 / m_angularMass);
};
if (((m_enableLimit) || (m_enableMotor))){
_local4 = _local2.m_xf.R;
_local18 = ((_local4.col1.x * m_localXAxis1.x) + (_local4.col2.x * m_localXAxis1.y));
_local19 = ((_local4.col1.y * m_localXAxis1.x) + (_local4.col2.y * m_localXAxis1.y));
m_motorJacobian.linear1.x = -(_local18);
m_motorJacobian.linear1.y = -(_local19);
m_motorJacobian.linear2.x = _local18;
m_motorJacobian.linear2.y = _local19;
m_motorJacobian.angular1 = -(((_local16 * _local19) - (_local17 * _local18)));
m_motorJacobian.angular2 = ((_local8 * _local19) - (_local9 * _local18));
m_motorMass = (((_local10 + ((_local12 * m_motorJacobian.angular1) * m_motorJacobian.angular1)) + _local11) + ((_local13 * m_motorJacobian.angular2) * m_motorJacobian.angular2));
m_motorMass = (1 / m_motorMass);
if (m_enableLimit){
_local20 = (_local16 - _local6);
_local21 = (_local17 - _local7);
_local22 = ((_local18 * _local20) + (_local19 * _local21));
if (b2Math.b2Abs((m_upperTranslation - m_lowerTranslation)) < (2 * b2Settings.b2_linearSlop)){
m_limitState = e_equalLimits;
} else {
if (_local22 <= m_lowerTranslation){
if (m_limitState != e_atLowerLimit){
m_limitForce = 0;
};
m_limitState = e_atLowerLimit;
} else {
if (_local22 >= m_upperTranslation){
if (m_limitState != e_atUpperLimit){
m_limitForce = 0;
};
m_limitState = e_atUpperLimit;
} else {
m_limitState = e_inactiveLimit;
m_limitForce = 0;
};
};
};
};
};
if (m_enableMotor == false){
m_motorForce = 0;
};
if (m_enableLimit == false){
m_limitForce = 0;
};
if (_arg1.warmStarting){
_local23 = (_arg1.dt * ((m_force * m_linearJacobian.linear1.x) + ((m_motorForce + m_limitForce) * m_motorJacobian.linear1.x)));
_local24 = (_arg1.dt * ((m_force * m_linearJacobian.linear1.y) + ((m_motorForce + m_limitForce) * m_motorJacobian.linear1.y)));
_local25 = (_arg1.dt * ((m_force * m_linearJacobian.linear2.x) + ((m_motorForce + m_limitForce) * m_motorJacobian.linear2.x)));
_local26 = (_arg1.dt * ((m_force * m_linearJacobian.linear2.y) + ((m_motorForce + m_limitForce) * m_motorJacobian.linear2.y)));
_local27 = (_arg1.dt * (((m_force * m_linearJacobian.angular1) - m_torque) + ((m_motorForce + m_limitForce) * m_motorJacobian.angular1)));
_local28 = (_arg1.dt * (((m_force * m_linearJacobian.angular2) + m_torque) + ((m_motorForce + m_limitForce) * m_motorJacobian.angular2)));
_local2.m_linearVelocity.x = (_local2.m_linearVelocity.x + (_local10 * _local23));
_local2.m_linearVelocity.y = (_local2.m_linearVelocity.y + (_local10 * _local24));
_local2.m_angularVelocity = (_local2.m_angularVelocity + (_local12 * _local27));
_local3.m_linearVelocity.x = (_local3.m_linearVelocity.x + (_local11 * _local25));
_local3.m_linearVelocity.y = (_local3.m_linearVelocity.y + (_local11 * _local26));
_local3.m_angularVelocity = (_local3.m_angularVelocity + (_local13 * _local28));
} else {
m_force = 0;
m_torque = 0;
m_limitForce = 0;
m_motorForce = 0;
};
m_limitPositionImpulse = 0;
}
public function GetMotorForce():Number{
return (m_motorForce);
}
public function EnableLimit(_arg1:Boolean):void{
m_enableLimit = _arg1;
}
public function SetMaxMotorForce(_arg1:Number):void{
m_maxMotorForce = _arg1;
}
override public function GetReactionTorque():Number{
return (m_torque);
}
public function IsLimitEnabled():Boolean{
return (m_enableLimit);
}
public function IsMotorEnabled():Boolean{
return (m_enableMotor);
}
public function SetLimits(_arg1:Number, _arg2:Number):void{
m_lowerTranslation = _arg1;
m_upperTranslation = _arg2;
}
}
}//package Box2D.Dynamics.Joints
Section 59
//b2PrismaticJointDef (Box2D.Dynamics.Joints.b2PrismaticJointDef)
package Box2D.Dynamics.Joints {
import Box2D.Common.Math.*;
import Box2D.Dynamics.*;
public class b2PrismaticJointDef extends b2JointDef {
public var motorSpeed:Number;
public var localAxis1:b2Vec2;
public var referenceAngle:Number;
public var upperTranslation:Number;
public var localAnchor1:b2Vec2;
public var localAnchor2:b2Vec2;
public var enableLimit:Boolean;
public var enableMotor:Boolean;
public var maxMotorForce:Number;
public var lowerTranslation:Number;
public function b2PrismaticJointDef(){
localAnchor1 = new b2Vec2();
localAnchor2 = new b2Vec2();
localAxis1 = new b2Vec2();
super();
type = b2Joint.e_prismaticJoint;
localAxis1.Set(1, 0);
referenceAngle = 0;
enableLimit = false;
lowerTranslation = 0;
upperTranslation = 0;
enableMotor = false;
maxMotorForce = 0;
motorSpeed = 0;
}
public function Initialize(_arg1:b2Body, _arg2:b2Body, _arg3:b2Vec2, _arg4:b2Vec2):void{
body1 = _arg1;
body2 = _arg2;
localAnchor1 = body1.GetLocalPoint(_arg3);
localAnchor2 = body2.GetLocalPoint(_arg3);
localAxis1 = body1.GetLocalVector(_arg4);
referenceAngle = (body2.GetAngle() - body1.GetAngle());
}
}
}//package Box2D.Dynamics.Joints
Section 60
//b2PulleyJoint (Box2D.Dynamics.Joints.b2PulleyJoint)
package Box2D.Dynamics.Joints {
import Box2D.Common.Math.*;
import Box2D.Dynamics.*;
import Box2D.Common.*;
public class b2PulleyJoint extends b2Joint {
public var m_limitState1:int;
public var m_limitState2:int;
public var m_ground:b2Body;
public var m_maxLength2:Number;
public var m_maxLength1:Number;
public var m_limitPositionImpulse1:Number;
public var m_limitPositionImpulse2:Number;
public var m_force:Number;
public var m_constant:Number;
public var m_positionImpulse:Number;
public var m_state:int;
public var m_ratio:Number;
public var m_groundAnchor1:b2Vec2;
public var m_groundAnchor2:b2Vec2;
public var m_localAnchor1:b2Vec2;
public var m_localAnchor2:b2Vec2;
public var m_limitMass1:Number;
public var m_limitMass2:Number;
public var m_pulleyMass:Number;
public var m_u1:b2Vec2;
public var m_limitForce1:Number;
public var m_limitForce2:Number;
public var m_u2:b2Vec2;
public static const b2_minPulleyLength:Number = 2;
public function b2PulleyJoint(_arg1:b2PulleyJointDef){
var _local2:b2Mat22;
var _local3:Number;
var _local4:Number;
m_groundAnchor1 = new b2Vec2();
m_groundAnchor2 = new b2Vec2();
m_localAnchor1 = new b2Vec2();
m_localAnchor2 = new b2Vec2();
m_u1 = new b2Vec2();
m_u2 = new b2Vec2();
super(_arg1);
m_ground = m_body1.m_world.m_groundBody;
m_groundAnchor1.x = (_arg1.groundAnchor1.x - m_ground.m_xf.position.x);
m_groundAnchor1.y = (_arg1.groundAnchor1.y - m_ground.m_xf.position.y);
m_groundAnchor2.x = (_arg1.groundAnchor2.x - m_ground.m_xf.position.x);
m_groundAnchor2.y = (_arg1.groundAnchor2.y - m_ground.m_xf.position.y);
m_localAnchor1.SetV(_arg1.localAnchor1);
m_localAnchor2.SetV(_arg1.localAnchor2);
m_ratio = _arg1.ratio;
m_constant = (_arg1.length1 + (m_ratio * _arg1.length2));
m_maxLength1 = b2Math.b2Min(_arg1.maxLength1, (m_constant - (m_ratio * b2_minPulleyLength)));
m_maxLength2 = b2Math.b2Min(_arg1.maxLength2, ((m_constant - b2_minPulleyLength) / m_ratio));
m_force = 0;
m_limitForce1 = 0;
m_limitForce2 = 0;
}
public function GetGroundAnchor2():b2Vec2{
var _local1:b2Vec2 = m_ground.m_xf.position.Copy();
_local1.Add(m_groundAnchor2);
return (_local1);
}
override public function GetAnchor1():b2Vec2{
return (m_body1.GetWorldPoint(m_localAnchor1));
}
override public function GetAnchor2():b2Vec2{
return (m_body2.GetWorldPoint(m_localAnchor2));
}
override public function GetReactionForce():b2Vec2{
var _local1:b2Vec2 = m_u2.Copy();
_local1.Multiply(m_force);
return (_local1);
}
override public function SolvePositionConstraints():Boolean{
var _local3:b2Mat22;
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 _local1:b2Body = m_body1;
var _local2:b2Body = m_body2;
var _local4:Number = (m_ground.m_xf.position.x + m_groundAnchor1.x);
var _local5:Number = (m_ground.m_xf.position.y + m_groundAnchor1.y);
var _local6:Number = (m_ground.m_xf.position.x + m_groundAnchor2.x);
var _local7:Number = (m_ground.m_xf.position.y + m_groundAnchor2.y);
var _local23:Number = 0;
if (m_state == e_atUpperLimit){
_local3 = _local1.m_xf.R;
_local8 = (m_localAnchor1.x - _local1.m_sweep.localCenter.x);
_local9 = (m_localAnchor1.y - _local1.m_sweep.localCenter.y);
_local22 = ((_local3.col1.x * _local8) + (_local3.col2.x * _local9));
_local9 = ((_local3.col1.y * _local8) + (_local3.col2.y * _local9));
_local8 = _local22;
_local3 = _local2.m_xf.R;
_local10 = (m_localAnchor2.x - _local2.m_sweep.localCenter.x);
_local11 = (m_localAnchor2.y - _local2.m_sweep.localCenter.y);
_local22 = ((_local3.col1.x * _local10) + (_local3.col2.x * _local11));
_local11 = ((_local3.col1.y * _local10) + (_local3.col2.y * _local11));
_local10 = _local22;
_local12 = (_local1.m_sweep.c.x + _local8);
_local13 = (_local1.m_sweep.c.y + _local9);
_local14 = (_local2.m_sweep.c.x + _local10);
_local15 = (_local2.m_sweep.c.y + _local11);
m_u1.Set((_local12 - _local4), (_local13 - _local5));
m_u2.Set((_local14 - _local6), (_local15 - _local7));
_local16 = m_u1.Length();
_local17 = m_u2.Length();
if (_local16 > b2Settings.b2_linearSlop){
m_u1.Multiply((1 / _local16));
} else {
m_u1.SetZero();
};
if (_local17 > b2Settings.b2_linearSlop){
m_u2.Multiply((1 / _local17));
} else {
m_u2.SetZero();
};
_local18 = ((m_constant - _local16) - (m_ratio * _local17));
_local23 = b2Math.b2Max(_local23, -(_local18));
_local18 = b2Math.b2Clamp((_local18 + b2Settings.b2_linearSlop), -(b2Settings.b2_maxLinearCorrection), 0);
_local19 = (-(m_pulleyMass) * _local18);
_local20 = m_positionImpulse;
m_positionImpulse = b2Math.b2Max(0, (m_positionImpulse + _local19));
_local19 = (m_positionImpulse - _local20);
_local12 = (-(_local19) * m_u1.x);
_local13 = (-(_local19) * m_u1.y);
_local14 = ((-(m_ratio) * _local19) * m_u2.x);
_local15 = ((-(m_ratio) * _local19) * m_u2.y);
_local1.m_sweep.c.x = (_local1.m_sweep.c.x + (_local1.m_invMass * _local12));
_local1.m_sweep.c.y = (_local1.m_sweep.c.y + (_local1.m_invMass * _local13));
_local1.m_sweep.a = (_local1.m_sweep.a + (_local1.m_invI * ((_local8 * _local13) - (_local9 * _local12))));
_local2.m_sweep.c.x = (_local2.m_sweep.c.x + (_local2.m_invMass * _local14));
_local2.m_sweep.c.y = (_local2.m_sweep.c.y + (_local2.m_invMass * _local15));
_local2.m_sweep.a = (_local2.m_sweep.a + (_local2.m_invI * ((_local10 * _local15) - (_local11 * _local14))));
_local1.SynchronizeTransform();
_local2.SynchronizeTransform();
};
if (m_limitState1 == e_atUpperLimit){
_local3 = _local1.m_xf.R;
_local8 = (m_localAnchor1.x - _local1.m_sweep.localCenter.x);
_local9 = (m_localAnchor1.y - _local1.m_sweep.localCenter.y);
_local22 = ((_local3.col1.x * _local8) + (_local3.col2.x * _local9));
_local9 = ((_local3.col1.y * _local8) + (_local3.col2.y * _local9));
_local8 = _local22;
_local12 = (_local1.m_sweep.c.x + _local8);
_local13 = (_local1.m_sweep.c.y + _local9);
m_u1.Set((_local12 - _local4), (_local13 - _local5));
_local16 = m_u1.Length();
if (_local16 > b2Settings.b2_linearSlop){
m_u1.x = (m_u1.x * (1 / _local16));
m_u1.y = (m_u1.y * (1 / _local16));
} else {
m_u1.SetZero();
};
_local18 = (m_maxLength1 - _local16);
_local23 = b2Math.b2Max(_local23, -(_local18));
_local18 = b2Math.b2Clamp((_local18 + b2Settings.b2_linearSlop), -(b2Settings.b2_maxLinearCorrection), 0);
_local19 = (-(m_limitMass1) * _local18);
_local21 = m_limitPositionImpulse1;
m_limitPositionImpulse1 = b2Math.b2Max(0, (m_limitPositionImpulse1 + _local19));
_local19 = (m_limitPositionImpulse1 - _local21);
_local12 = (-(_local19) * m_u1.x);
_local13 = (-(_local19) * m_u1.y);
_local1.m_sweep.c.x = (_local1.m_sweep.c.x + (_local1.m_invMass * _local12));
_local1.m_sweep.c.y = (_local1.m_sweep.c.y + (_local1.m_invMass * _local13));
_local1.m_sweep.a = (_local1.m_sweep.a + (_local1.m_invI * ((_local8 * _local13) - (_local9 * _local12))));
_local1.SynchronizeTransform();
};
if (m_limitState2 == e_atUpperLimit){
_local3 = _local2.m_xf.R;
_local10 = (m_localAnchor2.x - _local2.m_sweep.localCenter.x);
_local11 = (m_localAnchor2.y - _local2.m_sweep.localCenter.y);
_local22 = ((_local3.col1.x * _local10) + (_local3.col2.x * _local11));
_local11 = ((_local3.col1.y * _local10) + (_local3.col2.y * _local11));
_local10 = _local22;
_local14 = (_local2.m_sweep.c.x + _local10);
_local15 = (_local2.m_sweep.c.y + _local11);
m_u2.Set((_local14 - _local6), (_local15 - _local7));
_local17 = m_u2.Length();
if (_local17 > b2Settings.b2_linearSlop){
m_u2.x = (m_u2.x * (1 / _local17));
m_u2.y = (m_u2.y * (1 / _local17));
} else {
m_u2.SetZero();
};
_local18 = (m_maxLength2 - _local17);
_local23 = b2Math.b2Max(_local23, -(_local18));
_local18 = b2Math.b2Clamp((_local18 + b2Settings.b2_linearSlop), -(b2Settings.b2_maxLinearCorrection), 0);
_local19 = (-(m_limitMass2) * _local18);
_local21 = m_limitPositionImpulse2;
m_limitPositionImpulse2 = b2Math.b2Max(0, (m_limitPositionImpulse2 + _local19));
_local19 = (m_limitPositionImpulse2 - _local21);
_local14 = (-(_local19) * m_u2.x);
_local15 = (-(_local19) * m_u2.y);
_local2.m_sweep.c.x = (_local2.m_sweep.c.x + (_local2.m_invMass * _local14));
_local2.m_sweep.c.y = (_local2.m_sweep.c.y + (_local2.m_invMass * _local15));
_local2.m_sweep.a = (_local2.m_sweep.a + (_local2.m_invI * ((_local10 * _local15) - (_local11 * _local14))));
_local2.SynchronizeTransform();
};
return ((_local23 < b2Settings.b2_linearSlop));
}
override public function InitVelocityConstraints(_arg1:b2TimeStep):void{
var _local4:b2Mat22;
var _local23:Number;
var _local24:Number;
var _local25:Number;
var _local26:Number;
var _local2:b2Body = m_body1;
var _local3:b2Body = m_body2;
_local4 = _local2.m_xf.R;
var _local5:Number = (m_localAnchor1.x - _local2.m_sweep.localCenter.x);
var _local6:Number = (m_localAnchor1.y - _local2.m_sweep.localCenter.y);
var _local7:Number = ((_local4.col1.x * _local5) + (_local4.col2.x * _local6));
_local6 = ((_local4.col1.y * _local5) + (_local4.col2.y * _local6));
_local5 = _local7;
_local4 = _local3.m_xf.R;
var _local8:Number = (m_localAnchor2.x - _local3.m_sweep.localCenter.x);
var _local9:Number = (m_localAnchor2.y - _local3.m_sweep.localCenter.y);
_local7 = ((_local4.col1.x * _local8) + (_local4.col2.x * _local9));
_local9 = ((_local4.col1.y * _local8) + (_local4.col2.y * _local9));
_local8 = _local7;
var _local10:Number = (_local2.m_sweep.c.x + _local5);
var _local11:Number = (_local2.m_sweep.c.y + _local6);
var _local12:Number = (_local3.m_sweep.c.x + _local8);
var _local13:Number = (_local3.m_sweep.c.y + _local9);
var _local14:Number = (m_ground.m_xf.position.x + m_groundAnchor1.x);
var _local15:Number = (m_ground.m_xf.position.y + m_groundAnchor1.y);
var _local16:Number = (m_ground.m_xf.position.x + m_groundAnchor2.x);
var _local17:Number = (m_ground.m_xf.position.y + m_groundAnchor2.y);
m_u1.Set((_local10 - _local14), (_local11 - _local15));
m_u2.Set((_local12 - _local16), (_local13 - _local17));
var _local18:Number = m_u1.Length();
var _local19:Number = m_u2.Length();
if (_local18 > b2Settings.b2_linearSlop){
m_u1.Multiply((1 / _local18));
} else {
m_u1.SetZero();
};
if (_local19 > b2Settings.b2_linearSlop){
m_u2.Multiply((1 / _local19));
} else {
m_u2.SetZero();
};
var _local20:Number = ((m_constant - _local18) - (m_ratio * _local19));
if (_local20 > 0){
m_state = e_inactiveLimit;
m_force = 0;
} else {
m_state = e_atUpperLimit;
m_positionImpulse = 0;
};
if (_local18 < m_maxLength1){
m_limitState1 = e_inactiveLimit;
m_limitForce1 = 0;
} else {
m_limitState1 = e_atUpperLimit;
m_limitPositionImpulse1 = 0;
};
if (_local19 < m_maxLength2){
m_limitState2 = e_inactiveLimit;
m_limitForce2 = 0;
} else {
m_limitState2 = e_atUpperLimit;
m_limitPositionImpulse2 = 0;
};
var _local21:Number = ((_local5 * m_u1.y) - (_local6 * m_u1.x));
var _local22:Number = ((_local8 * m_u2.y) - (_local9 * m_u2.x));
m_limitMass1 = (_local2.m_invMass + ((_local2.m_invI * _local21) * _local21));
m_limitMass2 = (_local3.m_invMass + ((_local3.m_invI * _local22) * _local22));
m_pulleyMass = (m_limitMass1 + ((m_ratio * m_ratio) * m_limitMass2));
m_limitMass1 = (1 / m_limitMass1);
m_limitMass2 = (1 / m_limitMass2);
m_pulleyMass = (1 / m_pulleyMass);
if (_arg1.warmStarting){
_local23 = ((_arg1.dt * (-(m_force) - m_limitForce1)) * m_u1.x);
_local24 = ((_arg1.dt * (-(m_force) - m_limitForce1)) * m_u1.y);
_local25 = ((_arg1.dt * ((-(m_ratio) * m_force) - m_limitForce2)) * m_u2.x);
_local26 = ((_arg1.dt * ((-(m_ratio) * m_force) - m_limitForce2)) * m_u2.y);
_local2.m_linearVelocity.x = (_local2.m_linearVelocity.x + (_local2.m_invMass * _local23));
_local2.m_linearVelocity.y = (_local2.m_linearVelocity.y + (_local2.m_invMass * _local24));
_local2.m_angularVelocity = (_local2.m_angularVelocity + (_local2.m_invI * ((_local5 * _local24) - (_local6 * _local23))));
_local3.m_linearVelocity.x = (_local3.m_linearVelocity.x + (_local3.m_invMass * _local25));
_local3.m_linearVelocity.y = (_local3.m_linearVelocity.y + (_local3.m_invMass * _local26));
_local3.m_angularVelocity = (_local3.m_angularVelocity + (_local3.m_invI * ((_local8 * _local26) - (_local9 * _local25))));
} else {
m_force = 0;
m_limitForce1 = 0;
m_limitForce2 = 0;
};
}
override public function GetReactionTorque():Number{
return (0);
}
public function GetRatio():Number{
return (m_ratio);
}
override public function SolveVelocityConstraints(_arg1:b2TimeStep):void{
var _local4:b2Mat22;
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 _local2:b2Body = m_body1;
var _local3:b2Body = m_body2;
_local4 = _local2.m_xf.R;
var _local5:Number = (m_localAnchor1.x - _local2.m_sweep.localCenter.x);
var _local6:Number = (m_localAnchor1.y - _local2.m_sweep.localCenter.y);
var _local7:Number = ((_local4.col1.x * _local5) + (_local4.col2.x * _local6));
_local6 = ((_local4.col1.y * _local5) + (_local4.col2.y * _local6));
_local5 = _local7;
_local4 = _local3.m_xf.R;
var _local8:Number = (m_localAnchor2.x - _local3.m_sweep.localCenter.x);
var _local9:Number = (m_localAnchor2.y - _local3.m_sweep.localCenter.y);
_local7 = ((_local4.col1.x * _local8) + (_local4.col2.x * _local9));
_local9 = ((_local4.col1.y * _local8) + (_local4.col2.y * _local9));
_local8 = _local7;
if (m_state == e_atUpperLimit){
_local10 = (_local2.m_linearVelocity.x + (-(_local2.m_angularVelocity) * _local6));
_local11 = (_local2.m_linearVelocity.y + (_local2.m_angularVelocity * _local5));
_local12 = (_local3.m_linearVelocity.x + (-(_local3.m_angularVelocity) * _local9));
_local13 = (_local3.m_linearVelocity.y + (_local3.m_angularVelocity * _local8));
_local18 = (-(((m_u1.x * _local10) + (m_u1.y * _local11))) - (m_ratio * ((m_u2.x * _local12) + (m_u2.y * _local13))));
_local19 = ((-(_arg1.inv_dt) * m_pulleyMass) * _local18);
_local20 = m_force;
m_force = b2Math.b2Max(0, (m_force + _local19));
_local19 = (m_force - _local20);
_local14 = ((-(_arg1.dt) * _local19) * m_u1.x);
_local15 = ((-(_arg1.dt) * _local19) * m_u1.y);
_local16 = (((-(_arg1.dt) * m_ratio) * _local19) * m_u2.x);
_local17 = (((-(_arg1.dt) * m_ratio) * _local19) * m_u2.y);
_local2.m_linearVelocity.x = (_local2.m_linearVelocity.x + (_local2.m_invMass * _local14));
_local2.m_linearVelocity.y = (_local2.m_linearVelocity.y + (_local2.m_invMass * _local15));
_local2.m_angularVelocity = (_local2.m_angularVelocity + (_local2.m_invI * ((_local5 * _local15) - (_local6 * _local14))));
_local3.m_linearVelocity.x = (_local3.m_linearVelocity.x + (_local3.m_invMass * _local16));
_local3.m_linearVelocity.y = (_local3.m_linearVelocity.y + (_local3.m_invMass * _local17));
_local3.m_angularVelocity = (_local3.m_angularVelocity + (_local3.m_invI * ((_local8 * _local17) - (_local9 * _local16))));
};
if (m_limitState1 == e_atUpperLimit){
_local10 = (_local2.m_linearVelocity.x + (-(_local2.m_angularVelocity) * _local6));
_local11 = (_local2.m_linearVelocity.y + (_local2.m_angularVelocity * _local5));
_local18 = -(((m_u1.x * _local10) + (m_u1.y * _local11)));
_local19 = ((-(_arg1.inv_dt) * m_limitMass1) * _local18);
_local20 = m_limitForce1;
m_limitForce1 = b2Math.b2Max(0, (m_limitForce1 + _local19));
_local19 = (m_limitForce1 - _local20);
_local14 = ((-(_arg1.dt) * _local19) * m_u1.x);
_local15 = ((-(_arg1.dt) * _local19) * m_u1.y);
_local2.m_linearVelocity.x = (_local2.m_linearVelocity.x + (_local2.m_invMass * _local14));
_local2.m_linearVelocity.y = (_local2.m_linearVelocity.y + (_local2.m_invMass * _local15));
_local2.m_angularVelocity = (_local2.m_angularVelocity + (_local2.m_invI * ((_local5 * _local15) - (_local6 * _local14))));
};
if (m_limitState2 == e_atUpperLimit){
_local12 = (_local3.m_linearVelocity.x + (-(_local3.m_angularVelocity) * _local9));
_local13 = (_local3.m_linearVelocity.y + (_local3.m_angularVelocity * _local8));
_local18 = -(((m_u2.x * _local12) + (m_u2.y * _local13)));
_local19 = ((-(_arg1.inv_dt) * m_limitMass2) * _local18);
_local20 = m_limitForce2;
m_limitForce2 = b2Math.b2Max(0, (m_limitForce2 + _local19));
_local19 = (m_limitForce2 - _local20);
_local16 = ((-(_arg1.dt) * _local19) * m_u2.x);
_local17 = ((-(_arg1.dt) * _local19) * m_u2.y);
_local3.m_linearVelocity.x = (_local3.m_linearVelocity.x + (_local3.m_invMass * _local16));
_local3.m_linearVelocity.y = (_local3.m_linearVelocity.y + (_local3.m_invMass * _local17));
_local3.m_angularVelocity = (_local3.m_angularVelocity + (_local3.m_invI * ((_local8 * _local17) - (_local9 * _local16))));
};
}
public function GetLength1():Number{
var _local1:b2Vec2 = m_body1.GetWorldPoint(m_localAnchor1);
var _local2:Number = (m_ground.m_xf.position.x + m_groundAnchor1.x);
var _local3:Number = (m_ground.m_xf.position.y + m_groundAnchor1.y);
var _local4:Number = (_local1.x - _local2);
var _local5:Number = (_local1.y - _local3);
return (Math.sqrt(((_local4 * _local4) + (_local5 * _local5))));
}
public function GetLength2():Number{
var _local1:b2Vec2 = m_body2.GetWorldPoint(m_localAnchor2);
var _local2:Number = (m_ground.m_xf.position.x + m_groundAnchor2.x);
var _local3:Number = (m_ground.m_xf.position.y + m_groundAnchor2.y);
var _local4:Number = (_local1.x - _local2);
var _local5:Number = (_local1.y - _local3);
return (Math.sqrt(((_local4 * _local4) + (_local5 * _local5))));
}
public function GetGroundAnchor1():b2Vec2{
var _local1:b2Vec2 = m_ground.m_xf.position.Copy();
_local1.Add(m_groundAnchor1);
return (_local1);
}
}
}//package Box2D.Dynamics.Joints
Section 61
//b2PulleyJointDef (Box2D.Dynamics.Joints.b2PulleyJointDef)
package Box2D.Dynamics.Joints {
import Box2D.Common.Math.*;
import Box2D.Dynamics.*;
public class b2PulleyJointDef extends b2JointDef {
public var maxLength1:Number;
public var maxLength2:Number;
public var length1:Number;
public var localAnchor1:b2Vec2;
public var localAnchor2:b2Vec2;
public var groundAnchor1:b2Vec2;
public var groundAnchor2:b2Vec2;
public var ratio:Number;
public var length2:Number;
public function b2PulleyJointDef(){
groundAnchor1 = new b2Vec2();
groundAnchor2 = new b2Vec2();
localAnchor1 = new b2Vec2();
localAnchor2 = new b2Vec2();
super();
type = b2Joint.e_pulleyJoint;
groundAnchor1.Set(-1, 1);
groundAnchor2.Set(1, 1);
localAnchor1.Set(-1, 0);
localAnchor2.Set(1, 0);
length1 = 0;
maxLength1 = 0;
length2 = 0;
maxLength2 = 0;
ratio = 1;
collideConnected = true;
}
public function Initialize(_arg1:b2Body, _arg2:b2Body, _arg3:b2Vec2, _arg4:b2Vec2, _arg5:b2Vec2, _arg6:b2Vec2, _arg7:Number):void{
body1 = _arg1;
body2 = _arg2;
groundAnchor1.SetV(_arg3);
groundAnchor2.SetV(_arg4);
localAnchor1 = body1.GetLocalPoint(_arg5);
localAnchor2 = body2.GetLocalPoint(_arg6);
var _local8:Number = (_arg5.x - _arg3.x);
var _local9:Number = (_arg5.y - _arg3.y);
length1 = Math.sqrt(((_local8 * _local8) + (_local9 * _local9)));
var _local10:Number = (_arg6.x - _arg4.x);
var _local11:Number = (_arg6.y - _arg4.y);
length2 = Math.sqrt(((_local10 * _local10) + (_local11 * _local11)));
ratio = _arg7;
var _local12:Number = (length1 + (ratio * length2));
maxLength1 = (_local12 - (ratio * b2PulleyJoint.b2_minPulleyLength));
maxLength2 = ((_local12 - b2PulleyJoint.b2_minPulleyLength) / ratio);
}
}
}//package Box2D.Dynamics.Joints
Section 62
//b2RevoluteJoint (Box2D.Dynamics.Joints.b2RevoluteJoint)
package Box2D.Dynamics.Joints {
import Box2D.Common.Math.*;
import Box2D.Dynamics.*;
import Box2D.Common.*;
public class b2RevoluteJoint extends b2Joint {
public var m_limitForce:Number;
public var m_pivotMass:b2Mat22;
public var m_motorForce:Number;
public var m_enableLimit:Boolean;
public var m_limitState:int;
public var m_motorMass:Number;
public var m_localAnchor1:b2Vec2;
public var m_localAnchor2:b2Vec2;
private var K1:b2Mat22;
private var K2:b2Mat22;
private var K3:b2Mat22;
private var K:b2Mat22;
public var m_pivotForce:b2Vec2;
public var m_enableMotor:Boolean;
public var m_referenceAngle:Number;
public var m_limitPositionImpulse:Number;
public var m_motorSpeed:Number;
public var m_upperAngle:Number;
public var m_lowerAngle:Number;
public var m_maxMotorTorque:Number;
public static var tImpulse:b2Vec2 = new b2Vec2();
public function b2RevoluteJoint(_arg1:b2RevoluteJointDef){
K = new b2Mat22();
K1 = new b2Mat22();
K2 = new b2Mat22();
K3 = new b2Mat22();
m_localAnchor1 = new b2Vec2();
m_localAnchor2 = new b2Vec2();
m_pivotForce = new b2Vec2();
m_pivotMass = new b2Mat22();
super(_arg1);
m_localAnchor1.SetV(_arg1.localAnchor1);
m_localAnchor2.SetV(_arg1.localAnchor2);
m_referenceAngle = _arg1.referenceAngle;
m_pivotForce.Set(0, 0);
m_motorForce = 0;
m_limitForce = 0;
m_limitPositionImpulse = 0;
m_lowerAngle = _arg1.lowerAngle;
m_upperAngle = _arg1.upperAngle;
m_maxMotorTorque = _arg1.maxMotorTorque;
m_motorSpeed = _arg1.motorSpeed;
m_enableLimit = _arg1.enableLimit;
m_enableMotor = _arg1.enableMotor;
}
override public function SolveVelocityConstraints(_arg1:b2TimeStep):void{
var _local4:b2Mat22;
var _local5:Number;
var _local10:Number;
var _local16:Number;
var _local17:Number;
var _local18:Number;
var _local19:Number;
var _local20:Number;
var _local21:Number;
var _local2:b2Body = m_body1;
var _local3:b2Body = m_body2;
_local4 = _local2.m_xf.R;
var _local6:Number = (m_localAnchor1.x - _local2.m_sweep.localCenter.x);
var _local7:Number = (m_localAnchor1.y - _local2.m_sweep.localCenter.y);
_local5 = ((_local4.col1.x * _local6) + (_local4.col2.x * _local7));
_local7 = ((_local4.col1.y * _local6) + (_local4.col2.y * _local7));
_local6 = _local5;
_local4 = _local3.m_xf.R;
var _local8:Number = (m_localAnchor2.x - _local3.m_sweep.localCenter.x);
var _local9:Number = (m_localAnchor2.y - _local3.m_sweep.localCenter.y);
_local5 = ((_local4.col1.x * _local8) + (_local4.col2.x * _local9));
_local9 = ((_local4.col1.y * _local8) + (_local4.col2.y * _local9));
_local8 = _local5;
var _local11:Number = (((_local3.m_linearVelocity.x + (-(_local3.m_angularVelocity) * _local9)) - _local2.m_linearVelocity.x) - (-(_local2.m_angularVelocity) * _local7));
var _local12:Number = (((_local3.m_linearVelocity.y + (_local3.m_angularVelocity * _local8)) - _local2.m_linearVelocity.y) - (_local2.m_angularVelocity * _local6));
var _local13:Number = (-(_arg1.inv_dt) * ((m_pivotMass.col1.x * _local11) + (m_pivotMass.col2.x * _local12)));
var _local14:Number = (-(_arg1.inv_dt) * ((m_pivotMass.col1.y * _local11) + (m_pivotMass.col2.y * _local12)));
m_pivotForce.x = (m_pivotForce.x + _local13);
m_pivotForce.y = (m_pivotForce.y + _local14);
var _local15:Number = (_arg1.dt * _local13);
_local16 = (_arg1.dt * _local14);
_local2.m_linearVelocity.x = (_local2.m_linearVelocity.x - (_local2.m_invMass * _local15));
_local2.m_linearVelocity.y = (_local2.m_linearVelocity.y - (_local2.m_invMass * _local16));
_local2.m_angularVelocity = (_local2.m_angularVelocity - (_local2.m_invI * ((_local6 * _local16) - (_local7 * _local15))));
_local3.m_linearVelocity.x = (_local3.m_linearVelocity.x + (_local3.m_invMass * _local15));
_local3.m_linearVelocity.y = (_local3.m_linearVelocity.y + (_local3.m_invMass * _local16));
_local3.m_angularVelocity = (_local3.m_angularVelocity + (_local3.m_invI * ((_local8 * _local16) - (_local9 * _local15))));
if (((m_enableMotor) && (!((m_limitState == e_equalLimits))))){
_local17 = ((_local3.m_angularVelocity - _local2.m_angularVelocity) - m_motorSpeed);
_local18 = ((-(_arg1.inv_dt) * m_motorMass) * _local17);
_local19 = m_motorForce;
m_motorForce = b2Math.b2Clamp((m_motorForce + _local18), -(m_maxMotorTorque), m_maxMotorTorque);
_local18 = (m_motorForce - _local19);
_local2.m_angularVelocity = (_local2.m_angularVelocity - ((_local2.m_invI * _arg1.dt) * _local18));
_local3.m_angularVelocity = (_local3.m_angularVelocity + ((_local3.m_invI * _arg1.dt) * _local18));
};
if (((m_enableLimit) && (!((m_limitState == e_inactiveLimit))))){
_local20 = (_local3.m_angularVelocity - _local2.m_angularVelocity);
_local21 = ((-(_arg1.inv_dt) * m_motorMass) * _local20);
if (m_limitState == e_equalLimits){
m_limitForce = (m_limitForce + _local21);
} else {
if (m_limitState == e_atLowerLimit){
_local10 = m_limitForce;
m_limitForce = b2Math.b2Max((m_limitForce + _local21), 0);
_local21 = (m_limitForce - _local10);
} else {
if (m_limitState == e_atUpperLimit){
_local10 = m_limitForce;
m_limitForce = b2Math.b2Min((m_limitForce + _local21), 0);
_local21 = (m_limitForce - _local10);
};
};
};
_local2.m_angularVelocity = (_local2.m_angularVelocity - ((_local2.m_invI * _arg1.dt) * _local21));
_local3.m_angularVelocity = (_local3.m_angularVelocity + ((_local3.m_invI * _arg1.dt) * _local21));
};
}
override public function GetAnchor1():b2Vec2{
return (m_body1.GetWorldPoint(m_localAnchor1));
}
override public function GetAnchor2():b2Vec2{
return (m_body2.GetWorldPoint(m_localAnchor2));
}
public function GetUpperLimit():Number{
return (m_upperAngle);
}
public function GetLowerLimit():Number{
return (m_lowerAngle);
}
public function EnableMotor(_arg1:Boolean):void{
m_enableMotor = _arg1;
}
public function GetMotorSpeed():Number{
return (m_motorSpeed);
}
override public function GetReactionForce():b2Vec2{
return (m_pivotForce);
}
override public function SolvePositionConstraints():Boolean{
var _local1:Number;
var _local2:Number;
var _local6:b2Mat22;
var _local25:Number;
var _local26:Number;
var _local3:b2Body = m_body1;
var _local4:b2Body = m_body2;
var _local5:Number = 0;
_local6 = _local3.m_xf.R;
var _local7:Number = (m_localAnchor1.x - _local3.m_sweep.localCenter.x);
var _local8:Number = (m_localAnchor1.y - _local3.m_sweep.localCenter.y);
var _local9:Number = ((_local6.col1.x * _local7) + (_local6.col2.x * _local8));
_local8 = ((_local6.col1.y * _local7) + (_local6.col2.y * _local8));
_local7 = _local9;
_local6 = _local4.m_xf.R;
var _local10:Number = (m_localAnchor2.x - _local4.m_sweep.localCenter.x);
var _local11:Number = (m_localAnchor2.y - _local4.m_sweep.localCenter.y);
_local9 = ((_local6.col1.x * _local10) + (_local6.col2.x * _local11));
_local11 = ((_local6.col1.y * _local10) + (_local6.col2.y * _local11));
_local10 = _local9;
var _local12:Number = (_local3.m_sweep.c.x + _local7);
var _local13:Number = (_local3.m_sweep.c.y + _local8);
var _local14:Number = (_local4.m_sweep.c.x + _local10);
var _local15:Number = (_local4.m_sweep.c.y + _local11);
var _local16:Number = (_local14 - _local12);
var _local17:Number = (_local15 - _local13);
_local5 = Math.sqrt(((_local16 * _local16) + (_local17 * _local17)));
var _local18:Number = _local3.m_invMass;
var _local19:Number = _local4.m_invMass;
var _local20:Number = _local3.m_invI;
var _local21:Number = _local4.m_invI;
K1.col1.x = (_local18 + _local19);
K1.col2.x = 0;
K1.col1.y = 0;
K1.col2.y = (_local18 + _local19);
K2.col1.x = ((_local20 * _local8) * _local8);
K2.col2.x = ((-(_local20) * _local7) * _local8);
K2.col1.y = ((-(_local20) * _local7) * _local8);
K2.col2.y = ((_local20 * _local7) * _local7);
K3.col1.x = ((_local21 * _local11) * _local11);
K3.col2.x = ((-(_local21) * _local10) * _local11);
K3.col1.y = ((-(_local21) * _local10) * _local11);
K3.col2.y = ((_local21 * _local10) * _local10);
K.SetM(K1);
K.AddM(K2);
K.AddM(K3);
K.Solve(tImpulse, -(_local16), -(_local17));
var _local22:Number = tImpulse.x;
var _local23:Number = tImpulse.y;
_local3.m_sweep.c.x = (_local3.m_sweep.c.x - (_local3.m_invMass * _local22));
_local3.m_sweep.c.y = (_local3.m_sweep.c.y - (_local3.m_invMass * _local23));
_local3.m_sweep.a = (_local3.m_sweep.a - (_local3.m_invI * ((_local7 * _local23) - (_local8 * _local22))));
_local4.m_sweep.c.x = (_local4.m_sweep.c.x + (_local4.m_invMass * _local22));
_local4.m_sweep.c.y = (_local4.m_sweep.c.y + (_local4.m_invMass * _local23));
_local4.m_sweep.a = (_local4.m_sweep.a + (_local4.m_invI * ((_local10 * _local23) - (_local11 * _local22))));
_local3.SynchronizeTransform();
_local4.SynchronizeTransform();
var _local24:Number = 0;
if (((m_enableLimit) && (!((m_limitState == e_inactiveLimit))))){
_local25 = ((_local4.m_sweep.a - _local3.m_sweep.a) - m_referenceAngle);
_local26 = 0;
if (m_limitState == e_equalLimits){
_local2 = b2Math.b2Clamp(_local25, -(b2Settings.b2_maxAngularCorrection), b2Settings.b2_maxAngularCorrection);
_local26 = (-(m_motorMass) * _local2);
_local24 = b2Math.b2Abs(_local2);
} else {
if (m_limitState == e_atLowerLimit){
_local2 = (_local25 - m_lowerAngle);
_local24 = b2Math.b2Max(0, -(_local2));
_local2 = b2Math.b2Clamp((_local2 + b2Settings.b2_angularSlop), -(b2Settings.b2_maxAngularCorrection), 0);
_local26 = (-(m_motorMass) * _local2);
_local1 = m_limitPositionImpulse;
m_limitPositionImpulse = b2Math.b2Max((m_limitPositionImpulse + _local26), 0);
_local26 = (m_limitPositionImpulse - _local1);
} else {
if (m_limitState == e_atUpperLimit){
_local2 = (_local25 - m_upperAngle);
_local24 = b2Math.b2Max(0, _local2);
_local2 = b2Math.b2Clamp((_local2 - b2Settings.b2_angularSlop), 0, b2Settings.b2_maxAngularCorrection);
_local26 = (-(m_motorMass) * _local2);
_local1 = m_limitPositionImpulse;
m_limitPositionImpulse = b2Math.b2Min((m_limitPositionImpulse + _local26), 0);
_local26 = (m_limitPositionImpulse - _local1);
};
};
};
_local3.m_sweep.a = (_local3.m_sweep.a - (_local3.m_invI * _local26));
_local4.m_sweep.a = (_local4.m_sweep.a + (_local4.m_invI * _local26));
_local3.SynchronizeTransform();
_local4.SynchronizeTransform();
};
return ((((_local5 <= b2Settings.b2_linearSlop)) && ((_local24 <= b2Settings.b2_angularSlop))));
}
public function SetMotorSpeed(_arg1:Number):void{
m_motorSpeed = _arg1;
}
public function GetJointSpeed():Number{
return ((m_body2.m_angularVelocity - m_body1.m_angularVelocity));
}
public function SetMaxMotorTorque(_arg1:Number):void{
m_maxMotorTorque = _arg1;
}
public function GetJointAngle():Number{
return (((m_body2.m_sweep.a - m_body1.m_sweep.a) - m_referenceAngle));
}
public function GetMotorTorque():Number{
return (m_motorForce);
}
override public function InitVelocityConstraints(_arg1:b2TimeStep):void{
var _local2:b2Body;
var _local3:b2Body;
var _local4:b2Mat22;
var _local5:Number;
var _local7:Number;
var _local14:Number;
_local2 = m_body1;
_local3 = m_body2;
_local4 = _local2.m_xf.R;
var _local6:Number = (m_localAnchor1.x - _local2.m_sweep.localCenter.x);
_local7 = (m_localAnchor1.y - _local2.m_sweep.localCenter.y);
_local5 = ((_local4.col1.x * _local6) + (_local4.col2.x * _local7));
_local7 = ((_local4.col1.y * _local6) + (_local4.col2.y * _local7));
_local6 = _local5;
_local4 = _local3.m_xf.R;
var _local8:Number = (m_localAnchor2.x - _local3.m_sweep.localCenter.x);
var _local9:Number = (m_localAnchor2.y - _local3.m_sweep.localCenter.y);
_local5 = ((_local4.col1.x * _local8) + (_local4.col2.x * _local9));
_local9 = ((_local4.col1.y * _local8) + (_local4.col2.y * _local9));
_local8 = _local5;
var _local10:Number = _local2.m_invMass;
var _local11:Number = _local3.m_invMass;
var _local12:Number = _local2.m_invI;
var _local13:Number = _local3.m_invI;
K1.col1.x = (_local10 + _local11);
K1.col2.x = 0;
K1.col1.y = 0;
K1.col2.y = (_local10 + _local11);
K2.col1.x = ((_local12 * _local7) * _local7);
K2.col2.x = ((-(_local12) * _local6) * _local7);
K2.col1.y = ((-(_local12) * _local6) * _local7);
K2.col2.y = ((_local12 * _local6) * _local6);
K3.col1.x = ((_local13 * _local9) * _local9);
K3.col2.x = ((-(_local13) * _local8) * _local9);
K3.col1.y = ((-(_local13) * _local8) * _local9);
K3.col2.y = ((_local13 * _local8) * _local8);
K.SetM(K1);
K.AddM(K2);
K.AddM(K3);
K.Invert(m_pivotMass);
m_motorMass = (1 / (_local12 + _local13));
if (m_enableMotor == false){
m_motorForce = 0;
};
if (m_enableLimit){
_local14 = ((_local3.m_sweep.a - _local2.m_sweep.a) - m_referenceAngle);
if (b2Math.b2Abs((m_upperAngle - m_lowerAngle)) < (2 * b2Settings.b2_angularSlop)){
m_limitState = e_equalLimits;
} else {
if (_local14 <= m_lowerAngle){
if (m_limitState != e_atLowerLimit){
m_limitForce = 0;
};
m_limitState = e_atLowerLimit;
} else {
if (_local14 >= m_upperAngle){
if (m_limitState != e_atUpperLimit){
m_limitForce = 0;
};
m_limitState = e_atUpperLimit;
} else {
m_limitState = e_inactiveLimit;
m_limitForce = 0;
};
};
};
} else {
m_limitForce = 0;
};
if (_arg1.warmStarting){
_local2.m_linearVelocity.x = (_local2.m_linearVelocity.x - ((_arg1.dt * _local10) * m_pivotForce.x));
_local2.m_linearVelocity.y = (_local2.m_linearVelocity.y - ((_arg1.dt * _local10) * m_pivotForce.y));
_local2.m_angularVelocity = (_local2.m_angularVelocity - ((_arg1.dt * _local12) * ((((_local6 * m_pivotForce.y) - (_local7 * m_pivotForce.x)) + m_motorForce) + m_limitForce)));
_local3.m_linearVelocity.x = (_local3.m_linearVelocity.x + ((_arg1.dt * _local11) * m_pivotForce.x));
_local3.m_linearVelocity.y = (_local3.m_linearVelocity.y + ((_arg1.dt * _local11) * m_pivotForce.y));
_local3.m_angularVelocity = (_local3.m_angularVelocity + ((_arg1.dt * _local13) * ((((_local8 * m_pivotForce.y) - (_local9 * m_pivotForce.x)) + m_motorForce) + m_limitForce)));
} else {
m_pivotForce.SetZero();
m_motorForce = 0;
m_limitForce = 0;
};
m_limitPositionImpulse = 0;
}
public function EnableLimit(_arg1:Boolean):void{
m_enableLimit = _arg1;
}
override public function GetReactionTorque():Number{
return (m_limitForce);
}
public function IsLimitEnabled():Boolean{
return (m_enableLimit);
}
public function IsMotorEnabled():Boolean{
return (m_enableMotor);
}
public function SetLimits(_arg1:Number, _arg2:Number):void{
m_lowerAngle = _arg1;
m_upperAngle = _arg2;
}
}
}//package Box2D.Dynamics.Joints
Section 63
//b2RevoluteJointDef (Box2D.Dynamics.Joints.b2RevoluteJointDef)
package Box2D.Dynamics.Joints {
import Box2D.Common.Math.*;
import Box2D.Dynamics.*;
public class b2RevoluteJointDef extends b2JointDef {
public var upperAngle:Number;
public var enableMotor:Boolean;
public var referenceAngle:Number;
public var motorSpeed:Number;
public var localAnchor1:b2Vec2;
public var localAnchor2:b2Vec2;
public var enableLimit:Boolean;
public var lowerAngle:Number;
public var maxMotorTorque:Number;
public function b2RevoluteJointDef(){
localAnchor1 = new b2Vec2();
localAnchor2 = new b2Vec2();
super();
type = b2Joint.e_revoluteJoint;
localAnchor1.Set(0, 0);
localAnchor2.Set(0, 0);
referenceAngle = 0;
lowerAngle = 0;
upperAngle = 0;
maxMotorTorque = 0;
motorSpeed = 0;
enableLimit = false;
enableMotor = false;
}
public function Initialize(_arg1:b2Body, _arg2:b2Body, _arg3:b2Vec2):void{
body1 = _arg1;
body2 = _arg2;
localAnchor1 = body1.GetLocalPoint(_arg3);
localAnchor2 = body2.GetLocalPoint(_arg3);
referenceAngle = (body2.GetAngle() - body1.GetAngle());
}
}
}//package Box2D.Dynamics.Joints
Section 64
//b2Body (Box2D.Dynamics.b2Body)
package Box2D.Dynamics {
import Box2D.Common.Math.*;
import Box2D.Dynamics.Joints.*;
import Box2D.Collision.Shapes.*;
import Box2D.Dynamics.Contacts.*;
public class b2Body {
public var m_next:b2Body;
public var m_xf:b2XForm;
public var m_contactList:b2ContactEdge;
public var m_angularVelocity:Number;
public var m_shapeList:b2Shape;
public var m_force:b2Vec2;
public var m_mass:Number;
public var m_sweep:b2Sweep;
public var m_torque:Number;
public var m_userData;
public var m_flags:uint;
public var m_world:b2World;
public var m_prev:b2Body;
public var m_invMass:Number;
public var m_type:int;
public var m_linearDamping:Number;
public var m_shapeCount:int;
public var m_angularDamping:Number;
public var m_invI:Number;
public var m_linearVelocity:b2Vec2;
public var m_sleepTime:Number;
public var m_jointList:b2JointEdge;
public var m_I:Number;
public static var e_fixedRotationFlag:uint = 64;
public static var e_frozenFlag:uint = 2;
public static var e_maxTypes:uint = 3;
public static var e_sleepFlag:uint = 8;
private static var s_massData:b2MassData = new b2MassData();
public static var e_bulletFlag:uint = 32;
public static var e_staticType:uint = 1;
public static var e_islandFlag:uint = 4;
public static var e_allowSleepFlag:uint = 16;
private static var s_xf1:b2XForm = new b2XForm();
public static var e_dynamicType:uint = 2;
public function b2Body(_arg1:b2BodyDef, _arg2:b2World){
m_xf = new b2XForm();
m_sweep = new b2Sweep();
m_linearVelocity = new b2Vec2();
m_force = new b2Vec2();
super();
m_flags = 0;
if (_arg1.isBullet){
m_flags = (m_flags | e_bulletFlag);
};
if (_arg1.fixedRotation){
m_flags = (m_flags | e_fixedRotationFlag);
};
if (_arg1.allowSleep){
m_flags = (m_flags | e_allowSleepFlag);
};
if (_arg1.isSleeping){
m_flags = (m_flags | e_sleepFlag);
};
m_world = _arg2;
m_xf.position.SetV(_arg1.position);
m_xf.R.Set(_arg1.angle);
m_sweep.localCenter.SetV(_arg1.massData.center);
m_sweep.t0 = 1;
m_sweep.a0 = (m_sweep.a = _arg1.angle);
var _local3:b2Mat22 = m_xf.R;
var _local4:b2Vec2 = m_sweep.localCenter;
m_sweep.c.x = ((_local3.col1.x * _local4.x) + (_local3.col2.x * _local4.y));
m_sweep.c.y = ((_local3.col1.y * _local4.x) + (_local3.col2.y * _local4.y));
m_sweep.c.x = (m_sweep.c.x + m_xf.position.x);
m_sweep.c.y = (m_sweep.c.y + m_xf.position.y);
m_sweep.c0.SetV(m_sweep.c);
m_jointList = null;
m_contactList = null;
m_prev = null;
m_next = null;
m_linearDamping = _arg1.linearDamping;
m_angularDamping = _arg1.angularDamping;
m_force.Set(0, 0);
m_torque = 0;
m_linearVelocity.SetZero();
m_angularVelocity = 0;
m_sleepTime = 0;
m_invMass = 0;
m_I = 0;
m_invI = 0;
m_mass = _arg1.massData.mass;
if (m_mass > 0){
m_invMass = (1 / m_mass);
};
if ((m_flags & b2Body.e_fixedRotationFlag) == 0){
m_I = _arg1.massData.I;
};
if (m_I > 0){
m_invI = (1 / m_I);
};
if ((((m_invMass == 0)) && ((m_invI == 0)))){
m_type = e_staticType;
} else {
m_type = e_dynamicType;
};
m_userData = _arg1.userData;
m_shapeList = null;
m_shapeCount = 0;
}
public function GetLinearVelocityFromWorldPoint(_arg1:b2Vec2):b2Vec2{
return (new b2Vec2((m_linearVelocity.x + (m_angularVelocity * (_arg1.y - m_sweep.c.y))), (m_linearVelocity.x - (m_angularVelocity * (_arg1.x - m_sweep.c.x)))));
}
public function SetLinearVelocity(_arg1:b2Vec2):void{
m_linearVelocity.SetV(_arg1);
}
public function WakeUp():void{
m_flags = (m_flags & ~(e_sleepFlag));
m_sleepTime = 0;
}
public function GetLocalCenter():b2Vec2{
return (m_sweep.localCenter);
}
public function ApplyTorque(_arg1:Number):void{
if (IsSleeping()){
WakeUp();
};
m_torque = (m_torque + _arg1);
}
public function IsFrozen():Boolean{
return (((m_flags & e_frozenFlag) == e_frozenFlag));
}
public function IsDynamic():Boolean{
return ((m_type == e_dynamicType));
}
public function GetLinearVelocity():b2Vec2{
return (m_linearVelocity);
}
public function SynchronizeTransform():void{
m_xf.R.Set(m_sweep.a);
var _local1:b2Mat22 = m_xf.R;
var _local2:b2Vec2 = m_sweep.localCenter;
m_xf.position.x = (m_sweep.c.x - ((_local1.col1.x * _local2.x) + (_local1.col2.x * _local2.y)));
m_xf.position.y = (m_sweep.c.y - ((_local1.col1.y * _local2.x) + (_local1.col2.y * _local2.y)));
}
public function GetInertia():Number{
return (m_I);
}
public function IsSleeping():Boolean{
return (((m_flags & e_sleepFlag) == e_sleepFlag));
}
public function SetMassFromShapes():void{
var _local1:b2Shape;
if (m_world.m_lock == true){
return;
};
m_mass = 0;
m_invMass = 0;
m_I = 0;
m_invI = 0;
var _local2:Number = 0;
var _local3:Number = 0;
var _local4:b2MassData = s_massData;
_local1 = m_shapeList;
while (_local1) {
_local1.ComputeMass(_local4);
m_mass = (m_mass + _local4.mass);
_local2 = (_local2 + (_local4.mass * _local4.center.x));
_local3 = (_local3 + (_local4.mass * _local4.center.y));
m_I = (m_I + _local4.I);
_local1 = _local1.m_next;
};
if (m_mass > 0){
m_invMass = (1 / m_mass);
_local2 = (_local2 * m_invMass);
_local3 = (_local3 * m_invMass);
};
if ((((m_I > 0)) && (((m_flags & e_fixedRotationFlag) == 0)))){
m_I = (m_I - (m_mass * ((_local2 * _local2) + (_local3 * _local3))));
m_invI = (1 / m_I);
} else {
m_I = 0;
m_invI = 0;
};
m_sweep.localCenter.Set(_local2, _local3);
var _local5:b2Mat22 = m_xf.R;
var _local6:b2Vec2 = m_sweep.localCenter;
m_sweep.c.x = ((_local5.col1.x * _local6.x) + (_local5.col2.x * _local6.y));
m_sweep.c.y = ((_local5.col1.y * _local6.x) + (_local5.col2.y * _local6.y));
m_sweep.c.x = (m_sweep.c.x + m_xf.position.x);
m_sweep.c.y = (m_sweep.c.y + m_xf.position.y);
m_sweep.c0.SetV(m_sweep.c);
_local1 = m_shapeList;
while (_local1) {
_local1.UpdateSweepRadius(m_sweep.localCenter);
_local1 = _local1.m_next;
};
var _local7:int = m_type;
if ((((m_invMass == 0)) && ((m_invI == 0)))){
m_type = e_staticType;
} else {
m_type = e_dynamicType;
};
if (_local7 != m_type){
_local1 = m_shapeList;
while (_local1) {
_local1.RefilterProxy(m_world.m_broadPhase, m_xf);
_local1 = _local1.m_next;
};
};
}
public function PutToSleep():void{
m_flags = (m_flags | e_sleepFlag);
m_sleepTime = 0;
m_linearVelocity.SetZero();
m_angularVelocity = 0;
m_force.SetZero();
m_torque = 0;
}
public function GetJointList():b2JointEdge{
return (m_jointList);
}
public function SetXForm(_arg1:b2Vec2, _arg2:Number):Boolean{
var _local3:b2Shape;
var _local7:Boolean;
if (m_world.m_lock == true){
return (true);
};
if (IsFrozen()){
return (false);
};
m_xf.R.Set(_arg2);
m_xf.position.SetV(_arg1);
var _local4:b2Mat22 = m_xf.R;
var _local5:b2Vec2 = m_sweep.localCenter;
m_sweep.c.x = ((_local4.col1.x * _local5.x) + (_local4.col2.x * _local5.y));
m_sweep.c.y = ((_local4.col1.y * _local5.x) + (_local4.col2.y * _local5.y));
m_sweep.c.x = (m_sweep.c.x + m_xf.position.x);
m_sweep.c.y = (m_sweep.c.y + m_xf.position.y);
m_sweep.c0.SetV(m_sweep.c);
m_sweep.a0 = (m_sweep.a = _arg2);
var _local6:Boolean;
_local3 = m_shapeList;
while (_local3) {
_local7 = _local3.Synchronize(m_world.m_broadPhase, m_xf, m_xf);
if (_local7 == false){
_local6 = true;
break;
};
_local3 = _local3.m_next;
};
if (_local6 == true){
m_flags = (m_flags | e_frozenFlag);
m_linearVelocity.SetZero();
m_angularVelocity = 0;
_local3 = m_shapeList;
while (_local3) {
_local3.DestroyProxy(m_world.m_broadPhase);
_local3 = _local3.m_next;
};
return (false);
};
m_world.m_broadPhase.Commit();
return (true);
}
public function GetLocalPoint(_arg1:b2Vec2):b2Vec2{
return (b2Math.b2MulXT(m_xf, _arg1));
}
public function ApplyForce(_arg1:b2Vec2, _arg2:b2Vec2):void{
if (IsSleeping()){
WakeUp();
};
m_force.x = (m_force.x + _arg1.x);
m_force.y = (m_force.y + _arg1.y);
m_torque = (m_torque + (((_arg2.x - m_sweep.c.x) * _arg1.y) - ((_arg2.y - m_sweep.c.y) * _arg1.x)));
}
public function SynchronizeShapes():Boolean{
var _local4:b2Shape;
var _local1:b2XForm = s_xf1;
_local1.R.Set(m_sweep.a0);
var _local2:b2Mat22 = _local1.R;
var _local3:b2Vec2 = m_sweep.localCenter;
_local1.position.x = (m_sweep.c0.x - ((_local2.col1.x * _local3.x) + (_local2.col2.x * _local3.y)));
_local1.position.y = (m_sweep.c0.y - ((_local2.col1.y * _local3.x) + (_local2.col2.y * _local3.y)));
var _local5:Boolean;
_local4 = m_shapeList;
while (_local4) {
_local5 = _local4.Synchronize(m_world.m_broadPhase, _local1, m_xf);
if (_local5 == false){
break;
};
_local4 = _local4.m_next;
};
if (_local5 == false){
m_flags = (m_flags | e_frozenFlag);
m_linearVelocity.SetZero();
m_angularVelocity = 0;
_local4 = m_shapeList;
while (_local4) {
_local4.DestroyProxy(m_world.m_broadPhase);
_local4 = _local4.m_next;
};
return (false);
};
return (true);
}
public function GetAngle():Number{
return (m_sweep.a);
}
public function GetXForm():b2XForm{
return (m_xf);
}
public function GetLinearVelocityFromLocalPoint(_arg1:b2Vec2):b2Vec2{
var _local2:b2Mat22 = m_xf.R;
var _local3:b2Vec2 = new b2Vec2(((_local2.col1.x * _arg1.x) + (_local2.col2.x * _arg1.y)), ((_local2.col1.y * _arg1.x) + (_local2.col2.y * _arg1.y)));
_local3.x = (_local3.x + m_xf.position.x);
_local3.y = (_local3.y + m_xf.position.y);
return (new b2Vec2((m_linearVelocity.x + (m_angularVelocity * (_local3.y - m_sweep.c.y))), (m_linearVelocity.x - (m_angularVelocity * (_local3.x - m_sweep.c.x)))));
}
public function GetNext():b2Body{
return (m_next);
}
public function GetMass():Number{
return (m_mass);
}
public function ApplyImpulse(_arg1:b2Vec2, _arg2:b2Vec2):void{
if (IsSleeping()){
WakeUp();
};
m_linearVelocity.x = (m_linearVelocity.x + (m_invMass * _arg1.x));
m_linearVelocity.y = (m_linearVelocity.y + (m_invMass * _arg1.y));
m_angularVelocity = (m_angularVelocity + (m_invI * (((_arg2.x - m_sweep.c.x) * _arg1.y) - ((_arg2.y - m_sweep.c.y) * _arg1.x))));
}
public function GetAngularVelocity():Number{
return (m_angularVelocity);
}
public function SetAngularVelocity(_arg1:Number):void{
m_angularVelocity = _arg1;
}
public function SetMass(_arg1:b2MassData):void{
var _local2:b2Shape;
if (m_world.m_lock == true){
return;
};
m_invMass = 0;
m_I = 0;
m_invI = 0;
m_mass = _arg1.mass;
if (m_mass > 0){
m_invMass = (1 / m_mass);
};
if ((m_flags & b2Body.e_fixedRotationFlag) == 0){
m_I = _arg1.I;
};
if (m_I > 0){
m_invI = (1 / m_I);
};
m_sweep.localCenter.SetV(_arg1.center);
var _local3:b2Mat22 = m_xf.R;
var _local4:b2Vec2 = m_sweep.localCenter;
m_sweep.c.x = ((_local3.col1.x * _local4.x) + (_local3.col2.x * _local4.y));
m_sweep.c.y = ((_local3.col1.y * _local4.x) + (_local3.col2.y * _local4.y));
m_sweep.c.x = (m_sweep.c.x + m_xf.position.x);
m_sweep.c.y = (m_sweep.c.y + m_xf.position.y);
m_sweep.c0.SetV(m_sweep.c);
_local2 = m_shapeList;
while (_local2) {
_local2.UpdateSweepRadius(m_sweep.localCenter);
_local2 = _local2.m_next;
};
var _local5:int = m_type;
if ((((m_invMass == 0)) && ((m_invI == 0)))){
m_type = e_staticType;
} else {
m_type = e_dynamicType;
};
if (_local5 != m_type){
_local2 = m_shapeList;
while (_local2) {
_local2.RefilterProxy(m_world.m_broadPhase, m_xf);
_local2 = _local2.m_next;
};
};
}
public function IsStatic():Boolean{
return ((m_type == e_staticType));
}
public function GetWorldVector(_arg1:b2Vec2):b2Vec2{
return (b2Math.b2MulMV(m_xf.R, _arg1));
}
public function GetShapeList():b2Shape{
return (m_shapeList);
}
public function Advance(_arg1:Number):void{
m_sweep.Advance(_arg1);
m_sweep.c.SetV(m_sweep.c0);
m_sweep.a = m_sweep.a0;
SynchronizeTransform();
}
public function SetBullet(_arg1:Boolean):void{
if (_arg1){
m_flags = (m_flags | e_bulletFlag);
} else {
m_flags = (m_flags & ~(e_bulletFlag));
};
}
public function CreateShape(_arg1:b2ShapeDef):b2Shape{
if (m_world.m_lock == true){
return (null);
};
var _local2:b2Shape = b2Shape.Create(_arg1, m_world.m_blockAllocator);
_local2.m_next = m_shapeList;
m_shapeList = _local2;
m_shapeCount++;
_local2.m_body = this;
_local2.CreateProxy(m_world.m_broadPhase, m_xf);
_local2.UpdateSweepRadius(m_sweep.localCenter);
return (_local2);
}
public function IsConnected(_arg1:b2Body):Boolean{
var _local2:b2JointEdge = m_jointList;
while (_local2) {
if (_local2.other == _arg1){
return ((_local2.joint.m_collideConnected == false));
};
_local2 = _local2.next;
};
return (false);
}
public function DestroyShape(_arg1:b2Shape):void{
if (m_world.m_lock == true){
return;
};
_arg1.DestroyProxy(m_world.m_broadPhase);
var _local2:b2Shape = m_shapeList;
var _local3:b2Shape;
var _local4:Boolean;
while (_local2 != null) {
if (_local2 == _arg1){
if (_local3){
_local3.m_next = _arg1.m_next;
} else {
m_shapeList = _arg1.m_next;
};
_local4 = true;
break;
};
_local3 = _local2;
_local2 = _local2.m_next;
};
_arg1.m_body = null;
_arg1.m_next = null;
m_shapeCount--;
b2Shape.Destroy(_arg1, m_world.m_blockAllocator);
}
public function GetUserData(){
return (m_userData);
}
public function IsBullet():Boolean{
return (((m_flags & e_bulletFlag) == e_bulletFlag));
}
public function GetWorldCenter():b2Vec2{
return (m_sweep.c);
}
public function AllowSleeping(_arg1:Boolean):void{
if (_arg1){
m_flags = (m_flags | e_allowSleepFlag);
} else {
m_flags = (m_flags & ~(e_allowSleepFlag));
WakeUp();
};
}
public function SetUserData(_arg1):void{
m_userData = _arg1;
}
public function GetLocalVector(_arg1:b2Vec2):b2Vec2{
return (b2Math.b2MulTMV(m_xf.R, _arg1));
}
public function GetWorldPoint(_arg1:b2Vec2):b2Vec2{
var _local2:b2Mat22 = m_xf.R;
var _local3:b2Vec2 = new b2Vec2(((_local2.col1.x * _arg1.x) + (_local2.col2.x * _arg1.y)), ((_local2.col1.y * _arg1.x) + (_local2.col2.y * _arg1.y)));
_local3.x = (_local3.x + m_xf.position.x);
_local3.y = (_local3.y + m_xf.position.y);
return (_local3);
}
public function GetWorld():b2World{
return (m_world);
}
public function GetPosition():b2Vec2{
return (m_xf.position);
}
}
}//package Box2D.Dynamics
Section 65
//b2BodyDef (Box2D.Dynamics.b2BodyDef)
package Box2D.Dynamics {
import Box2D.Common.Math.*;
import Box2D.Collision.Shapes.*;
public class b2BodyDef {
public var angularDamping:Number;
public var angle:Number;
public var isSleeping:Boolean;
public var position:b2Vec2;
public var isBullet:Boolean;
public var allowSleep:Boolean;
public var userData;
public var fixedRotation:Boolean;
public var linearDamping:Number;
public var massData:b2MassData;
public function b2BodyDef(){
massData = new b2MassData();
position = new b2Vec2();
super();
massData.center.SetZero();
massData.mass = 0;
massData.I = 0;
userData = null;
position.Set(0, 0);
angle = 0;
linearDamping = 0;
angularDamping = 0;
allowSleep = true;
isSleeping = false;
fixedRotation = false;
isBullet = false;
}
}
}//package Box2D.Dynamics
Section 66
//b2BoundaryListener (Box2D.Dynamics.b2BoundaryListener)
package Box2D.Dynamics {
public class b2BoundaryListener {
public function Violation(_arg1:b2Body):void{
}
}
}//package Box2D.Dynamics
Section 67
//b2ContactFilter (Box2D.Dynamics.b2ContactFilter)
package Box2D.Dynamics {
import Box2D.Collision.Shapes.*;
public class b2ContactFilter {
public static var b2_defaultFilter:b2ContactFilter = new (b2ContactFilter);
;
public function ShouldCollide(_arg1:b2Shape, _arg2:b2Shape):Boolean{
var _local3:b2FilterData = _arg1.GetFilterData();
var _local4:b2FilterData = _arg2.GetFilterData();
if ((((_local3.groupIndex == _local4.groupIndex)) && (!((_local3.groupIndex == 0))))){
return ((_local3.groupIndex > 0));
};
var _local5:Boolean = ((!(((_local3.maskBits & _local4.categoryBits) == 0))) && (!(((_local3.categoryBits & _local4.maskBits) == 0))));
return (_local5);
}
public function RayCollide(_arg1, _arg2:b2Shape):Boolean{
if (!_arg1){
return (true);
};
return (ShouldCollide((_arg1 as b2Shape), _arg2));
}
}
}//package Box2D.Dynamics
Section 68
//b2ContactListener (Box2D.Dynamics.b2ContactListener)
package Box2D.Dynamics {
import Box2D.Collision.*;
import Box2D.Dynamics.Contacts.*;
public class b2ContactListener {
public function Add(_arg1:b2ContactPoint):void{
}
public function Remove(_arg1:b2ContactPoint):void{
}
public function Persist(_arg1:b2ContactPoint):void{
}
public function Result(_arg1:b2ContactResult):void{
}
}
}//package Box2D.Dynamics
Section 69
//b2ContactManager (Box2D.Dynamics.b2ContactManager)
package Box2D.Dynamics {
import Box2D.Common.Math.*;
import Box2D.Collision.*;
import Box2D.Collision.Shapes.*;
import Box2D.Common.*;
import Box2D.Dynamics.Contacts.*;
public class b2ContactManager extends b2PairCallback {
public var m_world:b2World;
public var m_destroyImmediate:Boolean;
public var m_nullContact:b2NullContact;
private static const s_evalCP:b2ContactPoint = new b2ContactPoint();
public function b2ContactManager(){
m_nullContact = new b2NullContact();
super();
m_world = null;
m_destroyImmediate = false;
}
override public function PairRemoved(_arg1, _arg2, _arg3):void{
if (_arg3 == null){
return;
};
var _local4:b2Contact = (_arg3 as b2Contact);
if (_local4 == m_nullContact){
return;
};
Destroy(_local4);
}
public function Destroy(_arg1:b2Contact):void{
var _local7:b2Body;
var _local8:b2Body;
var _local9:Array;
var _local10:b2ContactPoint;
var _local11:int;
var _local12:b2Manifold;
var _local13:int;
var _local14:b2ManifoldPoint;
var _local15:b2Vec2;
var _local16:b2Vec2;
var _local2:b2Shape = _arg1.m_shape1;
var _local3:b2Shape = _arg1.m_shape2;
var _local4:int = _arg1.m_manifoldCount;
if ((((_local4 > 0)) && (m_world.m_contactListener))){
_local7 = _local2.m_body;
_local8 = _local3.m_body;
_local9 = _arg1.GetManifolds();
_local10 = s_evalCP;
_local10.shape1 = _arg1.m_shape1;
_local10.shape2 = _arg1.m_shape1;
_local10.friction = _arg1.m_friction;
_local10.restitution = _arg1.m_restitution;
_local11 = 0;
while (_local11 < _local4) {
_local12 = _local9[_local11];
_local10.normal.SetV(_local12.normal);
_local13 = 0;
while (_local13 < _local12.pointCount) {
_local14 = _local12.points[_local13];
_local10.position = _local7.GetWorldPoint(_local14.localPoint1);
_local15 = _local7.GetLinearVelocityFromLocalPoint(_local14.localPoint1);
_local16 = _local8.GetLinearVelocityFromLocalPoint(_local14.localPoint2);
_local10.velocity.Set((_local16.x - _local15.x), (_local16.y - _local15.y));
_local10.separation = _local14.separation;
_local10.id.key = _local14.id._key;
m_world.m_contactListener.Remove(_local10);
_local13++;
};
_local11++;
};
};
if (_arg1.m_prev){
_arg1.m_prev.m_next = _arg1.m_next;
};
if (_arg1.m_next){
_arg1.m_next.m_prev = _arg1.m_prev;
};
if (_arg1 == m_world.m_contactList){
m_world.m_contactList = _arg1.m_next;
};
var _local5:b2Body = _local2.m_body;
var _local6:b2Body = _local3.m_body;
if (_arg1.m_node1.prev){
_arg1.m_node1.prev.next = _arg1.m_node1.next;
};
if (_arg1.m_node1.next){
_arg1.m_node1.next.prev = _arg1.m_node1.prev;
};
if (_arg1.m_node1 == _local5.m_contactList){
_local5.m_contactList = _arg1.m_node1.next;
};
if (_arg1.m_node2.prev){
_arg1.m_node2.prev.next = _arg1.m_node2.next;
};
if (_arg1.m_node2.next){
_arg1.m_node2.next.prev = _arg1.m_node2.prev;
};
if (_arg1.m_node2 == _local6.m_contactList){
_local6.m_contactList = _arg1.m_node2.next;
};
b2Contact.Destroy(_arg1, m_world.m_blockAllocator);
m_world.m_contactCount--;
}
override public function PairAdded(_arg1, _arg2){
var _local5:b2Body;
var _local3:b2Shape = (_arg1 as b2Shape);
var _local4:b2Shape = (_arg2 as b2Shape);
_local5 = _local3.m_body;
var _local6:b2Body = _local4.m_body;
if (((_local5.IsStatic()) && (_local6.IsStatic()))){
return (m_nullContact);
};
if (_local3.m_body == _local4.m_body){
return (m_nullContact);
};
if (_local6.IsConnected(_local5)){
return (m_nullContact);
};
if (((!((m_world.m_contactFilter == null))) && ((m_world.m_contactFilter.ShouldCollide(_local3, _local4) == false)))){
return (m_nullContact);
};
var _local7:b2Contact = b2Contact.Create(_local3, _local4, m_world.m_blockAllocator);
if (_local7 == null){
return (m_nullContact);
};
_local3 = _local7.m_shape1;
_local4 = _local7.m_shape2;
_local5 = _local3.m_body;
_local6 = _local4.m_body;
_local7.m_prev = null;
_local7.m_next = m_world.m_contactList;
if (m_world.m_contactList != null){
m_world.m_contactList.m_prev = _local7;
};
m_world.m_contactList = _local7;
_local7.m_node1.contact = _local7;
_local7.m_node1.other = _local6;
_local7.m_node1.prev = null;
_local7.m_node1.next = _local5.m_contactList;
if (_local5.m_contactList != null){
_local5.m_contactList.prev = _local7.m_node1;
};
_local5.m_contactList = _local7.m_node1;
_local7.m_node2.contact = _local7;
_local7.m_node2.other = _local5;
_local7.m_node2.prev = null;
_local7.m_node2.next = _local6.m_contactList;
if (_local6.m_contactList != null){
_local6.m_contactList.prev = _local7.m_node2;
};
_local6.m_contactList = _local7.m_node2;
m_world.m_contactCount++;
return (_local7);
}
public function Collide():void{
var _local2:b2Body;
var _local3:b2Body;
var _local1:b2Contact = m_world.m_contactList;
while (_local1) {
_local2 = _local1.m_shape1.m_body;
_local3 = _local1.m_shape2.m_body;
if (((_local2.IsSleeping()) && (_local3.IsSleeping()))){
} else {
_local1.Update(m_world.m_contactListener);
};
_local1 = _local1.m_next;
};
}
}
}//package Box2D.Dynamics
Section 70
//b2DebugDraw (Box2D.Dynamics.b2DebugDraw)
package Box2D.Dynamics {
import flash.display.*;
import Box2D.Common.Math.*;
import Box2D.Collision.*;
import Box2D.Collision.Shapes.*;
import Box2D.Common.*;
import Box2D.Dynamics.Contacts.*;
public class b2DebugDraw {
public var m_xformScale:Number;// = 1
public var m_fillAlpha:Number;// = 1
public var m_alpha:Number;// = 1
public var m_drawFlags:uint;
public var m_lineThickness:Number;// = 1
public var m_drawScale:Number;// = 1
public var m_sprite:Sprite;
public static var e_coreShapeBit:uint = 4;
public static var e_shapeBit:uint = 1;
public static var e_centerOfMassBit:uint = 64;
public static var e_aabbBit:uint = 8;
public static var e_obbBit:uint = 16;
public static var e_pairBit:uint = 32;
public static var e_jointBit:uint = 2;
public function b2DebugDraw(){
m_drawFlags = 0;
}
public function ClearFlags(_arg1:uint):void{
m_drawFlags = (m_drawFlags & ~(_arg1));
}
public function SetFlags(_arg1:uint):void{
m_drawFlags = _arg1;
}
public function AppendFlags(_arg1:uint):void{
m_drawFlags = (m_drawFlags | _arg1);
}
public function DrawSegment(_arg1:b2Vec2, _arg2:b2Vec2, _arg3:b2Color):void{
m_sprite.graphics.lineStyle(m_lineThickness, _arg3.color, m_alpha);
m_sprite.graphics.moveTo((_arg1.x * m_drawScale), (_arg1.y * m_drawScale));
m_sprite.graphics.lineTo((_arg2.x * m_drawScale), (_arg2.y * m_drawScale));
}
public function DrawSolidPolygon(_arg1:Array, _arg2:int, _arg3:b2Color):void{
m_sprite.graphics.lineStyle(m_lineThickness, _arg3.color, m_alpha);
m_sprite.graphics.moveTo((_arg1[0].x * m_drawScale), (_arg1[0].y * m_drawScale));
m_sprite.graphics.beginFill(_arg3.color, m_fillAlpha);
var _local4 = 1;
while (_local4 < _arg2) {
m_sprite.graphics.lineTo((_arg1[_local4].x * m_drawScale), (_arg1[_local4].y * m_drawScale));
_local4++;
};
m_sprite.graphics.lineTo((_arg1[0].x * m_drawScale), (_arg1[0].y * m_drawScale));
m_sprite.graphics.endFill();
}
public function DrawCircle(_arg1:b2Vec2, _arg2:Number, _arg3:b2Color):void{
m_sprite.graphics.lineStyle(m_lineThickness, _arg3.color, m_alpha);
m_sprite.graphics.drawCircle((_arg1.x * m_drawScale), (_arg1.y * m_drawScale), (_arg2 * m_drawScale));
}
public function DrawPolygon(_arg1:Array, _arg2:int, _arg3:b2Color):void{
m_sprite.graphics.lineStyle(m_lineThickness, _arg3.color, m_alpha);
m_sprite.graphics.moveTo((_arg1[0].x * m_drawScale), (_arg1[0].y * m_drawScale));
var _local4 = 1;
while (_local4 < _arg2) {
m_sprite.graphics.lineTo((_arg1[_local4].x * m_drawScale), (_arg1[_local4].y * m_drawScale));
_local4++;
};
m_sprite.graphics.lineTo((_arg1[0].x * m_drawScale), (_arg1[0].y * m_drawScale));
}
public function DrawSolidCircle(_arg1:b2Vec2, _arg2:Number, _arg3:b2Vec2, _arg4:b2Color):void{
m_sprite.graphics.lineStyle(m_lineThickness, _arg4.color, m_alpha);
m_sprite.graphics.moveTo(0, 0);
m_sprite.graphics.beginFill(_arg4.color, m_fillAlpha);
m_sprite.graphics.drawCircle((_arg1.x * m_drawScale), (_arg1.y * m_drawScale), (_arg2 * m_drawScale));
m_sprite.graphics.endFill();
m_sprite.graphics.moveTo((_arg1.x * m_drawScale), (_arg1.y * m_drawScale));
m_sprite.graphics.lineTo(((_arg1.x + (_arg3.x * _arg2)) * m_drawScale), ((_arg1.y + (_arg3.y * _arg2)) * m_drawScale));
}
public function GetFlags():uint{
return (m_drawFlags);
}
public function DrawXForm(_arg1:b2XForm):void{
m_sprite.graphics.lineStyle(m_lineThickness, 0xFF0000, m_alpha);
m_sprite.graphics.moveTo((_arg1.position.x * m_drawScale), (_arg1.position.y * m_drawScale));
m_sprite.graphics.lineTo(((_arg1.position.x + (m_xformScale * _arg1.R.col1.x)) * m_drawScale), ((_arg1.position.y + (m_xformScale * _arg1.R.col1.y)) * m_drawScale));
m_sprite.graphics.lineStyle(m_lineThickness, 0xFF00, m_alpha);
m_sprite.graphics.moveTo((_arg1.position.x * m_drawScale), (_arg1.position.y * m_drawScale));
m_sprite.graphics.lineTo(((_arg1.position.x + (m_xformScale * _arg1.R.col2.x)) * m_drawScale), ((_arg1.position.y + (m_xformScale * _arg1.R.col2.y)) * m_drawScale));
}
}
}//package Box2D.Dynamics
Section 71
//b2DestructionListener (Box2D.Dynamics.b2DestructionListener)
package Box2D.Dynamics {
import Box2D.Dynamics.Joints.*;
import Box2D.Collision.Shapes.*;
public class b2DestructionListener {
public function SayGoodbyeShape(_arg1:b2Shape):void{
}
public function SayGoodbyeJoint(_arg1:b2Joint):void{
}
}
}//package Box2D.Dynamics
Section 72
//b2Island (Box2D.Dynamics.b2Island)
package Box2D.Dynamics {
import Box2D.Common.Math.*;
import Box2D.Collision.*;
import Box2D.Dynamics.Joints.*;
import Box2D.Common.*;
import Box2D.Dynamics.Contacts.*;
public class b2Island {
public var m_listener:b2ContactListener;
public var m_positionIterationCount:int;
public var m_bodyCapacity:int;
public var m_bodies:Array;
public var m_joints:Array;
public var m_jointCapacity:int;
public var m_contactCount:int;
public var m_contacts:Array;
public var m_contactCapacity:int;
public var m_jointCount:int;
public var m_allocator;
public var m_bodyCount:int;
private static var s_reportCR:b2ContactResult = new b2ContactResult();
public function b2Island(_arg1:int, _arg2:int, _arg3:int, _arg4, _arg5:b2ContactListener){
var _local6:int;
super();
m_bodyCapacity = _arg1;
m_contactCapacity = _arg2;
m_jointCapacity = _arg3;
m_bodyCount = 0;
m_contactCount = 0;
m_jointCount = 0;
m_allocator = _arg4;
m_listener = _arg5;
m_bodies = new Array(_arg1);
_local6 = 0;
while (_local6 < _arg1) {
m_bodies[_local6] = null;
_local6++;
};
m_contacts = new Array(_arg2);
_local6 = 0;
while (_local6 < _arg2) {
m_contacts[_local6] = null;
_local6++;
};
m_joints = new Array(_arg3);
_local6 = 0;
while (_local6 < _arg3) {
m_joints[_local6] = null;
_local6++;
};
m_positionIterationCount = 0;
}
public function AddBody(_arg1:b2Body):void{
var _local2 = m_bodyCount++;
m_bodies[_local2] = _arg1;
}
public function AddJoint(_arg1:b2Joint):void{
var _local2 = m_jointCount++;
m_joints[_local2] = _arg1;
}
public function Report(_arg1:Array):void{
var _local2:b2Mat22;
var _local3:b2Vec2;
var _local5:b2Contact;
var _local6:b2ContactConstraint;
var _local7:b2ContactResult;
var _local8:b2Body;
var _local9:int;
var _local10:Array;
var _local11:int;
var _local12:b2Manifold;
var _local13:int;
var _local14:b2ManifoldPoint;
var _local15:b2ContactConstraintPoint;
if (m_listener == null){
return;
};
var _local4:int;
while (_local4 < m_contactCount) {
_local5 = m_contacts[_local4];
_local6 = _arg1[_local4];
_local7 = s_reportCR;
_local7.shape1 = _local5.m_shape1;
_local7.shape2 = _local5.m_shape2;
_local8 = _local7.shape1.m_body;
_local9 = _local5.m_manifoldCount;
_local10 = _local5.GetManifolds();
_local11 = 0;
while (_local11 < _local9) {
_local12 = _local10[_local11];
_local7.normal.SetV(_local12.normal);
_local13 = 0;
while (_local13 < _local12.pointCount) {
_local14 = _local12.points[_local13];
_local15 = _local6.points[_local13];
_local7.position = _local8.GetWorldPoint(_local14.localPoint1);
_local7.normalImpulse = _local15.normalImpulse;
_local7.tangentImpulse = _local15.tangentImpulse;
_local7.id.key = _local14.id.key;
m_listener.Result(_local7);
_local13++;
};
_local11++;
};
_local4++;
};
}
public function AddContact(_arg1:b2Contact):void{
var _local2 = m_contactCount++;
m_contacts[_local2] = _arg1;
}
public function Solve(_arg1:b2TimeStep, _arg2:b2Vec2, _arg3:Boolean, _arg4:Boolean):void{
var _local5:int;
var _local6:b2Body;
var _local7:b2Joint;
var _local9:int;
var _local10:Boolean;
var _local11:Boolean;
var _local12:Boolean;
var _local13:Number;
var _local14:Number;
var _local15:Number;
_local5 = 0;
while (_local5 < m_bodyCount) {
_local6 = m_bodies[_local5];
if (_local6.IsStatic()){
} else {
_local6.m_linearVelocity.x = (_local6.m_linearVelocity.x + (_arg1.dt * (_arg2.x + (_local6.m_invMass * _local6.m_force.x))));
_local6.m_linearVelocity.y = (_local6.m_linearVelocity.y + (_arg1.dt * (_arg2.y + (_local6.m_invMass * _local6.m_force.y))));
_local6.m_angularVelocity = (_local6.m_angularVelocity + ((_arg1.dt * _local6.m_invI) * _local6.m_torque));
_local6.m_force.SetZero();
_local6.m_torque = 0;
_local6.m_linearVelocity.Multiply(b2Math.b2Clamp((1 - (_arg1.dt * _local6.m_linearDamping)), 0, 1));
_local6.m_angularVelocity = (_local6.m_angularVelocity * b2Math.b2Clamp((1 - (_arg1.dt * _local6.m_angularDamping)), 0, 1));
if (_local6.m_linearVelocity.LengthSquared() > b2Settings.b2_maxLinearVelocitySquared){
_local6.m_linearVelocity.Normalize();
_local6.m_linearVelocity.x = (_local6.m_linearVelocity.x * b2Settings.b2_maxLinearVelocity);
_local6.m_linearVelocity.y = (_local6.m_linearVelocity.y * b2Settings.b2_maxLinearVelocity);
};
if ((_local6.m_angularVelocity * _local6.m_angularVelocity) > b2Settings.b2_maxAngularVelocitySquared){
if (_local6.m_angularVelocity < 0){
_local6.m_angularVelocity = -(b2Settings.b2_maxAngularVelocity);
} else {
_local6.m_angularVelocity = b2Settings.b2_maxAngularVelocity;
};
};
};
_local5++;
};
var _local8:b2ContactSolver = new b2ContactSolver(_arg1, m_contacts, m_contactCount, m_allocator);
_local8.InitVelocityConstraints(_arg1);
_local5 = 0;
while (_local5 < m_jointCount) {
_local7 = m_joints[_local5];
_local7.InitVelocityConstraints(_arg1);
_local5++;
};
_local5 = 0;
while (_local5 < _arg1.maxIterations) {
_local8.SolveVelocityConstraints();
_local9 = 0;
while (_local9 < m_jointCount) {
_local7 = m_joints[_local9];
_local7.SolveVelocityConstraints(_arg1);
_local9++;
};
_local5++;
};
_local8.FinalizeVelocityConstraints();
_local5 = 0;
while (_local5 < m_bodyCount) {
_local6 = m_bodies[_local5];
if (_local6.IsStatic()){
} else {
_local6.m_sweep.c0.SetV(_local6.m_sweep.c);
_local6.m_sweep.a0 = _local6.m_sweep.a;
_local6.m_sweep.c.x = (_local6.m_sweep.c.x + (_arg1.dt * _local6.m_linearVelocity.x));
_local6.m_sweep.c.y = (_local6.m_sweep.c.y + (_arg1.dt * _local6.m_linearVelocity.y));
_local6.m_sweep.a = (_local6.m_sweep.a + (_arg1.dt * _local6.m_angularVelocity));
_local6.SynchronizeTransform();
};
_local5++;
};
if (_arg3){
_local5 = 0;
while (_local5 < m_jointCount) {
_local7 = m_joints[_local5];
_local7.InitPositionConstraints();
_local5++;
};
m_positionIterationCount = 0;
while (m_positionIterationCount < _arg1.maxIterations) {
_local10 = _local8.SolvePositionConstraints(b2Settings.b2_contactBaumgarte);
_local11 = true;
_local5 = 0;
while (_local5 < m_jointCount) {
_local7 = m_joints[_local5];
_local12 = _local7.SolvePositionConstraints();
_local11 = ((_local11) && (_local12));
_local5++;
};
if (((_local10) && (_local11))){
break;
};
m_positionIterationCount++;
};
};
Report(_local8.m_constraints);
if (_arg4){
_local13 = Number.MAX_VALUE;
_local14 = (b2Settings.b2_linearSleepTolerance * b2Settings.b2_linearSleepTolerance);
_local15 = (b2Settings.b2_angularSleepTolerance * b2Settings.b2_angularSleepTolerance);
_local5 = 0;
while (_local5 < m_bodyCount) {
_local6 = m_bodies[_local5];
if (_local6.m_invMass == 0){
} else {
if ((_local6.m_flags & b2Body.e_allowSleepFlag) == 0){
_local6.m_sleepTime = 0;
_local13 = 0;
};
if (((((((_local6.m_flags & b2Body.e_allowSleepFlag) == 0)) || (((_local6.m_angularVelocity * _local6.m_angularVelocity) > _local15)))) || ((b2Math.b2Dot(_local6.m_linearVelocity, _local6.m_linearVelocity) > _local14)))){
_local6.m_sleepTime = 0;
_local13 = 0;
} else {
_local6.m_sleepTime = (_local6.m_sleepTime + _arg1.dt);
_local13 = b2Math.b2Min(_local13, _local6.m_sleepTime);
};
};
_local5++;
};
if (_local13 >= b2Settings.b2_timeToSleep){
_local5 = 0;
while (_local5 < m_bodyCount) {
_local6 = m_bodies[_local5];
m_bodies[_local5].m_flags = (_local6.m_flags | b2Body.e_sleepFlag);
_local6.m_linearVelocity.SetZero();
_local6.m_angularVelocity = 0;
_local5++;
};
};
};
}
public function Clear():void{
m_bodyCount = 0;
m_contactCount = 0;
m_jointCount = 0;
}
public function SolveTOI(_arg1:b2TimeStep):void{
var _local2:int;
var _local5:b2Body;
var _local6:Boolean;
var _local3:b2ContactSolver = new b2ContactSolver(_arg1, m_contacts, m_contactCount, m_allocator);
_local2 = 0;
while (_local2 < _arg1.maxIterations) {
_local3.SolveVelocityConstraints();
_local2++;
};
_local2 = 0;
while (_local2 < m_bodyCount) {
_local5 = m_bodies[_local2];
if (_local5.IsStatic()){
} else {
_local5.m_sweep.c0.SetV(_local5.m_sweep.c);
_local5.m_sweep.a0 = _local5.m_sweep.a;
_local5.m_sweep.c.x = (_local5.m_sweep.c.x + (_arg1.dt * _local5.m_linearVelocity.x));
_local5.m_sweep.c.y = (_local5.m_sweep.c.y + (_arg1.dt * _local5.m_linearVelocity.y));
_local5.m_sweep.a = (_local5.m_sweep.a + (_arg1.dt * _local5.m_angularVelocity));
_local5.SynchronizeTransform();
};
_local2++;
};
var _local4:Number = 0.75;
_local2 = 0;
while (_local2 < _arg1.maxIterations) {
_local6 = _local3.SolvePositionConstraints(_local4);
if (_local6){
break;
};
_local2++;
};
Report(_local3.m_constraints);
}
}
}//package Box2D.Dynamics
Section 73
//b2TimeStep (Box2D.Dynamics.b2TimeStep)
package Box2D.Dynamics {
public class b2TimeStep {
public var warmStarting:Boolean;
public var positionCorrection:Boolean;
public var dt:Number;
public var maxIterations:int;
public var dtRatio:Number;
public var inv_dt:Number;
}
}//package Box2D.Dynamics
Section 74
//b2World (Box2D.Dynamics.b2World)
package Box2D.Dynamics {
import Box2D.Common.Math.*;
import Box2D.Collision.*;
import Box2D.Dynamics.Joints.*;
import Box2D.Collision.Shapes.*;
import Box2D.Common.*;
import Box2D.Dynamics.Contacts.*;
public class b2World {
public var m_inv_dt0:Number;
public var m_boundaryListener:b2BoundaryListener;
public var m_contactList:b2Contact;
public var m_blockAllocator;
public var m_contactListener:b2ContactListener;
public var m_raycastSegment:b2Segment;
public var m_broadPhase:b2BroadPhase;
public var m_destructionListener:b2DestructionListener;
public var m_jointCount:int;
public var m_lock:Boolean;
public var m_bodyCount:int;
public var m_raycastUserData;
public var m_allowSleep:Boolean;
public var m_positionIterationCount:int;
public var m_groundBody:b2Body;
public var m_contactCount:int;
public var m_raycastNormal:b2Vec2;
public var m_contactFilter:b2ContactFilter;
public var m_bodyList:b2Body;
public var m_debugDraw:b2DebugDraw;
public var m_stackAllocator;
public var m_jointList:b2Joint;
public var m_gravity:b2Vec2;
public var m_contactManager:b2ContactManager;
private static var s_jointColor:b2Color = new b2Color(0.5, 0.8, 0.8);
public static var m_continuousPhysics:Boolean;
public static var m_warmStarting:Boolean;
private static var s_coreColor:b2Color = new b2Color(0.9, 0.6, 0.6);
public static var m_positionCorrection:Boolean;
private static var s_xf:b2XForm = new b2XForm();
public function b2World(_arg1:b2AABB, _arg2:b2Vec2, _arg3:Boolean){
m_raycastNormal = new b2Vec2();
m_contactManager = new b2ContactManager();
super();
m_destructionListener = null;
m_boundaryListener = null;
m_contactFilter = b2ContactFilter.b2_defaultFilter;
m_contactListener = null;
m_debugDraw = null;
m_bodyList = null;
m_contactList = null;
m_jointList = null;
m_bodyCount = 0;
m_contactCount = 0;
m_jointCount = 0;
m_positionCorrection = true;
m_warmStarting = true;
m_continuousPhysics = true;
m_allowSleep = _arg3;
m_gravity = _arg2;
m_lock = false;
m_inv_dt0 = 0;
m_contactManager.m_world = this;
m_broadPhase = new b2BroadPhase(_arg1, m_contactManager);
var _local4:b2BodyDef = new b2BodyDef();
m_groundBody = CreateBody(_local4);
}
public function DrawJoint(_arg1:b2Joint):void{
var _local11:b2PulleyJoint;
var _local12:b2Vec2;
var _local13:b2Vec2;
var _local2:b2Body = _arg1.m_body1;
var _local3:b2Body = _arg1.m_body2;
var _local4:b2XForm = _local2.m_xf;
var _local5:b2XForm = _local3.m_xf;
var _local6:b2Vec2 = _local4.position;
var _local7:b2Vec2 = _local5.position;
var _local8:b2Vec2 = _arg1.GetAnchor1();
var _local9:b2Vec2 = _arg1.GetAnchor2();
var _local10:b2Color = s_jointColor;
switch (_arg1.m_type){
case b2Joint.e_distanceJoint:
m_debugDraw.DrawSegment(_local8, _local9, _local10);
break;
case b2Joint.e_pulleyJoint:
_local11 = (_arg1 as b2PulleyJoint);
_local12 = _local11.GetGroundAnchor1();
_local13 = _local11.GetGroundAnchor2();
m_debugDraw.DrawSegment(_local12, _local8, _local10);
m_debugDraw.DrawSegment(_local13, _local9, _local10);
m_debugDraw.DrawSegment(_local12, _local13, _local10);
break;
case b2Joint.e_mouseJoint:
m_debugDraw.DrawSegment(_local8, _local9, _local10);
break;
default:
if (_local2 != m_groundBody){
m_debugDraw.DrawSegment(_local6, _local8, _local10);
};
m_debugDraw.DrawSegment(_local8, _local9, _local10);
if (_local3 != m_groundBody){
m_debugDraw.DrawSegment(_local7, _local9, _local10);
};
};
}
public function Refilter(_arg1:b2Shape):void{
_arg1.RefilterProxy(m_broadPhase, _arg1.m_body.m_xf);
}
public function SetDebugDraw(_arg1:b2DebugDraw):void{
m_debugDraw = _arg1;
}
public function SetContinuousPhysics(_arg1:Boolean):void{
m_continuousPhysics = _arg1;
}
public function GetProxyCount():int{
return (m_broadPhase.m_proxyCount);
}
public function DrawDebugData():void{
var _local2:int;
var _local3:b2Body;
var _local4:b2Shape;
var _local5:b2Joint;
var _local6:b2BroadPhase;
var _local11:b2XForm;
var _local15:Boolean;
var _local16:uint;
var _local17:b2Pair;
var _local18:b2Proxy;
var _local19:b2Proxy;
var _local20:b2Vec2;
var _local21:b2Vec2;
var _local22:b2Proxy;
var _local23:b2PolygonShape;
var _local24:b2OBB;
var _local25:b2Vec2;
var _local26:b2Mat22;
var _local27:b2Vec2;
var _local28:Number;
if (m_debugDraw == null){
return;
};
m_debugDraw.m_sprite.graphics.clear();
var _local1:uint = m_debugDraw.GetFlags();
var _local7:b2Vec2 = new b2Vec2();
var _local8:b2Vec2 = new b2Vec2();
var _local9:b2Vec2 = new b2Vec2();
var _local10:b2Color = new b2Color(0, 0, 0);
var _local12:b2AABB = new b2AABB();
var _local13:b2AABB = new b2AABB();
var _local14:Array = [new b2Vec2(), new b2Vec2(), new b2Vec2(), new b2Vec2()];
if ((_local1 & b2DebugDraw.e_shapeBit)){
_local15 = ((_local1 & b2DebugDraw.e_coreShapeBit) == b2DebugDraw.e_coreShapeBit);
_local3 = m_bodyList;
while (_local3) {
_local11 = _local3.m_xf;
_local4 = _local3.GetShapeList();
while (_local4) {
if (_local3.IsStatic()){
DrawShape(_local4, _local11, new b2Color(0.5, 0.9, 0.5), _local15);
} else {
if (_local3.IsSleeping()){
DrawShape(_local4, _local11, new b2Color(0.5, 0.5, 0.9), _local15);
} else {
DrawShape(_local4, _local11, new b2Color(0.9, 0.9, 0.9), _local15);
};
};
_local4 = _local4.m_next;
};
_local3 = _local3.m_next;
};
};
if ((_local1 & b2DebugDraw.e_jointBit)){
_local5 = m_jointList;
while (_local5) {
DrawJoint(_local5);
_local5 = _local5.m_next;
};
};
if ((_local1 & b2DebugDraw.e_pairBit)){
_local6 = m_broadPhase;
_local7.Set((1 / _local6.m_quantizationFactor.x), (1 / _local6.m_quantizationFactor.y));
_local10.Set(0.9, 0.9, 0.3);
_local2 = 0;
while (_local2 < b2Pair.b2_tableCapacity) {
_local16 = _local6.m_pairManager.m_hashTable[_local2];
while (_local16 != b2Pair.b2_nullPair) {
_local17 = _local6.m_pairManager.m_pairs[_local16];
_local18 = _local6.m_proxyPool[_local17.proxyId1];
_local19 = _local6.m_proxyPool[_local17.proxyId2];
_local12.lowerBound.x = (_local6.m_worldAABB.lowerBound.x + (_local7.x * _local6.m_bounds[0][_local18.lowerBounds[0]].value));
_local12.lowerBound.y = (_local6.m_worldAABB.lowerBound.y + (_local7.y * _local6.m_bounds[1][_local18.lowerBounds[1]].value));
_local12.upperBound.x = (_local6.m_worldAABB.lowerBound.x + (_local7.x * _local6.m_bounds[0][_local18.upperBounds[0]].value));
_local12.upperBound.y = (_local6.m_worldAABB.lowerBound.y + (_local7.y * _local6.m_bounds[1][_local18.upperBounds[1]].value));
_local13.lowerBound.x = (_local6.m_worldAABB.lowerBound.x + (_local7.x * _local6.m_bounds[0][_local19.lowerBounds[0]].value));
_local13.lowerBound.y = (_local6.m_worldAABB.lowerBound.y + (_local7.y * _local6.m_bounds[1][_local19.lowerBounds[1]].value));
_local13.upperBound.x = (_local6.m_worldAABB.lowerBound.x + (_local7.x * _local6.m_bounds[0][_local19.upperBounds[0]].value));
_local13.upperBound.y = (_local6.m_worldAABB.lowerBound.y + (_local7.y * _local6.m_bounds[1][_local19.upperBounds[1]].value));
_local8.x = (0.5 * (_local12.lowerBound.x + _local12.upperBound.x));
_local8.y = (0.5 * (_local12.lowerBound.y + _local12.upperBound.y));
_local9.x = (0.5 * (_local13.lowerBound.x + _local13.upperBound.x));
_local9.y = (0.5 * (_local13.lowerBound.y + _local13.upperBound.y));
m_debugDraw.DrawSegment(_local8, _local9, _local10);
_local16 = _local17.next;
};
_local2++;
};
};
if ((_local1 & b2DebugDraw.e_aabbBit)){
_local6 = m_broadPhase;
_local20 = _local6.m_worldAABB.lowerBound;
_local21 = _local6.m_worldAABB.upperBound;
_local7.Set((1 / _local6.m_quantizationFactor.x), (1 / _local6.m_quantizationFactor.y));
_local10.Set(0.9, 0.3, 0.9);
_local2 = 0;
while (_local2 < b2Settings.b2_maxProxies) {
_local22 = _local6.m_proxyPool[_local2];
if (_local22.IsValid() == false){
} else {
_local12.lowerBound.x = (_local20.x + (_local7.x * _local6.m_bounds[0][_local22.lowerBounds[0]].value));
_local12.lowerBound.y = (_local20.y + (_local7.y * _local6.m_bounds[1][_local22.lowerBounds[1]].value));
_local12.upperBound.x = (_local20.x + (_local7.x * _local6.m_bounds[0][_local22.upperBounds[0]].value));
_local12.upperBound.y = (_local20.y + (_local7.y * _local6.m_bounds[1][_local22.upperBounds[1]].value));
_local14[0].Set(_local12.lowerBound.x, _local12.lowerBound.y);
_local14[1].Set(_local12.upperBound.x, _local12.lowerBound.y);
_local14[2].Set(_local12.upperBound.x, _local12.upperBound.y);
_local14[3].Set(_local12.lowerBound.x, _local12.upperBound.y);
m_debugDraw.DrawPolygon(_local14, 4, _local10);
};
_local2++;
};
_local14[0].Set(_local20.x, _local20.y);
_local14[1].Set(_local21.x, _local20.y);
_local14[2].Set(_local21.x, _local21.y);
_local14[3].Set(_local20.x, _local21.y);
m_debugDraw.DrawPolygon(_local14, 4, new b2Color(0.3, 0.9, 0.9));
};
if ((_local1 & b2DebugDraw.e_obbBit)){
_local10.Set(0.5, 0.3, 0.5);
_local3 = m_bodyList;
while (_local3) {
_local11 = _local3.m_xf;
_local4 = _local3.GetShapeList();
while (_local4) {
if (_local4.m_type != b2Shape.e_polygonShape){
} else {
_local23 = (_local4 as b2PolygonShape);
_local24 = _local23.GetOBB();
_local25 = _local24.extents;
_local14[0].Set(-(_local25.x), -(_local25.y));
_local14[1].Set(_local25.x, -(_local25.y));
_local14[2].Set(_local25.x, _local25.y);
_local14[3].Set(-(_local25.x), _local25.y);
_local2 = 0;
while (_local2 < 4) {
_local26 = _local24.R;
_local27 = _local14[_local2];
_local28 = (_local24.center.x + ((_local26.col1.x * _local27.x) + (_local26.col2.x * _local27.y)));
_local14[_local2].y = (_local24.center.y + ((_local26.col1.y * _local27.x) + (_local26.col2.y * _local27.y)));
_local14[_local2].x = _local28;
_local26 = _local11.R;
_local28 = (_local11.position.x + ((_local26.col1.x * _local27.x) + (_local26.col2.x * _local27.y)));
_local14[_local2].y = (_local11.position.y + ((_local26.col1.y * _local27.x) + (_local26.col2.y * _local27.y)));
_local14[_local2].x = _local28;
_local2++;
};
m_debugDraw.DrawPolygon(_local14, 4, _local10);
};
_local4 = _local4.m_next;
};
_local3 = _local3.m_next;
};
};
if ((_local1 & b2DebugDraw.e_centerOfMassBit)){
_local3 = m_bodyList;
while (_local3) {
_local11 = s_xf;
_local11.R = _local3.m_xf.R;
_local11.position = _local3.GetWorldCenter();
m_debugDraw.DrawXForm(_local11);
_local3 = _local3.m_next;
};
};
}
public function DestroyBody(_arg1:b2Body):void{
var _local4:b2JointEdge;
var _local5:b2Shape;
if (m_lock == true){
return;
};
var _local2:b2JointEdge = _arg1.m_jointList;
while (_local2) {
_local4 = _local2;
_local2 = _local2.next;
if (m_destructionListener){
m_destructionListener.SayGoodbyeJoint(_local4.joint);
};
DestroyJoint(_local4.joint);
};
var _local3:b2Shape = _arg1.m_shapeList;
while (_local3) {
_local5 = _local3;
_local3 = _local3.m_next;
if (m_destructionListener){
m_destructionListener.SayGoodbyeShape(_local5);
};
_local5.DestroyProxy(m_broadPhase);
b2Shape.Destroy(_local5, m_blockAllocator);
};
if (_arg1.m_prev){
_arg1.m_prev.m_next = _arg1.m_next;
};
if (_arg1.m_next){
_arg1.m_next.m_prev = _arg1.m_prev;
};
if (_arg1 == m_bodyList){
m_bodyList = _arg1.m_next;
};
m_bodyCount--;
}
public function DrawShape(_arg1:b2Shape, _arg2:b2XForm, _arg3:b2Color, _arg4:Boolean):void{
var _local6:b2CircleShape;
var _local7:b2Vec2;
var _local8:Number;
var _local9:b2Vec2;
var _local10:int;
var _local11:b2PolygonShape;
var _local12:int;
var _local13:Array;
var _local14:Array;
var _local15:Array;
var _local5:b2Color = s_coreColor;
switch (_arg1.m_type){
case b2Shape.e_circleShape:
_local6 = (_arg1 as b2CircleShape);
_local7 = b2Math.b2MulX(_arg2, _local6.m_localPosition);
_local8 = _local6.m_radius;
_local9 = _arg2.R.col1;
m_debugDraw.DrawSolidCircle(_local7, _local8, _local9, _arg3);
if (_arg4){
m_debugDraw.DrawCircle(_local7, (_local8 - b2Settings.b2_toiSlop), _local5);
};
break;
case b2Shape.e_polygonShape:
_local11 = (_arg1 as b2PolygonShape);
_local12 = _local11.GetVertexCount();
_local13 = _local11.GetVertices();
_local14 = new Array(b2Settings.b2_maxPolygonVertices);
_local10 = 0;
while (_local10 < _local12) {
_local14[_local10] = b2Math.b2MulX(_arg2, _local13[_local10]);
_local10++;
};
m_debugDraw.DrawSolidPolygon(_local14, _local12, _arg3);
if (_arg4){
_local15 = _local11.GetCoreVertices();
_local10 = 0;
while (_local10 < _local12) {
_local14[_local10] = b2Math.b2MulX(_arg2, _local15[_local10]);
_local10++;
};
m_debugDraw.DrawPolygon(_local14, _local12, _local5);
};
break;
};
}
public function GetGroundBody():b2Body{
return (m_groundBody);
}
public function SetContactFilter(_arg1:b2ContactFilter):void{
m_contactFilter = _arg1;
}
public function Solve(_arg1:b2TimeStep):void{
var _local2:b2Body;
var _local9:int;
var _local10:int;
var _local11:b2Body;
var _local12:b2ContactEdge;
var _local13:b2JointEdge;
var _local14:Boolean;
m_positionIterationCount = 0;
var _local3:b2Island = new b2Island(m_bodyCount, m_contactCount, m_jointCount, m_stackAllocator, m_contactListener);
_local2 = m_bodyList;
while (_local2) {
_local2.m_flags = (_local2.m_flags & ~(b2Body.e_islandFlag));
_local2 = _local2.m_next;
};
var _local4:b2Contact = m_contactList;
while (_local4) {
_local4.m_flags = (_local4.m_flags & ~(b2Contact.e_islandFlag));
_local4 = _local4.m_next;
};
var _local5:b2Joint = m_jointList;
while (_local5) {
_local5.m_islandFlag = false;
_local5 = _local5.m_next;
};
var _local6:int = m_bodyCount;
var _local7:Array = new Array(_local6);
var _local8:b2Body = m_bodyList;
while (_local8) {
if ((_local8.m_flags & ((b2Body.e_islandFlag | b2Body.e_sleepFlag) | b2Body.e_frozenFlag))){
} else {
if (_local8.IsStatic()){
} else {
_local3.Clear();
_local9 = 0;
var _temp1 = _local9;
_local9 = (_local9 + 1);
var _local15 = _temp1;
_local7[_local15] = _local8;
_local8.m_flags = (_local8.m_flags | b2Body.e_islandFlag);
while (_local9 > 0) {
--_local9;
_local2 = _local7[_local9];
_local3.AddBody(_local2);
_local2.m_flags = (_local2.m_flags & ~(b2Body.e_sleepFlag));
if (_local2.IsStatic()){
} else {
_local12 = _local2.m_contactList;
while (_local12) {
if ((_local12.contact.m_flags & (b2Contact.e_islandFlag | b2Contact.e_nonSolidFlag))){
} else {
if (_local12.contact.m_manifoldCount == 0){
} else {
_local3.AddContact(_local12.contact);
_local12.contact.m_flags = (_local12.contact.m_flags | b2Contact.e_islandFlag);
_local11 = _local12.other;
if ((_local11.m_flags & b2Body.e_islandFlag)){
} else {
var _temp2 = _local9;
_local9 = (_local9 + 1);
var _local16 = _temp2;
_local7[_local16] = _local11;
_local11.m_flags = (_local11.m_flags | b2Body.e_islandFlag);
};
};
};
_local12 = _local12.next;
};
_local13 = _local2.m_jointList;
while (_local13) {
if (_local13.joint.m_islandFlag == true){
} else {
_local3.AddJoint(_local13.joint);
_local13.joint.m_islandFlag = true;
_local11 = _local13.other;
if ((_local11.m_flags & b2Body.e_islandFlag)){
} else {
var _temp3 = _local9;
_local9 = (_local9 + 1);
_local16 = _temp3;
_local7[_local16] = _local11;
_local11.m_flags = (_local11.m_flags | b2Body.e_islandFlag);
};
};
_local13 = _local13.next;
};
};
};
_local3.Solve(_arg1, m_gravity, m_positionCorrection, m_allowSleep);
if (_local3.m_positionIterationCount > m_positionIterationCount){
m_positionIterationCount = _local3.m_positionIterationCount;
};
_local10 = 0;
while (_local10 < _local3.m_bodyCount) {
_local2 = _local3.m_bodies[_local10];
if (_local2.IsStatic()){
_local2.m_flags = (_local2.m_flags & ~(b2Body.e_islandFlag));
};
_local10++;
};
};
};
_local8 = _local8.m_next;
};
_local2 = m_bodyList;
while (_local2) {
if ((_local2.m_flags & (b2Body.e_sleepFlag | b2Body.e_frozenFlag))){
} else {
if (_local2.IsStatic()){
} else {
_local14 = _local2.SynchronizeShapes();
if ((((_local14 == false)) && (!((m_boundaryListener == null))))){
m_boundaryListener.Violation(_local2);
};
};
};
_local2 = _local2.m_next;
};
m_broadPhase.Commit();
}
public function Query(_arg1:b2AABB, _arg2:Array, _arg3:int):int{
var _local4:Array = new Array(_arg3);
var _local5:int = m_broadPhase.QueryAABB(_arg1, _local4, _arg3);
var _local6:int;
while (_local6 < _local5) {
_arg2[_local6] = _local4[_local6];
_local6++;
};
return (_local5);
}
public function GetContactCount():int{
return (m_contactCount);
}
public function SolveTOI(_arg1:b2TimeStep):void{
var _local2:b2Body;
var _local3:b2Shape;
var _local4:b2Shape;
var _local5:b2Body;
var _local6:b2Body;
var _local7:b2ContactEdge;
var _local11:b2Contact;
var _local12:b2Contact;
var _local13:Number;
var _local14:b2Body;
var _local15:int;
var _local16:b2TimeStep;
var _local17:int;
var _local18:Number;
var _local19:Number;
var _local20:b2Body;
var _local21:Boolean;
var _local8:b2Island = new b2Island(m_bodyCount, b2Settings.b2_maxTOIContactsPerIsland, 0, m_stackAllocator, m_contactListener);
var _local9:int = m_bodyCount;
var _local10:Array = new Array(_local9);
_local2 = m_bodyList;
while (_local2) {
_local2.m_flags = (_local2.m_flags & ~(b2Body.e_islandFlag));
_local2.m_sweep.t0 = 0;
_local2 = _local2.m_next;
};
_local11 = m_contactList;
while (_local11) {
_local11.m_flags = (_local11.m_flags & ~((b2Contact.e_toiFlag | b2Contact.e_islandFlag)));
_local11 = _local11.m_next;
};
while (true) {
_local12 = null;
_local13 = 1;
_local11 = m_contactList;
for (;_local11;(_local11 = _local11.m_next)) {
if ((_local11.m_flags & (b2Contact.e_slowFlag | b2Contact.e_nonSolidFlag))){
} else {
_local18 = 1;
if ((_local11.m_flags & b2Contact.e_toiFlag)){
_local18 = _local11.m_toi;
} else {
_local3 = _local11.m_shape1;
_local4 = _local11.m_shape2;
_local5 = _local3.m_body;
_local6 = _local4.m_body;
if (((((_local5.IsStatic()) || (_local5.IsSleeping()))) && (((_local6.IsStatic()) || (_local6.IsSleeping()))))){
continue;
};
_local19 = _local5.m_sweep.t0;
if (_local5.m_sweep.t0 < _local6.m_sweep.t0){
_local19 = _local6.m_sweep.t0;
_local5.m_sweep.Advance(_local19);
} else {
if (_local6.m_sweep.t0 < _local5.m_sweep.t0){
_local19 = _local5.m_sweep.t0;
_local6.m_sweep.Advance(_local19);
};
};
_local18 = b2TimeOfImpact.TimeOfImpact(_local11.m_shape1, _local5.m_sweep, _local11.m_shape2, _local6.m_sweep);
if ((((_local18 > 0)) && ((_local18 < 1)))){
_local18 = (((1 - _local18) * _local19) + _local18);
if (_local18 > 1){
_local18 = 1;
};
};
_local11.m_toi = _local18;
_local11.m_flags = (_local11.m_flags | b2Contact.e_toiFlag);
};
if ((((Number.MIN_VALUE < _local18)) && ((_local18 < _local13)))){
_local12 = _local11;
_local13 = _local18;
};
};
};
if ((((_local12 == null)) || (((1 - (100 * Number.MIN_VALUE)) < _local13)))){
break;
};
_local3 = _local12.m_shape1;
_local4 = _local12.m_shape2;
_local5 = _local3.m_body;
_local6 = _local4.m_body;
_local5.Advance(_local13);
_local6.Advance(_local13);
_local12.Update(m_contactListener);
_local12.m_flags = (_local12.m_flags & ~(b2Contact.e_toiFlag));
if (_local12.m_manifoldCount == 0){
} else {
_local14 = _local5;
if (_local14.IsStatic()){
_local14 = _local6;
};
_local8.Clear();
_local15 = 0;
var _temp1 = _local15;
_local15 = (_local15 + 1);
var _local22 = _temp1;
_local10[_local22] = _local14;
_local14.m_flags = (_local14.m_flags | b2Body.e_islandFlag);
while (_local15 > 0) {
--_local15;
_local2 = _local10[_local15];
_local8.AddBody(_local2);
_local2.m_flags = (_local2.m_flags & ~(b2Body.e_sleepFlag));
if (_local2.IsStatic()){
} else {
_local7 = _local2.m_contactList;
while (_local7) {
if (_local8.m_contactCount == _local8.m_contactCapacity){
} else {
if ((_local7.contact.m_flags & ((b2Contact.e_islandFlag | b2Contact.e_slowFlag) | b2Contact.e_nonSolidFlag))){
} else {
if (_local7.contact.m_manifoldCount == 0){
} else {
_local8.AddContact(_local7.contact);
_local7.contact.m_flags = (_local7.contact.m_flags | b2Contact.e_islandFlag);
_local20 = _local7.other;
if ((_local20.m_flags & b2Body.e_islandFlag)){
} else {
if (_local20.IsStatic() == false){
_local20.Advance(_local13);
_local20.WakeUp();
};
var _temp2 = _local15;
_local15 = (_local15 + 1);
var _local23 = _temp2;
_local10[_local23] = _local20;
_local20.m_flags = (_local20.m_flags | b2Body.e_islandFlag);
};
};
};
};
_local7 = _local7.next;
};
};
};
_local16 = new b2TimeStep();
_local16.dt = ((1 - _local13) * _arg1.dt);
_local16.inv_dt = (1 / _local16.dt);
_local16.maxIterations = _arg1.maxIterations;
_local8.SolveTOI(_local16);
_local17 = 0;
while (_local17 < _local8.m_bodyCount) {
_local2 = _local8.m_bodies[_local17];
_local2.m_flags = (_local2.m_flags & ~(b2Body.e_islandFlag));
if ((_local2.m_flags & (b2Body.e_sleepFlag | b2Body.e_frozenFlag))){
} else {
if (_local2.IsStatic()){
} else {
_local21 = _local2.SynchronizeShapes();
if ((((_local21 == false)) && (!((m_boundaryListener == null))))){
m_boundaryListener.Violation(_local2);
};
_local7 = _local2.m_contactList;
while (_local7) {
_local7.contact.m_flags = (_local7.contact.m_flags & ~(b2Contact.e_toiFlag));
_local7 = _local7.next;
};
};
};
_local17++;
};
_local17 = 0;
while (_local17 < _local8.m_contactCount) {
_local11 = _local8.m_contacts[_local17];
_local8.m_contacts[_local17].m_flags = (_local11.m_flags & ~((b2Contact.e_toiFlag | b2Contact.e_islandFlag)));
_local17++;
};
m_broadPhase.Commit();
};
};
}
public function GetJointList():b2Joint{
return (m_jointList);
}
public function Validate():void{
m_broadPhase.Validate();
}
public function SetGravity(_arg1:b2Vec2):void{
m_gravity = _arg1;
}
public function GetPairCount():int{
return (m_broadPhase.m_pairManager.m_pairCount);
}
public function GetBodyList():b2Body{
return (m_bodyList);
}
public function SetWarmStarting(_arg1:Boolean):void{
m_warmStarting = _arg1;
}
public function SetPositionCorrection(_arg1:Boolean):void{
m_positionCorrection = _arg1;
}
public function CreateJoint(_arg1:b2JointDef):b2Joint{
var _local3:b2Body;
var _local4:b2Shape;
var _local2:b2Joint = b2Joint.Create(_arg1, m_blockAllocator);
_local2.m_prev = null;
_local2.m_next = m_jointList;
if (m_jointList){
m_jointList.m_prev = _local2;
};
m_jointList = _local2;
m_jointCount++;
_local2.m_node1.joint = _local2;
_local2.m_node1.other = _local2.m_body2;
_local2.m_node1.prev = null;
_local2.m_node1.next = _local2.m_body1.m_jointList;
if (_local2.m_body1.m_jointList){
_local2.m_body1.m_jointList.prev = _local2.m_node1;
};
_local2.m_body1.m_jointList = _local2.m_node1;
_local2.m_node2.joint = _local2;
_local2.m_node2.other = _local2.m_body1;
_local2.m_node2.prev = null;
_local2.m_node2.next = _local2.m_body2.m_jointList;
if (_local2.m_body2.m_jointList){
_local2.m_body2.m_jointList.prev = _local2.m_node2;
};
_local2.m_body2.m_jointList = _local2.m_node2;
if (_arg1.collideConnected == false){
_local3 = ((_arg1.body1.m_shapeCount < _arg1.body2.m_shapeCount)) ? _arg1.body1 : _arg1.body2;
_local4 = _local3.m_shapeList;
while (_local4) {
_local4.RefilterProxy(m_broadPhase, _local3.m_xf);
_local4 = _local4.m_next;
};
};
return (_local2);
}
public function DestroyJoint(_arg1:b2Joint):void{
var _local5:b2Body;
var _local6:b2Shape;
var _local2:Boolean = _arg1.m_collideConnected;
if (_arg1.m_prev){
_arg1.m_prev.m_next = _arg1.m_next;
};
if (_arg1.m_next){
_arg1.m_next.m_prev = _arg1.m_prev;
};
if (_arg1 == m_jointList){
m_jointList = _arg1.m_next;
};
var _local3:b2Body = _arg1.m_body1;
var _local4:b2Body = _arg1.m_body2;
_local3.WakeUp();
_local4.WakeUp();
if (_arg1.m_node1.prev){
_arg1.m_node1.prev.next = _arg1.m_node1.next;
};
if (_arg1.m_node1.next){
_arg1.m_node1.next.prev = _arg1.m_node1.prev;
};
if (_arg1.m_node1 == _local3.m_jointList){
_local3.m_jointList = _arg1.m_node1.next;
};
_arg1.m_node1.prev = null;
_arg1.m_node1.next = null;
if (_arg1.m_node2.prev){
_arg1.m_node2.prev.next = _arg1.m_node2.next;
};
if (_arg1.m_node2.next){
_arg1.m_node2.next.prev = _arg1.m_node2.prev;
};
if (_arg1.m_node2 == _local4.m_jointList){
_local4.m_jointList = _arg1.m_node2.next;
};
_arg1.m_node2.prev = null;
_arg1.m_node2.next = null;
b2Joint.Destroy(_arg1, m_blockAllocator);
m_jointCount--;
if (_local2 == false){
_local5 = ((_local3.m_shapeCount < _local4.m_shapeCount)) ? _local3 : _local4;
_local6 = _local5.m_shapeList;
while (_local6) {
_local6.RefilterProxy(m_broadPhase, _local5.m_xf);
_local6 = _local6.m_next;
};
};
}
public function SetContactListener(_arg1:b2ContactListener):void{
m_contactListener = _arg1;
}
public function Raycast(_arg1:b2Segment, _arg2:Array, _arg3:int, _arg4):int{
var _local5:Array = new Array(_arg3);
m_raycastSegment = _arg1;
m_raycastUserData = _arg4;
var _local6:int = m_broadPhase.QuerySegment(_arg1, _local5, _arg3, RaycastSortKey);
var _local7:int;
while (_local7 < _local6) {
_arg2[_local7] = _local5[_local7];
_local7++;
};
return (_local6);
}
public function RaycastOne(_arg1:b2Segment, _arg2:Array, _arg3:b2Vec2, _arg4):b2Shape{
var _local5:Array = new Array(1);
var _local6:Number = Raycast(_arg1, _local5, 1, _arg4);
if (_local6 == 0){
return (null);
};
if (_local6 > 1){
trace(_local6);
};
var _local7:b2Shape = _local5[0];
var _local8:b2XForm = _local7.GetBody().GetXForm();
_local7.TestSegment(_local8, _arg2, _arg3, _arg1, 1);
return (_local7);
}
public function CreateBody(_arg1:b2BodyDef):b2Body{
if (m_lock == true){
return (null);
};
var _local2:b2Body = new b2Body(_arg1, this);
_local2.m_prev = null;
_local2.m_next = m_bodyList;
if (m_bodyList){
m_bodyList.m_prev = _local2;
};
m_bodyList = _local2;
m_bodyCount++;
return (_local2);
}
public function RaycastSortKey(_arg1:b2Shape){
if (((m_contactFilter) && (!(m_contactFilter.RayCollide(m_raycastUserData, _arg1))))){
return (-1);
};
var _local2:b2Body = _arg1.GetBody();
var _local3:b2XForm = _local2.GetXForm();
var _local4:Array = [0];
if (!_arg1.TestSegment(_local3, _local4, m_raycastNormal, m_raycastSegment, 1)){
return (-1);
};
return (_local4[0]);
}
public function SetBoundaryListener(_arg1:b2BoundaryListener):void{
m_boundaryListener = _arg1;
}
public function SetDestructionListener(_arg1:b2DestructionListener):void{
m_destructionListener = _arg1;
}
public function Step(_arg1:Number, _arg2:int):void{
m_lock = true;
var _local3:b2TimeStep = new b2TimeStep();
_local3.dt = _arg1;
_local3.maxIterations = _arg2;
if (_arg1 > 0){
_local3.inv_dt = (1 / _arg1);
} else {
_local3.inv_dt = 0;
};
_local3.dtRatio = (m_inv_dt0 * _arg1);
_local3.positionCorrection = m_positionCorrection;
_local3.warmStarting = m_warmStarting;
m_contactManager.Collide();
if (_local3.dt > 0){
Solve(_local3);
};
if (((m_continuousPhysics) && ((_local3.dt > 0)))){
SolveTOI(_local3);
};
DrawDebugData();
m_inv_dt0 = _local3.inv_dt;
m_lock = false;
}
public function GetBodyCount():int{
return (m_bodyCount);
}
public function GetJointCount():int{
return (m_jointCount);
}
}
}//package Box2D.Dynamics
Section 75
//MD5 (com.adobe.crypto.MD5)
package com.adobe.crypto {
import flash.utils.*;
import com.adobe.utils.*;
public class MD5 {
public static var digest:ByteArray;
private static function ff(_arg1:int, _arg2:int, _arg3:int, _arg4:int, _arg5:int, _arg6:int, _arg7:int):int{
return (transform(f, _arg1, _arg2, _arg3, _arg4, _arg5, _arg6, _arg7));
}
private static function f(_arg1:int, _arg2:int, _arg3:int):int{
return (((_arg1 & _arg2) | (~(_arg1) & _arg3)));
}
private static function g(_arg1:int, _arg2:int, _arg3:int):int{
return (((_arg1 & _arg3) | (_arg2 & ~(_arg3))));
}
private static function h(_arg1:int, _arg2:int, _arg3:int):int{
return (((_arg1 ^ _arg2) ^ _arg3));
}
private static function i(_arg1:int, _arg2:int, _arg3:int):int{
return ((_arg2 ^ (_arg1 | ~(_arg3))));
}
private static function transform(_arg1:Function, _arg2:int, _arg3:int, _arg4:int, _arg5:int, _arg6:int, _arg7:int, _arg8:int):int{
var _local9:int = (((_arg2 + int(_arg1(_arg3, _arg4, _arg5))) + _arg6) + _arg8);
return ((IntUtil.rol(_local9, _arg7) + _arg3));
}
private static function hh(_arg1:int, _arg2:int, _arg3:int, _arg4:int, _arg5:int, _arg6:int, _arg7:int):int{
return (transform(h, _arg1, _arg2, _arg3, _arg4, _arg5, _arg6, _arg7));
}
public static function hash(_arg1:String):String{
var _local2:ByteArray = new ByteArray();
_local2.writeUTFBytes(_arg1);
return (hashBinary(_local2));
}
private static function createBlocks(_arg1:ByteArray):Array{
var _local2:Array = new Array();
var _local3:int = (_arg1.length * 8);
var _local4 = 0xFF;
var _local5:int;
while (_local5 < _local3) {
_local2[int((_local5 >> 5))] = (_local2[int((_local5 >> 5))] | ((_arg1[(_local5 / 8)] & _local4) << (_local5 % 32)));
_local5 = (_local5 + 8);
};
_local2[int((_local3 >> 5))] = (_local2[int((_local3 >> 5))] | (128 << (_local3 % 32)));
_local2[int(((((_local3 + 64) >>> 9) << 4) + 14))] = _local3;
return (_local2);
}
public static function hashBinary(_arg1:ByteArray):String{
var _local6:int;
var _local7:int;
var _local8:int;
var _local9:int;
var _local2 = 1732584193;
var _local3 = -271733879;
var _local4 = -1732584194;
var _local5 = 271733878;
var _local10:Array = createBlocks(_arg1);
var _local11:int = _local10.length;
var _local12:int;
while (_local12 < _local11) {
_local6 = _local2;
_local7 = _local3;
_local8 = _local4;
_local9 = _local5;
_local2 = ff(_local2, _local3, _local4, _local5, _local10[int((_local12 + 0))], 7, -680876936);
_local5 = ff(_local5, _local2, _local3, _local4, _local10[int((_local12 + 1))], 12, -389564586);
_local4 = ff(_local4, _local5, _local2, _local3, _local10[int((_local12 + 2))], 17, 606105819);
_local3 = ff(_local3, _local4, _local5, _local2, _local10[int((_local12 + 3))], 22, -1044525330);
_local2 = ff(_local2, _local3, _local4, _local5, _local10[int((_local12 + 4))], 7, -176418897);
_local5 = ff(_local5, _local2, _local3, _local4, _local10[int((_local12 + 5))], 12, 1200080426);
_local4 = ff(_local4, _local5, _local2, _local3, _local10[int((_local12 + 6))], 17, -1473231341);
_local3 = ff(_local3, _local4, _local5, _local2, _local10[int((_local12 + 7))], 22, -45705983);
_local2 = ff(_local2, _local3, _local4, _local5, _local10[int((_local12 + 8))], 7, 1770035416);
_local5 = ff(_local5, _local2, _local3, _local4, _local10[int((_local12 + 9))], 12, -1958414417);
_local4 = ff(_local4, _local5, _local2, _local3, _local10[int((_local12 + 10))], 17, -42063);
_local3 = ff(_local3, _local4, _local5, _local2, _local10[int((_local12 + 11))], 22, -1990404162);
_local2 = ff(_local2, _local3, _local4, _local5, _local10[int((_local12 + 12))], 7, 1804603682);
_local5 = ff(_local5, _local2, _local3, _local4, _local10[int((_local12 + 13))], 12, -40341101);
_local4 = ff(_local4, _local5, _local2, _local3, _local10[int((_local12 + 14))], 17, -1502002290);
_local3 = ff(_local3, _local4, _local5, _local2, _local10[int((_local12 + 15))], 22, 1236535329);
_local2 = gg(_local2, _local3, _local4, _local5, _local10[int((_local12 + 1))], 5, -165796510);
_local5 = gg(_local5, _local2, _local3, _local4, _local10[int((_local12 + 6))], 9, -1069501632);
_local4 = gg(_local4, _local5, _local2, _local3, _local10[int((_local12 + 11))], 14, 643717713);
_local3 = gg(_local3, _local4, _local5, _local2, _local10[int((_local12 + 0))], 20, -373897302);
_local2 = gg(_local2, _local3, _local4, _local5, _local10[int((_local12 + 5))], 5, -701558691);
_local5 = gg(_local5, _local2, _local3, _local4, _local10[int((_local12 + 10))], 9, 38016083);
_local4 = gg(_local4, _local5, _local2, _local3, _local10[int((_local12 + 15))], 14, -660478335);
_local3 = gg(_local3, _local4, _local5, _local2, _local10[int((_local12 + 4))], 20, -405537848);
_local2 = gg(_local2, _local3, _local4, _local5, _local10[int((_local12 + 9))], 5, 568446438);
_local5 = gg(_local5, _local2, _local3, _local4, _local10[int((_local12 + 14))], 9, -1019803690);
_local4 = gg(_local4, _local5, _local2, _local3, _local10[int((_local12 + 3))], 14, -187363961);
_local3 = gg(_local3, _local4, _local5, _local2, _local10[int((_local12 + 8))], 20, 1163531501);
_local2 = gg(_local2, _local3, _local4, _local5, _local10[int((_local12 + 13))], 5, -1444681467);
_local5 = gg(_local5, _local2, _local3, _local4, _local10[int((_local12 + 2))], 9, -51403784);
_local4 = gg(_local4, _local5, _local2, _local3, _local10[int((_local12 + 7))], 14, 1735328473);
_local3 = gg(_local3, _local4, _local5, _local2, _local10[int((_local12 + 12))], 20, -1926607734);
_local2 = hh(_local2, _local3, _local4, _local5, _local10[int((_local12 + 5))], 4, -378558);
_local5 = hh(_local5, _local2, _local3, _local4, _local10[int((_local12 + 8))], 11, -2022574463);
_local4 = hh(_local4, _local5, _local2, _local3, _local10[int((_local12 + 11))], 16, 1839030562);
_local3 = hh(_local3, _local4, _local5, _local2, _local10[int((_local12 + 14))], 23, -35309556);
_local2 = hh(_local2, _local3, _local4, _local5, _local10[int((_local12 + 1))], 4, -1530992060);
_local5 = hh(_local5, _local2, _local3, _local4, _local10[int((_local12 + 4))], 11, 1272893353);
_local4 = hh(_local4, _local5, _local2, _local3, _local10[int((_local12 + 7))], 16, -155497632);
_local3 = hh(_local3, _local4, _local5, _local2, _local10[int((_local12 + 10))], 23, -1094730640);
_local2 = hh(_local2, _local3, _local4, _local5, _local10[int((_local12 + 13))], 4, 681279174);
_local5 = hh(_local5, _local2, _local3, _local4, _local10[int((_local12 + 0))], 11, -358537222);
_local4 = hh(_local4, _local5, _local2, _local3, _local10[int((_local12 + 3))], 16, -722521979);
_local3 = hh(_local3, _local4, _local5, _local2, _local10[int((_local12 + 6))], 23, 76029189);
_local2 = hh(_local2, _local3, _local4, _local5, _local10[int((_local12 + 9))], 4, -640364487);
_local5 = hh(_local5, _local2, _local3, _local4, _local10[int((_local12 + 12))], 11, -421815835);
_local4 = hh(_local4, _local5, _local2, _local3, _local10[int((_local12 + 15))], 16, 530742520);
_local3 = hh(_local3, _local4, _local5, _local2, _local10[int((_local12 + 2))], 23, -995338651);
_local2 = ii(_local2, _local3, _local4, _local5, _local10[int((_local12 + 0))], 6, -198630844);
_local5 = ii(_local5, _local2, _local3, _local4, _local10[int((_local12 + 7))], 10, 1126891415);
_local4 = ii(_local4, _local5, _local2, _local3, _local10[int((_local12 + 14))], 15, -1416354905);
_local3 = ii(_local3, _local4, _local5, _local2, _local10[int((_local12 + 5))], 21, -57434055);
_local2 = ii(_local2, _local3, _local4, _local5, _local10[int((_local12 + 12))], 6, 1700485571);
_local5 = ii(_local5, _local2, _local3, _local4, _local10[int((_local12 + 3))], 10, -1894986606);
_local4 = ii(_local4, _local5, _local2, _local3, _local10[int((_local12 + 10))], 15, -1051523);
_local3 = ii(_local3, _local4, _local5, _local2, _local10[int((_local12 + 1))], 21, -2054922799);
_local2 = ii(_local2, _local3, _local4, _local5, _local10[int((_local12 + 8))], 6, 1873313359);
_local5 = ii(_local5, _local2, _local3, _local4, _local10[int((_local12 + 15))], 10, -30611744);
_local4 = ii(_local4, _local5, _local2, _local3, _local10[int((_local12 + 6))], 15, -1560198380);
_local3 = ii(_local3, _local4, _local5, _local2, _local10[int((_local12 + 13))], 21, 1309151649);
_local2 = ii(_local2, _local3, _local4, _local5, _local10[int((_local12 + 4))], 6, -145523070);
_local5 = ii(_local5, _local2, _local3, _local4, _local10[int((_local12 + 11))], 10, -1120210379);
_local4 = ii(_local4, _local5, _local2, _local3, _local10[int((_local12 + 2))], 15, 718787259);
_local3 = ii(_local3, _local4, _local5, _local2, _local10[int((_local12 + 9))], 21, -343485551);
_local2 = (_local2 + _local6);
_local3 = (_local3 + _local7);
_local4 = (_local4 + _local8);
_local5 = (_local5 + _local9);
_local12 = (_local12 + 16);
};
digest = new ByteArray();
digest.writeInt(_local2);
digest.writeInt(_local3);
digest.writeInt(_local4);
digest.writeInt(_local5);
digest.position = 0;
return ((((IntUtil.toHex(_local2) + IntUtil.toHex(_local3)) + IntUtil.toHex(_local4)) + IntUtil.toHex(_local5)));
}
private static function gg(_arg1:int, _arg2:int, _arg3:int, _arg4:int, _arg5:int, _arg6:int, _arg7:int):int{
return (transform(g, _arg1, _arg2, _arg3, _arg4, _arg5, _arg6, _arg7));
}
private static function ii(_arg1:int, _arg2:int, _arg3:int, _arg4:int, _arg5:int, _arg6:int, _arg7:int):int{
return (transform(i, _arg1, _arg2, _arg3, _arg4, _arg5, _arg6, _arg7));
}
public static function hashBytes(_arg1:ByteArray):String{
return (hashBinary(_arg1));
}
}
}//package com.adobe.crypto
Section 76
//PNGEncoder (com.adobe.images.PNGEncoder)
package com.adobe.images {
import flash.display.*;
import flash.geom.*;
import flash.utils.*;
public class PNGEncoder {
private static var crcTableComputed:Boolean = false;
private static var crcTable:Array;
private static function writeChunk(_arg1:ByteArray, _arg2:uint, _arg3:ByteArray):void{
var _local8:uint;
var _local9:uint;
var _local10:uint;
if (!crcTableComputed){
crcTableComputed = true;
crcTable = [];
_local9 = 0;
while (_local9 < 0x0100) {
_local8 = _local9;
_local10 = 0;
while (_local10 < 8) {
if ((_local8 & 1)){
_local8 = uint((uint(3988292384) ^ uint((_local8 >>> 1))));
} else {
_local8 = uint((_local8 >>> 1));
};
_local10++;
};
crcTable[_local9] = _local8;
_local9++;
};
};
var _local4:uint;
if (_arg3 != null){
_local4 = _arg3.length;
};
_arg1.writeUnsignedInt(_local4);
var _local5:uint = _arg1.position;
_arg1.writeUnsignedInt(_arg2);
if (_arg3 != null){
_arg1.writeBytes(_arg3);
};
var _local6:uint = _arg1.position;
_arg1.position = _local5;
_local8 = 4294967295;
var _local7:int;
while (_local7 < (_local6 - _local5)) {
_local8 = uint((crcTable[((_local8 ^ _arg1.readUnsignedByte()) & uint(0xFF))] ^ uint((_local8 >>> 8))));
_local7++;
};
_local8 = uint((_local8 ^ uint(4294967295)));
_arg1.position = _local6;
_arg1.writeUnsignedInt(_local8);
}
public static function encode(_arg1:BitmapData):ByteArray{
var _local6:uint;
var _local7:int;
var _local2:ByteArray = new ByteArray();
_local2.writeUnsignedInt(2303741511);
_local2.writeUnsignedInt(218765834);
var _local3:ByteArray = new ByteArray();
_local3.writeInt(_arg1.width);
_local3.writeInt(_arg1.height);
_local3.writeUnsignedInt(134610944);
_local3.writeByte(0);
writeChunk(_local2, 1229472850, _local3);
var _local4:ByteArray = new ByteArray();
var _local5:int;
while (_local5 < _arg1.height) {
_local4.writeByte(0);
if (!_arg1.transparent){
_local7 = 0;
while (_local7 < _arg1.width) {
_local6 = _arg1.getPixel(_local7, _local5);
_local4.writeUnsignedInt(uint((((_local6 & 0xFFFFFF) << 8) | 0xFF)));
_local7++;
};
} else {
_local7 = 0;
while (_local7 < _arg1.width) {
_local6 = _arg1.getPixel32(_local7, _local5);
_local4.writeUnsignedInt(uint((((_local6 & 0xFFFFFF) << 8) | (_local6 >>> 24))));
_local7++;
};
};
_local5++;
};
_local4.compress();
writeChunk(_local2, 1229209940, _local4);
writeChunk(_local2, 1229278788, null);
return (_local2);
}
}
}//package com.adobe.images
Section 77
//JSON (com.adobe.serialization.json.JSON)
package com.adobe.serialization.json {
public class JSON {
public static function decode(_arg1:String){
var _local2:JSONDecoder = new JSONDecoder(_arg1);
return (_local2.getValue());
}
public static function encode(_arg1:Object):String{
var _local2:JSONEncoder = new JSONEncoder(_arg1);
return (_local2.getString());
}
}
}//package com.adobe.serialization.json
Section 78
//JSONDecoder (com.adobe.serialization.json.JSONDecoder)
package com.adobe.serialization.json {
public class JSONDecoder {
private var value;
private var tokenizer:JSONTokenizer;
private var token:JSONToken;
public function JSONDecoder(_arg1:String){
tokenizer = new JSONTokenizer(_arg1);
nextToken();
value = parseValue();
}
private function parseObject():Object{
var _local2:String;
var _local1:Object = new Object();
nextToken();
if (token.type == JSONTokenType.RIGHT_BRACE){
return (_local1);
};
while (true) {
if (token.type == JSONTokenType.STRING){
_local2 = String(token.value);
nextToken();
if (token.type == JSONTokenType.COLON){
nextToken();
_local1[_local2] = parseValue();
nextToken();
if (token.type == JSONTokenType.RIGHT_BRACE){
return (_local1);
};
if (token.type == JSONTokenType.COMMA){
nextToken();
} else {
tokenizer.parseError(("Expecting } or , but found " + token.value));
};
} else {
tokenizer.parseError(("Expecting : but found " + token.value));
};
} else {
tokenizer.parseError(("Expecting string but found " + token.value));
};
};
return (null);
}
private function parseValue():Object{
if (token == null){
tokenizer.parseError("Unexpected end of input");
};
switch (token.type){
case JSONTokenType.LEFT_BRACE:
return (parseObject());
case JSONTokenType.LEFT_BRACKET:
return (parseArray());
case JSONTokenType.STRING:
case JSONTokenType.NUMBER:
case JSONTokenType.TRUE:
case JSONTokenType.FALSE:
case JSONTokenType.NULL:
return (token.value);
default:
tokenizer.parseError(("Unexpected " + token.value));
};
return (null);
}
private function nextToken():JSONToken{
return ((token = tokenizer.getNextToken()));
}
public function getValue(){
return (value);
}
private function parseArray():Array{
var _local1:Array = new Array();
nextToken();
if (token.type == JSONTokenType.RIGHT_BRACKET){
return (_local1);
};
while (true) {
_local1.push(parseValue());
nextToken();
if (token.type == JSONTokenType.RIGHT_BRACKET){
return (_local1);
};
if (token.type == JSONTokenType.COMMA){
nextToken();
} else {
tokenizer.parseError(("Expecting ] or , but found " + token.value));
};
};
return (null);
}
}
}//package com.adobe.serialization.json
Section 79
//JSONEncoder (com.adobe.serialization.json.JSONEncoder)
package com.adobe.serialization.json {
import flash.utils.*;
public class JSONEncoder {
private var jsonString:String;
public function JSONEncoder(_arg1){
jsonString = convertToString(_arg1);
}
private function escapeString(_arg1:String):String{
var _local3:String;
var _local6:String;
var _local7:String;
var _local2 = "";
var _local4:Number = _arg1.length;
var _local5:int;
while (_local5 < _local4) {
_local3 = _arg1.charAt(_local5);
switch (_local3){
case "\"":
_local2 = (_local2 + "\\\"");
break;
case "\\":
_local2 = (_local2 + "\\\\");
break;
case "\b":
_local2 = (_local2 + "\\b");
break;
case "\f":
_local2 = (_local2 + "\\f");
break;
case "\n":
_local2 = (_local2 + "\\n");
break;
case "\r":
_local2 = (_local2 + "\\r");
break;
case "\t":
_local2 = (_local2 + "\\t");
break;
default:
if (_local3 < " "){
_local6 = _local3.charCodeAt(0).toString(16);
_local7 = ((_local6.length == 2)) ? "00" : "000";
_local2 = (_local2 + (("\\u" + _local7) + _local6));
} else {
_local2 = (_local2 + _local3);
};
};
_local5++;
};
return ((("\"" + _local2) + "\""));
}
private function arrayToString(_arg1:Array):String{
var _local2 = "";
var _local3:int;
while (_local3 < _arg1.length) {
if (_local2.length > 0){
_local2 = (_local2 + ",");
};
_local2 = (_local2 + convertToString(_arg1[_local3]));
_local3++;
};
return ((("[" + _local2) + "]"));
}
public function getString():String{
return (jsonString);
}
private function objectToString(_arg1:Object):String{
var value:Object;
var key:String;
var v:XML;
var o = _arg1;
var s = "";
var classInfo:XML = describeType(o);
if (classInfo.@name.toString() == "Object"){
for (key in o) {
value = o[key];
if ((value is Function)){
} else {
if (s.length > 0){
s = (s + ",");
};
s = (s + ((escapeString(key) + ":") + convertToString(value)));
};
};
} else {
for each (v in classInfo..*.(((name() == "variable")) || ((name() == "accessor")))) {
if (s.length > 0){
s = (s + ",");
};
s = (s + ((escapeString(v.@name.toString()) + ":") + convertToString(o[v.@name])));
};
};
return ((("{" + s) + "}"));
}
private function convertToString(_arg1):String{
if ((_arg1 is String)){
return (escapeString((_arg1 as String)));
};
if ((_arg1 is Number)){
return ((isFinite((_arg1 as Number))) ? _arg1.toString() : "null");
} else {
if ((_arg1 is Boolean)){
return ((_arg1) ? "true" : "false");
} else {
if ((_arg1 is Array)){
return (arrayToString((_arg1 as Array)));
};
if ((((_arg1 is Object)) && (!((_arg1 == null))))){
return (objectToString(_arg1));
};
};
};
return ("null");
}
}
}//package com.adobe.serialization.json
Section 80
//JSONParseError (com.adobe.serialization.json.JSONParseError)
package com.adobe.serialization.json {
public class JSONParseError extends Error {
private var _location:int;
private var _text:String;
public function JSONParseError(_arg1:String="", _arg2:int=0, _arg3:String=""){
super(_arg1);
name = "JSONParseError";
_location = _arg2;
_text = _arg3;
}
public function get location():int{
return (_location);
}
public function get text():String{
return (_text);
}
}
}//package com.adobe.serialization.json
Section 81
//JSONToken (com.adobe.serialization.json.JSONToken)
package com.adobe.serialization.json {
public class JSONToken {
private var _value:Object;
private var _type:int;
public function JSONToken(_arg1:int=-1, _arg2:Object=null){
_type = _arg1;
_value = _arg2;
}
public function get value():Object{
return (_value);
}
public function get type():int{
return (_type);
}
public function set type(_arg1:int):void{
_type = _arg1;
}
public function set value(_arg1:Object):void{
_value = _arg1;
}
}
}//package com.adobe.serialization.json
Section 82
//JSONTokenizer (com.adobe.serialization.json.JSONTokenizer)
package com.adobe.serialization.json {
public class JSONTokenizer {
private var loc:int;
private var ch:String;
private var obj:Object;
private var jsonString:String;
public function JSONTokenizer(_arg1:String){
jsonString = _arg1;
loc = 0;
nextChar();
}
private function skipComments():void{
if (ch == "/"){
nextChar();
switch (ch){
case "/":
do {
nextChar();
} while (((!((ch == "\n"))) && (!((ch == "")))));
nextChar();
break;
case "*":
nextChar();
while (true) {
if (ch == "*"){
nextChar();
if (ch == "/"){
nextChar();
break;
};
} else {
nextChar();
};
if (ch == ""){
parseError("Multi-line comment not closed");
};
};
break;
default:
parseError((("Unexpected " + ch) + " encountered (expecting '/' or '*' )"));
};
};
}
private function isDigit(_arg1:String):Boolean{
return ((((_arg1 >= "0")) && ((_arg1 <= "9"))));
}
private function readString():JSONToken{
var _local3:String;
var _local4:int;
var _local1:JSONToken = new JSONToken();
_local1.type = JSONTokenType.STRING;
var _local2 = "";
nextChar();
while (((!((ch == "\""))) && (!((ch == ""))))) {
if (ch == "\\"){
nextChar();
switch (ch){
case "\"":
_local2 = (_local2 + "\"");
break;
case "/":
_local2 = (_local2 + "/");
break;
case "\\":
_local2 = (_local2 + "\\");
break;
case "b":
_local2 = (_local2 + "\b");
break;
case "f":
_local2 = (_local2 + "\f");
break;
case "n":
_local2 = (_local2 + "\n");
break;
case "r":
_local2 = (_local2 + "\r");
break;
case "t":
_local2 = (_local2 + "\t");
break;
case "u":
_local3 = "";
_local4 = 0;
while (_local4 < 4) {
if (!isHexDigit(nextChar())){
parseError((" Excepted a hex digit, but found: " + ch));
};
_local3 = (_local3 + ch);
_local4++;
};
_local2 = (_local2 + String.fromCharCode(parseInt(_local3, 16)));
break;
default:
_local2 = (_local2 + ("\\" + ch));
};
} else {
_local2 = (_local2 + ch);
};
nextChar();
};
if (ch == ""){
parseError("Unterminated string literal");
};
nextChar();
_local1.value = _local2;
return (_local1);
}
private function nextChar():String{
return ((ch = jsonString.charAt(loc++)));
}
public function getNextToken():JSONToken{
var _local2:String;
var _local3:String;
var _local4:String;
var _local1:JSONToken = new JSONToken();
skipIgnored();
switch (ch){
case "{":
_local1.type = JSONTokenType.LEFT_BRACE;
_local1.value = "{";
nextChar();
break;
case "}":
_local1.type = JSONTokenType.RIGHT_BRACE;
_local1.value = "}";
nextChar();
break;
case "[":
_local1.type = JSONTokenType.LEFT_BRACKET;
_local1.value = "[";
nextChar();
break;
case "]":
_local1.type = JSONTokenType.RIGHT_BRACKET;
_local1.value = "]";
nextChar();
break;
case ",":
_local1.type = JSONTokenType.COMMA;
_local1.value = ",";
nextChar();
break;
case ":":
_local1.type = JSONTokenType.COLON;
_local1.value = ":";
nextChar();
break;
case "t":
_local2 = ((("t" + nextChar()) + nextChar()) + nextChar());
if (_local2 == "true"){
_local1.type = JSONTokenType.TRUE;
_local1.value = true;
nextChar();
} else {
parseError(("Expecting 'true' but found " + _local2));
};
break;
case "f":
_local3 = (((("f" + nextChar()) + nextChar()) + nextChar()) + nextChar());
if (_local3 == "false"){
_local1.type = JSONTokenType.FALSE;
_local1.value = false;
nextChar();
} else {
parseError(("Expecting 'false' but found " + _local3));
};
break;
case "n":
_local4 = ((("n" + nextChar()) + nextChar()) + nextChar());
if (_local4 == "null"){
_local1.type = JSONTokenType.NULL;
_local1.value = null;
nextChar();
} else {
parseError(("Expecting 'null' but found " + _local4));
};
break;
case "\"":
_local1 = readString();
break;
default:
if (((isDigit(ch)) || ((ch == "-")))){
_local1 = readNumber();
} else {
if (ch == ""){
return (null);
};
parseError((("Unexpected " + ch) + " encountered"));
};
};
return (_local1);
}
private function skipWhite():void{
while (isWhiteSpace(ch)) {
nextChar();
};
}
public function parseError(_arg1:String):void{
throw (new JSONParseError(_arg1, loc, jsonString));
}
private function isWhiteSpace(_arg1:String):Boolean{
return ((((((((_arg1 == " ")) || ((_arg1 == "\t")))) || ((_arg1 == "\n")))) || ((_arg1 == "\r"))));
}
private function skipIgnored():void{
var _local1:int;
do {
_local1 = loc;
skipWhite();
skipComments();
} while (_local1 != loc);
}
private function isHexDigit(_arg1:String):Boolean{
var _local2:String = _arg1.toUpperCase();
return (((isDigit(_arg1)) || ((((_local2 >= "A")) && ((_local2 <= "F"))))));
}
private function readNumber():JSONToken{
var _local1:JSONToken = new JSONToken();
_local1.type = JSONTokenType.NUMBER;
var _local2 = "";
if (ch == "-"){
_local2 = (_local2 + "-");
nextChar();
};
if (!isDigit(ch)){
parseError("Expecting a digit");
};
if (ch == "0"){
_local2 = (_local2 + ch);
nextChar();
if (isDigit(ch)){
parseError("A digit cannot immediately follow 0");
};
} else {
while (isDigit(ch)) {
_local2 = (_local2 + ch);
nextChar();
};
};
if (ch == "."){
_local2 = (_local2 + ".");
nextChar();
if (!isDigit(ch)){
parseError("Expecting a digit");
};
while (isDigit(ch)) {
_local2 = (_local2 + ch);
nextChar();
};
};
if ((((ch == "e")) || ((ch == "E")))){
_local2 = (_local2 + "e");
nextChar();
if ((((ch == "+")) || ((ch == "-")))){
_local2 = (_local2 + ch);
nextChar();
};
if (!isDigit(ch)){
parseError("Scientific notation number needs exponent value");
};
while (isDigit(ch)) {
_local2 = (_local2 + ch);
nextChar();
};
};
var _local3:Number = Number(_local2);
if (((isFinite(_local3)) && (!(isNaN(_local3))))){
_local1.value = _local3;
return (_local1);
};
parseError((("Number " + _local3) + " is not valid!"));
return (null);
}
}
}//package com.adobe.serialization.json
Section 83
//JSONTokenType (com.adobe.serialization.json.JSONTokenType)
package com.adobe.serialization.json {
public class JSONTokenType {
public static const NUMBER:int = 11;
public static const FALSE:int = 8;
public static const RIGHT_BRACKET:int = 4;
public static const NULL:int = 9;
public static const TRUE:int = 7;
public static const RIGHT_BRACE:int = 2;
public static const UNKNOWN:int = -1;
public static const COMMA:int = 0;
public static const LEFT_BRACKET:int = 3;
public static const STRING:int = 10;
public static const LEFT_BRACE:int = 1;
public static const COLON:int = 6;
}
}//package com.adobe.serialization.json
Section 84
//IntUtil (com.adobe.utils.IntUtil)
package com.adobe.utils {
public class IntUtil {
private static var hexChars:String = "0123456789abcdef";
public static function toHex(_arg1:int, _arg2:Boolean=false):String{
var _local4:int;
var _local5:int;
var _local3 = "";
if (_arg2){
_local4 = 0;
while (_local4 < 4) {
_local3 = (_local3 + (hexChars.charAt(((_arg1 >> (((3 - _local4) * 8) + 4)) & 15)) + hexChars.charAt(((_arg1 >> ((3 - _local4) * 8)) & 15))));
_local4++;
};
} else {
_local5 = 0;
while (_local5 < 4) {
_local3 = (_local3 + (hexChars.charAt(((_arg1 >> ((_local5 * 8) + 4)) & 15)) + hexChars.charAt(((_arg1 >> (_local5 * 8)) & 15))));
_local5++;
};
};
return (_local3);
}
public static function ror(_arg1:int, _arg2:int):uint{
var _local3:int = (32 - _arg2);
return (((_arg1 << _local3) | (_arg1 >>> (32 - _local3))));
}
public static function rol(_arg1:int, _arg2:int):int{
return (((_arg1 << _arg2) | (_arg1 >>> (32 - _arg2))));
}
}
}//package com.adobe.utils
Section 85
//APIConnector (com.newgrounds.components.APIConnector)
package com.newgrounds.components {
import com.newgrounds.*;
import flash.display.*;
import flash.events.*;
import flash.net.*;
public dynamic class APIConnector extends MovieClip {
public var encryption_key:String;
public var movie_version:String;
public var movie_id:String;
private var _initialized:Boolean;
public function APIConnector(){
visible = false;
addEventListener(Event.ENTER_FRAME, onEnterFrame);
stop();
}
private function onOfficialVersionClicked(_arg1:Event):void{
navigateToURL(new URLRequest(NewgroundsAPI.getOfficialVersionURL()), "_blank");
}
private function onHostBlocked(_arg1:APIEvent):void{
gotoAndStop("bad_host");
visible = true;
}
private function forceAlwaysOnTop():void{
var _local1:uint;
var _local2:uint;
if (((parent) && (visible))){
_local1 = parent.getChildIndex(this);
_local2 = (parent.numChildren - 1);
if (((parent) && (!((_local1 == _local2))))){
parent.setChildIndex(this, _local2);
};
};
}
private function onMovieConnected(_arg1:APIEvent):void{
if (_arg1.success){
if (((NewgroundsAPI.isPublishedHost()) && (NewgroundsAPI.hasPublisher()))){
if (((!(NewgroundsAPI.hasUserSession())) && (!(NewgroundsAPI.debugMode)))){
gotoAndStop("no_login");
visible = true;
};
};
} else {
gotoAndStop("no_connect");
visible = true;
};
}
private function onNewVersionAvailable(_arg1:APIEvent):void{
gotoAndStop("new_version");
visible = true;
}
private function onEnterFrame(_arg1:Event):void{
if (!_initialized){
if (root){
if (stage){
x = (stage.stageWidth / 2);
y = (stage.stageHeight / 2);
};
NewgroundsAPI.addEventListener(APIEvent.MOVIE_CONNECTED, onMovieConnected);
NewgroundsAPI.addEventListener(APIEvent.NEW_VERSION_AVAILABLE, onNewVersionAvailable);
NewgroundsAPI.addEventListener(APIEvent.HOST_BLOCKED, onHostBlocked);
NewgroundsAPI.setMovieVersion(movie_version);
NewgroundsAPI.connectMovie(root.loaderInfo, movie_id.toString(), encryption_key);
_initialized = true;
} else {
return;
};
};
if (((this.closeButton) && (!(this.closeButton.hasEventListener(MouseEvent.CLICK))))){
this.closeButton.addEventListener(MouseEvent.CLICK, onCloseButtonClicked);
};
if (((this.viewLatestButton) && (!(this.viewLatestButton.hasEventListener(MouseEvent.CLICK))))){
this.viewLatestButton.addEventListener(MouseEvent.CLICK, onOfficialVersionClicked);
};
if (((this.viewLegalButton) && (!(this.viewLegalButton.hasEventListener(MouseEvent.CLICK))))){
this.viewLegalButton.addEventListener(MouseEvent.CLICK, onOfficialVersionClicked);
};
forceAlwaysOnTop();
}
private function onCloseButtonClicked(_arg1:Event):void{
visible = false;
}
}
}//package com.newgrounds.components
Section 86
//FlashAd (com.newgrounds.components.FlashAd)
package com.newgrounds.components {
import com.newgrounds.*;
import flash.display.*;
import flash.events.*;
public dynamic class FlashAd extends MovieClip {
public var show_background:Boolean;// = true
public function FlashAd(){
if (loaderInfo){
loaderInfo.addEventListener(Event.INIT, onInit);
} else {
onInit(null);
};
x = Math.round(x);
y = Math.round(y);
scaleX = 1;
scaleY = 1;
}
private function onAdsApproved(_arg1:APIEvent):void{
if (_arg1.success){
addChild(NewgroundsAPI.createAd());
};
NewgroundsAPI.removeEventListener(APIEvent.ADS_APPROVED, onAdsApproved, false);
}
private function onInit(_arg1:Event):void{
if (this.background){
this.background.visible = show_background;
};
if (loaderInfo){
loaderInfo.removeEventListener(Event.INIT, onInit);
};
if (NewgroundsAPI.adsApproved){
onAdsApproved(null);
} else {
NewgroundsAPI.addEventListener(APIEvent.ADS_APPROVED, onAdsApproved, false, 0, true);
};
}
}
}//package com.newgrounds.components
Section 87
//MedalPopup (com.newgrounds.components.MedalPopup)
package com.newgrounds.components {
import com.newgrounds.*;
import flash.display.*;
import flash.events.*;
import flash.text.*;
import flash.utils.*;
public dynamic class MedalPopup extends MovieClip {
private const MEDAL_POPUP_TIME:uint = 3000;
public var medalValueText:TextField;
public var medalContainer:DisplayObjectContainer;
private var _medalIcon:Bitmap;
private var _initialized:Boolean;
private var _popDelay:Timer;
public var medalNameText:TextField;
private var _medal:Medal;
private var _medalQueue:Array;
public function MedalPopup(){
_medalQueue = [];
super();
addFrameScript(0, frame1, 9, frame10);
visible = false;
addEventListener(Event.ENTER_FRAME, onEnterFrame);
stop();
}
function frame10(){
medalNameText.text = _medal.name;
medalValueText.text = (_medal.value + "pts");
showMedalIcon(medalContainer);
stop();
}
private function showMedalIcon(_arg1:DisplayObjectContainer):void{
if (!_medal){
return;
};
_medalIcon = _medal.createIconBitmap();
_arg1.addChild(_medalIcon);
}
private function initialize():void{
_initialized = true;
NewgroundsAPI.addEventListener(APIEvent.MEDAL_UNLOCKED, onMedalUnlocked);
_popDelay = new Timer(MEDAL_POPUP_TIME, 1);
_popDelay.addEventListener(TimerEvent.TIMER, onTimer);
}
private function onMedalUnlocked(_arg1:APIEvent):void{
if (((((_arg1.success) && (_arg1.data))) && ((_arg1.data is Medal)))){
_medalQueue.push(Medal(_arg1.data));
};
}
function frame1(){
visible = false;
stop();
}
private function onTimer(_arg1:TimerEvent):void{
if (((_medalIcon) && (_medalIcon.parent))){
_medalIcon.parent.removeChild(_medalIcon);
_medalIcon = null;
};
gotoAndPlay("medal_hide");
_popDelay.stop();
}
private function onEnterFrame(_arg1:Event):void{
var _local2:uint;
var _local3:uint;
if (((!(_initialized)) && (stage))){
initialize();
};
if (((_medalQueue.length) && (!(visible)))){
_medal = _medalQueue.pop();
_popDelay.start();
gotoAndPlay("medal_show");
visible = true;
};
if (((visible) && (parent))){
_local2 = parent.getChildIndex(this);
_local3 = (parent.numChildren - 1);
if (_local2 != _local3){
parent.setChildIndex(this, _local3);
};
};
}
}
}//package com.newgrounds.components
Section 88
//PreloaderBar (com.newgrounds.components.PreloaderBar)
package com.newgrounds.components {
import flash.display.*;
import flash.events.*;
public dynamic class PreloaderBar extends MovieClip {
public var bar:MovieClip;
public var autoPlay:Boolean;// = false
public var playButton:SimpleButton;
public function PreloaderBar(){
addFrameScript(51, frame52);
gotoAndStop("LOAD");
if (bar){
bar.scaleX = 0;
};
addEventListener(Event.ENTER_FRAME, onEnterFrame);
}
function frame52(){
stop();
if (playButton){
playButton.addEventListener(MouseEvent.CLICK, onPlayButtonClicked);
} else {
startMovie();
};
}
public function onPlayButtonClicked(_arg1:MouseEvent):void{
startMovie();
}
private function onEnterFrame(_arg1:Event):void{
var _local2:Number;
if (((root) && (root.loaderInfo))){
if ((root is MovieClip)){
MovieClip(root).stop();
};
_local2 = (root.loaderInfo.bytesLoaded / root.loaderInfo.bytesTotal);
if (bar){
bar.scaleX = _local2;
};
if (_local2 == 1){
removeEventListener(Event.ENTER_FRAME, onEnterFrame);
if (autoPlay){
startMovie();
} else {
gotoAndPlay("COMPLETE_STOP");
};
};
};
}
private function startMovie():void{
if (((root) && ((root is MovieClip)))){
MovieClip(root).play();
};
dispatchEvent(new Event(Event.COMPLETE));
}
}
}//package com.newgrounds.components
Section 89
//ScoreTable (com.newgrounds.components.ScoreTable)
package com.newgrounds.components {
import com.newgrounds.*;
import flash.display.*;
import flash.events.*;
public dynamic class ScoreTable extends MovieClip {
public var period:String;// = "Today"
public var board_name:String;// = "High Scores"
public var ngLinkButton:SimpleButton;
private var _board:ScoreBoard;
public function ScoreTable(){
addFrameScript(0, frame1);
clearBoard();
stop();
if (loaderInfo){
loaderInfo.addEventListener(Event.INIT, onInit);
} else {
onInit(null);
};
}
function frame1(){
ngLinkButton.addEventListener(MouseEvent.CLICK, onNGLinkClicked);
loadScores(10, period);
}
public function onScoresLoaded(_arg1:APIEvent):void{
var _local3:MovieClip;
NewgroundsAPI.removeEventListener(APIEvent.SCORES_LOADED, onScoresLoaded);
if (((!(_board)) || (!(_board.scores)))){
clearBoard();
return;
};
var _local2:uint;
while (_local2 < _board.num_results) {
_local3 = this[("score_row_" + _local2)];
if (_local3){
if (_board.scores[_local2]){
if (_local3.positionText){
_local3.positionText.text = (_board.scores[_local2].position.toString() + ":");
};
if (_local3.usernameText){
_local3.usernameText.text = _board.scores[_local2].username;
};
if (_local3.scoreText){
_local3.scoreText.text = _board.scores[_local2].value.toString();
};
} else {
if (_local3.positionText){
_local3.positionText.text = "";
};
if (_local3.usernameText){
_local3.usernameText.text = "";
};
if (_local3.scoreText){
_local3.scoreText.text = "";
};
};
};
_local2++;
};
}
private function onInit(_arg1:Event):void{
if (loaderInfo){
loaderInfo.removeEventListener(Event.INIT, onInit);
};
if (((!(board_name)) || ((board_name == "")))){
trace("No board name specified!");
};
_board = NewgroundsAPI.getScoreBoardByName(board_name);
if (!_board){
trace((("[WARNING] :: Could not initialize the scoreboard for '" + board_name) + "'."));
} else {
if (this.boardNameText){
this.boardNameText.text = _board.name;
};
if (this.period_select){
this.period_select.period = period;
};
};
}
public function onNGLinkClicked(_arg1:MouseEvent):void{
NewgroundsAPI.loadNewgrounds();
}
public function loadScores(_arg1:uint, _arg2:String):void{
if (!_board){
_board = NewgroundsAPI.getScoreBoardByName(board_name);
if (!_board){
return;
};
if (this.boardNameText){
this.boardNameText.text = _board.name;
};
};
period = _arg2;
clearBoard();
if (_board){
_board.loadScores(period, 1, _arg1);
NewgroundsAPI.addEventListener(APIEvent.SCORES_LOADED, onScoresLoaded, false, 0, true);
};
}
private function clearBoard():void{
var _local2:MovieClip;
var _local1:uint;
while (_local1 < 10) {
_local2 = this[("score_row_" + _local1)];
if (_local2){
_local2.gotoAndStop((((_local1 % 2) == 0)) ? 1 : 2);
if (_local2.positionText){
_local2.positionText.text = "";
};
if (_local2.usernameText){
_local2.usernameText.text = "";
};
if (_local2.scoreText){
_local2.scoreText.text = "";
};
};
_local1++;
};
}
}
}//package com.newgrounds.components
Section 90
//AdDisplay (com.newgrounds.AdDisplay)
package com.newgrounds {
import flash.display.*;
import flash.events.*;
import flash.net.*;
public class AdDisplay extends Sprite {
private var _adURLLoader:URLLoader;
private var _ad:Loader;
private var _mask:Shape;
private static const REMOVED_FROM_STAGE:String = "removedFromStage";
private static var _currentAdUrl:URLRequest;
private static var _adResetTime:Number = 0;
public function AdDisplay(_arg1:String){
var adFeedURL = _arg1;
super();
var adRect:Shape = new Shape();
adRect.graphics.beginFill(0);
adRect.graphics.moveTo(0, 0);
adRect.graphics.lineTo(300, 0);
adRect.graphics.lineTo(300, 250);
adRect.graphics.lineTo(0, 250);
adRect.graphics.lineTo(0, 0);
adRect.graphics.endFill();
_mask = new Shape();
_mask.graphics.beginFill(0);
_mask.graphics.moveTo(0, 0);
_mask.graphics.lineTo(300, 0);
_mask.graphics.lineTo(300, 250);
_mask.graphics.lineTo(0, 250);
_mask.graphics.lineTo(0, 0);
_mask.graphics.endFill();
addChild(adRect);
addChild(_mask);
_adURLLoader = new URLLoader();
_adURLLoader.addEventListener(Event.COMPLETE, onAdFeedLoaded);
_adURLLoader.addEventListener(IOErrorEvent.IO_ERROR, onAdError);
_adURLLoader.addEventListener(SecurityErrorEvent.SECURITY_ERROR, onAdError);
if (((adFeedURL) && (hasAdElapsed))){
if (adFeedURL.indexOf("?") > -1){
_currentAdUrl = new URLRequest(((adFeedURL + "&random=") + Math.random()));
} else {
_currentAdUrl = new URLRequest(((adFeedURL + "?random=") + Math.random()));
};
};
if (_currentAdUrl){
try {
_adURLLoader.load(_currentAdUrl);
} catch(e:Error) {
onAdError(null);
};
} else {
trace("[NewgroundsAPI] :: No ad feed URL supplied to Newgrounds API ad!");
};
if (NewgroundsAPI.isFlashVersion(9, 0, 28)){
addEventListener(REMOVED_FROM_STAGE, onRemovedFromStage);
};
}
private function onAdFeedLoaded(_arg1:Event):void{
var _local2:URLLoader = URLLoader(_arg1.target);
if (_local2.data){
loadAd(String(_local2.data));
} else {
dispatchEvent(new APIEvent(APIEvent.AD_ATTACHED, false, new APIError("FLASH_ADS_NOT_APPROVED", "Unable to render ad")));
};
}
private function onAdError(_arg1:Event):void{
dispatchEvent(new APIEvent(APIEvent.AD_ATTACHED, false, new APIError("FLASH_ADS_NOT_APPROVED", "Unable to render ad")));
removeAd();
}
private function onAdFeedError(_arg1:Event):void{
trace("[NewgroundsAPI] :: Unable to load ad feed!");
}
private function loadAd(_arg1:String):void{
if (_ad){
removeAd();
};
_ad = new Loader();
addChild(_ad);
_ad.mask = _mask;
_ad.contentLoaderInfo.addEventListener(Event.COMPLETE, onAdLoaded);
_ad.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, onAdError);
_ad.load(new URLRequest(_arg1));
}
private function onAdLoaded(_arg1:Event):void{
trace("[NewgroundsAPI] :: Ad loaded!");
dispatchEvent(new APIEvent(APIEvent.AD_ATTACHED, true));
}
public function removeAd():void{
removeEventListener(REMOVED_FROM_STAGE, onRemovedFromStage);
if (_adURLLoader){
try {
_adURLLoader.close();
} catch(e:Error) {
};
};
if (_ad){
trace("[NewgroundsAPI] :: Ad removed");
try {
_ad.close();
} catch(e:Error) {
};
try {
Object(_ad).unloadAndStop(true);
} catch(e:Error) {
_ad.unload();
};
if (_ad.parent){
_ad.parent.removeChild(_ad);
};
};
_ad = null;
}
private function onRemovedFromStage(_arg1:Event):void{
removeAd();
}
private function get hasAdElapsed():Boolean{
var _local1:Date = new Date();
if (_local1.getTime() >= _adResetTime){
_adResetTime = (_local1.getTime() + ((1000 * 60) * 5));
return (true);
};
return (false);
}
}
}//package com.newgrounds
Section 91
//APIError (com.newgrounds.APIError)
package com.newgrounds {
import flash.utils.*;
public class APIError {
public var alias:String;
public var message:String;
public var name:String;
public var code:Number;// = 0
private static const always_caps:Array = new Array("API", "URL", "ID");
public static const error_names:Object = init_names();
public static const aliases:Array = new Array("UNKNOWN_ERROR", "INVALID_API_ID", "MISSING_PARAM", "INVALID_STAT_ID", "INVALID_COMMAND_ID", "FLASH_ADS_NOT_APPROVED", "PERMISSION_DENIED", "IDENTIFICATION_REQUIRED", "INVALID_EMAIL_ADDRESS", "BANNED_USER", "SESSION_EXPIRED", "INVALID_SCORE", "INVALID_MEDAL", "INVALID_FOLDER", "FILE_NOT_FOUND", "SITE_ID_REQUIRED", "UPLOAD_IN_PROGRESS", "USER_CANCELLED", "CONFIRM_REQUEST", "CONNECTION_FAILED");
public static const error_codes:Object = init_codes();
public function APIError(_arg1, _arg2:String){
if ((_arg1 is String)){
_arg1 = error_codes[_arg1];
} else {
if (!(_arg1 is uint)){
_arg1 = 0;
};
};
trace(_arg1);
code = _arg1;
message = _arg2;
name = error_names[_arg1];
trace(name);
alias = aliases[_arg1];
}
public function isError():Boolean{
return (true);
}
private static function init_names():Array{
var _local3:Array;
var _local4:uint;
var _local5:String;
var _local1:Array = new Array();
var _local2:uint;
while (_local2 < aliases.length) {
_local3 = aliases[_local2].toLowerCase().split("_");
_local4 = 0;
while (_local4 < _local3.length) {
_local3[_local4] = (_local3[_local4].substr(0, 1).toUpperCase() + _local3[_local4].substr(1, _local3[_local4].length));
for each (_local5 in always_caps) {
if (_local3[_local4].toUpperCase() == _local5){
_local3[_local4] = _local3[_local4].toUpperCase();
};
};
_local4++;
};
_local1[_local2] = _local3.join(" ");
_local2++;
};
return (_local1);
}
public static function init_codes():Dictionary{
var _local1:Dictionary = new Dictionary();
var _local2:uint;
while (_local2 < aliases.length) {
_local1[aliases[_local2]] = _local2;
_local2++;
};
return (_local1);
}
}
}//package com.newgrounds
Section 92
//APIEvent (com.newgrounds.APIEvent)
package com.newgrounds {
import flash.events.*;
public class APIEvent extends Event {
private var _success:Boolean;
private var _target;
private var _data;
public static const AD_ATTACHED:String = "adAttached";
public static const FILE_PRIVS_LOADED:String = "filePrivsLoaded";
public static const ADS_APPROVED:String = "adsApproved";
public static const MEDALS_LOADED:String = "medalsLoaded";
public static const MEDAL_UNLOCKED:String = "medalUnlocked";
public static const METADATA_LOADED:String = "metadataLoaded";
public static const NEW_VERSION_AVAILABLE:String = "newVersionAvailable";
public static const FILE_SAVED:String = "fileSaved";
public static const EVENT_LOGGED:String = "eventLogged";
public static const SCORE_POSTED:String = "scorePosted";
public static const VOTE_COMPLETE:String = "voteComplete";
public static const FILE_LOADED:String = "fileLoaded";
public static const QUERY_COMPLETE:String = "queryComplete";
public static const SCORES_LOADED:String = "scoresLoaded";
public static const HOST_BLOCKED:String = "hostBlocked";
public static const MOVIE_CONNECTED:String = "movieConnected";
public function APIEvent(_arg1:String, _arg2:Boolean=true, _arg3=undefined){
super(_arg1);
_data = _arg3;
_success = _arg2;
}
public function get data(){
return (_data);
}
public function get success():Boolean{
return (_success);
}
}
}//package com.newgrounds
Section 93
//BaseN (com.newgrounds.BaseN)
package com.newgrounds {
import flash.utils.*;
public class BaseN {
private var _hashVal:Dictionary;
private var _hashIndex:String;
private var _base:Number;
public function BaseN(_arg1:String=null){
if (_arg1){
_hashIndex = _arg1;
} else {
_hashIndex = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ`~@#$%^&*()+|;/";
};
_base = _hashIndex.length;
_hashVal = new Dictionary();
var _local2:uint;
while (_local2 < _base) {
_hashVal[_hashIndex.charAt(_local2)] = _local2;
_local2++;
};
}
public function encode(_arg1:Number, _arg2:uint=1):String{
var _local3:String = _arg1.toString();
var _local4 = "";
if (_local3.charAt(0) == "-"){
_local4 = "-";
_local3 = _local3.substring(1);
};
var _local5:Array = _local3.split(".", 2);
_local4 = (_local4 + baseNEncoder(_local5[0], _arg2));
if (_local5.length > 1){
_local4 = (_local4 + ("." + baseNEncoder(_local5[1])));
};
return (_local4);
}
private function baseNDecoder(_arg1:String):uint{
var _local2:uint;
var _local3:uint;
while (_local3 < _arg1.length) {
_local2 = (_local2 * _base);
_local2 = (_local2 + _hashVal[_arg1.charAt(_local3)]);
_local3++;
};
return (_local2);
}
public function decode(_arg1:String):Number{
var _local2 = "";
if (_arg1.charAt(0) == "-"){
_local2 = "-";
_arg1 = _arg1.substring(1);
};
var _local3:Array = _arg1.split(".", 2);
_local2 = (_local2 + baseNDecoder(_local3[0]));
if (_local3.length > 1){
_local2 = (_local2 + ".");
_local2 = (_local2 + baseNDecoder(_local3[1]));
};
return (Number(_local2));
}
private function baseNEncoder(_arg1:uint, _arg2:uint=1):String{
var _local3 = "";
var _local4:uint = _arg1;
while (_local4 != 0) {
_local3 = (_hashIndex.charAt((_local4 % _base)) + _local3);
_local4 = (_local4 / _base);
};
if (_arg2){
while (_local3.length < _arg2) {
_local3 = (_hashIndex.charAt(0) + _local3);
};
};
return (_local3);
}
}
}//package com.newgrounds
Section 94
//Medal (com.newgrounds.Medal)
package com.newgrounds {
import flash.display.*;
import flash.events.*;
import flash.net.*;
import flash.system.*;
public class Medal {
private var _unlocked:Boolean;// = false
private var _iconLoader:Loader;
private var _difficultyId:uint;
private var _icon:BitmapData;
private var _value:uint;
private var _iconUrl:URLRequest;
private var _name:String;
private var _id:uint;
private static const DIFFICULT_NAMES:Array = [null, "Easy", "Moderate", "Challenging", "Difficult", "Brutal"];
private static const DEFAULT_ICON:BitmapData = new BitmapData(50, 50, false, 0);
public function Medal(_arg1:uint, _arg2:String, _arg3:uint, _arg4:uint, _arg5:Boolean, _arg6:String){
var id = _arg1;
var name = _arg2;
var value = _arg3;
var difficulty = _arg4;
var unlocked = _arg5;
var iconUrl = _arg6;
_icon = DEFAULT_ICON;
super();
_id = id;
_name = name;
_value = value;
_difficultyId = difficulty;
_unlocked = unlocked;
if (iconUrl){
_iconUrl = new URLRequest(iconUrl);
_iconLoader = new Loader();
_iconLoader.contentLoaderInfo.addEventListener(Event.INIT, onIconLoaderInit);
_iconLoader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, onIconLoaderError);
_iconLoader.contentLoaderInfo.addEventListener(SecurityErrorEvent.SECURITY_ERROR, onIconLoaderError);
_iconLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onIconLoaderComplete);
try {
_iconLoader.load(_iconUrl, new LoaderContext(true));
} catch(e:Error) {
onIconLoaderError(null);
};
};
}
public function get icon():BitmapData{
return (_icon);
}
public function set unlocked(_arg1:Boolean):void{
_unlocked = _arg1;
}
public function get bytesLoaded():uint{
return ((_iconLoader) ? _iconLoader.contentLoaderInfo.bytesLoaded : 0);
}
public function get name():String{
return (_name);
}
private function onIconLoaderComplete(_arg1:Event):void{
trace((((("[NewgroundsAPI] :: Successfully loaded medal icon for " + name) + " (") + _iconUrl.url.split("/").pop()) + ")"));
var _local2:Bitmap = (_iconLoader.content as Bitmap);
_icon = _local2.bitmapData;
_iconLoader.unload();
_iconLoader = null;
}
public function get bytesTotal():uint{
return ((_iconLoader) ? _iconLoader.contentLoaderInfo.bytesTotal : 0);
}
public function get id():uint{
return (_id);
}
public function unlock():void{
if (!_unlocked){
NewgroundsAPI.unlockMedal(this);
};
}
private function onIconLoaderError(_arg1:IOErrorEvent):void{
trace((((("[NewgroundsAPI WARNING] :: Failed to load medal icon for " + name) + " (") + _iconUrl.url.split("/").pop()) + ")"));
_iconLoader.unload();
_iconLoader = null;
}
private function onIconLoaderInit(_arg1:Event):void{
trace((((("[NewgroundsAPI] :: Loading medal icon for " + name) + " (") + _iconUrl.url.split("/").pop()) + ")"));
}
public function get unlocked():Boolean{
return (_unlocked);
}
public function createIconBitmap():Bitmap{
return (new Bitmap(icon));
}
public function toString():String{
return (_name);
}
public function get value():uint{
return (_value);
}
public function get difficultyId():uint{
return (_difficultyId);
}
public function get difficulty():String{
return (DIFFICULT_NAMES[_difficultyId]);
}
public static function createFromObject(_arg1:Object):Medal{
return (new Medal(_arg1.medal_id, _arg1.medal_name, _arg1.medal_value, _arg1.medal_difficulty, _arg1.medal_unlocked, _arg1.medal_icon));
}
}
}//package com.newgrounds
Section 95
//NewgroundsAPI (com.newgrounds.NewgroundsAPI)
package com.newgrounds {
import flash.display.*;
import flash.events.*;
import flash.utils.*;
import com.adobe.serialization.json.*;
import flash.net.*;
import com.adobe.crypto.*;
import com.adobe.images.*;
import flash.system.*;
public class NewgroundsAPI {
private static const COMMANDS_WIKI_URL:String = "http://www.newgrounds.com/wiki/flashapi/commands/";
private static const AD_TERMS_URL:String = "http://www.newgrounds.com/wiki/flashads/terms/";
private static const GATEWAY_URL:String = "http://www.ngads.com/gateway_v2.php";
private static var connected:Boolean;
private static var user_id:uint;
private static var _initialized:Boolean = false;
private static var user_email:String;
private static var _saveFilePath:String;
private static var publisher_id:uint;
private static var debug:Boolean;
private static var do_echo:Boolean = false;
private static var ad_url:String;
private static var _saveGroups:Array = [];
private static var session_id:String;
public static var errors:Dictionary = APIError.init_codes();
private static var timeoutTimer:Timer = new Timer(8000, 1);
private static var _medals:Array;
private static var user_name:String;
private static var period_aliases:Object = {t:{name:"Today", alias:"TODAY"}, p:{name:"Yesterday", alias:"YESTERDAY"}, w:{name:"This Week", alias:"THIS_WEEK"}, m:{name:"This Month", alias:"THIS_MONTH"}, y:{name:"This Year", alias:"THIS_YEAR"}, a:{name:"All-Time", alias:"ALL_TIME"}};
private static var tracker_id:uint;
private static var movie_id:String;
private static var _scoreboards:Array = new Array();
private static var _eventDispatcher:EventDispatcher = new EventDispatcher();
private static var encryption_key:String;
private static var host:String;
private static var compressor:BaseN = new BaseN(compression_radix);
private static var score_page_counts:Object = new Object();
private static var _adsApproved:Boolean = false;
private static var _preload:Boolean = true;
private static var version:String;
public static var periods:Object = getPeriodAliases();
private static var root:DisplayObject;
private static var _inSaveQuery:Boolean;
private static var compression_radix:String = "/g8236klvBQ#&|;Zb*7CEA59%s`Oue1wziFp$rDVY@TKxUPWytSaGHJ>dmoMR^<0~4qNLhc(I+fjn)X";
private static var _preloadAssets:Array = [];
private static var sharedObjects:Object = new Object();
private static var _saveFile:SaveFile;
public static function setMovieVersion(_arg1:String):void{
if (((_arg1) && (!((_arg1 == ""))))){
version = _arg1;
};
}
public static function get preload():Boolean{
return (_preload);
}
public static function unlockMedal(_arg1:Medal, _arg2:Boolean=false):void{
var _local3:Object;
var _local4:Object;
if (!_arg1){
sendError({command_id:getCommandID("unlockMedal")}, new APIError("MISSING_PARAM", "missing required medal name"));
return;
};
if (((hasUserSession()) || (debugMode))){
sendMessage((("Attempting to unlock '" + _arg1.name) + "'"));
if (_arg1.unlocked){
sendWarning((("Medal '" + _arg1.name) + "' is already unlocked!"));
return;
};
_local3 = new Object();
_local3.medal_id = _arg1.id;
if (_arg2){
_local3.get_score = _arg2;
};
sendSecureCommand("unlockMedal", _local3);
} else {
sendMessage(("Locally unlocking " + _arg1.name));
if (_arg1.unlocked){
sendWarning((("Medal '" + _arg1.name) + "' is already unlocked!"));
return;
};
_arg1.unlocked = true;
_local4 = loadLocal("medals_unlocked");
if (!_local4){
_local4 = new Object();
};
_local4[_arg1.id.toString()] = true;
saveLocal("medals_unlocked", _local4);
callListener(APIEvent.MEDAL_UNLOCKED, true, _arg1);
};
}
public static function set preload(_arg1:Boolean):void{
_preload = _arg1;
}
private static function getHost():String{
return (host);
}
private static function uncompressHex(_arg1:String):String{
var _local4:uint;
var _local6:String;
var _local7:uint;
var _local8:String;
var _local2:uint = uint(_arg1.charAt(0));
var _local3 = "";
var _local5:uint = 1;
while (_local5 < _arg1.length) {
_local6 = _arg1.substr(_local5, 4);
_local7 = uint(compressor.decode(_local6));
_local8 = _local7.toString(16);
if ((_local5 + 4) < _arg1.length){
_local4 = 6;
} else {
_local4 = _local2;
};
while (_local8.length < _local4) {
_local8 = ("0" + _local8);
};
_local3 = (_local3 + _local8);
_local5 = (_local5 + 4);
};
return (_local3);
}
public static function isFlashVersion(_arg1:uint, _arg2:uint=0, _arg3:uint=0, _arg4:uint=0):Boolean{
var _local6:Array = Capabilities.version.split(" ")[1].split(",");
var _local7:Array = arguments;
var _local8:uint;
while (_local8 < _local7.length) {
_local6[_local8] = uint(_local6[_local8]);
_local8++;
};
_local8 = 0;
while (_local8 < _local7.length) {
if (_local6[_local8] > _local7[_local8]){
return (true);
};
if (_local6[_local8] < _local7[_local8]){
return (false);
};
_local8++;
};
return (true);
}
public static function getMedalByName(_arg1:String):Medal{
var _local2:Medal;
for each (_local2 in _medals) {
if (_local2.name == _arg1){
return (_local2);
};
};
return (null);
}
public static function hasUserEmail():Boolean{
return (((!((user_email == null))) && (!((user_email == "")))));
}
public static function loadLocal(_arg1:String){
var sharedObj:SharedObject;
var save_id = _arg1;
try {
if (!sharedObjects[save_id]){
sharedObjects[save_id] = SharedObject.getLocal(((("ng_ap_secure_" + movie_id) + "_") + save_id));
};
sharedObj = sharedObjects[save_id];
if (((((sharedObj) && (sharedObj.data))) && (sharedObj.data[save_id]))){
return (decodeData(sharedObj.data[save_id]));
} else {
return (null);
};
} catch(e:Error) {
sendWarning(("loadLocal ERROR: " + e));
return (null);
};
}
private static function callListener(_arg1:String, _arg2:Boolean=true, _arg3=undefined):void{
dispatchEvent(new APIEvent(_arg1, _arg2, _arg3));
}
public static function sendSecureCommand(_arg1:String, _arg2:Object, _arg3:Object=null, _arg4:Object=null, _arg5=null):void{
if (((((!(debug)) && (!(hasUserSession())))) && (!(hasUserEmail())))){
sendError({command_id:getCommandID(_arg1)}, new APIError("IDENTIFICATION_REQUIRED", (("You must be logged in or provide an e-mail address ( using NewgroundsAPI.setUserEmail(\"name@domain.com\"); ) to use " + _arg1) + "().")));
return;
};
if (!_arg1){
fatalError("Missing command", "sendSecureCommand");
};
if (!_arg2){
fatalError("Missing secure_params", "sendSecureCommand");
};
if (!_arg3){
_arg3 = new Object();
};
var _local6 = "";
var _local7:uint;
while (_local7 < 16) {
_local6 = (_local6 + compression_radix.charAt(Math.floor((Math.random() * compression_radix.length))));
_local7++;
};
if (((debug) && (!(session_id)))){
_arg2.session_id = "";
} else {
_arg2.session_id = session_id;
};
_arg2.as_version = 3;
_arg2.user_email = user_email;
_arg2.publisher_id = publisher_id;
_arg2.seed = _local6;
_arg2.command_id = getCommandID(_arg1);
var _local8:String = MD5.hash(_local6);
var _local9:String = RC4.encrypt(JSON.encode(_arg2), encryption_key);
var _local10:String = (_local8 + _local9);
_arg3.secure = compressHex(_local10);
sendCommand("securePacket", _arg3, false, _arg4, _arg5);
}
private static function echo(_arg1:String):void{
if (do_echo){
trace(_arg1);
};
}
private static function populateScoreBoards(_arg1:Array):void{
_scoreboards = [];
var _local2:uint;
while (_local2 < _arg1.length) {
_scoreboards.push(new ScoreBoard(_arg1[_local2].id, _arg1[_local2].name));
_local2++;
};
}
private static function populateSaveGroups(_arg1:Array):void{
var _local3:SaveGroup;
_saveGroups = [];
var _local2:uint;
while (_local2 < _arg1.length) {
_local3 = SaveGroup.createFromObject(_arg1[_local2]);
_saveGroups.push(_local3);
_local2++;
};
}
public static function createAd():AdDisplay{
sendMessage("You may see a security sandbox violation. This is normal!");
return (new AdDisplay(ad_url));
}
public static function getSaveGroupById(_arg1:uint):SaveGroup{
if (((!(_saveGroups)) || ((_saveGroups.length < 1)))){
sendWarning("No save groups found");
return (null);
};
var _local2:uint;
while (_local2 < _saveGroups.length) {
if (_saveGroups[_local2].id == _arg1){
return (_saveGroups[_local2]);
};
_local2++;
};
return (null);
}
private static function dispatchEvent(_arg1:Event):void{
_eventDispatcher.dispatchEvent(_arg1);
echo(("Fired Event: " + _arg1.type));
}
public static function removeEventListener(_arg1:String, _arg2:Function, _arg3:Boolean=false):void{
_eventDispatcher.removeEventListener(_arg1, _arg2, _arg3);
}
public static function addEventListener(_arg1:String, _arg2:Function, _arg3:Boolean=false, _arg4:uint=0, _arg5:Boolean=false):void{
_eventDispatcher.addEventListener(_arg1, _arg2, _arg3, _arg4, _arg5);
}
private static function getPeriodAliases():Object{
var _local2:String;
var _local1:Object = new Object();
for (_local2 in period_aliases) {
_local1[period_aliases[_local2].alias] = _local2;
};
return (_local1);
}
public static function setUserEmail(_arg1:String):void{
user_email = _arg1;
}
public static function hasUserSession():Boolean{
return (((((!((session_id == null))) && (!((session_id == ""))))) && (!((publisher_id == 0)))));
}
public static function executeSaveQuery(_arg1:SaveGroupQuery):void{
sendCommand("lookupSaveFiles", {publisher_id:publisher_id, group_id:_arg1.groupId, query:JSON.encode(_arg1.toObject())}, false, null, _arg1);
trace(JSON.encode(_arg1.toObject()));
}
private static function getCommandName(_arg1:String):String{
return (_arg1);
}
public static function getScoreBoardById(_arg1:uint):ScoreBoard{
var _local2:ScoreBoard;
for each (_local2 in _scoreboards) {
if (_local2.id == _arg1){
return (_local2);
};
};
return (null);
}
private static function compressHex(_arg1:String):String{
var _local2:uint = (_arg1.length % 6);
var _local3 = "";
var _local4:uint;
while (_local4 < _arg1.length) {
_local3 = (_local3 + compressor.encode(uint(("0x" + _arg1.substr(_local4, 6))), 4));
_local4 = (_local4 + 6);
};
return ((_local2.toString() + _local3));
}
public static function get medals():Array{
return ((_medals) ? _medals.concat() : []);
}
public static function connectMovie(_arg1:LoaderInfo, _arg2:String, _arg3:String):void{
if (!_arg1){
fatalError("Null loaderInfo paremeter passed in to connectMovie!", "");
return;
};
host = _arg1.url;
if ((((host.indexOf("http://") > -1)) || ((host.indexOf("https://") > -1)))){
host = host.split("/")[2].toLowerCase();
} else {
host = "localhost";
};
var _local4:Object = _arg1.parameters;
debug = !(isPublishedHost());
if (((!(debug)) && (_local4))){
if (_local4.NewgroundsAPI_UserName){
user_name = _local4.NewgroundsAPI_UserName;
};
if (_local4.NewgroundsAPI_UserID){
user_id = _local4.NewgroundsAPI_UserID;
};
if (_local4.NewgroundsAPI_PublisherID){
publisher_id = _local4.NewgroundsAPI_PublisherID;
};
if (_local4.NewgroundsAPI_SessionID){
session_id = _local4.NewgroundsAPI_SessionID;
};
} else {
publisher_id = 1;
session_id = "D3bu64p1U53R";
user_id = 10;
user_name = "API-Debugger";
};
if (connected){
return;
};
timeoutTimer.start();
if (!_arg2){
fatalError("NewgroundsAPI.connectMovie() - missing required movie_id parameter", "connectMovie");
};
movie_id = String(_arg2);
tracker_id = uint(movie_id.substring(0, movie_id.indexOf(":")));
encryption_key = _arg3;
connected = true;
sendCommand("connectMovie", {host:getHost(), movie_version:version});
}
private static function sendError(_arg1:Object, _arg2:APIError):void{
trace(((((("[NewgroundsAPI ERROR] :: " + getCommandName(_arg1.command_id)) + "() - ") + _arg2.name) + ":\n\t\t\t\t") + _arg2.message));
}
public static function sendMessage(_arg1:String, _arg2:Boolean=false):void{
var _local3:String = ("[NewgroundsAPI] :: " + _arg1);
trace(_local3);
}
public static function newSaveFile(_arg1:String):SaveFile{
var _local2:SaveGroup = getSaveGroupByName(_arg1);
if (_local2){
return (new SaveFile(_local2));
};
sendError({command_id:"newSaveFile"}, new APIError("INVALID_SAVE_GROUP", (("'" + _local2) + "' is not a valid save group.")));
return (null);
}
public static function get bytesLoaded():uint{
var _local2:*;
var _local1:uint = root.loaderInfo.bytesLoaded;
if (_preload){
for each (_local2 in _preloadAssets) {
_local1 = (_local1 + _local2.bytesLoaded);
};
};
return (_local1);
}
public static function unlockMedalByName(_arg1:String, _arg2:Boolean=false):void{
var _local3:Medal = getMedalByName(_arg1);
if (_local3){
unlockMedal(_local3, _arg2);
};
}
static function reportAssetFailed(_arg1):void{
var _local2:uint;
while (_local2 < _preloadAssets.length) {
if (_arg1 == _preloadAssets[_local2]){
_preloadAssets.splice(_local2, 1);
return;
};
_local2++;
};
}
public static function connectionTimeOut(_arg1:Event=null):void{
dispatchEvent(new APIEvent(APIEvent.MOVIE_CONNECTED, false, new APIError("CONNECTION_FAILED", "Connection to NewgroundsAPI gateway timed out.")));
}
static function reportNewAsset(_arg1):void{
_preloadAssets.push(_arg1);
}
public static function unlockMedalById(_arg1:uint, _arg2:Boolean=false):void{
var _local3:Medal = getMedalById(_arg1);
if (_local3){
unlockMedal(_local3, _arg2);
};
}
private static function fatalError(_arg1:String, _arg2:String):void{
if (_arg2){
_arg1 = (_arg1 + ((("\n\tSee " + COMMANDS_WIKI_URL) + _arg2.toLowerCase()) + " for additional information."));
};
throw (new Error(("***ERROR*** class=NewgroundsAPI\n\n" + _arg1)));
}
public static function get adsApproved():Boolean{
return (_adsApproved);
}
public static function hasPublisher():Boolean{
return (!((publisher_id == 0)));
}
public static function getScoreBoardByName(_arg1:String):ScoreBoard{
var _local2:ScoreBoard;
for each (_local2 in _scoreboards) {
if (_local2.name == _arg1){
return (_local2);
};
};
return (null);
}
private static function sendNotice(_arg1:String, _arg2:String=null):void{
if (_arg2){
_arg1 = (_arg1 + ((("\n[NewgroundsAPI NOTICE] :: \tSee " + COMMANDS_WIKI_URL) + _arg2.toLowerCase()) + " for additional information."));
};
trace(("[NewgroundsAPI NOTICE] :: " + _arg1));
}
public static function get debugMode():Boolean{
return (debug);
}
public static function loadCustomLink(_arg1:String):void{
sendCommand("loadCustomLink", {host:getHost(), link:_arg1}, true);
}
public static function get bytesTotal():uint{
var _local2:*;
var _local1:uint = root.loaderInfo.bytesTotal;
if (_preload){
for each (_local2 in _preloadAssets) {
_local1 = (_local1 + Math.max(_local2.bytesTotal, 1));
};
};
return (_local1);
}
public static function checkFilePrivledges(_arg1:SaveFile):void{
sendCommand("checkFilePrivs", {group:_arg1.groupId, filename:_arg1.name, user_id:(user_id) ? user_id : 0, publisher_id:publisher_id});
}
public static function get percentLoaded():Number{
return ((bytesLoaded / bytesTotal));
}
public static function isPublishedHost():Boolean{
return (((!((getHost() == "localhost"))) && ((getHost().indexOf("file://") == -1))));
}
private static function assertInitialized():Boolean{
if (!_initialized){
return (false);
};
return (true);
}
public static function createSaveQuery(_arg1:String):SaveGroupQuery{
var _local2:SaveGroup = getSaveGroupByName(_arg1);
if (_local2){
return (_local2.createQuery());
};
return (null);
}
public static function loadMySite():void{
sendCommand("loadMySite", {host:getHost()});
}
public static function getMedalById(_arg1:uint):Medal{
var _local2:Medal;
for each (_local2 in _medals) {
if (_local2.id == _arg1){
return (_local2);
};
};
return (null);
}
public static function getOfficialVersionURL():String{
var _local1:String = ((((((GATEWAY_URL + "?tracker_id=") + movie_id) + "&command_id=") + getCommandID("loadOfficalVersion")) + "&seed=") + Math.random());
if (debug){
_local1 = (_local1 + "&debug=1");
};
return (_local1);
}
public static function loadNewgrounds():void{
sendCommand("loadNewgrounds", {host:getHost()}, true);
}
public static function saveFile(_arg1:SaveFile, _arg2:Boolean=false):void{
var _local3:Object = _arg1.toObject();
_local3.user_name = user_name;
_local3.overwrite = (_arg2) ? 1 : 0;
var _local4:ByteArray = new ByteArray();
if ((_arg1.contents is ByteArray)){
_local4.writeByte(0);
_local4.writeBytes(_arg1.contents);
} else {
_local4.writeByte(1);
_local4.writeObject(_arg1.contents);
};
_local4.compress();
var _local5:Object = new Object();
_local5.file = _local4;
if (_arg1.thumbnail){
_local5.thumbnail = PNGEncoder.encode(_arg1.thumbnail);
};
sendSecureCommand("saveFile", _local3, null, _local5, _arg1);
}
public static function loadScores(_arg1:ScoreBoard):void{
var _local2 = "loadScores";
if (!_arg1.id){
sendError({command_id:getCommandID(_local2)}, new APIError("MISSING_PARAM", "missing required ScoreBoard instance"));
return;
};
if (!hasUserSession()){
callListener(APIEvent.SCORES_LOADED, false, new APIError("SITE_ID_REQUIRED", (("Host '" + getHost()) + "' does not have high scores enabled")));
return;
};
var _local3:Object = {};
_local3.publisher_id = publisher_id;
_local3.period = _arg1.period;
_local3.board = _arg1.id;
_local3.num_results = _arg1.num_results;
_local3.page = _arg1.page;
sendCommand(_local2, _local3);
}
public static function rateSaveFile(_arg1:SaveFile, _arg2:SaveRating, _arg3:Number):void{
sendSecureCommand("rateSaveFile", {group:_arg1.groupId, save_id:_arg1.id, rating_id:_arg2.id, vote:_arg3, user_id:user_id}, null, null, _arg1);
}
public static function logCustomEvent(_arg1:String):void{
sendCommand("logCustomEvent", {host:getHost(), event:_arg1});
}
public static function decodeData(_arg1:String){
return (JSON.decode(RC4.decrypt(uncompressHex(_arg1), encryption_key)));
}
public static function postScore(_arg1:String, _arg2:Number, _arg3:Boolean=false):void{
if (((((!(_arg1)) || ((_arg1 == "")))) || (isNaN(_arg2)))){
sendError({command_id:getCommandID("postScore")}, new APIError("MISSING_PARAM", "missing required parameter(s)"));
return;
};
sendSecureCommand("postScore", {user_name:user_name, board:_arg1, value:_arg2, get_best:_arg3, publisher_id:publisher_id});
}
private static function onCommandComplete(_arg1:Event):void{
var _local4:Object;
var _local5:APIError;
var _local2:SmartURLLoader = SmartURLLoader(_arg1.target);
echo((("INPUT: \n" + _local2.response) + "\n"));
var _local3:uint;
while (_local3 < _preloadAssets.length) {
if (_preloadAssets[_local3] == _local2){
_preloadAssets.splice(_local3, 1);
break;
};
_local3++;
};
if (_local2.response){
_local4 = JSON.decode(_local2.response);
} else {
_local4 = {success:false};
};
if (!_local4.success){
_local5 = new APIError(_local4.error_code, _local4.error_msg);
sendError(_local4, _local5);
} else {
_local4.owner = _local2.owner;
doEvent(_local4);
};
}
private static function sendCommand(_arg1:String, _arg2:Object, _arg3:Boolean=false, _arg4:Object=null, _arg5=null):void{
var _local7:String;
var _local8:String;
var _local9:String;
if (((!(connected)) && (!((_arg1 == "connectMovie"))))){
_local7 = (("NewgroundsAPI." + _arg1) + "() - NewgroundsAPI.connectMovie() must be called before this command can be called\n");
fatalError(_local7, "connectMovie");
};
var _local6:SmartURLLoader = new SmartURLLoader();
_local6.addVariable("command_id", getCommandID(_arg1));
_local6.addVariable("tracker_id", movie_id);
if (debug){
_local6.addVariable("debug", 1);
};
if ((((_arg1 == "connectMovie")) && (preload))){
_local6.addVariable("preload", 1);
};
if (_arg2){
for (_local8 in _arg2) {
_local6.addVariable(_local8, _arg2[_local8]);
};
};
if (_arg4){
for (_local9 in _arg4) {
_local6.addFile(_local9, _arg4[_local9], _local9);
};
};
if (_arg3){
_local6.method = URLRequestMethod.GET;
} else {
_local6.method = URLRequestMethod.POST;
};
_local6.preventCache = true;
if (_arg3){
_local6.openBrowser = true;
_local6.method = URLRequestMethod.GET;
} else {
_local6.addEventListener(Event.COMPLETE, onCommandComplete);
_local6.addEventListener(IOErrorEvent.IO_ERROR, onCommandError);
_local6.addEventListener(SecurityErrorEvent.SECURITY_ERROR, onCommandError);
_local6.method = URLRequestMethod.POST;
};
_local6.owner = _arg5;
_local6.load(GATEWAY_URL);
}
public static function encodeData(_arg1:Object):String{
return (compressHex(RC4.encrypt(JSON.encode(_arg1), encryption_key)));
}
private static function populateMedals(_arg1:Array):void{
var _local2:uint;
var _local3:Object;
if (_medals === null){
_medals = new Array();
_local2 = 0;
while (_local2 < _arg1.length) {
_local3 = _arg1[_local2];
_medals.push(Medal.createFromObject(_local3));
_local2++;
};
};
}
public static function getPeriodAlias(_arg1:String):String{
var _local2:String;
for (_local2 in period_aliases) {
if (_local2 == _arg1){
return (period_aliases[_local2].alias);
};
};
return (null);
}
public static function loadMedals():void{
if (_medals){
dispatchEvent(new APIEvent(APIEvent.MEDALS_LOADED, true, medals));
return;
};
var _local1:Object = new Object();
if (hasUserSession()){
_local1.publisher_id = publisher_id;
_local1.user_id = user_id;
};
sendCommand("getMedals", _local1);
}
public static function saveLocal(_arg1:String, _arg2:Object, _arg3:uint=0):void{
var sharedObj:SharedObject;
var save_id = _arg1;
var save_data = _arg2;
var size_allocation = _arg3;
try {
if (!sharedObjects[save_id]){
sharedObjects[save_id] = SharedObject.getLocal(((("ng_ap_secure_" + movie_id) + "_") + save_id));
};
sharedObj = sharedObjects[save_id];
sharedObj.data[save_id] = encodeData(save_data);
sharedObj.flush();
} catch(e:Error) {
sendWarning(("saveLocal ERROR: " + e));
};
}
private static function doEvent(_arg1:Object):void{
var _local2:String;
var _local3:Object;
var _local4:String;
var _local5:Boolean;
var _local6:ScoreBoard;
var _local7:Array;
var _local8:*;
var _local9:String;
var _local10:Medal;
var _local11:uint;
var _local12:Object;
var _local13:SaveFile;
var _local14:uint;
switch (getCommandName(_arg1.command_id)){
case "connectMovie":
timeoutTimer.stop();
sendMessage("You have successfully connected to the Newgrounds API Gateway");
sendMessage((("Movie identified as \"" + _arg1.movie_name) + "\""));
callListener(APIEvent.MOVIE_CONNECTED, _arg1.success, {movie_name:_arg1.movie_name});
_local5 = false;
if (_arg1.ad_status === -1){
_local2 = "This movie was not approved to run Flash Ads.";
sendWarning(_local2);
sendWarning((("visit " + AD_TERMS_URL) + " to view our approval guidelines"));
if (!_arg1.ad_url){
callListener(APIEvent.ADS_APPROVED, false, new APIError("FLASH_ADS_NOT_APPROVED", _local2));
} else {
_local5 = true;
};
} else {
if (_arg1.ad_status === 0){
_local2 = "Flash Ads are currently awaiting approval.";
sendNotice(_local2);
if (!_arg1.ad_url){
callListener(APIEvent.ADS_APPROVED, false, new APIError("FLASH_ADS_NOT_APPROVED", _local2));
} else {
_local5 = true;
};
};
};
if (_arg1.ad_url){
ad_url = unescape(_arg1.ad_url);
if (!_local5){
sendMessage("This movie has been approved to run Flash Ads!");
};
callListener(APIEvent.ADS_APPROVED, true);
_adsApproved = true;
};
if (_arg1.deny_host){
_local2 = (getHost() + " does not have permission to run this movie!");
sendWarning(_local2);
sendWarning(("\tUpdate your API configuration to unblock " + getHost()));
callListener(APIEvent.HOST_BLOCKED, true, {movie_url:unescape(_arg1.movie_url), redirect_url:getOfficialVersionURL()});
};
if (_arg1.movie_version){
sendWarning("According to your API Configuration, this version is out of date.");
if (version){
sendWarning(("\tThe this movie is version " + version));
};
sendWarning(("\tThe most current version is " + _arg1.movie_version));
callListener(APIEvent.NEW_VERSION_AVAILABLE, true, {movie_version:_arg1.movie_version, movie_url:unescape(_arg1.movie_url), redirect_url:getOfficialVersionURL()});
};
if (_arg1.request_portal_url){
sendCommand("setPortalID", {portal_url:host});
};
if (preload){
sendCommand("preloadSettings", {publisher_id:publisher_id, user_id:user_id});
};
break;
case "preloadSettings":
if (_arg1.medals){
populateMedals(_arg1.medals);
if (((!(hasUserSession())) && (!(debugMode)))){
echo("Checking for SharedObject Medals...");
_local8 = loadLocal("medals_unlocked");
if (_local8){
for (_local9 in _local8) {
if (_local8[_local9]){
_local10 = getMedalById(uint(_local9));
echo(("Now unlocking " + _local10.name));
_local10.unlocked = true;
};
};
};
};
};
if (_arg1.save_groups){
populateSaveGroups(_arg1.save_groups);
};
if (_arg1.save_file_path){
_saveFilePath = (_arg1.save_file_path + "/");
};
if (_arg1.score_boards){
populateScoreBoards(_arg1.score_boards);
};
callListener(APIEvent.METADATA_LOADED);
break;
case "logCustomEvent":
if (_arg1.success){
sendMessage((("Event '" + _arg1.event) + "' was logged."));
};
callListener(APIEvent.EVENT_LOGGED, _arg1.success, {event:_arg1.event});
break;
case "postScore":
if (_arg1.success){
_local4 = "User";
if (user_email){
_local4 = user_email;
} else {
if (user_name){
_local4 = user_name;
};
};
sendMessage((((((_local4 + " posted ") + _arg1.value) + " to '") + _arg1.score) + "'"));
_local3 = {score:_arg1.score, value:_arg1.value, username:_local4};
};
callListener(APIEvent.SCORE_POSTED, _arg1.success, _local3);
break;
case "loadScores":
_local3 = new Object();
_local6 = getScoreBoardById(_arg1.board);
if (_local6){
_local6.setScores(_arg1.scores, _arg1.period, _arg1.page, _arg1.num_results);
};
callListener(APIEvent.SCORES_LOADED, _arg1.success, _local6);
break;
case "unlockMedal":
if (_medals){
_local10 = getMedalByName(_arg1.medal_name);
_local10.unlocked = true;
};
callListener(APIEvent.MEDAL_UNLOCKED, _arg1.success, _local10);
break;
case "getMedals":
populateMedals(_arg1.medals);
callListener(APIEvent.MEDALS_LOADED, _arg1.success, _local3);
break;
case "lookupSaveFiles":
_local7 = [];
_local11 = 0;
while (_local11 < _arg1.files.length) {
_local12 = _arg1.files[_local11];
_local13 = new SaveFile(getSaveGroupById(_arg1.group_id));
_local13.name = _local12.filename;
_local13.id = _local12.save_id;
_local13.description = _local12.description;
_local13.thumbnailUrl = _local12.thumb;
_local13.fileUrl = (_saveFilePath + _local12.file);
if (((_local12.keys) && (_local12.keys.length))){
_local14 = 0;
while (_local14 < _local12.keys.length) {
_local13.setKey(_local12.keys[_local14].id, _local12.keys[_local14].value);
_local14++;
};
};
if (((_local12.ratings) && (_local12.ratings.length))){
_local14 = 0;
while (_local14 < _local12.ratings.length) {
_local13.setRating(_local12.ratings[_local14].id, _local12.ratings[_local14].votes, _local12.ratings[_local14].score);
_local14++;
};
};
_local7.push(_local13);
_local11++;
};
_arg1.owner.dispatchEvent(new APIEvent(APIEvent.QUERY_COMPLETE, _arg1.success, _local7));
break;
case "rateSaveFile":
_local13 = _arg1.owner;
if (_arg1.success){
_local13.setRating(_arg1.rating_id, _arg1.votes, _arg1.score);
};
_local13.dispatchEvent(new APIEvent(APIEvent.VOTE_COMPLETE, _arg1.success, _arg1));
break;
case "saveFile":
_local3 = {save_id:_arg1.save_id, filename:_arg1.filename, file_url:_arg1.file_url, thumbnail:_arg1.thumbnail, icon:_arg1.icon};
_arg1.owner.dispatchEvent(new APIEvent(APIEvent.FILE_SAVED, _arg1.success, _local3));
break;
case "checkFilePrivs":
_local3 = {filename:_arg1.filename, folder:_arg1.folder, can_read:_arg1.can_read, can_write:_arg1.can_write};
callListener(APIEvent.FILE_PRIVS_LOADED, _arg1.success, _local3);
break;
};
}
public static function hasEventListener(_arg1:String):Boolean{
return (_eventDispatcher.hasEventListener(_arg1));
}
public static function getSaveGroupByName(_arg1:String):SaveGroup{
if (((!(_saveGroups)) || ((_saveGroups.length < 1)))){
sendWarning("No save groups found");
return (null);
};
var _local2:uint;
while (_local2 < _saveGroups.length) {
if (_saveGroups[_local2].name == _arg1){
return (_saveGroups[_local2]);
};
_local2++;
};
return (null);
}
public static function isNewgrounds():Boolean{
return ((((publisher_id == 1)) || ((getHost().toLowerCase().indexOf("ungrounded.net") > -1))));
}
private static function getCommandID(_arg1:String):String{
return (_arg1);
}
public static function getPeriodName(_arg1:String):String{
var _local2:String;
for (_local2 in period_aliases) {
if (_local2 == _arg1){
return (period_aliases[_local2].name);
};
};
return (null);
}
private static function sendWarning(_arg1:String, _arg2:String=null):void{
if (_arg2){
_arg1 = (_arg1 + ((("\n[NewgroundsAPI WARNING] :: \tSee " + COMMANDS_WIKI_URL) + _arg2.toLowerCase()) + " for additional information."));
};
trace(("[NewgroundsAPI WARNING] :: " + _arg1));
}
private static function onCommandError(_arg1:Event):void{
var _local2:SmartURLLoader = SmartURLLoader(_arg1.target);
var _local3:uint;
while (_local3 < _preloadAssets.length) {
if (_preloadAssets[_local3] == _local2){
_preloadAssets.splice(_local3, 1);
break;
};
_local3++;
};
}
}
}//package com.newgrounds
Section 96
//RC4 (com.newgrounds.RC4)
package com.newgrounds {
public class RC4 {
private static var mykey:Array = new Array(0xFF);
private static var sbox:Array = new Array(0xFF);
private static function charsToHex(_arg1:Array):String{
var _local2:String = new String("");
var _local3:Array = new Array("0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f");
var _local4:uint;
while (_local4 < _arg1.length) {
_local2 = (_local2 + (_local3[(_arg1[_local4] >> 4)] + _local3[(_arg1[_local4] & 15)]));
_local4++;
};
return (_local2);
}
public static function encrypt(_arg1:String, _arg2:String):String{
var _local3:Array = strToChars(_arg1);
var _local4:Array = strToChars(_arg2);
var _local5:Array = calculate(_local3, _local4);
return (charsToHex(_local5));
}
private static function hexToChars(_arg1:String):Array{
var _local2:Array = new Array();
var _local3:uint = ((_arg1.substr(0, 2))=="0x") ? 2 : 0;
while (_local3 < _arg1.length) {
_local2.push(parseInt(_arg1.substr(_local3, 2), 16));
_local3 = (_local3 + 2);
};
return (_local2);
}
public static function encryptbin(_arg1:String, _arg2:String):Array{
var _local3:Array = strToChars(_arg1);
var _local4:Array = strToChars(_arg2);
var _local5:Array = calculate(_local3, _local4);
return (_local5);
}
public static function decrypt(_arg1:String, _arg2:String):String{
var _local3:Array = hexToChars(_arg1);
var _local4:Array = strToChars(_arg2);
var _local5:Array = calculate(_local3, _local4);
return (charsToStr(_local5));
}
private static function strToChars(_arg1:String):Array{
var _local2:Array = new Array();
var _local3:uint;
while (_local3 < _arg1.length) {
_local2.push(_arg1.charCodeAt(_local3));
_local3++;
};
return (_local2);
}
private static function calculate(_arg1:Array, _arg2:Array):Array{
var _local6:uint;
var _local7:uint;
var _local8:uint;
var _local10:uint;
initialize(_arg2);
var _local3:uint;
var _local4:uint;
var _local5:Array = new Array();
var _local9:uint;
while (_local9 < _arg1.length) {
_local3 = ((_local3 + 1) % 0x0100);
_local4 = ((_local4 + sbox[_local3]) % 0x0100);
_local7 = sbox[_local3];
sbox[_local3] = sbox[_local4];
sbox[_local4] = _local7;
_local10 = ((sbox[_local3] + sbox[_local4]) % 0x0100);
_local6 = sbox[_local10];
_local8 = (_arg1[_local9] ^ _local6);
_local5.push(_local8);
_local9++;
};
return (_local5);
}
private static function initialize(_arg1:Array):void{
var _local3:uint;
var _local2:uint;
var _local4:uint = _arg1.length;
var _local5:uint;
while (_local5 <= 0xFF) {
mykey[_local5] = _arg1[(_local5 % _local4)];
sbox[_local5] = _local5;
_local5++;
};
_local5 = 0;
while (_local5 <= 0xFF) {
_local2 = (((_local2 + sbox[_local5]) + mykey[_local5]) % 0x0100);
_local3 = sbox[_local5];
sbox[_local5] = sbox[_local2];
sbox[_local2] = _local3;
_local5++;
};
}
private static function charsToStr(_arg1:Array):String{
var _local2:String = new String("");
var _local3:uint;
while (_local3 < _arg1.length) {
_local2 = (_local2 + String.fromCharCode(_arg1[_local3]));
_local3++;
};
return (_local2);
}
}
}//package com.newgrounds
Section 97
//SaveFile (com.newgrounds.SaveFile)
package com.newgrounds {
import flash.display.*;
import flash.events.*;
import flash.utils.*;
import flash.net.*;
public class SaveFile extends EventDispatcher {
private var _group:SaveGroup;
private var _id:uint;
private var _thumbnailUrl:String;
private var _status:uint;
private var _keys:Dictionary;
private var _fileUrl:String;
private var _filename:String;
private var _ratings:Dictionary;
private var _contents;
private var _thumbnail:BitmapData;
private var _description:String;
public function SaveFile(_arg1:SaveGroup){
_keys = new Dictionary();
_ratings = new Dictionary();
_group = _arg1;
_description = "";
}
public function get description():String{
return (_description);
}
public function sendRating(_arg1:String, _arg2:Number):void{
var _local3:SaveRating = _group.getRatingByName(_arg1);
if (!_local3){
trace((("[NewgroundsAPISaveFile] " + _arg1) + " is not a recognized save file"));
return;
};
if ((((_arg2 < _local3.minValue)) || ((_arg2 > _local3.maxValue)))){
trace(((("[NewgroundsAPISaveFile] Vote must be between " + _local3.minValue) + " and ") + _local3.maxValue));
return;
};
_local3.voted = true;
NewgroundsAPI.rateSaveFile(this, _local3, _arg2);
}
public function set thumbnailUrl(_arg1:String):void{
_thumbnailUrl = _arg1;
}
public function get groupId():uint{
return (_group.id);
}
public function get name():String{
return (_filename);
}
override public function toString():String{
var _local2:Object;
var _local3:Object;
var _local1 = (((((("Save File " + _filename) + " ID: ") + _id) + "\n ") + _description) + "\n");
for each (_local2 in _keys) {
_local1 = (_local1 + ((((" " + _group.getKeyById(_local2.id).name) + ": ") + _local2.val) + "\n"));
};
for each (_local3 in _ratings) {
_local1 = (_local1 + ((((((" " + _group.getRatingById(_local3.id).name) + "\n Score: ") + _local3.score) + " Votes: ") + _local3.votes) + "\n"));
};
return (_local1);
}
public function save():void{
NewgroundsAPI.saveFile(this);
}
public function set name(_arg1:String):void{
_filename = _arg1;
}
public function get groupType():uint{
return (_group.type);
}
public function get id():uint{
return (_id);
}
public function setKey(_arg1, _arg2):void{
var _local3:SaveKey;
if ((_local3 is String)){
_local3 = _group.getKeyByName(_arg1);
} else {
_local3 = _group.getKeyById(_arg1);
};
if (_local3){
_keys[_local3] = {id:_local3.id, val:_arg2};
};
}
public function setRating(_arg1, _arg2:Number, _arg3:Number):void{
var _local4:SaveRating;
if ((_arg1 is String)){
_local4 = _group.getRatingByName(_arg1);
} else {
_local4 = _group.getRatingById(_arg1);
};
if (_local4){
_ratings[_local4] = {id:_local4.id, name:_local4.name, votes:_arg2, score:_arg3};
};
}
public function toObject():Object{
var _local2:Object;
var _local1:Object = {group:groupId, filename:name, description:description, shared:true};
_local1.keys = [];
for each (_local2 in _keys) {
_local1.push({id:_local2.id, value:_local2.val});
};
return (_local1);
}
public function get contents(){
return (_contents);
}
public function get thumbnailUrl():String{
return (_thumbnailUrl);
}
public function get shared():Boolean{
return (true);
}
public function getRating(_arg1):Object{
var _local2:SaveRating;
if ((_arg1 is String)){
_local2 = _group.getRatingByName(_arg1);
} else {
_local2 = _group.getRatingById(_arg1);
};
if (_local2){
return (_ratings[_local2]);
};
return (null);
}
public function getKey(_arg1){
var _local2:SaveKey;
if ((_local2 is String)){
_local2 = _group.getKeyByName(_arg1);
} else {
_local2 = _group.getKeyById(_arg1);
};
if (_local2){
return (_keys[_local2]);
};
return (null);
}
public function get groupName():String{
return (_group.name);
}
public function get fileUrl():String{
return (_fileUrl);
}
public function get thumbnail():BitmapData{
return (_thumbnail);
}
public function loadContents():void{
var _local1:SmartURLLoader;
if (_fileUrl){
_local1 = new SmartURLLoader();
_local1.responseFormat = URLLoaderDataFormat.BINARY;
_local1.addEventListener(Event.COMPLETE, onContentsLoaded);
_local1.load(_fileUrl);
};
}
public function set fileUrl(_arg1:String):void{
_fileUrl = _arg1;
}
public function set id(_arg1:uint):void{
_id = _arg1;
}
public function set description(_arg1:String):void{
_description = _arg1;
}
public function set contents(_arg1):void{
_contents = _arg1;
}
private function onContentsLoaded(_arg1:Event):void{
var _local2:ByteArray = _arg1.target.response;
_local2.uncompress();
var _local3:uint = _local2.readUnsignedByte();
if (_local3 == 0){
_contents = new ByteArray();
_contents.writeBytes(_local2, 1);
} else {
_contents = _local2.readObject();
};
dispatchEvent(new APIEvent(APIEvent.FILE_LOADED, true, contents));
}
}
}//package com.newgrounds
Section 98
//SaveGroup (com.newgrounds.SaveGroup)
package com.newgrounds {
public class SaveGroup {
private var _id:uint;
private var _keys:Array;
private var _type:uint;
private var _name:String;
private var _ratings:Array;
private var _files:Array;
public static const TYPE_SYSTEM:uint = 0;
public static const TYPE_PRIVATE:uint = 1;
public static const TYPE_MODERATED:uint = 3;
public static const TYPE_PUBLIC:uint = 2;
public function SaveGroup(_arg1:uint, _arg2:String, _arg3:uint){
_name = _arg2;
_id = _arg1;
_type = _arg3;
_ratings = [];
_keys = [];
_files = [];
}
public function toString():String{
return ((((((("SaveGroup { name: " + _name) + ", id: ") + _id) + ", keys: ") + _keys) + "}"));
}
public function getRatingById(_arg1:uint):SaveRating{
var _local2:uint;
while (_local2 < _ratings.length) {
if (_ratings[_local2].id == _arg1){
return (_ratings[_local2]);
};
_local2++;
};
return (null);
}
public function getKeyByName(_arg1:String):SaveKey{
var _local2:uint;
while (_local2 < _keys.length) {
if (_keys[_local2].name == _arg1){
return (_keys[_local2]);
};
_local2++;
};
return (null);
}
public function get name():String{
return (_name);
}
public function getKeyById(_arg1:uint):SaveKey{
var _local2:uint;
while (_local2 < _keys.length) {
if (_keys[_local2].id == _arg1){
return (_keys[_local2]);
};
_local2++;
};
return (null);
}
public function addRating(_arg1:SaveRating):void{
_ratings.push(_arg1);
}
public function get id():uint{
return (_id);
}
public function createQuery():SaveGroupQuery{
return (new SaveGroupQuery(this));
}
public function get keys():Array{
return (_keys.concat());
}
public function getRatingByName(_arg1:String):SaveRating{
var _local2:uint;
while (_local2 < _ratings.length) {
if (_ratings[_local2].name == _arg1){
return (_ratings[_local2]);
};
_local2++;
};
return (null);
}
public function get ratings():Array{
return (_ratings.concat());
}
public function get type():uint{
return (_type);
}
public function addKey(_arg1:SaveKey):void{
_keys.push(_arg1);
}
public static function createFromObject(_arg1:Object):SaveGroup{
var _local4:Object;
var _local5:Object;
var _local2:SaveGroup = new SaveGroup(_arg1.group_id, _arg1.group_name, _arg1.group_type);
var _local3:uint;
while (_local3 < _arg1.keys.length) {
_local4 = _arg1.keys[_local3];
_local2.addKey(new SaveKey(_local4.id, _local4.name, _local4.type));
_local3++;
};
_local3 = 0;
while (_local3 < _arg1.ratings.length) {
_local5 = _arg1.ratings[_local3];
_local2.addRating(new SaveRating(_local5.id, _local5.name, _local5.float, _local5.min, _local5.max));
_local3++;
};
return (_local2);
}
}
}//package com.newgrounds
Section 99
//SaveGroupQuery (com.newgrounds.SaveGroupQuery)
package com.newgrounds {
import flash.events.*;
public class SaveGroupQuery extends EventDispatcher {
private var _group:SaveGroup;
private var _fileConditions:Array;
private var _ratingConditions:Array;
private var _resultsPerPage:uint;
private var _sortConditions:Array;
private var _lookupRatings:Array;
private var _randomizeResults:Boolean;
private var _lookupKeys:Array;
private var _page:uint;
private var _groupBy:Array;
private var _keyConditions:Array;
public static const UPDATED_ON:uint = 5;
public static const TABLE_RATINGS:uint = 3;
public static const TABLE_FILES:uint = 1;
public static const TOTAL_VOTES:String = "votes";
public static const AUTHOR_ID:uint = 1;
public static const FILE_STATUS:uint = 7;
public static const TABLE_KEYS:uint = 2;
public static const FILE_NAME:uint = 3;
public static const SCORE:String = "score";
public static const TOTAL_VIEWS:uint = 6;
public static const CREATED_ON:uint = 4;
public static const FILE_ID:uint = 0;
public static const AUTHOR_NAME:uint = 2;
public function SaveGroupQuery(_arg1:SaveGroup){
_group = _arg1;
reset();
}
public function addKeyCondition(_arg1:String, _arg2:String, _arg3):void{
var _local4:SaveKey = _group.getKeyByName(_arg1);
if (!_local4){
return;
};
if (!checkValue(_arg3, _local4.type)){
return;
};
_keyConditions.push({key:_local4.id, operator:_arg2, value:_arg3});
}
public function sortOn(_arg1:uint, _arg2:Boolean=false):void{
addSortCondition(TABLE_FILES, _arg1, _arg2);
}
public function set isRandomized(_arg1:Boolean):void{
_randomizeResults = _arg1;
}
public function get isRandomized():Boolean{
return (_randomizeResults);
}
public function groupByRating(_arg1:String):void{
var _local2:SaveRating = _group.getRatingByName(_arg1);
if (!_local2){
return;
};
_groupBy.push({table:TABLE_RATINGS, field:_local2.id});
}
public function execute():void{
NewgroundsAPI.executeSaveQuery(this);
}
public function get page():uint{
return (_page);
}
public function groupByKey(_arg1:String):void{
var _local2:SaveKey = _group.getKeyByName(_arg1);
if (!_local2){
return;
};
_groupBy.push({table:TABLE_KEYS, field:_local2.id});
}
public function sortOnKey(_arg1:String, _arg2:Boolean=false):void{
addSortCondition(TABLE_KEYS, _group.getKeyByName(_arg1).id, _arg2);
}
public function toObject():Object{
var _local1:Object = {page:_page, num_results:_resultsPerPage};
if (isRandomized){
_local1.randomize = 1;
};
if (((_fileConditions) && ((_fileConditions.length > 0)))){
_local1.file_conditions = _fileConditions;
};
if (((_keyConditions) && ((_keyConditions.length > 0)))){
_local1.key_conditions = _keyConditions;
};
if (((_ratingConditions) && ((_ratingConditions.length > 0)))){
_local1.rating_conditions = _ratingConditions;
};
if (((_sortConditions) && ((_sortConditions.length > 0)))){
_local1.sort_conditions = _sortConditions;
};
if (((_lookupKeys) && ((_lookupKeys.length > 0)))){
_local1.lookup_keys = _lookupKeys;
};
if (((_lookupRatings) && ((_lookupRatings.length > 0)))){
_local1.lookup_ratings = _lookupRatings;
};
if (((_groupBy) && ((_groupBy.length > 0)))){
_local1.group_by = _groupBy;
};
return (_local1);
}
public function reset():void{
_fileConditions = [];
_keyConditions = [];
_ratingConditions = [];
_sortConditions = [];
_groupBy = [];
_lookupKeys = [];
_lookupRatings = [];
_randomizeResults = false;
_resultsPerPage = 20;
_page = 1;
}
public function includeKey(_arg1:String):void{
var _local2:SaveKey = _group.getKeyByName(_arg1);
if (_local2){
_lookupKeys.push(_local2.id);
};
}
private function checkValue(_arg1, _arg2:uint):Boolean{
return (true);
}
public function set page(_arg1:uint):void{
_page = _arg1;
}
public function addRatingCondition(_arg1:String, _arg2:String, _arg3, _arg4:String="score"):void{
var _local5:SaveRating = _group.getRatingByName(_arg1);
if (!_local5){
return;
};
_ratingConditions.push({rating:_local5.id, operator:_arg2, value:_arg3, column:_arg4});
}
public function includeRating(_arg1:String):void{
var _local2:SaveRating = _group.getRatingByName(_arg1);
if (_local2){
_lookupRatings.push(_local2.id);
};
}
public function sortOnRating(_arg1:String, _arg2:Boolean=false, _arg3:String="score"):void{
addSortCondition(TABLE_RATINGS, _group.getRatingByName(_arg1).id, _arg2, _arg3);
}
public function set resultsPerPage(_arg1:uint):void{
_resultsPerPage = _arg1;
}
public function excludeRating(_arg1:String):void{
var _local2:SaveRating = _group.getRatingByName(_arg1);
var _local3:uint;
while (_local3 < _lookupRatings.length) {
if (_lookupRatings[_local3] == _local2.id){
_lookupRatings.splice(_local3, 1);
return;
};
_local3++;
};
}
public function addFileCondition(_arg1:uint, _arg2:String, _arg3):void{
_fileConditions.push({field:_arg1, operator:_arg2, value:_arg3});
}
public function excludeKey(_arg1:String):void{
var _local2:SaveKey = _group.getKeyByName(_arg1);
var _local3:uint;
while (_local3 < _lookupKeys.length) {
if (_lookupKeys[_local3] == _local2.id){
_lookupKeys.splice(_local3, 1);
return;
};
_local3++;
};
}
public function get resultsPerPage():uint{
return (_resultsPerPage);
}
public function get groupId():uint{
return (_group.id);
}
override public function toString():String{
return ("");
}
private function addSortCondition(_arg1:uint, _arg2:uint, _arg3:Boolean=false, _arg4=null):void{
var _local5:Object = {table:_arg1, field:_arg2, desc:_arg3};
if (_arg4){
_local5.extra = _arg4;
};
_sortConditions.push(_local5);
}
public function groupBy(_arg1:uint):void{
_groupBy.push({table:TABLE_FILES, field:_arg1});
}
public function get group():SaveGroup{
return (_group);
}
}
}//package com.newgrounds
Section 100
//SaveKey (com.newgrounds.SaveKey)
package com.newgrounds {
public class SaveKey {
private var _id:uint;
private var _type:uint;
private var _name:String;
public static const TYPE_BOOLEAN:uint = 4;
public static const TYPE_STRING:uint = 3;
public static const TYPE_FLOAT:uint = 1;
public static const TYPE_INTEGER:uint = 2;
public function SaveKey(_arg1:uint, _arg2:String, _arg3:uint){
_id = _arg1;
_name = _arg2;
_type = _arg3;
}
public function isValueValid(_arg1):Boolean{
if (_type == TYPE_INTEGER){
return ((((_arg1 is int)) || ((_arg1 is uint))));
};
if (_type == TYPE_FLOAT){
return ((((((_arg1 is int)) || ((_arg1 is uint)))) || ((_arg1 is Number))));
};
if (_type == TYPE_STRING){
return ((_arg1 is String));
};
if (_type == TYPE_BOOLEAN){
return ((((((((_arg1 is Boolean)) || ((_arg1 === 0)))) || ((_arg1 === 1)))) || ((_arg1 == ""))));
};
return (false);
}
public function get name():String{
return (_name);
}
public function get type():uint{
return (_type);
}
public function get id():uint{
return (_id);
}
public function toString():String{
return (_name);
}
}
}//package com.newgrounds
Section 101
//SaveRating (com.newgrounds.SaveRating)
package com.newgrounds {
public class SaveRating {
private var _voted:Boolean;
private var _name:String;
private var _maxValue:Number;
private var _isFloat:Boolean;
private var _id:uint;
private var _minValue:Number;
public function SaveRating(_arg1:uint, _arg2:String, _arg3:Boolean, _arg4:Number=-INF, _arg5:Number=INF){
_id = _arg1;
_name = _arg2;
_isFloat = _arg3;
_minValue = _arg4;
_maxValue = _arg5;
}
public function get voted():Boolean{
return (_voted);
}
public function set voted(_arg1:Boolean):void{
_voted = _arg1;
}
public function toString():String{
return (_name);
}
public function get maxValue():Number{
return (_maxValue);
}
public function get name():String{
return (_name);
}
public function get isFloat():Boolean{
return (_isFloat);
}
public function get id():uint{
return (_id);
}
public function get minValue():Number{
return (_minValue);
}
}
}//package com.newgrounds
Section 102
//Score (com.newgrounds.Score)
package com.newgrounds {
public class Score {
private var _board:ScoreBoard;
private var _position:uint;
private var _numeric_value:Number;
private var _value:String;
private var _username:String;
public function Score(_arg1:ScoreBoard, _arg2:Number, _arg3:String, _arg4:String, _arg5:Number){
_board = _arg1;
_position = _arg2;
_username = _arg3;
_value = _arg4;
_numeric_value = _arg5;
}
public function get board():ScoreBoard{
return (_board);
}
public function get position():uint{
return (_position);
}
public function get value():String{
return (_value);
}
public function get username():String{
return (_username);
}
public function get numeric_value():Number{
return (_numeric_value);
}
}
}//package com.newgrounds
Section 103
//ScoreBoard (com.newgrounds.ScoreBoard)
package com.newgrounds {
import flash.events.*;
public class ScoreBoard extends EventDispatcher {
private var _scores:Array;
private var _name:String;
private var _page:uint;// = 1
private var _period:String;// = "Today"
private var _id:uint;
private var _num_results:uint;// = 10
public function ScoreBoard(_arg1:uint, _arg2:String){
_name = _arg2;
_id = _arg1;
_scores = [];
}
public function get period():String{
return (_period);
}
public function get id():Number{
return (_id);
}
function setScores(_arg1:Array, _arg2:String, _arg3:Number, _arg4:Number):void{
var _local6:uint;
_period = _arg2;
_page = _arg3;
_num_results = _arg4;
_scores = [];
var _local5:uint;
while (_local5 < _arg1.length) {
_local6 = (((_num_results * (_page - 1)) + 1) + _local5);
_scores.push(new Score(this, _local6, _arg1[_local5].username, _arg1[_local5].value, _arg1[_local5].numeric_value));
_local5++;
};
}
public function get scores():Array{
return (_scores);
}
public function exists():Boolean{
return ((_id > 0));
}
public function get name():String{
return (_name);
}
public function get page():uint{
return (_page);
}
public function postScore(_arg1:Number, _arg2:Boolean):void{
NewgroundsAPI.postScore(_name, _arg1, _arg2);
}
public function get num_results():uint{
return (_num_results);
}
public function loadScores(_arg1:String, _arg2:uint, _arg3:uint):void{
_period = _arg1;
if (((!(_period)) || ((_period == "")))){
_period = "Today";
};
_page = _arg2;
_num_results = _arg3;
NewgroundsAPI.loadScores(this);
}
}
}//package com.newgrounds
Section 104
//SmartURLLoader (com.newgrounds.SmartURLLoader)
package com.newgrounds {
import flash.events.*;
import flash.utils.*;
import flash.net.*;
import flash.errors.*;
public class SmartURLLoader extends EventDispatcher {
private var _urlRequest:URLRequest;
private var _method:String;// = "GET"
private var _files:Dictionary;
private var _hasVariables:Boolean;
private var _dataFormat:String;// = "text"
private var _urlLoader:URLLoader;
private var _preventCache:Boolean;// = false
private var _variables:Dictionary;
public var owner;
private var _openBrowser:Boolean;// = false
private static const CRLF:String = "
";
private static var _loaders:Dictionary = new Dictionary();
public function SmartURLLoader(){
_urlRequest = new URLRequest();
_variables = new Dictionary();
}
public function get response(){
return (_urlLoader.data);
}
public function set method(_arg1:String):void{
if (((hasFiles) && ((_arg1 == URLRequestMethod.GET)))){
throw (new IllegalOperationError("GET cannot be used to upload files."));
};
_method = _arg1;
}
private function onIOError(_arg1:IOErrorEvent):void{
dispatchEvent(_arg1);
dispose();
}
public function addVariable(_arg1:String, _arg2=""):void{
_variables[_arg1] = _arg2;
if (_arg2){
_hasVariables = true;
};
}
private function onSecurityError(_arg1:SecurityErrorEvent):void{
dispatchEvent(_arg1);
dispose();
}
public function get preventCache():Boolean{
return (_preventCache);
}
public function addFile(_arg1:String, _arg2:ByteArray, _arg3:String, _arg4:String="application/octect-stream"):void{
method = URLRequestMethod.POST;
if (!_files){
_files = new Dictionary();
};
_files[_arg1] = new File(_arg1, _arg2, _arg3, _arg4);
}
public function get openBrowser():Boolean{
return (_openBrowser);
}
public function set preventCache(_arg1:Boolean):void{
_preventCache = _arg1;
}
public function get responseFormat():String{
return (_dataFormat);
}
private function onComplete(_arg1:Event):void{
dispatchEvent(_arg1);
dispose();
}
public function dispose():void{
_files = null;
_variables = null;
if (_urlLoader){
_urlLoader.removeEventListener(Event.COMPLETE, onComplete);
_urlLoader.removeEventListener(ProgressEvent.PROGRESS, onProgress);
_urlLoader.removeEventListener(IOErrorEvent.IO_ERROR, onIOError);
_urlLoader.removeEventListener(HTTPStatusEvent.HTTP_STATUS, onHTTPStatus);
_urlLoader.removeEventListener(SecurityErrorEvent.SECURITY_ERROR, onSecurityError);
_urlLoader = null;
};
_urlRequest = null;
_loaders[this] = null;
}
public function get method():String{
return (_method);
}
public function close():void{
try {
_urlLoader.close();
} catch(e:Error) {
};
}
private function buildMultipartData(_arg1:String):ByteArray{
var _local3:String;
var _local4:File;
var _local2:ByteArray = new ByteArray();
_local2.endian = Endian.BIG_ENDIAN;
_arg1 = ("--" + _arg1);
for (_local3 in _variables) {
_local2.writeUTFBytes((_arg1 + CRLF));
_local2.writeUTFBytes(((("Content-Disposition: form-data; name=\"" + _local3) + "\"") + CRLF));
_local2.writeUTFBytes(CRLF);
_local2.writeUTFBytes((_variables[_local3] + CRLF));
};
if (hasFiles){
for each (_local4 in _files) {
_local2.writeUTFBytes((_arg1 + CRLF));
_local2.writeUTFBytes(("Content-Disposition: form-data; name=\"Filename\"" + CRLF));
_local2.writeUTFBytes(CRLF);
_local2.writeUTFBytes((_local4.fileName + CRLF));
_local2.writeUTFBytes((_arg1 + CRLF));
_local2.writeUTFBytes(((((("Content-Disposition: form-data; name=\"" + _local4.dataField) + "\"; filename=\"") + _local4.fileName) + "\"") + CRLF));
_local2.writeUTFBytes((("Content-Type: " + _local4.contentType) + CRLF));
_local2.writeUTFBytes(CRLF);
_local2.writeBytes(_local4.data);
_local2.writeUTFBytes(CRLF);
};
_local2.writeUTFBytes((_arg1 + CRLF));
_local2.writeUTFBytes(("Content-Disposition: form-data; name=\"Upload\"" + CRLF));
_local2.writeUTFBytes(CRLF);
_local2.writeUTFBytes(("Submit Query" + CRLF));
};
_local2.writeUTFBytes((_arg1 + "--"));
_local2.position = 0;
trace(_local2.readUTFBytes(_local2.length));
_local2.position = 0;
return (_local2);
}
public function clearVariables():void{
_variables = new Dictionary();
}
private function onProgress(_arg1:ProgressEvent):void{
dispatchEvent(_arg1);
}
public function load(_arg1:String):void{
var urlVariables:URLVariables;
var key:String;
var boundary:String;
var i:uint;
var event:SecurityErrorEvent;
var url = _arg1;
_urlRequest.url = url;
if (_preventCache){
url = (url + ("?seed=" + Math.random()));
if (_hasVariables){
url = (url + "&");
};
};
_urlRequest.method = _method;
if ((((_urlRequest.method == URLRequestMethod.GET)) || (!(hasFiles)))){
_urlRequest.contentType = "application/x-www-form-urlencoded";
if (_hasVariables){
urlVariables = new URLVariables();
for (key in _variables) {
urlVariables[key] = _variables[key];
};
_urlRequest.data = urlVariables;
};
} else {
boundary = "";
i = 0;
while (i < 32) {
boundary = (boundary + String.fromCharCode(uint((97 + (Math.random() * 25)))));
i = (i + 1);
};
_urlRequest.contentType = (("multipart/form-data; boundary=\"" + boundary) + "\"");
_urlRequest.data = buildMultipartData(boundary);
};
if (openBrowser){
navigateToURL(_urlRequest, "_blank");
} else {
_urlLoader = new URLLoader();
_urlLoader.dataFormat = _dataFormat;
_urlLoader.addEventListener(Event.COMPLETE, onComplete);
_urlLoader.addEventListener(ProgressEvent.PROGRESS, onProgress);
_urlLoader.addEventListener(IOErrorEvent.IO_ERROR, onIOError);
_urlLoader.addEventListener(HTTPStatusEvent.HTTP_STATUS, onHTTPStatus);
_urlLoader.addEventListener(SecurityErrorEvent.SECURITY_ERROR, onSecurityError);
_loaders[_urlLoader] = this;
try {
_urlLoader.load(_urlRequest);
} catch(error:Error) {
event = new SecurityErrorEvent(SecurityErrorEvent.SECURITY_ERROR, false, false, error.message);
onSecurityError(event);
};
};
}
public function set responseFormat(_arg1:String):void{
_dataFormat = _arg1;
}
public function clearFiles():void{
_files = null;
}
private function onHTTPStatus(_arg1:HTTPStatusEvent):void{
dispatchEvent(_arg1);
}
public function set openBrowser(_arg1:Boolean):void{
_openBrowser = _arg1;
}
public function get hasFiles():Boolean{
return (Boolean(_files));
}
}
}//package com.newgrounds
import flash.utils.*;
class File {
private var dataField:String;
private var contentType:String;
private var fileName:String;
private var data:ByteArray;
private function File(_arg1:String, _arg2:ByteArray, _arg3:String="Filedata", _arg4:String="application/octet-stream"){
this.fileName = _arg1;
this.data = _arg2;
this.dataField = _arg3;
this.contentType = _arg4;
}
}
Section 105
//AdLoader (CPMStar.AdLoader)
package CPMStar {
import flash.display.*;
import flash.events.*;
import flash.net.*;
import flash.system.*;
public class AdLoader extends Sprite {
private var cpmstarLoader:Loader;
private var contentspotid:String;
public function AdLoader(_arg1:String){
this.contentspotid = _arg1;
addEventListener(Event.ADDED, addedHandler);
}
private function dispatchHandler(_arg1:Event):void{
dispatchEvent(_arg1);
}
private function addedHandler(_arg1:Event):void{
removeEventListener(Event.ADDED, addedHandler);
Security.allowDomain("server.cpmstar.com");
var _local2 = "http://server.cpmstar.com/adviewas3.swf";
var _local3:DisplayObjectContainer = parent;
cpmstarLoader = new Loader();
cpmstarLoader.contentLoaderInfo.addEventListener(Event.INIT, dispatchHandler);
cpmstarLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, dispatchHandler);
cpmstarLoader.load(new URLRequest(((_local2 + "?contentspotid=") + contentspotid)));
addChild(cpmstarLoader);
}
}
}//package CPMStar
Section 106
//bubble_logo3_115 (Zomgies_NG_fla.bubble_logo3_115)
package Zomgies_NG_fla {
import flash.display.*;
public dynamic class bubble_logo3_115 extends MovieClip {
public function bubble_logo3_115(){
addFrameScript(0, frame1, 9, frame10);
}
function frame10(){
stop();
}
function frame1(){
stop();
}
}
}//package Zomgies_NG_fla
Section 107
//clip_sd88detincelle_214 (Zomgies_NG_fla.clip_sd88detincelle_214)
package Zomgies_NG_fla {
import flash.display.*;
public dynamic class clip_sd88detincelle_214 extends MovieClip {
public function clip_sd88detincelle_214(){
addFrameScript(13, frame14);
}
function frame14(){
stop();
}
}
}//package Zomgies_NG_fla
Section 108
//freeinternetgames_213 (Zomgies_NG_fla.freeinternetgames_213)
package Zomgies_NG_fla {
import flash.display.*;
public dynamic class freeinternetgames_213 extends MovieClip {
public function freeinternetgames_213(){
addFrameScript(59, frame60);
}
function frame60(){
stop();
}
}
}//package Zomgies_NG_fla
Section 109
//logodrop_188 (Zomgies_NG_fla.logodrop_188)
package Zomgies_NG_fla {
import flash.display.*;
public dynamic class logodrop_188 extends MovieClip {
public function logodrop_188(){
addFrameScript(127, frame128);
}
function frame128(){
stop();
}
}
}//package Zomgies_NG_fla
Section 110
//MainTimeline (Zomgies_NG_fla.MainTimeline)
package Zomgies_NG_fla {
import flash.display.*;
public dynamic class MainTimeline extends MovieClip {
public function MainTimeline(){
addFrameScript(0, frame1, 2, frame3);
}
function frame1(){
trace(("Stage: " + this));
Lic.InitFromTimeLine(this);
}
function frame3(){
stop();
Lic.TimeLineComplete();
}
}
}//package Zomgies_NG_fla
Section 111
//MB_Explode_184 (Zomgies_NG_fla.MB_Explode_184)
package Zomgies_NG_fla {
import flash.display.*;
public dynamic class MB_Explode_184 extends MovieClip {
public function MB_Explode_184(){
addFrameScript(0, frame1, 18, frame19);
}
function frame1(){
}
function frame19(){
stop();
}
}
}//package Zomgies_NG_fla
Section 112
//MB_eyes_MB_183 (Zomgies_NG_fla.MB_eyes_MB_183)
package Zomgies_NG_fla {
import flash.display.*;
public dynamic class MB_eyes_MB_183 extends MovieClip {
public function MB_eyes_MB_183(){
addFrameScript(31, frame32);
}
function frame32(){
gotoAndPlay(1);
}
}
}//package Zomgies_NG_fla
Section 113
//MB_mouse_182 (Zomgies_NG_fla.MB_mouse_182)
package Zomgies_NG_fla {
import flash.display.*;
public dynamic class MB_mouse_182 extends MovieClip {
public function MB_mouse_182(){
addFrameScript(6, frame7);
}
function frame7(){
gotoAndPlay(1);
}
}
}//package Zomgies_NG_fla
Section 114
//MB_mouse_185 (Zomgies_NG_fla.MB_mouse_185)
package Zomgies_NG_fla {
import flash.display.*;
public dynamic class MB_mouse_185 extends MovieClip {
public function MB_mouse_185(){
addFrameScript(35, frame36);
}
function frame36(){
gotoAndPlay(1);
}
}
}//package Zomgies_NG_fla
Section 115
//mcLogo_animation_231 (Zomgies_NG_fla.mcLogo_animation_231)
package Zomgies_NG_fla {
import flash.display.*;
import flash.media.*;
public dynamic class mcLogo_animation_231 extends MovieClip {
public var fogsound:fogaudio;
public var channel:SoundChannel;
public function mcLogo_animation_231(){
addFrameScript(59, frame60);
}
function frame60(){
stop();
stop();
fogsound = new fogaudio();
channel = fogsound.play();
}
}
}//package Zomgies_NG_fla
Section 116
//mcLogo2_232 (Zomgies_NG_fla.mcLogo2_232)
package Zomgies_NG_fla {
import flash.display.*;
import flash.events.*;
import flash.geom.*;
import flash.media.*;
import flash.text.*;
import flash.utils.*;
import flash.net.*;
import flash.filters.*;
import flash.system.*;
import flash.ui.*;
import flash.errors.*;
import adobe.utils.*;
import flash.accessibility.*;
import flash.external.*;
import flash.printing.*;
import flash.profiler.*;
import flash.sampler.*;
import flash.xml.*;
public dynamic class mcLogo2_232 extends MovieClip {
public var me;
public var mcNotice:MovieClip;
public function mcLogo2_232(){
addFrameScript(0, frame1, 119, frame120);
}
function frame120(){
stop();
me = parent.parent;
if ((((me.Furl.indexOf("freeonlinegames.com") >= 0)) && ((me.Furl.indexOf("file:") == -1)))){
me.okToPlay = true;
me.play();
stop();
} else {
if (me.debug){
me.okToPlay = true;
me.play();
stop();
} else {
me.mcTaglines.visible = false;
mcNotice.visible = true;
};
};
}
function frame1(){
mcNotice.visible = false;
}
}
}//package Zomgies_NG_fla
Section 117
//mcSounds_235 (Zomgies_NG_fla.mcSounds_235)
package Zomgies_NG_fla {
import flash.display.*;
public dynamic class mcSounds_235 extends MovieClip {
public function mcSounds_235(){
addFrameScript(0, frame1);
}
function frame1(){
stop();
}
}
}//package Zomgies_NG_fla
Section 118
//NewgroundsAPIAsset_FlashAd_Container_259 (Zomgies_NG_fla.NewgroundsAPIAsset_FlashAd_Container_259)
package Zomgies_NG_fla {
import com.newgrounds.*;
import flash.display.*;
import flash.events.*;
public dynamic class NewgroundsAPIAsset_FlashAd_Container_259 extends MovieClip {
public var ngLinkButton:SimpleButton;
public function NewgroundsAPIAsset_FlashAd_Container_259(){
addFrameScript(0, frame1, 10, frame11);
}
function frame1(){
ngLinkButton.addEventListener(MouseEvent.CLICK, onNGLinkClicked);
}
public function onNGLinkClicked(_arg1:MouseEvent):void{
NewgroundsAPI.loadNewgrounds();
}
function frame11(){
gotoAndPlay(1);
}
}
}//package Zomgies_NG_fla
Section 119
//NewgroundsAPIAsset_Load_Indicator_260 (Zomgies_NG_fla.NewgroundsAPIAsset_Load_Indicator_260)
package Zomgies_NG_fla {
import flash.display.*;
import flash.events.*;
public dynamic class NewgroundsAPIAsset_Load_Indicator_260 extends MovieClip {
public function NewgroundsAPIAsset_Load_Indicator_260(){
addFrameScript(0, frame1);
}
function frame1(){
addEventListener(Event.ENTER_FRAME, onEnterFrame);
}
public function onEnterFrame(_arg1:Event):void{
if (((visible) && (stage))){
rotation = (rotation + 30);
} else {
removeEventListener(Event.ENTER_FRAME, onEnterFrame);
};
}
}
}//package Zomgies_NG_fla
Section 120
//prelMCxcopy_ovidiu2_227 (Zomgies_NG_fla.prelMCxcopy_ovidiu2_227)
package Zomgies_NG_fla {
import flash.display.*;
import flash.text.*;
public dynamic class prelMCxcopy_ovidiu2_227 extends MovieClip {
public var procent:TextField;
public function prelMCxcopy_ovidiu2_227(){
addFrameScript(0, frame1);
}
function frame1(){
stop();
}
}
}//package Zomgies_NG_fla
Section 121
//score_period_dropdown_251 (Zomgies_NG_fla.score_period_dropdown_251)
package Zomgies_NG_fla {
import flash.display.*;
import flash.events.*;
import flash.text.*;
import com.newgrounds.components.*;
public dynamic class score_period_dropdown_251 extends MovieClip {
public var allTimeButton:SimpleButton;
public var periodListUpButton:SimpleButton;
public var weekButton:SimpleButton;
public var periodText:TextField;
public var yearButton:SimpleButton;
public var periodListButton:SimpleButton;
public var monthButton:SimpleButton;
public var todayButton:SimpleButton;
public function score_period_dropdown_251(){
addFrameScript(0, frame1, 1, frame2);
}
function frame2(){
if (periodListUpButton){
periodListUpButton.addEventListener(MouseEvent.CLICK, onPeriodUpButtonClicked);
todayButton.addEventListener(MouseEvent.CLICK, onPeriodChanged);
weekButton.addEventListener(MouseEvent.CLICK, onPeriodChanged);
monthButton.addEventListener(MouseEvent.CLICK, onPeriodChanged);
yearButton.addEventListener(MouseEvent.CLICK, onPeriodChanged);
allTimeButton.addEventListener(MouseEvent.CLICK, onPeriodChanged);
};
}
function frame1(){
stop();
periodListButton.addEventListener(MouseEvent.CLICK, onPeriodButtonClicked);
}
public function onPeriodChanged(_arg1:MouseEvent):void{
var _local2:ScoreTable = (parent as ScoreTable);
var _local3 = "Today";
if (_local2){
if (_arg1.currentTarget == todayButton){
_local3 = "Today";
} else {
if (_arg1.currentTarget == weekButton){
_local3 = "This Week";
} else {
if (_arg1.currentTarget == monthButton){
_local3 = "This Month";
} else {
if (_arg1.currentTarget == yearButton){
_local3 = "This Year";
} else {
if (_arg1.currentTarget == allTimeButton){
_local3 = "All-Time";
};
};
};
};
};
};
_local2.loadScores(10, _local3);
if (periodText){
periodText.text = _local3;
};
gotoAndStop(1);
}
public function onPeriodButtonClicked(_arg1:MouseEvent):void{
gotoAndStop(2);
}
public function onPeriodUpButtonClicked(_arg1:MouseEvent):void{
gotoAndStop(1);
}
}
}//package Zomgies_NG_fla
Section 122
//Timeline_265 (Zomgies_NG_fla.Timeline_265)
package Zomgies_NG_fla {
import flash.display.*;
public dynamic class Timeline_265 extends MovieClip {
public function Timeline_265(){
addFrameScript(39, frame40);
}
function frame40(){
stop();
}
}
}//package Zomgies_NG_fla
Section 123
//title_91 (Zomgies_NG_fla.title_91)
package Zomgies_NG_fla {
import flash.display.*;
public dynamic class title_91 extends MovieClip {
public function title_91(){
addFrameScript(59, frame60);
}
function frame60(){
stop();
}
}
}//package Zomgies_NG_fla
Section 124
//Achievement (Achievement)
package {
public class Achievement {
var specificLevel:int;
var testFunction:String;
var name:String;
var testFunctionParams:String;
var completeFunction:String;
var completeFunctionParams:String;
var complete:Boolean;
var description:String;
public function Achievement(){
name = "undefined";
description = "undefined";
complete = false;
testFunction = null;
completeFunction = null;
completeFunctionParams = null;
testFunctionParams = null;
specificLevel = -1;
}
}
}//package
Section 125
//Achievements (Achievements)
package {
public class Achievements {
public var list:Array;
public function Achievements(){
list = new Array();
Add(1, "Level 1 Timetrial", "finish level 1 in 120 seconds to unlock level 2", "AchTest_FinishLevel", "-1,1,120", "AchPass_UnlockLevel", "2");
Add(2, "Level 2 Timetrial", "finish level 2 in 30 seconds to unlock level 3", "AchTest_FinishLevel", "-1,2,30", "AchPass_UnlockLevel", "2");
Add(1, "Level 1 Forward Somersault Challenge", "Complete 10 forward somersaults to unlock Clownbike", "AchTest_ForwardSomersault", "-1,1,2", "AchPass_UnlockBike", "6");
Add(1, "Level 1 Dino Challenge", "Total Real Wheel Wheelie for 20 seconds with Trikeceratops to unlock Level 3", "AchTest_TotalRearWheelie", "13,1,2", "AchPass_UnlockLevel", "3");
}
public function Add(_arg1:int, _arg2:String, _arg3:String, _arg4:String, _arg5:String, _arg6:String, _arg7:String){
var _local8:Achievement;
_local8 = new Achievement();
_local8.specificLevel = _arg1;
_local8.name = _arg2;
_local8.description = _arg3;
_local8.testFunction = _arg4;
_local8.testFunctionParams = _arg5;
_local8.completeFunction = _arg6;
_local8.completeFunctionParams = _arg7;
list.push(_local8);
}
function AchTest_ForwardSomersault(_arg1:String):Boolean{
var _local2:Array = _arg1.split(",");
var _local3:int = int(_local2[0]);
if (_local3 != -1){
if ((_local3 - 1) != Game.currentBikeIndex){
return (false);
};
};
var _local4:int = int(_local2[1]);
_local4--;
var _local5:Number = Number(_local2[2]);
if (_local4 != Game.currentLevel){
return (false);
};
if (Game.levelForwardSomersaults >= _local5){
return (true);
};
return (true);
}
function AchTest_FinishLevel(_arg1:String):Boolean{
var _local2:Array = _arg1.split(",");
var _local3:int = int(_local2[0]);
if (_local3 != -1){
if ((_local3 - 1) != Game.currentBikeIndex){
return (false);
};
};
var _local4:int = int(_local2[1]);
_local4--;
var _local5:Number = Number(_local2[2]);
if (_local4 != Game.currentLevel){
return (false);
};
var _local6:Number = (_local5 * Defs.fps);
if (Game.raceTimer <= _local6){
return (true);
};
return (false);
}
function AchTest_TotalRearWheelie(_arg1:String):Boolean{
var _local2:Array = _arg1.split(",");
var _local3:int = int(_local2[0]);
if (_local3 != -1){
if ((_local3 - 1) != Game.currentBikeIndex){
return (false);
};
};
var _local4:int = int(_local2[1]);
_local4--;
var _local5:Number = Number(_local2[2]);
_local5 = (_local5 * Defs.fps);
if (_local4 != Game.currentLevel){
return (false);
};
if (Game.levelWheelieTime >= _local5){
return (true);
};
return (true);
}
public function TestAll(){
var _local1:Achievement;
var _local2:Boolean;
for each (_local1 in list) {
if (_local1.complete == false){
_local2 = this[_local1.testFunction](_local1.testFunctionParams);
if (_local2){
var _local5 = this;
_local5[_local1.completeFunction](_local1.completeFunctionParams);
_local1.complete = true;
};
};
};
}
}
}//package
Section 126
//arm_chainsaw_forward (arm_chainsaw_forward)
package {
import flash.display.*;
public dynamic class arm_chainsaw_forward extends MovieClip {
}
}//package
Section 127
//arm_crowbar_forward (arm_crowbar_forward)
package {
import flash.display.*;
public dynamic class arm_crowbar_forward extends MovieClip {
}
}//package
Section 128
//arm_flamethrower_forward (arm_flamethrower_forward)
package {
import flash.display.*;
public dynamic class arm_flamethrower_forward extends MovieClip {
}
}//package
Section 129
//arm_hmg_forward (arm_hmg_forward)
package {
import flash.display.*;
public dynamic class arm_hmg_forward extends MovieClip {
}
}//package
Section 130
//arm_laser_forward (arm_laser_forward)
package {
import flash.display.*;
public dynamic class arm_laser_forward extends MovieClip {
}
}//package
Section 131
//arm_pistol_forward (arm_pistol_forward)
package {
import flash.display.*;
public dynamic class arm_pistol_forward extends MovieClip {
}
}//package
Section 132
//arm_rifle_forward (arm_rifle_forward)
package {
import flash.display.*;
public dynamic class arm_rifle_forward extends MovieClip {
}
}//package
Section 133
//arm_rocketlauncher_forward (arm_rocketlauncher_forward)
package {
import flash.display.*;
public dynamic class arm_rocketlauncher_forward extends MovieClip {
}
}//package
Section 134
//arm_shotgun_forward (arm_shotgun_forward)
package {
import flash.display.*;
public dynamic class arm_shotgun_forward extends MovieClip {
}
}//package
Section 135
//arm_smg_forward (arm_smg_forward)
package {
import flash.display.*;
public dynamic class arm_smg_forward extends MovieClip {
}
}//package
Section 136
//arm_uzi_forward (arm_uzi_forward)
package {
import flash.display.*;
public dynamic class arm_uzi_forward extends MovieClip {
}
}//package
Section 137
//BetweenLevelsScreen (BetweenLevelsScreen)
package {
import flash.display.*;
import flash.text.*;
public dynamic class BetweenLevelsScreen extends MovieClip {
public var textLevelHeadshots:TextField;
public var textLevelKills:TextField;
public var textPickups:TextField;
public var foundWeaponText:TextField;
public var w10:WeaponSelector;
public var w0:WeaponSelector;
public var w1:WeaponSelector;
public var w2:WeaponSelector;
public var w3:WeaponSelector;
public var w4:WeaponSelector;
public var w5:WeaponSelector;
public var w6:WeaponSelector;
public var w7:WeaponSelector;
public var w8:WeaponSelector;
public var w9:WeaponSelector;
public var textScore:TextField;
public var textLevelPickups:TextField;
public var textKills:TextField;
public var textHeadshots:TextField;
public var buttonContinue:SimpleButton;
}
}//package
Section 138
//Blocker (Blocker)
package {
import flash.display.*;
public dynamic class Blocker extends MovieClip {
}
}//package
Section 139
//BloodPuddle01 (BloodPuddle01)
package {
import flash.display.*;
public dynamic class BloodPuddle01 extends MovieClip {
}
}//package
Section 140
//BloodSplat01 (BloodSplat01)
package {
import flash.display.*;
public dynamic class BloodSplat01 extends MovieClip {
}
}//package
Section 141
//BloodSplat02 (BloodSplat02)
package {
import flash.display.*;
public dynamic class BloodSplat02 extends MovieClip {
}
}//package
Section 142
//BloodyFootprints (BloodyFootprints)
package {
import flash.display.*;
public dynamic class BloodyFootprints extends MovieClip {
}
}//package
Section 143
//bubblebox_score (bubblebox_score)
package {
import flash.display.*;
import flash.events.*;
import flash.geom.*;
import flash.media.*;
import flash.text.*;
import flash.utils.*;
import flash.net.*;
import flash.filters.*;
import flash.system.*;
import flash.ui.*;
import flash.errors.*;
import flash.accessibility.*;
import flash.external.*;
public dynamic class bubblebox_score extends MovieClip {
public var loader:URLLoader;
public var loadingStatus:String;
public var hexChars:String;
public var score:Number;
public var gameID:Number;
public var insertname:TextField;
public function bubblebox_score(){
addFrameScript(0, frame1);
}
public function hh(_arg1:int, _arg2:int, _arg3:int, _arg4:int, _arg5:int, _arg6:int, _arg7:int):int{
return (tr(h, _arg1, _arg2, _arg3, _arg4, _arg5, _arg6, _arg7));
}
public function hash(_arg1:String):String{
var _local2:ByteArray;
_local2 = new ByteArray();
_local2.writeUTFBytes(_arg1);
return (hashBinary(_local2));
}
public function removeListeners():void{
loader.removeEventListener(Event.COMPLETE, completeHandler);
loader.removeEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler);
loader.removeEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
}
public function clicked(_arg1:MouseEvent):void{
var _local2:String;
var _local3:String;
var _local4:String;
var _local5:String;
var _local6:URLVariables;
var _local7:URLRequest;
if (loadingStatus == "insertName"){
if (((((!((_arg1.target.name == "insertName"))) && (!((this.insertname.text == "YOUR NAME"))))) && ((this.insertname.text.length > 0)))){
_local2 = this.insertname.text;
_local3 = ((((gameID + "_") + score) + "_") + _local2);
_local4 = ((((((((((gameID + "_") + "4234232143214421") + "_") + score) + "_") + "2537625476251") + "_") + _local2) + "_") + "desleutelistessa");
_local5 = hash(_local4);
_local6 = new URLVariables();
_local6.datastring = _local3;
_local6.hashstring = _local5;
_local7 = new URLRequest("http://www.bubblebox.com/scripts/insertscore2008.php");
_local7.data = _local6;
_local7.method = URLRequestMethod.POST;
loader.dataFormat = URLLoaderDataFormat.TEXT;
loader.addEventListener(Event.COMPLETE, completeHandler, false, 0, true);
loader.addEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler, false, 0, true);
loader.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler, false, 0, true);
loader.load(_local7);
this.gotoAndStop(2);
loadingStatus = "sending";
};
} else {
if (loadingStatus == "sending"){
} else {
if (loadingStatus == "completed"){
navigateToURL(new URLRequest((("http://www.bubblebox.com/highscores/" + gameID) + ".htm")), "_blank");
} else {
if (loadingStatus == "failed"){
loadingStatus = "insertName";
this.gotoAndStop(1);
};
};
};
};
}
public function ii(_arg1:int, _arg2:int, _arg3:int, _arg4:int, _arg5:int, _arg6:int, _arg7:int):int{
return (tr(i, _arg1, _arg2, _arg3, _arg4, _arg5, _arg6, _arg7));
}
public function failed():void{
loadingStatus = "failed";
removeListeners();
this.gotoAndStop(4);
}
public function setScore(_arg1:Number, _arg2:Number):void{
score = _arg1;
gameID = _arg2;
}
public function f(_arg1:int, _arg2:int, _arg3:int):int{
return (((_arg1 & _arg2) | (~(_arg1) & _arg3)));
}
public function i(_arg1:int, _arg2:int, _arg3:int):int{
return ((_arg2 ^ (_arg1 | ~(_arg3))));
}
function frame1(){
hexChars = "0123456789abcdef";
this.stage.focus = this.insertname;
this.insertname.setSelection(0, this.insertname.text.length);
loader = new URLLoader();
loadingStatus = "insertName";
this.addEventListener(MouseEvent.CLICK, clicked, false, 0, true);
stop();
}
public function g(_arg1:int, _arg2:int, _arg3:int):int{
return (((_arg1 & _arg3) | (_arg2 & ~(_arg3))));
}
public function h(_arg1:int, _arg2:int, _arg3:int):int{
return (((_arg1 ^ _arg2) ^ _arg3));
}
public function ioErrorHandler(_arg1:IOErrorEvent):void{
trace("ioError");
failed();
}
public function securityErrorHandler(_arg1:SecurityErrorEvent):void{
trace("securityError");
failed();
}
public function toHex(_arg1:int, _arg2:Boolean=false):String{
var _local3:String;
var _local4:int;
var _local5:int;
_local3 = "";
if (_arg2){
_local4 = 0;
while (_local4 < 4) {
_local3 = (_local3 + (hexChars.charAt(((_arg1 >> (((3 - _local4) * 8) + 4)) & 15)) + hexChars.charAt(((_arg1 >> ((3 - _local4) * 8)) & 15))));
_local4++;
};
} else {
_local5 = 0;
while (_local5 < 4) {
_local3 = (_local3 + (hexChars.charAt(((_arg1 >> ((_local5 * 8) + 4)) & 15)) + hexChars.charAt(((_arg1 >> (_local5 * 8)) & 15))));
_local5++;
};
};
return (_local3);
}
public function createBlocks(_arg1:ByteArray):Array{
var _local2:Array;
var _local3:int;
var _local4:int;
var _local5:int;
_local2 = new Array();
_local3 = (_arg1.length * 8);
_local4 = 0xFF;
_local5 = 0;
while (_local5 < _local3) {
_local2[int((_local5 >> 5))] = (_local2[int((_local5 >> 5))] | ((_arg1[(_local5 / 8)] & _local4) << (_local5 % 32)));
_local5 = (_local5 + 8);
};
_local2[int((_local3 >> 5))] = (_local2[int((_local3 >> 5))] | (128 << (_local3 % 32)));
_local2[int(((((_local3 + 64) >>> 9) << 4) + 14))] = _local3;
return (_local2);
}
public function hashBinary(_arg1:ByteArray):String{
var _local2:int;
var _local3:int;
var _local4:int;
var _local5:int;
var _local6:int;
var _local7:int;
var _local8:int;
var _local9:int;
var _local10:Array;
var _local11:int;
var _local12:int;
_local2 = 1732584193;
_local3 = -271733879;
_local4 = -1732584194;
_local5 = 271733878;
_local10 = createBlocks(_arg1);
_local11 = _local10.length;
_local12 = 0;
while (_local12 < _local11) {
_local6 = _local2;
_local7 = _local3;
_local8 = _local4;
_local9 = _local5;
_local2 = ff(_local2, _local3, _local4, _local5, _local10[int((_local12 + 0))], 7, -680876936);
_local5 = ff(_local5, _local2, _local3, _local4, _local10[int((_local12 + 1))], 12, -389564586);
_local4 = ff(_local4, _local5, _local2, _local3, _local10[int((_local12 + 2))], 17, 606105819);
_local3 = ff(_local3, _local4, _local5, _local2, _local10[int((_local12 + 3))], 22, -1044525330);
_local2 = ff(_local2, _local3, _local4, _local5, _local10[int((_local12 + 4))], 7, -176418897);
_local5 = ff(_local5, _local2, _local3, _local4, _local10[int((_local12 + 5))], 12, 1200080426);
_local4 = ff(_local4, _local5, _local2, _local3, _local10[int((_local12 + 6))], 17, -1473231341);
_local3 = ff(_local3, _local4, _local5, _local2, _local10[int((_local12 + 7))], 22, -45705983);
_local2 = ff(_local2, _local3, _local4, _local5, _local10[int((_local12 + 8))], 7, 1770035416);
_local5 = ff(_local5, _local2, _local3, _local4, _local10[int((_local12 + 9))], 12, -1958414417);
_local4 = ff(_local4, _local5, _local2, _local3, _local10[int((_local12 + 10))], 17, -42063);
_local3 = ff(_local3, _local4, _local5, _local2, _local10[int((_local12 + 11))], 22, -1990404162);
_local2 = ff(_local2, _local3, _local4, _local5, _local10[int((_local12 + 12))], 7, 1804603682);
_local5 = ff(_local5, _local2, _local3, _local4, _local10[int((_local12 + 13))], 12, -40341101);
_local4 = ff(_local4, _local5, _local2, _local3, _local10[int((_local12 + 14))], 17, -1502002290);
_local3 = ff(_local3, _local4, _local5, _local2, _local10[int((_local12 + 15))], 22, 1236535329);
_local2 = gg(_local2, _local3, _local4, _local5, _local10[int((_local12 + 1))], 5, -165796510);
_local5 = gg(_local5, _local2, _local3, _local4, _local10[int((_local12 + 6))], 9, -1069501632);
_local4 = gg(_local4, _local5, _local2, _local3, _local10[int((_local12 + 11))], 14, 643717713);
_local3 = gg(_local3, _local4, _local5, _local2, _local10[int((_local12 + 0))], 20, -373897302);
_local2 = gg(_local2, _local3, _local4, _local5, _local10[int((_local12 + 5))], 5, -701558691);
_local5 = gg(_local5, _local2, _local3, _local4, _local10[int((_local12 + 10))], 9, 38016083);
_local4 = gg(_local4, _local5, _local2, _local3, _local10[int((_local12 + 15))], 14, -660478335);
_local3 = gg(_local3, _local4, _local5, _local2, _local10[int((_local12 + 4))], 20, -405537848);
_local2 = gg(_local2, _local3, _local4, _local5, _local10[int((_local12 + 9))], 5, 568446438);
_local5 = gg(_local5, _local2, _local3, _local4, _local10[int((_local12 + 14))], 9, -1019803690);
_local4 = gg(_local4, _local5, _local2, _local3, _local10[int((_local12 + 3))], 14, -187363961);
_local3 = gg(_local3, _local4, _local5, _local2, _local10[int((_local12 + 8))], 20, 1163531501);
_local2 = gg(_local2, _local3, _local4, _local5, _local10[int((_local12 + 13))], 5, -1444681467);
_local5 = gg(_local5, _local2, _local3, _local4, _local10[int((_local12 + 2))], 9, -51403784);
_local4 = gg(_local4, _local5, _local2, _local3, _local10[int((_local12 + 7))], 14, 1735328473);
_local3 = gg(_local3, _local4, _local5, _local2, _local10[int((_local12 + 12))], 20, -1926607734);
_local2 = hh(_local2, _local3, _local4, _local5, _local10[int((_local12 + 5))], 4, -378558);
_local5 = hh(_local5, _local2, _local3, _local4, _local10[int((_local12 + 8))], 11, -2022574463);
_local4 = hh(_local4, _local5, _local2, _local3, _local10[int((_local12 + 11))], 16, 1839030562);
_local3 = hh(_local3, _local4, _local5, _local2, _local10[int((_local12 + 14))], 23, -35309556);
_local2 = hh(_local2, _local3, _local4, _local5, _local10[int((_local12 + 1))], 4, -1530992060);
_local5 = hh(_local5, _local2, _local3, _local4, _local10[int((_local12 + 4))], 11, 1272893353);
_local4 = hh(_local4, _local5, _local2, _local3, _local10[int((_local12 + 7))], 16, -155497632);
_local3 = hh(_local3, _local4, _local5, _local2, _local10[int((_local12 + 10))], 23, -1094730640);
_local2 = hh(_local2, _local3, _local4, _local5, _local10[int((_local12 + 13))], 4, 681279174);
_local5 = hh(_local5, _local2, _local3, _local4, _local10[int((_local12 + 0))], 11, -358537222);
_local4 = hh(_local4, _local5, _local2, _local3, _local10[int((_local12 + 3))], 16, -722521979);
_local3 = hh(_local3, _local4, _local5, _local2, _local10[int((_local12 + 6))], 23, 76029189);
_local2 = hh(_local2, _local3, _local4, _local5, _local10[int((_local12 + 9))], 4, -640364487);
_local5 = hh(_local5, _local2, _local3, _local4, _local10[int((_local12 + 12))], 11, -421815835);
_local4 = hh(_local4, _local5, _local2, _local3, _local10[int((_local12 + 15))], 16, 530742520);
_local3 = hh(_local3, _local4, _local5, _local2, _local10[int((_local12 + 2))], 23, -995338651);
_local2 = ii(_local2, _local3, _local4, _local5, _local10[int((_local12 + 0))], 6, -198630844);
_local5 = ii(_local5, _local2, _local3, _local4, _local10[int((_local12 + 7))], 10, 1126891415);
_local4 = ii(_local4, _local5, _local2, _local3, _local10[int((_local12 + 14))], 15, -1416354905);
_local3 = ii(_local3, _local4, _local5, _local2, _local10[int((_local12 + 5))], 21, -57434055);
_local2 = ii(_local2, _local3, _local4, _local5, _local10[int((_local12 + 12))], 6, 1700485571);
_local5 = ii(_local5, _local2, _local3, _local4, _local10[int((_local12 + 3))], 10, -1894986606);
_local4 = ii(_local4, _local5, _local2, _local3, _local10[int((_local12 + 10))], 15, -1051523);
_local3 = ii(_local3, _local4, _local5, _local2, _local10[int((_local12 + 1))], 21, -2054922799);
_local2 = ii(_local2, _local3, _local4, _local5, _local10[int((_local12 + 8))], 6, 1873313359);
_local5 = ii(_local5, _local2, _local3, _local4, _local10[int((_local12 + 15))], 10, -30611744);
_local4 = ii(_local4, _local5, _local2, _local3, _local10[int((_local12 + 6))], 15, -1560198380);
_local3 = ii(_local3, _local4, _local5, _local2, _local10[int((_local12 + 13))], 21, 1309151649);
_local2 = ii(_local2, _local3, _local4, _local5, _local10[int((_local12 + 4))], 6, -145523070);
_local5 = ii(_local5, _local2, _local3, _local4, _local10[int((_local12 + 11))], 10, -1120210379);
_local4 = ii(_local4, _local5, _local2, _local3, _local10[int((_local12 + 2))], 15, 718787259);
_local3 = ii(_local3, _local4, _local5, _local2, _local10[int((_local12 + 9))], 21, -343485551);
_local2 = (_local2 + _local6);
_local3 = (_local3 + _local7);
_local4 = (_local4 + _local8);
_local5 = (_local5 + _local9);
_local12 = (_local12 + 16);
};
return ((((toHex(_local2) + toHex(_local3)) + toHex(_local4)) + toHex(_local5)));
}
public function tr(_arg1:Function, _arg2:int, _arg3:int, _arg4:int, _arg5:int, _arg6:int, _arg7:int, _arg8:int):int{
var _local9:int;
_local9 = (((_arg2 + int(_arg1(_arg3, _arg4, _arg5))) + _arg6) + _arg8);
return ((rol(_local9, _arg7) + _arg3));
}
public function rol(_arg1:int, _arg2:int):int{
return (((_arg1 << _arg2) | (_arg1 >>> (32 - _arg2))));
}
public function completeHandler(_arg1:Event):void{
loadingStatus = "completed";
removeListeners();
this.gotoAndStop(3);
}
public function ror(_arg1:int, _arg2:int):uint{
var _local3:int;
_local3 = (32 - _arg2);
return (((_arg1 << _local3) | (_arg1 >>> (32 - _local3))));
}
public function gg(_arg1:int, _arg2:int, _arg3:int, _arg4:int, _arg5:int, _arg6:int, _arg7:int):int{
return (tr(g, _arg1, _arg2, _arg3, _arg4, _arg5, _arg6, _arg7));
}
public function ff(_arg1:int, _arg2:int, _arg3:int, _arg4:int, _arg5:int, _arg6:int, _arg7:int):int{
return (tr(f, _arg1, _arg2, _arg3, _arg4, _arg5, _arg6, _arg7));
}
}
}//package
Section 144
//BulletFlame (BulletFlame)
package {
import flash.display.*;
public dynamic class BulletFlame extends MovieClip {
}
}//package
Section 145
//BulletRocket (BulletRocket)
package {
import flash.display.*;
public dynamic class BulletRocket extends MovieClip {
}
}//package
Section 146
//Cartridges (Cartridges)
package {
import flash.display.*;
public dynamic class Cartridges extends MovieClip {
}
}//package
Section 147
//Collision (Collision)
package {
import flash.geom.*;
public class Collision {
public static var stats_numIntersections:int;
static var PolyCollision_LineHit:Line;
public static var IntersectionX:Number = 0;
public static var IntersectionY:Number = 0;
public static var stats_numBBTests:int;
public static var stats_numPolyCollisionTests:int;
public static var closestX:Number = 0;
public static var closestY:Number = 0;
public static var closestInfiniteX:Number = 0;
public static var closestInfiniteY:Number = 0;
public static var main:Main;
public static function FindNearestPathStartPointToPos(_arg1:Number, _arg2:Number):Poly{
var _local5:Poly;
var _local6:Point;
var _local7:*;
var _local3:Poly;
var _local4:Number = 99999999;
for each (_local5 in Game.polygonList) {
if (((_local5.active) && ((_local5.type == Poly.polytype_PATH)))){
_local6 = _local5.GetPoint(0);
_local7 = Utils.Dist2BetweenPoints(_local6.x, _local6.y, _arg1, _arg2);
if (_local7 < _local4){
_local4 = _local7;
_local3 = _local5;
};
};
};
return (_local3);
}
static function SideOfLine(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Number, _arg6:Number):Boolean{
var _local7:Number = DotProduct((_arg3 - _arg1), (_arg4 - _arg2), (_arg5 - _arg1), (_arg6 - _arg2));
if (_local7 < 0){
return (false);
};
return (true);
}
static function GameObjectInPolyBoundingBox(_arg1:GameObj, _arg2:Poly):Boolean{
var _local3:Number = (_arg1.radius + 50);
var _local4:Number = _arg1.xpos;
var _local5:Number = _arg1.ypos;
if (_arg2.boundingRectangle == null){
return (false);
};
stats_numBBTests++;
if (_local4 < (_arg2.boundingRectangle.left - _local3)){
return (false);
};
if (_local4 > (_arg2.boundingRectangle.right + _local3)){
return (false);
};
if (_local5 < (_arg2.boundingRectangle.top - _local3)){
return (false);
};
if (_local5 > (_arg2.boundingRectangle.bottom + _local3)){
return (false);
};
return (true);
}
static function DotProduct(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number):Number{
var _local5:Number = ((_arg1 * _arg3) + (_arg2 * _arg4));
return (_local5);
}
static function PolyCollision(_arg1:GameObj, _arg2:Poly, _arg3:Number, _arg4:Number, _arg5:Number):Boolean{
var _local8:Line;
var _local9:Boolean;
var _local10:Number;
var _local15:Line;
var _local16:int;
var _local17:int;
var _local18:*;
var _local19:Number;
var _local20:Number;
var _local21:Line;
var _local22:Line;
stats_numPolyCollisionTests++;
var _local6:Array = new Array();
var _local7:Array = new Array();
var _local11:Number = (_arg1.xpos + _arg3);
var _local12:Number = (_arg1.ypos + _arg4);
var _local13:Number = _arg5;
var _local14:Number = (_arg5 * _local13);
for each (_local15 in _arg2.lineList) {
_local9 = SideOfLine(_local15.x0, _local15.y0, _local15.x1, _local15.y1, _local11, _local12);
if (_local9 == true){
_local10 = Dist2ToLine(_local15.x0, _local15.y0, _local15.x1, _local15.y1, _local11, _local12);
if (_local10 < _local14){
_local6.push(_local15);
_local7.push(_local10);
};
};
};
_local18 = _local6.length;
_local16 = 0;
while (_local16 < (_local18 - 1)) {
_local17 = _local16;
while (_local17 < _local18) {
_local19 = _local7[_local16];
_local20 = _local7[_local17];
_local21 = _local6[_local16];
_local22 = _local6[_local17];
if (_local20 < _local19){
_local7[_local16] = _local20;
_local7[_local17] = _local19;
_local6[_local16] = _local22;
_local6[_local17] = _local21;
};
_local17++;
};
_local16++;
};
_local16 = 0;
while (_local16 < _local18) {
_local8 = _local6[_local16];
_local9 = SideOfLine(_local8.x0, _local8.y0, _local8.x1, _local8.y1, _local11, _local12);
if (_local9 == true){
_local10 = Dist2ToLine(_local8.x0, _local8.y0, _local8.x1, _local8.y1, _local11, _local12);
if (_local10 < _local14){
stats_numIntersections++;
Intersected(_arg1, _local8, closestX, closestY, _arg3, _arg4, _arg5);
PolyCollision_LineHit = _local8;
return (true);
};
};
return (true);
_local16++;
};
return (false);
}
public static function PlayerEnemyBulletCollision(){
var _local2:GameObj;
var _local3:Number;
var _local1:GameObj = Game.goPlayer;
if (_local1.controlMode == -1){
return;
};
if (_local1.controlMode == 0){
return;
};
if (_local1.invincibleTimer > 0){
return;
};
for each (_local2 in GameObjects.objs) {
if (((_local2.active) && (_local2.colFlag_isEnemyBullet))){
_local3 = (10 * 10);
if (_local1.shieldOn){
_local3 = (30 * 30);
if (Utils.Dist2BetweenPoints(_local1.xpos, _local1.ypos, _local2.xpos, _local2.ypos) < _local3){
_local2.active = false;
_local1.PlayerShieldHitByBullet(_local2);
return;
};
} else {
if (Utils.Dist2BetweenPoints(_local1.xpos, _local1.ypos, _local2.xpos, _local2.ypos) < _local3){
_local2.active = false;
Game.playerHitFloor = true;
return;
};
};
};
};
}
public static function LineLineIntersection(_arg1:Line, _arg2:Line):Boolean{
var _local3:Number = _arg1.x0;
var _local4:Number = _arg1.y0;
var _local5:Number = _arg1.x1;
var _local6:Number = _arg1.y1;
var _local7:Number = _arg2.x0;
var _local8:Number = _arg2.y0;
var _local9:Number = _arg2.x1;
var _local10:Number = _arg2.y1;
var _local11:Number = (_local5 - _local3);
var _local12:Number = (_local9 - _local7);
var _local13:Number = ((_local6 - _local4) / _local11);
var _local14:Number = ((_local10 - _local8) / _local12);
var _local15:Number = (_local4 - (_local13 * _local3));
var _local16:Number = (_local8 - (_local14 * _local7));
var _local17:Number = ((_local15 - _local16) / (_local14 - _local13));
var _local18:Number = (((_local13 * (_local16 - _local15)) / (_local13 - _local14)) + _local15);
if (_arg1.boundingRect.contains(_local17, _local18)){
if (_arg2.boundingRect.contains(_local17, _local18)){
IntersectionX = _local17;
IntersectionY = _local18;
return (true);
};
};
return (false);
}
public static function FindHighestFloorPos(_arg1:Number):Number{
var _local2:Number;
var _local3:Boolean;
var _local4:Poly;
var _local5:Line;
var _local6:Number;
var _local7:Number;
var _local8:Number;
var _local9:Number;
for each (_local4 in Game.polygonList) {
for each (_local5 in _local4.lineList) {
_local6 = _arg1;
_local7 = 0;
if ((((_local6 >= _local5.x0)) && ((_local6 <= _local5.x1)))){
_local8 = ((1 / (_local5.x1 - _local5.x0)) * (_local6 - _local5.x0));
_local9 = (_local5.y0 + (_local5.dy * _local8));
return (_local9);
};
};
};
return (999999);
}
public static function PlayerPickupCollision(){
var _local2:GameObj;
var _local3:Number;
var _local1:GameObj = Game.goPlayer;
for each (_local2 in GameObjects.objs) {
if (((_local2.active) && (_local2.colFlag_canBePickedUp))){
_local3 = (30 * 30);
if (Utils.Dist2BetweenPoints(_local1.xpos, _local1.ypos, _local2.xpos, _local2.ypos) < _local3){
if (_local2.hitFunction != null){
_local2.hitFunction();
};
};
};
};
}
static function Dist2ToLine(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Number, _arg6:Number):Number{
ClosestPointOnLine(_arg1, _arg2, _arg3, _arg4, _arg5, _arg6);
var _local7:Number = (closestX - _arg5);
var _local8:Number = (closestY - _arg6);
return (((_local7 * _local7) + (_local8 * _local8)));
}
public static function BulletEnemyCollision(){
var _local2:GameObj;
var _local3:GameObj;
var _local4:Number;
var _local5:Number;
var _local1:Weapon = Game.GetCurrentWeapon();
for each (_local2 in GameObjects.objs) {
if (((_local2.active) && (_local2.colFlag_isBullet))){
for each (_local3 in GameObjects.objs) {
_local4 = (_local2.xpos - _local3.xpos);
_local5 = (_local2.ypos - _local3.ypos);
if (((((_local3.active) && (_local3.colFlag_isEnemy))) && ((_local3.controlMode < 100)))){
if (_local3.headColBox.contains(_local4, _local5)){
if (_local3.hitFunction != null){
_local3.hitFunction(_local1.damage, true);
};
if (_local2.hitFunction != null){
_local2.hitFunction();
};
return;
};
if (_local3.bodyColBox.contains(_local4, _local5)){
if (_local2.hitFunction != null){
_local2.hitFunction();
};
if (_local3.hitFunction != null){
_local3.hitFunction(_local1.damage, false);
};
return;
};
};
if (((_local3.active) && (_local3.colFlag_isShootable))){
if (_local3.bodyColBox.contains(_local4, _local5)){
if (_local3.hitFunction != null){
_local3.hitFunction(_local1.damage, false);
};
};
};
};
};
};
}
static function DistBetweenPoints(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number):Number{
var _local5:Number = (_arg3 - _arg1);
var _local6:Number = (_arg4 - _arg2);
return (Math.sqrt(((_local5 * _local5) + (_local6 * _local6))));
}
public static function SingleObjectZoneCollision(_arg1:GameObj):Poly{
var _local2:Poly;
for each (_local2 in Game.polygonList) {
if (((_local2.active) && ((_local2.type == Poly.polytype_ZONE)))){
if (GameObjectInPolyBoundingBox(_arg1, _local2)){
if (PointInConvexPoly(_arg1.xpos, _arg1.ypos, _local2.lineList)){
return (_local2);
};
};
};
};
return (null);
}
public static function PointInConvexPoly(_arg1:Number, _arg2:Number, _arg3:Array):Boolean{
var _local5:int;
var _local6:Line;
var _local7:Number;
var _local4:int = _arg3.length;
_local5 = 0;
while (_local5 < _local4) {
_local6 = _arg3[_local5];
_local7 = DotProduct((_local6.x0 - _arg1), (_local6.y0 - _arg2), _local6.nx, _local6.ny);
if (_local7 < 0){
return (false);
};
_local5++;
};
return (true);
}
static function DistBetween(_arg1:GameObj, _arg2:GameObj):Number{
var _local3:Number = (_arg2.xpos - _arg1.xpos);
var _local4:Number = (_arg2.ypos - _arg1.ypos);
return (Math.sqrt(((_local3 * _local3) + (_local4 * _local4))));
}
public static function ClosestPointOnLine(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Number, _arg6:Number):void{
var _local7:Number = (_arg5 - _arg1);
var _local8:Number = (_arg6 - _arg2);
var _local9:Number = (_arg3 - _arg1);
var _local10:Number = (_arg4 - _arg2);
var _local11:Number = ((_local9 * _local9) + (_local10 * _local10));
var _local12:Number = ((_local7 * _local9) + (_local8 * _local10));
var _local13:Number = (_local12 / _local11);
closestInfiniteX = (_arg1 + (_local9 * _local13));
closestInfiniteY = (_arg2 + (_local10 * _local13));
if (_local13 < 0){
_local13 = 0;
};
if (_local13 > 1){
_local13 = 1;
};
closestX = (_arg1 + (_local9 * _local13));
closestY = (_arg2 + (_local10 * _local13));
}
static function Intersected(_arg1:GameObj, _arg2:Line, _arg3:Number, _arg4:Number, _arg5:Number, _arg6:Number, _arg7:Number):void{
var _local14:int;
var _local15:Number;
var _local8 = 50;
var _local9:Number = ((_arg1.oldxpos + _arg5) - _arg3);
var _local10:Number = ((_arg1.oldypos + _arg6) - _arg4);
_local9 = (_local9 / Number(_local8));
_local10 = (_local10 / Number(_local8));
var _local11:Number = (_arg1.xpos + _arg5);
var _local12:Number = (_arg1.ypos + _arg6);
var _local13:Number = (_arg7 * _arg7);
_local14 = 0;
while (_local14 < _local8) {
_local11 = (_local11 + _local9);
_local12 = (_local12 + _local10);
_local15 = Dist2ToLine(_arg2.x0, _arg2.y0, _arg2.x1, _arg2.y1, _local11, _local12);
if (_local15 > _local13){
_arg1.xpos = (_local11 - _arg5);
_arg1.ypos = (_local12 - _arg6);
return;
};
_local14++;
};
}
static function SideOfLine1(_arg1:Line, _arg2:Number, _arg3:Number):Boolean{
var _local4:Number = DotProduct((_arg1.x1 - _arg1.x0), (_arg1.y1 - _arg1.y0), (_arg2 - _arg1.x0), (_arg3 - _arg1.y0));
if (_local4 < 0){
return (false);
};
return (true);
}
public static function Update(){
main = Game.main;
stats_numIntersections = 0;
stats_numBBTests = 0;
stats_numPolyCollisionTests = 0;
BulletEnemyCollision();
PlayerPickupCollision();
}
public static function PlayerEnemyCollision(){
var _local2:GameObj;
var _local3:Number;
var _local1:GameObj = Game.goPlayer;
if (_local1.controlMode == -1){
return;
};
if (_local1.controlMode == 0){
return;
};
if (_local1.invincibleTimer > 0){
return;
};
if (_local1.shieldOn){
return;
};
for each (_local2 in GameObjects.objs) {
if (((_local2.active) && (_local2.colFlag_isEnemy))){
_local3 = (_local2.radius * _local2.radius);
if (Utils.Dist2BetweenPoints(_local1.xpos, _local1.ypos, _local2.xpos, _local2.ypos) < _local3){
if (_local2.hitFunction != null){
_local2.hitFunction();
};
Game.playerHitFloor = true;
return;
};
};
};
}
public static function PlayerDeathZoneCollision():void{
var _local2:Poly;
if (Game.goPlayer.colFlag_playercanbekilled == false){
return;
};
var _local1:GameObj = Game.goPlayer;
for each (_local2 in Game.polygonList) {
if (((((_local2.active) && ((_local2.type == Poly.polytype_ZONE)))) && ((_local2.subTypeName == "Death")))){
if (GameObjectInPolyBoundingBox(_local1, _local2)){
if (PointInConvexPoly(_local1.xpos, _local1.ypos, _local2.lineList)){
_local1.PlayerHitEnemy(null);
return;
};
};
};
};
}
static function DistToLine(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Number, _arg6:Number):Number{
ClosestPointOnLine(_arg1, _arg2, _arg3, _arg4, _arg5, _arg6);
var _local7:Number = (closestX - _arg5);
var _local8:Number = (closestY - _arg6);
var _local9:Number = Math.sqrt(((_local7 * _local7) + (_local8 * _local8)));
return (_local9);
}
static function Dist2Between(_arg1:GameObj, _arg2:GameObj):Number{
var _local3:Number = (_arg2.xpos - _arg1.xpos);
var _local4:Number = (_arg2.ypos - _arg1.ypos);
return (((_local3 * _local3) + (_local4 * _local4)));
}
public static function FindPathByIndex(_arg1:int):Poly{
var _local3:Poly;
var _local2:int;
for each (_local3 in Game.polygonList) {
if (((_local3.active) && ((_local3.type == Poly.polytype_PATH)))){
if (_local2 == _arg1){
return (_local3);
};
_local2++;
};
};
return (null);
}
static function Dist2BetweenPoints(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number):Number{
var _local5:Number = (_arg3 - _arg1);
var _local6:Number = (_arg4 - _arg2);
return (((_local5 * _local5) + (_local6 * _local6)));
}
}
}//package
Section 148
//ContactListener (ContactListener)
package {
import Box2D.Common.Math.*;
import Box2D.Collision.*;
import Box2D.Dynamics.*;
public class ContactListener extends b2ContactListener {
function MagnetCollision(_arg1:b2ContactPoint){
var _local3:PhysObj_BodyUserData;
var _local2:b2Body = _arg1.shape1.GetBody();
_local3 = _local2.GetUserData();
var _local4:b2Body = _arg1.shape2.GetBody();
var _local5:PhysObj_BodyUserData = _local4.GetUserData();
if (_local3.type.match("magnet")){
_local5.instance.collideFunction = Game.CollideWithMagnet;
_local5.instance.collidetimer = 10;
_local5.instance.collideWithInstance = _local3.instance;
};
if (_local5.type.match("magnet")){
_local3.instance.collideFunction = Game.CollideWithMagnet;
_local3.instance.collidetimer = 10;
_local3.instance.collideWithInstance = _local5.instance;
};
}
override public function Add(_arg1:b2ContactPoint):void{
var _local2:GameObj;
var _local3:PhysObj_Instance;
var _local8:b2Vec2;
var _local9:Number;
var _local4:b2Body = _arg1.shape1.GetBody();
var _local5:PhysObj_BodyUserData = _local4.GetUserData();
var _local6:b2Body = _arg1.shape2.GetBody();
var _local7:PhysObj_BodyUserData = _local6.GetUserData();
Game.numCollisionTests++;
if (_local5.type.match("animal")){
_local8 = _local4.GetWorldCenter();
_local9 = (_local8.y * Game.p2w);
if (_local9 < Game.highestPoint){
Game.highestPoint = _local9;
};
};
if (_local7.type.match("animal")){
_local8 = _local6.GetWorldCenter();
_local9 = (_local8.y * Game.p2w);
if (_local9 < Game.highestPoint){
Game.highestPoint = _local9;
};
};
}
function BallBalloonCollision(_arg1:PhysObj_BodyUserData, _arg2:PhysObj_BodyUserData){
var _local3:PhysObj_Instance;
var _local4:b2Vec2;
if (_arg2.instance.collidetimer == 0){
_arg2.instance.collideFunction = Game.RemoveObj_Standard;
_arg2.instance.collidetimer = 10;
_local3 = _arg1.instance;
_local3.ball_hitcount++;
_local4 = _arg2.instance.GetBodyWorldPos(0);
Game.InitMessage(("Combo x " + _local3.ball_hitcount), (_local4.x * Game.p2w), (_local4.y * Game.p2w));
Game.numBalloonsActive--;
};
}
}
}//package
Section 149
//CPMStarLoaderScreen (CPMStarLoaderScreen)
package {
import flash.display.*;
public dynamic class CPMStarLoaderScreen extends MovieClip {
public var loader:MovieClip;
public var buttonSkipCPMStarAd:SimpleButton;
public var adBox:MovieClip;
}
}//package
Section 150
//Debug (Debug)
package {
public class Debug {
public static var debugMode:int = 0;
public static function IsSet(_arg1:int):Boolean{
if ((debugMode & _arg1) == 0){
return (false);
};
return (true);
}
public static function RenderCollision(){
var _local3:int;
var _local4:uint;
var _local5:Line;
var _local6:Line;
var _local8:Poly;
return;
}
public static function RenderPlayerInfo(){
var _local1:String;
}
}
}//package
Section 151
//Defs (Defs)
package {
import flash.geom.*;
public class Defs {
public static const zpos_PICKUP = 1100;
public static const zpos_ENEMY = 1000;
public static const displayarea_w = 800;
public static const zpos_OVERLAY = 500;
public static const zpos_PLAYER = 1000;
public static const fps:Number = 33;
public static const zpos_FAR = 10000;
public static const zpos_BACKGROUND = 10000;
public static const displayarea_h = 500;
public static const platformW2 = 15;
public static var screenRect:Rectangle = new Rectangle(0, 0, displayarea_w, displayarea_h);
public static var pointZero:Point = new Point(0, 0);
}
}//package
Section 152
//DisplayObj (DisplayObj)
package {
import flash.display.*;
import flash.events.*;
import flash.geom.*;
import flash.text.*;
public class DisplayObj {
var frames:Array;
var flags:int;
public var frame:int;
public function DisplayObj(_arg1:MovieClip, _arg2:Number, _arg3:int):void{
flags = _arg3;
frame = 0;
if (_arg1 != null){
CreateBitmapsFromMovieClip(_arg1, flags);
};
}
public function GetHeight():Number{
return (frames[frame].bitmap.height);
}
public function GetBitmap():Bitmap{
return (frames[frame].bitmap);
}
function CreateAsciiStringTable():Array{
var _local1:Array = new Array();
_local1.push("");
_local1.push("");
_local1.push("");
_local1.push("");
_local1.push("");
_local1.push("");
_local1.push("");
_local1.push("");
_local1.push("");
_local1.push("");
_local1.push("");
_local1.push("");
_local1.push("");
_local1.push("");
_local1.push("");
_local1.push("");
_local1.push("");
_local1.push("");
_local1.push("");
_local1.push("");
_local1.push("");
_local1.push("");
_local1.push("");
_local1.push("");
_local1.push("");
_local1.push("");
_local1.push("");
_local1.push("");
_local1.push("");
_local1.push("");
_local1.push("");
_local1.push("");
_local1.push(" ");
_local1.push("!");
_local1.push("'");
_local1.push("#");
_local1.push("$");
_local1.push("%");
_local1.push("&");
_local1.push("'");
_local1.push("(");
_local1.push(")");
_local1.push("*");
_local1.push("+");
_local1.push(",");
_local1.push("-");
_local1.push(".");
_local1.push("/");
_local1.push("0");
_local1.push("1");
_local1.push("2");
_local1.push("3");
_local1.push("4");
_local1.push("5");
_local1.push("6");
_local1.push("7");
_local1.push("8");
_local1.push("9");
_local1.push(":");
_local1.push(";");
_local1.push("<");
_local1.push("=");
_local1.push(">");
_local1.push("?");
_local1.push("@");
_local1.push("A");
_local1.push("B");
_local1.push("C");
_local1.push("D");
_local1.push("E");
_local1.push("F");
_local1.push("G");
_local1.push("H");
_local1.push("I");
_local1.push("J");
_local1.push("K");
_local1.push("L");
_local1.push("M");
_local1.push("N");
_local1.push("O");
_local1.push("P");
_local1.push("Q");
_local1.push("R");
_local1.push("S");
_local1.push("T");
_local1.push("U");
_local1.push("V");
_local1.push("W");
_local1.push("X");
_local1.push("Y");
_local1.push("Z");
_local1.push("[");
_local1.push("\\");
_local1.push("]");
_local1.push("^");
_local1.push("_");
_local1.push("'");
_local1.push("a");
_local1.push("b");
_local1.push("c");
_local1.push("d");
_local1.push("e");
_local1.push("f");
_local1.push("g");
_local1.push("h");
_local1.push("i");
_local1.push("j");
_local1.push("k");
_local1.push("l");
_local1.push("m");
_local1.push("n");
_local1.push("o");
_local1.push("p");
_local1.push("q");
_local1.push("r");
_local1.push("s");
_local1.push("t");
_local1.push("u");
_local1.push("v");
_local1.push("w");
_local1.push("x");
_local1.push("y");
_local1.push("z");
_local1.push("{");
_local1.push("|");
_local1.push("}");
_local1.push("~");
return (_local1);
}
public function RenderAt(_arg1:BitmapData, _arg2:Number, _arg3:Number, _arg4:Boolean=false):void{
frames[frame].RenderAt(_arg1, _arg2, _arg3, _arg4);
}
public function SetFrame(_arg1:int){
frame = _arg1;
if (frame < 0){
frame = 0;
};
if (frame >= frames.length){
frame = (frames.length - 1);
};
}
public function CreateBitmapsFromMovieClip(_arg1:MovieClip, _arg2:int):void{
var _local5:int;
var _local6:int;
var _local7:int;
var _local8:int;
var _local9:Matrix;
var _local10:Rectangle;
var _local11:Bitmap;
var _local12:BitmapData;
var _local13:Bitmap;
var _local14:BitmapData;
var _local16:*;
var _local17:Number;
var _local18:Number;
var _local19:Number;
var _local20:Boolean;
var _local21:Number;
var _local22:*;
var _local23:Number;
var _local24:Point;
var _local25:Point;
var _local26:Point;
var _local27:Point;
var _local28:ColorTransform;
var _local29:ColorTransform;
var _local3:Boolean;
var _local4:Boolean;
if (_arg2 == 3){
_local4 = true;
_arg2 = 0;
};
if (_arg2 == 2){
_local3 = true;
_arg2 = 0;
};
if (_arg2 == 3){
};
frames = new Array();
_arg1.gotoAndStop(0);
var _local15 = 32;
_local5 = 0;
while (_local5 < _arg1.totalFrames) {
_local16 = new DisplayObjFrame();
_local16.bitmaps = new Array();
_local16.burnedbitmaps = new Array();
_local16.xoffsets = new Array();
_local16.yoffsets = new Array();
_local16.mat = new Matrix();
_local16.colTrans = new ColorTransform();
if (_arg2 == 3){
_local17 = 1000;
_local10 = _arg1.getBounds(null);
_local18 = _local10.width;
_local19 = (_local18 + _local17);
_local20 = true;
_local21 = 0;
do {
_local9 = new Matrix();
_local9.translate(-(_local21), 0);
_local7 = _local21;
_local8 = 0;
_local16.xoffsets.push(Number(_local21));
_local16.yoffsets.push(Number(_local8));
_local21 = (_local21 + _local17);
_local22 = _local17;
_local19 = (_local19 - _local17);
if (_local19 < _local17){
_local20 = false;
_local22 = _local19;
};
trace(((("split: w:" + _local22) + " xoff:") + _local21));
_local11 = new Bitmap();
_local12 = new BitmapData(_local22, _arg1.height, true, 0);
_local12.draw(_arg1, _local9);
_local11.bitmapData = _local12;
_local16.bitmaps.push(_local11);
} while (_local20);
} else {
if (_arg2 == 1){
_local6 = 0;
while (_local6 < _local15) {
_local23 = (((Math.PI * 2) / Number(_local15)) * Number(_local6));
_local23 = -(_local23);
_local23 = (_local23 + (Math.PI / 2));
_local10 = _arg1.getBounds(null);
_local9 = new Matrix();
_local9.rotate(_local23);
_local9.translate(_local10.width, _local10.height);
_local24 = _local9.transformPoint(new Point(_local10.left, _local10.top));
_local25 = _local9.transformPoint(new Point(_local10.right, _local10.top));
_local26 = _local9.transformPoint(new Point(_local10.right, _local10.bottom));
_local27 = _local9.transformPoint(new Point(_local10.left, _local10.bottom));
if (((!((_arg1.width == 0))) && (!((_arg1.height == 0))))){
_local12 = new BitmapData((_local10.width * 2), (_local10.height * 2), true, 0);
_local12.draw(_arg1, _local9);
_local11 = new Bitmap(_local12);
_local16.bitmaps.push(_local11);
_local28 = new ColorTransform(1, 1, 1, 1, -100, -100, -100, 0);
_local14 = new BitmapData((_local10.width * 2), (_local10.height * 2), true, 0);
_local14.draw(_arg1, _local9, _local28);
_local13 = new Bitmap(_local14);
_local16.burnedbitmaps.push(_local13);
_local7 = (_local10.width / 2);
_local8 = (_local10.height / 2);
_local16.xoffsets.push(Number(-(_local10.width)));
_local16.yoffsets.push(Number(-(_local10.height)));
} else {
_local16.bitmaps.push(null);
_local16.burnedbitmaps.push(null);
_local16.xoffsets.push(0);
_local16.yoffsets.push(0);
};
_local6++;
};
} else {
_local10 = _arg1.getBounds(null);
_local10.x = Math.floor(_local10.x);
_local10.y = Math.floor(_local10.y);
_local10.width = Math.ceil(_local10.width);
_local10.height = Math.ceil(_local10.height);
_local10.x = (_local10.x - 4);
_local10.y = (_local10.y - 4);
_local10.width = (_local10.width + 8);
_local10.height = (_local10.height + 8);
_local8 = Math.floor(_local8);
_local9 = new Matrix();
_local7 = _local10.left;
_local8 = _local10.top;
_local9.translate(-(_local7), -(_local8));
_local16.xoffsets.push(Number(_local7));
_local16.yoffsets.push(Number(_local8));
if (((!((_arg1.width == 0))) && (!((_arg1.height == 0))))){
_local11 = new Bitmap();
_local12 = new BitmapData(_local10.width, _local10.height, true, 0);
_local12.draw(_arg1, _local9);
_local11.bitmapData = _local12;
_local16.bitmaps.push(_local11);
} else {
_local16.bitmaps.push(null);
};
if (_local3){
_local10 = _arg1.getBounds(null);
_local10.x = Math.floor(_local10.x);
_local10.y = Math.floor(_local10.y);
_local10.width = Math.floor(_local10.width);
_local10.height = Math.floor(_local10.height);
_local10.x = (_local10.x - 4);
_local10.y = (_local10.y - 4);
_local10.width = (_local10.width + 8);
_local10.height = (_local10.height + 8);
_local9 = new Matrix();
_local7 = _local10.left;
_local8 = _local10.top;
_local9.translate(-(_local7), -(_local8));
_local9.scale(-1, 1);
_local9.translate(_local10.width, 0);
_local16.xoffsets.push(Number(-(_local10.right)));
_local16.yoffsets.push(Number(_local8));
if (((!((_arg1.width == 0))) && (!((_arg1.height == 0))))){
_local11 = new Bitmap();
_local12 = new BitmapData(_local10.width, _local10.height, true, 0);
_local12.draw(_arg1, _local9);
_local11.bitmapData = _local12;
_local16.bitmaps.push(_local11);
} else {
_local16.bitmaps.push(null);
};
} else {
if (_local4){
_local29 = new ColorTransform(0.1, 0.1, 0.1, 0.3);
_local10 = _arg1.getBounds(null);
_local10.x = Math.floor(_local10.x);
_local10.y = Math.floor(_local10.y);
_local10.width = Math.floor((_local10.width + 1));
_local10.height = Math.floor((_local10.height + 1));
_local8 = Math.floor(_local8);
_local9 = new Matrix();
_local7 = _local10.left;
_local8 = _local10.top;
_local9.translate(-(_local7), -(_local8));
_local16.xoffsets.push(Number(_local7));
_local16.yoffsets.push(Number(_local8));
if (((!((_arg1.width == 0))) && (!((_arg1.height == 0))))){
_local11 = new Bitmap();
_local12 = new BitmapData(_local10.width, _local10.height, true, 0);
_local12.draw(_arg1, _local9, _local29);
_local11.bitmapData = _local12;
_local16.bitmaps.push(_local11);
} else {
_local16.bitmaps.push(null);
};
};
};
};
};
frames.push(_local16);
_arg1.nextFrame();
_local5++;
};
}
public function GetFrameWidth(_arg1:int):Number{
return (frames[_arg1].bitmap.width);
}
public function GetWidth():Number{
return (frames[frame].bitmap.width);
}
public function RenderAtColTrans(_arg1:BitmapData, _arg2:Number, _arg3:Number, _arg4:ColorTransform, _arg5:Boolean=false):void{
frames[frame].RenderAtColTrans(_arg1, _arg2, _arg3, _arg4, _arg5);
}
public function CreateFont(_arg1:TextFormat):void{
var _local2:int;
var _local3:int;
var _local4:int;
var _local5:int;
var _local6:Matrix;
var _local7:Rectangle;
var _local8:Bitmap;
var _local9:BitmapData;
var _local11:TextField;
var _local12:*;
frames = new Array();
var _local10:Array = CreateAsciiStringTable();
_local2 = 0;
while (_local2 < _local10.length) {
_local11 = new TextField();
_local11.textColor = 4294967295;
_local11.selectable = false;
_local11.embedFonts = true;
_local11.autoSize = TextFieldAutoSize.LEFT;
_local11.x = 0;
_local11.y = 0;
_local11.text = _local10[_local2];
_local11.setTextFormat(_arg1);
_local12 = new DisplayObjFrame();
_local12.bitmaps = new Array();
_local12.xoffsets = new Array();
_local12.yoffsets = new Array();
_local12.mat = new Matrix();
_local12.colTrans = new ColorTransform();
_local7 = _local11.getBounds(null);
_local6 = new Matrix();
_local6.translate(-(_local7.x), -(_local7.y));
_local12.xoffsets.push(0);
_local12.yoffsets.push(0);
_local8 = new Bitmap();
_local9 = new BitmapData(_local7.width, _local7.height, true, 0);
_local9.draw(_local11, _local6, null, null, null, true);
_local8.bitmapData = _local9;
_local12.bitmaps.push(_local8);
frames.push(_local12);
_local2++;
};
}
public function GetMaxFrames():int{
return (frames.length);
}
public function GetYOffset():Number{
return (frames[frame].yoffset);
}
public function GetFrame():int{
return (frame);
}
public function GetXOffset():Number{
return (frames[frame].xoffset);
}
public function RenderAtRot(_arg1:BitmapData, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Boolean):void{
if (_arg5){
frames[frame].RenderAtRotBurned(_arg1, _arg2, _arg3, _arg4);
} else {
frames[frame].RenderAtRot(_arg1, _arg2, _arg3, _arg4);
};
}
public function GetScaledBitmap():Bitmap{
return (frames[frame].scaledBitmap);
}
}
}//package
import flash.display.*;
import flash.events.*;
import flash.geom.*;
class DisplayObjFrame {
public var mat:Matrix;
public var bitmaps:Array;
public var yoffsets:Array;
public var xoffsets:Array;
public var colTrans:ColorTransform;
public var burnedbitmaps:Array;
private function DisplayObjFrame(){
}
public function RenderAtRotScaled(_arg1:BitmapData, _arg2:Number, _arg3:Number, _arg4:Boolean=false, _arg5:Number=1, _arg6:Number=0, _arg7:ColorTransform=null, _arg8:Boolean=false):void{
var _local9:Bitmap = bitmaps[0];
var _local10:Number = xoffsets[0];
var _local11:Number = yoffsets[0];
if (_arg4){
_local9 = bitmaps[1];
_local10 = xoffsets[1];
_local11 = yoffsets[1];
};
mat.identity();
mat.translate(_local10, _local11);
mat.rotate(_arg6);
mat.translate(-(_local10), -(_local11));
mat.scale(_arg5, _arg5);
mat.translate((_arg2 + (_local10 * _arg5)), (_arg3 + (_local11 * _arg5)));
if (_local9 != null){
if (_local9.bitmapData != null){
_arg1.draw(_local9.bitmapData, mat, _arg7, null, null, _arg8);
};
};
}
public function RenderAtScaled(_arg1:BitmapData, _arg2:Number, _arg3:Number, _arg4:Boolean=false, _arg5:Number=1):void{
var _local6:Bitmap = bitmaps[0];
var _local7:Number = xoffsets[0];
var _local8:Number = yoffsets[0];
if (_arg4){
_local6 = bitmaps[1];
_local7 = xoffsets[1];
_local8 = yoffsets[1];
};
mat.identity();
mat.scale(_arg5, _arg5);
mat.translate((_arg2 + (_local7 * _arg5)), (_arg3 + (_local8 * _arg5)));
if (_local6 != null){
if (_local6.bitmapData != null){
_arg1.draw(_local6.bitmapData, mat);
};
};
}
public function RenderAt(_arg1:BitmapData, _arg2:Number, _arg3:Number, _arg4:Boolean=false):void{
var _local5:Bitmap = bitmaps[0];
var _local6:Number = xoffsets[0];
var _local7:Number = yoffsets[0];
if (_arg4){
_local5 = bitmaps[1];
_local6 = xoffsets[1];
_local7 = yoffsets[1];
};
_arg1.copyPixels(_local5.bitmapData, new Rectangle(0, 0, _local5.width, _local5.height), new Point((_arg2 + _local6), (_arg3 + _local7)), null, null, true);
}
public function RenderAtSplit(_arg1:BitmapData, _arg2:Number, _arg3:Number):void{
var _local4:int;
var _local5:Bitmap;
var _local6:Number;
var _local7:Number;
_local4 = 0;
while (_local4 < bitmaps.length) {
_local5 = bitmaps[_local4];
_local6 = xoffsets[_local4];
_local7 = yoffsets[_local4];
_arg1.copyPixels(_local5.bitmapData, new Rectangle(0, 0, _local5.width, _local5.height), new Point((_arg2 + _local6), (_arg3 + _local7)), null, null, true);
_local4++;
};
}
public function RenderAtColTrans(_arg1:BitmapData, _arg2:Number, _arg3:Number, _arg4:ColorTransform, _arg5:Boolean=false):void{
var _local6:Bitmap = bitmaps[0];
var _local7:Number = xoffsets[0];
var _local8:Number = yoffsets[0];
if (_arg5){
_local6 = bitmaps[1];
_local7 = xoffsets[1];
_local8 = yoffsets[1];
};
mat.identity();
mat.translate((_arg2 + _local7), (_arg3 + _local8));
if (_local6 != null){
if (_local6.bitmapData != null){
_arg1.draw(_local6.bitmapData, mat, _arg4);
};
};
}
public function RenderAtAdditive(_arg1:BitmapData, _arg2:Number, _arg3:Number, _arg4:Number):void{
var _local5:Bitmap = bitmaps[0];
var _local6:Number = xoffsets[0];
var _local7:Number = yoffsets[0];
mat.identity();
mat.translate((_arg2 + _local6), (_arg3 + _local7));
colTrans.alphaMultiplier = _arg4;
if (_local5 != null){
if (_local5.bitmapData != null){
_arg1.draw(_local5.bitmapData, mat, colTrans, "add");
};
};
}
public function RenderAtAlpha(_arg1:BitmapData, _arg2:Number, _arg3:Number, _arg4:Number):void{
var _local5:Bitmap = bitmaps[0];
var _local6:Number = xoffsets[0];
var _local7:Number = yoffsets[0];
mat.identity();
mat.translate((_arg2 + _local6), (_arg3 + _local7));
colTrans.alphaMultiplier = _arg4;
if (_local5 != null){
if (_local5.bitmapData != null){
_arg1.draw(_local5.bitmapData, mat, colTrans);
};
};
}
public function RenderAtRot(_arg1:BitmapData, _arg2:Number, _arg3:Number, _arg4:Number):void{
_arg4 = (_arg4 - 0.01);
var _local5:int = bitmaps.length;
_arg4 = ((Number(_local5) / (Math.PI * 2)) * _arg4);
var _local6:int = _arg4;
while (_local6 < 0) {
_local6 = (_local6 + _local5);
};
while (_local6 > (_local5 - 1)) {
_local6 = (_local6 - _local5);
};
_local6 = ((_local5 - 1) - _local6);
var _local7:Bitmap = bitmaps[_local6];
var _local8:Number = xoffsets[_local6];
var _local9:Number = yoffsets[_local6];
_arg1.copyPixels(_local7.bitmapData, new Rectangle(0, 0, _local7.width, _local7.height), new Point((_arg2 + _local8), (_arg3 + _local9)));
}
}
Section 153
//end_animation (end_animation)
package {
import flash.display.*;
public dynamic class end_animation extends MovieClip {
public var buttonQuit:SimpleButton;
public var buttonSubmitHighscore:SimpleButton;
public var buttonContinue:SimpleButton;
public function end_animation(){
addFrameScript(599, frame600);
}
function frame600(){
stop();
}
}
}//package
Section 154
//enemy1 (enemy1)
package {
import flash.display.*;
public dynamic class enemy1 extends MovieClip {
}
}//package
Section 155
//enemy1_2 (enemy1_2)
package {
import flash.display.*;
public dynamic class enemy1_2 extends MovieClip {
}
}//package
Section 156
//enemy2 (enemy2)
package {
import flash.display.*;
public dynamic class enemy2 extends MovieClip {
}
}//package
Section 157
//enemy2_2 (enemy2_2)
package {
import flash.display.*;
public dynamic class enemy2_2 extends MovieClip {
}
}//package
Section 158
//enemy3 (enemy3)
package {
import flash.display.*;
public dynamic class enemy3 extends MovieClip {
}
}//package
Section 159
//enemy4 (enemy4)
package {
import flash.display.*;
public dynamic class enemy4 extends MovieClip {
}
}//package
Section 160
//enemy5 (enemy5)
package {
import flash.display.*;
public dynamic class enemy5 extends MovieClip {
}
}//package
Section 161
//enemy5_2 (enemy5_2)
package {
import flash.display.*;
public dynamic class enemy5_2 extends MovieClip {
}
}//package
Section 162
//ExplosiveBarrel (ExplosiveBarrel)
package {
import flash.display.*;
public dynamic class ExplosiveBarrel extends MovieClip {
}
}//package
Section 163
//ExternalData (ExternalData)
package {
import flash.events.*;
import flash.net.*;
import flash.system.*;
public class ExternalData {
static var xmlLoader:URLLoader;
public static var constants:Object;
static var loader:URLLoader;
public static var xml:XML;
static var xxx:XML = <data>
<constants>
<constant name="hoseangdamp" value="0"/>
<constant name="hoselindamp" value="0"/>
<constant name="hoselowerang" value="-7"/>
<constant name="hoseupperang" value="7"/>
<constant name="hosedensity" value="0.4"/>
</constants>
<gameconstants>
<constant name="swingdist" value="30"/>
<constant name="swingforce" value="4"/>
<constant name="swingreleaseforce" value="0.2"/>
</gameconstants>
<!-- *************************************************************************************** -->
<!-- START OF EASY LEVELS -->
<!-- *************************************************************************************** -->
<level name="Easiest" category="0" fillframe="1" surfaceframe="5" surfacethickness="10" type="none" opponents="" win="1" exclusivechar="1">
<times gold="10" silver="20"/>
</level>
</data>
;
public static var gameconstants:Object;
static var cb:Function;
public static function GetConstants(){
var _local1:*;
var _local2:int;
var _local3:XML;
constants = new Object();
_local1 = xml.constants.constant.length();
_local2 = 0;
while (_local2 < _local1) {
_local3 = xml.constants.constant[_local2];
constants[_local3.@name] = _local3.@value;
_local2++;
};
gameconstants = new Object();
_local1 = xml.gameconstants.constant.length();
_local2 = 0;
while (_local2 < _local1) {
_local3 = xml.gameconstants.constant[_local2];
gameconstants[_local3.@name] = _local3.@value;
_local2++;
};
}
public static function Load(_arg1:Function){
cb = _arg1;
XmlLoadedInternal();
}
public static function poo(_arg1:Event){
trace(loader.data.status);
}
public static function OutputString(_arg1:String){
System.setClipboard(_arg1);
}
static function XmlLoadedInternal(){
var _local1:int;
XML.ignoreWhitespace = true;
xml = new XML(xxx);
GetConstants();
cb();
}
public static function xmlLoaded(_arg1:Event){
var _local2:int;
XML.ignoreWhitespace = true;
xml = new XML(_arg1.target.data);
GetConstants();
cb();
}
}
}//package
Section 164
//FarBackgrounds (FarBackgrounds)
package {
import flash.display.*;
public dynamic class FarBackgrounds extends MovieClip {
}
}//package
Section 165
//fireworks (fireworks)
package {
import flash.display.*;
public dynamic class fireworks extends MovieClip {
}
}//package
Section 166
//flame (flame)
package {
import flash.display.*;
public dynamic class flame extends MovieClip {
}
}//package
Section 167
//fog_1 (fog_1)
package {
import flash.display.*;
public dynamic class fog_1 extends MovieClip {
public function fog_1(){
addFrameScript(0, frame1);
}
function frame1(){
stop();
}
}
}//package
Section 168
//fogaudio (fogaudio)
package {
import flash.media.*;
public dynamic class fogaudio extends Sound {
}
}//package
Section 169
//Font20 (Font20)
package {
import flash.text.*;
public dynamic class Font20 extends Font {
}
}//package
Section 170
//Game (Game)
package {
import flash.display.*;
import flash.events.*;
import flash.geom.*;
import flash.media.*;
import Box2D.Common.Math.*;
import Box2D.Collision.*;
import Box2D.Dynamics.*;
import Box2D.Dynamics.Joints.*;
import Box2D.Collision.Shapes.*;
import Box2D.Common.*;
import Box2D.Dynamics.Contacts.*;
import com.newgrounds.components.*;
import flash.ui.*;
public class Game {
static const levelFinishedState_WON = 1;
static const levelState_SplatTimeStart = 6;
static const levelState_Play = 1;
static const colCategory_Background:int = 1;
static const levelState_Complete = 4;
static const levelState_Dead = 7;
static const colCategory_Pellet:int = 4;
static const levelFinishedState_NOT = 0;
static const levelState_Editor = 3;
static const levelState_EndScreen = 5;
static const levelFinishedState_LOST = 2;
static const colCategory_Ball:int = 2;
static const levelState_Null = 2;
static const levelState_LevelStart = 0;
public static var scrollCX:Number;
public static var scrollCY:Number;
public static var backWheelUpTimer:int = 0;
public static var bikeWheelUpTimer:int;
static var bgFrame:int = 0;
static var rainbow_thickness:Number;
static var rainbow_timer1:Number;
static var rainbow_timer3:Number;
static var rainbow_timer4:Number;
public static var playerHitFloorTimerMax:int;
static var foundWeapon:int;
static var rainbow_timer0:Number;
static var player_calculated_boostmul:Number;
static var rainbow_timer2:Number;
static var maxZombiesAllowed:Number;
static var currentStartPointIndex:int;
static var trodInBloodMaxTime:int;
static var pickupGenTimer:int = 0;
public static var currentWorldID:int = 0;
static var roadFrameList:Array = new Array(0, 1, 0, 0, 1);
static var zt_A:int = 0;
static var zt_B:int = 1;
static var zt_C:int = 2;
static var vehicleGenTimerMax:int = 0;
public static var maxFallSpeed;
static var physObjs:PhysObjs;
static var numAnimalsReady:int = 0;
static var currentWeaponSlot:int;
static var numLevels:int;
static var currentScore:Number;
public static var frontWheelieTimer:int = 0;
static var scrollXvel:Number = 15;
public static var boostTimerMax:int;
public static var playerHitFloorMaxRot:Number;
static var secondaryWeapon:int;
public static var LevelUpdateCallback:Object;
static var canShootPellet:Boolean;
static var switchFlag:int = 0;
static var scrollToDX:Number = 0;
static var powerupTimer:int;
static var scrollMaxVel:Number;
public static var levelForwardSomersaults:int = 0;
static var numBikes:int;
static var zposOffset:Number = 0;
public static var oldPlayerRot:Number = 0;
static var scrollToDY:Number = 0;
static var version:Number = 1;
static var shieldBonusActive:Boolean;
static var shootHeldTime:int = 0;
static var difftime_min:Number = 0;
public static var bikeWheelDownTimer:int;
static var bgFrameList:Array = new Array(0, 1, 2, 3, 3, 1, 0, 2, 1, 0);
static var numKills:int;
static var deathBonusActive:Boolean;
static var blockerGenTimerMax:int = 0;
public static var polygonList:Array;
static var numCreds:int;
public static var timesList:Array;
static var playerHeadGO:GameObj;
static var currentWeapon:int;
static var sitelocked:Boolean = true;
static var numLevelHeadshotKills:int;
static var numLives:int;
static var vehicleGenTimer:int = 0;
static var usedebug:Boolean = false;
static var w2p:Number = (1 / p2w);
public static var playerHitFloorTimer:int;
static var hoseTimer:int = 0;
static var totalPickupsGenerated:int = 0;
static var shakeCamDX:Number = 0;
static var minspeed:Number = 15;
public static var aiCarTypes:Array;
static var mouseox:Number = 0;
static var shakeCamDY:Number = 0;
static var testMode:int = 0;
static var init_powerupAdder:Number = 1;
static var maxspeed:Number = 40;
public static var boostTimer:int;
static var levels:Array;
static var init_powerupMax:Number = 10;
public static var backWheelDown:Boolean;
static var numPickupsActive:int = 0;
static var numPickupsGenerated:int = 0;
static var previousStaticPoints:Array;
static var currentLevel:int;
static var playerOldX:Number = 0;
static var shakeCamToX:Number = 0;
static var shakeCamToY:Number = 0;
static var playerX:Number = 0;
static var scrollVel:Number;
public static var boostLevel:Number;
static var levelStateCount:int;
static var canUseObject:Boolean = false;
static var numBallsActiveMax:int = 5;
static var main:Main;
public static var playerType:int = 0;
static var maxZombieSpeed:Number = 0;
static var multiplier:int;
public static var boostMultiplier:int;
static var mousetimer:int = 0;
static var numVehiclesActive:int = 0;
static var upgrades:Array;
static var lastGeneratedGameObj:GameObj;
static var shakeCamTimer:int = 50;
static var weapons:Array;
static var goPlayer:GameObj;
static var blockerGenTimer:int = 0;
static var pause:Boolean;
static var shakeCamTimerMax:int = 50;
static var titleTimer1:Number = 0;
static var bgTimer:Number = 0;
public static var playerRotLeaveGround:Number;
public static var playerRotMode:int;
static var levelFinishedState:int;
static var farbgScrollX:Number = 0;
static var panelRect:Rectangle = new Rectangle(200, 10, 200, 10);
static var levelTimer:int;
static var player_acc:Number = 200;
public static var scrollYOi:Number;
static var zombieLevelTypes:Array;
static var goExit:GameObj;
static var plungerHeldTimer:int = 0;
static var secondaryWeaponNumBullets:int;
static var roadFrame:int = 0;
static var numHeadshotKills:int;
static var scrollXMax:Number = 0;
static var zt_FAST:int = 3;
public static var gravity;
public static var playerHitFloor:Boolean;
public static var numAnimalsLost:int;
static var zt_BIG:int = 4;
static var shootMode:int = 0;
public static var scrollXOi:Number;
static var levelStateTimerMax:int;
static var powerupTimerMax:int;
public static var frontWheelDown:Boolean;
public static var frontWheelUpTimer:int = 0;
static var scrollAcc:Number;
public static var scrollXO:Number;
static var shakeCamY:Number = 0;
static var swapTimerMax:int;
static var rainbow_dir:Number;
public static var scrollXa:Number;
public static var levelBackSomersaults:int = 0;
public static var scrollXi:int;
static var killAllBonusActive:Boolean;
public static var scrollYO:Number;
static var currentPowerup:int;
static var currentProjectileType:int = 0;
static var shakeCamX:Number = 0;
static var numPickupsTotal:int = 0;
public static var scrollYa:Number;
public static var scrollYi:Number;
static var scrollScale:Number = 1;
static var floorColorTimer:Number = 0;
static var plasma_x1:Number = 64;
static var player_maxvel:Number = 30;
static var plasma_x3:Number = 192;
static var physGravity:Number = (600 * w2p);
public static var levelFrontWheelieTime:int = 0;
static var hoseMode:int = 0;
static var mouseJoint:b2MouseJoint = null;
static var plasma_x0:Number = 128;
static var pauseGameplayInput:Boolean;
static var plasma_x2:Number = 192;
static var raceTimer:int;
static var p2w:Number = 1;
static var totalPickupsCollected:int = 0;
static var plasma_y3:Number = 100;
static var plasma_y0:Number = 128;
static var numPigsSacrificed:int = 0;
static var rainbow_startx:Number;
public static var levelWheelieTime:int = 0;
static var plasma_y2:Number = 64;
static var rainbow_starty:Number;
static var player_calculated_brake:Number;
static var vgt_max:Number = 300;
public static var levelAirTime:int = 0;
static var roadPos:Number = 0;
public static var scrollH:Number;
public static var playerCarType:int;
static var numBallsActive:int = 0;
public static var achievements:Achievements;
static var bgScrollX:Number = 0;
static var scrollXPos:Number = 0;
public static var scrollW:Number;
public static var scrollX:Number;
public static var scrollY:Number;
static var soundon:Boolean = true;
static var numZombiesKilledWithBarrel:int = 0;
static var floorColorTimer1:Number = 0;
static var cash:int;
static var difftime_add:Number = 1;
static var numPickupsCollected:int = 0;
static var pickupGenTimerMax:int = 0;
static var plasma_y1:Number = 64;
public static var playerRot:Number = 0;
static var plasmaTime:Number = 0;
static var testString:String = "";
static var player_calculated_angvel:Number;
static var dustAccum:Number = 0;
static var backgroundSoundTimer:int;
public static var highestPoint:Number;
public static var numCollisionTests:int;
static var rainbow_dirchange:Number;
static var panelRect1:Rectangle = new Rectangle(200, 3, 200, 5);
public static var currentHighestPoint:Number;
static var physNumIterations:int = 10;
static var levelState:int;
static var numWeapons:int = 5;
static var numBalloonsActive:int = 0;
static var physObjInstances:PhysObj_Instances;
static var scrollXvelMax:Number = 15;
static var levelTimerMax:int;
static var level_instances:Array;
static var player_calculated_maxvel:Number;
public static var playerRotCount:int;
public static var world:b2World;
static var barrelGenTimer:int = 0;
static var player_calculated_acc:Number;
static var foundWeaponLevelList:Array = new Array(-1, -1, 1, 4, 7, 10, 14, 18, 22, 26, 30);
static var zsortoffset:Number = 0;
static var plungerMaxTime:int = 33;
static var goEntrance:GameObj;
public static var maxBoostMultiplier:int = 5;
static var cursorY:Number = 0;
static var secondaryWeaponFiredTimer:int;
static var groundBody:b2Body;
public static var bikeWheelDown:Boolean;
static var titleTimer:Number = 0;
public static var wheelieTimer:int = 0;
static var cursorX:Number = 0;
static var numLevelKills:int;
static var levelStateTimer:int;
static var currentGameMusic:int = 0;
static var lanePositions:Array;
static var scrollMaxX;
static var scrollMaxY;
static var startPoints:Array;
public static var boostMode:int;
static var pickupBonusActive:Boolean;
static var roadScrollX:Number = 0;
static var vgt_min:Number = 80;
static var difftime_max:Number = 4950;
static var currentBikeIndex:int = 0;
public static function RemoveObj_Standard(_arg1:PhysObj_Instance){
physObjInstances.Remove(_arg1);
}
static function RenderBackgroundObjs(_arg1:BitmapData){
var _local2:GameObj;
for each (_local2 in GameObjects.objs) {
if (((((_local2.active) && (_local2.visible))) && (_local2.colFlag_isBackgroundObj))){
_local2.Render(_arg1);
};
};
}
public static function RemoveObj_BallInHopper(_arg1:PhysObj_Instance){
physObjInstances.Remove(_arg1);
}
public static function ApplyImpulseToObjectsFromPoint(_arg1:PhysObj_Instance, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Number):void{
var _local6:Number;
var _local7:b2Body;
var _local8:PhysObj_BodyUserData;
var _local9:PhysObj_Instance;
var _local10:int;
var _local11:b2Vec2;
var _local12:Number;
_local7 = world.GetBodyList();
while (_local7) {
if (_local7.GetUserData() != -1){
_local8 = _local7.GetUserData();
_local9 = _local8.instance;
if (_local9 != null){
_local10 = _local9.colflags;
if (_local9 != _arg1){
_local11 = new b2Vec2((_local7.GetWorldCenter().x - _arg2), (_local7.GetWorldCenter().y - _arg3));
_local6 = _local11.Length();
if (_local10 == 0){
if (_local6 <= _arg5){
_local11.Normalize();
_local12 = Utils.ScaleTo(0, _arg4, 0, _arg5, (_arg5 - _local6));
_local11.Multiply(_local12);
_local7.ApplyImpulse(_local11, _local7.GetWorldCenter());
};
} else {
if (_local10 == 1){
} else {
if (_local10 == 2){
_local9.BreakObject(_local6);
};
};
};
};
};
};
_local7 = _local7.GetNext();
};
}
static function AddPhysObjAt(_arg1:String, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:String="", _arg6:String=""):PhysObj_Instance{
var _local8:PhysObj_Body;
var _local9:PhysObj_Graphic;
var _local7:PhysObj = physObjs.FindByName(_arg1);
for each (_local8 in _local7.bodies) {
if (_local8.graphics.length != 0){
_local9 = _local8.graphics[0];
InitPhysicsGO(_arg2, _arg3, _local9, _local9.graphicID, _local9.frame, 1000, Utils.DegToRad(_arg4), _arg6);
};
};
return (null);
}
static function GetInitialStartPoint():Point{
var _local2:Point;
var _local1:Point;
var _local3:Number = 999999;
for each (_local2 in startPoints) {
if (_local2.x < _local3){
_local3 = _local2.x;
_local1 = _local2;
};
};
return (_local1);
}
public static function CollideWithCannon(_arg1:PhysObj_Instance){
DoCannon(_arg1);
_arg1.collideFunction = null;
_arg1.collidetimer = 0;
}
static function NextLevel():void{
currentLevel++;
StartLevelPlay();
}
public static function InitLevel(){
InitLevel1();
}
static function UpdateBoost(){
if (boostMode == 1){
boostTimer--;
if (boostTimer <= 0){
BoostFinished();
};
};
}
static function UpdateControl(){
var _local3:int;
var _local4:PhysObj_Instance;
var _local5:b2Vec2;
return;
}
public static function StartLevelPlay2():void{
var _local5:int;
var _local6:GameObj;
var _local10:int;
KeyReader.InitOnce(main.stage);
MusicPlayer.StopMusic();
main.InitStageForGame();
var _local1:MedalPopup = new MedalPopup();
main.addChild(_local1);
var _local2:Level = GetCurrentLevel();
startPoints = new Array();
Particles.Reset();
InitBox2D();
previousStaticPoints = new Array();
mouseJoint = null;
goExit = null;
goEntrance = null;
numPickupsActive = 0;
numPickupsTotal = 0;
pickupBonusActive = true;
shieldBonusActive = true;
deathBonusActive = true;
killAllBonusActive = false;
numPickupsCollected = 0;
numPickupsGenerated = 0;
GameObjects.ClearAll();
physObjInstances = new PhysObj_Instances();
var _local3:Number = 100;
var _local4:Number = 100;
if (startPoints.length != 0){
_local3 = GetInitialStartPoint().x;
_local4 = GetInitialStartPoint().y;
};
pause = false;
pauseGameplayInput = false;
playerHitFloor = false;
playerHitFloorTimer = 0;
bikeWheelDown = false;
ResetBoost();
levelAirTime = 0;
levelWheelieTime = 0;
levelFrontWheelieTime = 0;
levelBackSomersaults = 0;
levelForwardSomersaults = 0;
levelTimer = 0;
playerOldX = 0;
playerX = 0;
dustAccum = 0;
numBallsActive = 0;
numPigsSacrificed = 0;
goPlayer = GameObjects.AddObj(200, 300, 0);
goPlayer.InitPlayer();
numAnimalsLost = 0;
roadPos = 0;
numVehiclesActive = 0;
InitVehicleGen();
playerHitFloor = false;
InitLevelState(levelState_LevelStart);
scrollXPos = 0;
scrollXMax = 10000;
scrollXMax = (scrollXMax + (currentLevel * 1000));
if (scrollXMax > 20000){
scrollXMax = 20000;
};
var _local7:int = currentLevel;
if (_local7 > 50){
_local7 = 50;
};
maxZombiesAllowed = (5 + int((_local7 * 0.3)));
if (maxZombiesAllowed > 30){
maxZombiesAllowed = 30;
};
vehicleGenTimerMax = (30 - (_local7 * 5));
if (vehicleGenTimerMax < 0){
vehicleGenTimerMax = 0;
};
maxZombieSpeed = (7 + (_local7 * 0.3));
if (maxZombieSpeed > 14){
maxZombieSpeed = 14;
};
trodInBloodMaxTime = 100;
swapTimerMax = 6;
currentWeaponSlot = 0;
backgroundSoundTimer = 0;
numLevelHeadshotKills = 0;
numLevelKills = 0;
StartLevelSounds();
secondaryWeaponNumBullets = 0;
secondaryWeaponFiredTimer = 0;
if (currentWeapon < secondaryWeapon){
_local10 = currentWeapon;
currentWeapon = secondaryWeapon;
secondaryWeapon = _local10;
};
var _local8:Weapon = GetCurrentWeapon();
var _local9:Weapon = GetSecondaryWeapon();
goPlayer.numBullets = _local8.clipSize;
secondaryWeaponNumBullets = _local9.clipSize;
playerHeadGO = null;
}
public static function RemoveObj_BubbleSplat(_arg1:PhysObj_Instance){
}
static function StartLevelSounds(){
var _local1:SoundChannel;
_local1 = SoundPlayer.GetSoundChannelByName("crowd");
SoundPlayer.SetSoundChannelVolume(_local1, 0.5);
_local1 = SoundPlayer.GetSoundChannelByName("footstep");
SoundPlayer.SetSoundChannelVolume(_local1, 1);
}
static function CreatePhysObjInstanceAt(_arg1:String, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:String="", _arg6:String=""):PhysObj_Instance{
var _local7:PhysObj_Instance = new PhysObj_Instance();
_local7.typeName = _arg1;
_local7.x = _arg2;
_local7.y = _arg3;
_local7.rot = _arg4;
_local7.bodies = new Array();
_local7.instanceName = _arg5;
_local7.initParams = _arg6;
return (_local7);
}
static function CountGameObjs1():int{
var _local2:GameObj;
var _local1:int;
for each (_local2 in GameObjects.objs) {
if (_local2.active){
_local1++;
};
};
return (_local1);
}
public static function CollideWithSpringboard(_arg1:PhysObj_Instance){
var _local2:Number = _arg1.collideWithInstance.GetBodyAngle(0);
_local2 = (_local2 - (Math.PI / 2));
var _local3:Number = 2;
var _local4:Number = (Math.cos(_local2) * _local3);
var _local5:Number = (Math.sin(_local2) * _local3);
_arg1.ApplyImpulse(_local4, _local5);
_arg1.collideWithInstance.TriggerPhysObj_Springboard();
_arg1.collideFunction = null;
_arg1.collidetimer = 0;
}
static function InitBoost(){
boostMode = 1;
boostTimer = (Defs.fps * 10);
boostTimerMax = boostTimer;
}
static function BackgroundPointCollision(_arg1:Number, _arg2:Number):Boolean{
var _local3:Number;
var _local4:Number;
var _local5:uint;
_local3 = (_arg1 - scrollX);
_local4 = (_arg2 - scrollY);
if (_local3 < 0){
return (false);
};
if (_local4 < 0){
return (false);
};
if (_local3 >= 600){
return (false);
};
if (_local4 >= 600){
return (false);
};
_local5 = main.scrollScreenBD.getPixel32(_local3, _local4);
if (_local5 != 0){
return (true);
};
return (false);
}
public static function InitInitialZombies(){
var _local1:int;
var _local2:GameObj;
_local1 = 0;
while (_local1 < 200) {
_local2 = GameObjects.AddObj(0, 0, 0);
_local2.InitStartZombie();
_local1++;
};
}
static function UpdateMouseControl(){
var _local1:Number = cursorX;
var _local2:Number = cursorY;
cursorX = (cursorX + ((MouseControl.x - cursorX) * 0.4));
cursorY = (cursorY + ((MouseControl.y - cursorY) * 0.4));
}
static function UpdatePhysObjs():void{
var _local1:PhysObj_Instance;
for each (_local1 in physObjInstances.list) {
_local1.Update();
};
}
public static function BackWheelIsDown():void{
backWheelDown = true;
}
static function SwapWeapons():void{
var _local1:int = goPlayer.numBullets;
var _local2:int = goPlayer.firedTimer;
var _local3:int = currentWeapon;
currentWeapon = secondaryWeapon;
secondaryWeapon = _local3;
currentWeaponSlot = (1 - currentWeaponSlot);
var _local4:Weapon = GetCurrentWeapon();
goPlayer.numBullets = secondaryWeaponNumBullets;
goPlayer.firedTimer = 0;
secondaryWeaponNumBullets = _local1;
secondaryWeaponFiredTimer = _local2;
}
static function RenderCursor(){
var _local1:BitmapData;
var _local2:int;
var _local3:int;
if (TitleScreenState.showingInstructions){
return;
};
_local1 = main.screenBD;
_local2 = GraphicObjects.GetIndexByName("Cursors");
_local3 = 0;
if (canUseObject){
_local3 = 2;
};
GraphicObjects.RenderAt(_local2, _local3, _local1, MouseControl.x, MouseControl.y);
}
static function InitFloor(){
var _local1:b2BodyDef;
var _local2:b2Body;
var _local3:b2PolygonDef;
var _local4:Point;
var _local5:Point;
var _local6:Point;
var _local7:Point;
var _local8:Point;
var _local9:int;
var _local15:PhysLine;
var _local16:Array;
var _local17:int;
var _local18:int;
var _local19:Number;
var _local20:Number;
var _local21:Number;
var _local22:Number;
var _local10:PhysObj_BodyUserData = new PhysObj_BodyUserData();
var _local11:Number = 50;
var _local12:Level = GetCurrentLevel();
var _local13:b2FilterData = new b2FilterData();
_local13.categoryBits = 1;
_local13.maskBits = 15;
var _local14:b2FilterData = new b2FilterData();
_local14.categoryBits = 2;
_local14.maskBits = 2;
for each (_local15 in _local12.lines) {
_local16 = _local15.points;
_local17 = _local15.type;
if (_local17 <= 0){
if (_local16.length >= 2){
_local9 = 0;
while (_local9 < _local16.length) {
_local5 = _local16[_local9].clone();
_local18 = (_local9 + 1);
_local18 = (_local18 % _local16.length);
_local6 = _local16[_local18].clone();
_local7 = _local6.clone();
_local8 = _local5.clone();
_local19 = Math.atan2((_local6.y - _local5.y), (_local6.x - _local5.x));
_local19 = (_local19 + (Math.PI / 2));
_local20 = 5;
_local21 = (Math.cos(_local19) * _local20);
_local22 = (Math.sin(_local19) * _local20);
_local7.x = (_local7.x + _local21);
_local7.y = (_local7.y + _local22);
_local8.x = (_local8.x + _local21);
_local8.y = (_local8.y + _local22);
_local1 = new b2BodyDef();
_local1.position.Set(0, 0);
_local2 = world.CreateBody(_local1);
if (_local2 != null){
_local3 = new b2PolygonDef();
_local3.filter = _local13;
if (_local17 == 1){
_local3.filter = _local14;
};
_local3.vertexCount = 4;
_local3.vertices[0].Set((_local5.x * w2p), (_local5.y * w2p));
_local3.vertices[1].Set((_local6.x * w2p), (_local6.y * w2p));
_local3.vertices[2].Set((_local7.x * w2p), (_local7.y * w2p));
_local3.vertices[3].Set((_local8.x * w2p), (_local8.y * w2p));
_local3.friction = 1;
if (_local17 == 1){
_local3.friction = 0;
};
_local3.restitution = 0.2;
_local3.density = 1;
_local2.CreateShape(_local3);
_local2.SetUserData(_local10);
};
_local9++;
};
};
};
};
}
public static function InitLevelState(_arg1:int){
levelState = _arg1;
levelStateTimer = 0;
if (levelState == levelState_LevelStart){
InitInitialZombies();
goPlayer.PlayerSetStartMode();
};
if (levelState == levelState_Complete){
levelStateTimer = (levelStateTimerMax = (Defs.fps * 3));
goPlayer.controlMode = 101;
};
if (levelState == levelState_SplatTimeStart){
levelStateTimer = (Defs.fps * 2);
};
if (levelState == levelState_EndScreen){
};
if (levelState == levelState_Play){
raceTimer = 0;
levelStateTimer = (Defs.fps * 4);
};
if (levelState == levelState_Dead){
levelStateTimer = (Defs.fps * 3);
SubmitStats();
};
if (levelState == levelState_Editor){
PhysEditor.InitEditor();
PhysEditor.currentLevel = currentLevel;
};
}
static function LevelFailed(){
InitLevelState(levelState_Null);
TitleScreenState.InitLevelFailScreen();
}
static function InitSideFlowers(){
var _local1:int;
var _local2:Number;
var _local3:GameObj;
_local2 = 0;
_local1 = 0;
while (_local1 < 20) {
_local3 = GameObjects.AddObj(20, _local2, 0);
_local3.InitSideFlower();
_local3 = GameObjects.AddObj((640 - 20), _local2, 0);
_local3.InitSideFlower();
_local2 = (_local2 + (600 / 20));
_local1++;
};
}
static function InitMessage(_arg1:String, _arg2:Number=320, _arg3:Number=100){
var _local4:GameObj;
_local4 = GameObjects.AddObj(0, 0, 100);
_local4.InitTextMessage(_arg1, _arg2, _arg3);
}
public static function DoPortal(_arg1:PhysObj_Instance){
var _local4:String;
var _local5:PhysObj_Instance;
var _local6:b2Vec2;
var _local7:b2Vec2;
var _local8:GameObj;
var _local2:Number = _arg1.GetBodyAngularVelocity(0);
var _local3:b2Vec2 = _arg1.GetBodyLinearVelocity(0);
trace(("portal name " + _arg1.portalName));
if (_arg1.portalName == "portal_entry01"){
_local4 = "portal_exit01";
};
if (_arg1.portalName == "portal_entry02"){
_local4 = "portal_exit02";
};
if (_arg1.portalName == "portal_entry03"){
_local4 = "portal_exit03";
};
if (_arg1.portalName == "portal_entry04"){
_local4 = "portal_exit04";
};
if (_arg1.portalName == "portal_entry05"){
_local4 = "portal_exit05";
};
for each (_local5 in physObjInstances.list) {
if (_local5.typeName == _local4){
_local6 = _local5.GetBodyWorldPos(0);
_local7 = _arg1.GetBodyWorldPos(0);
_local8 = GameObjects.AddObj((_local7.x * p2w), (_local7.y * p2w), 100);
_local8.InitSparks(true);
_arg1.SetXForm(_local6.x, _local6.y, 0);
_arg1.SetAngularVelocity(0, _local2);
_arg1.SetLinearVelocity(_local3.x, _local3.y);
_local8 = GameObjects.AddObj((_local6.x * p2w), (_local6.y * p2w), 100);
_local8.InitSparks(false);
SoundPlayer.Play("portalwav");
};
};
}
static function GetLevelAward(_arg1:Level):int{
var _local2 = -1;
if (_arg1.complete){
_local2 = 0;
if (_arg1.bestTimeTotal < _arg1.silverTime){
_local2 = 1;
};
if (_arg1.bestTimeTotal < _arg1.goldTime){
_local2 = 2;
};
};
return (_local2);
}
static function BoostFinished(){
boostMode = 0;
boostTimer = 0;
boostMultiplier = 0;
}
static function UpdateScroll(){
farbgScrollX = (farbgScrollX + (scrollXvel / 10));
bgScrollX = (bgScrollX + scrollXvel);
roadScrollX = (roadScrollX + scrollXvel);
scrollXPos = (scrollXPos + scrollXvel);
if (scrollXPos >= scrollXMax){
scrollXPos = scrollXMax;
if (levelState == levelState_Play){
InitLevelState(levelState_Complete);
};
};
scrollXvel = (scrollXvel + 0.5);
if (scrollXvel > 15){
scrollXvel = 15;
};
}
static function AlignWithPreviousVerts(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Number):Point{
var _local9:Point;
var _local10:Number;
var _local11:Number;
var _local6:Matrix = new Matrix();
_local6.rotate(_arg5);
var _local7:Point = new Point(_arg1, _arg2);
var _temp1 = _local6.transformPoint(_local7);
_local7 = _local6.transformPoint(_local7);
_temp1.x = (_local7.x + _arg3);
_local7.y = (_local7.y + _arg4);
var _local8:Number = (2 * w2p);
for each (_local9 in previousStaticPoints) {
if (Math.abs((_local9.x - _local7.x)) < _local8){
if (Math.abs((_local9.y - _local7.y)) < _local8){
_local10 = (_local9.x - _local7.x);
_local11 = (_local9.y - _local7.y);
return (new Point(_local10, _local11));
};
};
};
previousStaticPoints.push(_local7.clone());
return (null);
}
static function DoEndLevelStuff(){
var _local1:int;
foundWeapon = -1;
_local1 = 0;
while (_local1 < foundWeaponLevelList.length) {
if (foundWeaponLevelList[_local1] == currentLevel){
foundWeapon = _local1;
weapons[_local1].available = true;
if (weapons[_local1].name == "chainsaw"){
Lic.Newgrounds_UnlockMedal("Shredder");
};
};
_local1++;
};
if (currentLevel == (10 - 2)){
Lic.Newgrounds_UnlockMedal("Zombieland");
};
if (currentLevel == (20 - 2)){
Lic.Newgrounds_UnlockMedal("Marathon");
};
if (currentLevel == (30 - 2)){
Lic.Newgrounds_UnlockMedal("Zomg!");
};
if (numLevelKills == numLevelHeadshotKills){
Lic.Newgrounds_UnlockMedal("Zoller");
};
}
public static function Init(_arg1:Main){
main = _arg1;
currentScore = 0;
multiplier = 1;
numLevels = 8;
currentLevel = 0;
currentGameMusic = 0;
playerType = 0;
InitWeapons();
ResetGame();
}
public static function InitGame(){
Debug.debugMode = 0;
numLives = 3;
polygonList = new Array();
startPoints = new Array();
currentStartPointIndex = 0;
currentLevel = 0;
pause = true;
cash = 0;
LoadLevels();
Player.InitOnce();
SaveData.Load();
zposOffset = 0;
InitBackgroundSounds();
numHeadshotKills = 0;
numKills = 0;
currentScore = 0;
}
static function GetLastLevelAward(_arg1:Level):int{
var _local2 = -1;
if (_arg1.complete){
_local2 = 0;
if (_arg1.lastTimeTotal < _arg1.silverTime){
_local2 = 1;
};
if (_arg1.lastTimeTotal < _arg1.goldTime){
_local2 = 2;
};
};
return (_local2);
}
static function RenderBox2D():void{
var _local4:int;
var _local5:b2Body;
var _local6:b2Shape;
var _local7:b2Vec2;
var _local8:Number;
var _local9:*;
var _local10:b2PolygonShape;
var _local11:Array;
var _local12:int;
var _local13:int;
var _local14:b2Vec2;
var _local15:b2Vec2;
var _local16:Matrix;
var _local17:Point;
var _local18:Point;
var _local19:b2CircleShape;
var _local20:Number;
if (Debug.IsSet(1) == false){
return;
};
var _local1:Number = scrollX;
var _local2:Number = scrollY;
var _local3:Number = p2w;
_local5 = world.GetBodyList();
while (_local5) {
_local7 = _local5.GetPosition();
_local8 = _local5.GetAngle();
_local6 = _local5.GetShapeList();
while (_local6) {
_local9 = _local6.GetType();
if (_local9 == b2Shape.e_polygonShape){
_local10 = b2PolygonShape(_local6);
_local11 = _local10.GetVertices();
_local12 = _local10.GetVertexCount();
_local4 = 0;
while (_local4 < _local12) {
_local13 = (_local4 + 1);
if (_local13 >= _local12){
_local13 = 0;
};
_local14 = _local11[_local4].Copy();
_local15 = _local11[_local13].Copy();
_local16 = new Matrix();
_local16.rotate(_local8);
_local17 = new Point(_local14.x, _local14.y);
_local18 = new Point(_local15.x, _local15.y);
_local17 = _local16.transformPoint(_local17);
_local18 = _local16.transformPoint(_local18);
_local14.x = _local17.x;
_local14.y = _local17.y;
_local15.x = _local18.x;
_local15.y = _local18.y;
_local14.Add(_local7);
_local15.Add(_local7);
Utils.RenderDotLine(main.scrollScreenBD, ((_local14.x * _local3) - _local1), ((_local14.y * _local3) - _local2), ((_local15.x * _local3) - _local1), ((_local15.y * _local3) - _local2), 50, 4294967295);
_local4++;
};
};
if (_local9 == b2Shape.e_circleShape){
_local19 = b2CircleShape(_local6);
_local20 = (_local19.GetRadius() * _local3);
Utils.RenderCircle(main.scrollScreenBD, ((_local7.x * _local3) - _local1), ((_local7.y * _local3) - _local2), _local20, 4294967295);
};
_local6 = _local6.GetNext();
};
_local5 = _local5.GetNext();
};
}
static function GetCurrentWeapon():Weapon{
return (weapons[currentWeapon]);
}
static function InitBackgroundSounds(){
SoundPlayer.Reset();
SoundPlayer.Play("sfx_crowd", 0, 999999, "crowd");
SoundPlayer.Play("sfx_chainsaw", 0, 999999, "chainsaw");
SoundPlayer.Play("sfx_footstep", 0, 999999, "footstep");
backgroundSoundTimer = 0;
}
static function RenderTitleScreen(){
}
public static function ZeroStuntTimers():void{
bikeWheelDownTimer = 0;
bikeWheelUpTimer = 0;
frontWheelieTimer = 0;
wheelieTimer = 0;
playerHitFloorTimer = 0;
backWheelUpTimer = 0;
frontWheelUpTimer = 0;
}
public static function RemoveObj_KillGuinea(_arg1:PhysObj_Instance){
SoundPlayer.Play("baddie");
SoundPlayer.PlayRandomBetween("guineadie01", "guineadie03", 1);
Game.numBallsActive--;
Game.numPigsSacrificed++;
physObjInstances.Remove(_arg1);
}
public static function DoCannon(_arg1:PhysObj_Instance){
var _local2:PhysObj_Instance = physObjInstances.FindByTypeName("cannon");
var _local3:b2Vec2 = _arg1.GetBodyWorldPos(0);
var _local4:b2Vec2 = _local2.GetBodyWorldPos(0);
var _local5:Number = 50;
var _local6:Number = _local2.GetBodyAngle(0);
_local6 = (_local6 - (Math.PI / 2));
var _local7:Number = (Math.cos(_local6) * _local5);
var _local8:Number = (Math.sin(_local6) * _local5);
var _local9:PhysObj_Instance = AddPhysObjAt("cannonball", (_local4.x * p2w), (_local4.y * p2w), 0, "", "");
_local9.ApplyImpulse(_local7, _local8);
_local2.cannon_firing = true;
SoundPlayer.Play("cannonwav");
numBallsActive--;
numPigsSacrificed++;
physObjInstances.Remove(_arg1);
}
static function dist(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number):Number{
var _local5:Number = (_arg3 - _arg1);
var _local6:Number = (_arg4 - _arg2);
return (Math.sqrt(((_local5 * _local5) + (_local6 * _local6))));
}
static function Reload(_arg1:Function){
ExternalData.Load(_arg1);
}
static function Render(){
var _local1:BitmapData;
var _local2:int;
var _local3:int;
var _local4:Number;
var _local5:Number;
var _local6:int;
var _local8:int;
var _local9:int;
var _local11:int;
var _local12:int;
var _local13:int;
var _local14:Graphics;
if (pause){
return;
};
if (levelState == levelState_EndScreen){
return;
};
if (levelState == levelState_Null){
return;
};
if (levelState == levelState_Editor){
_local14 = main.fillScreenMC.graphics;
_local14.clear();
PhysEditor.RenderEditor();
return;
};
_local1 = main.scrollScreenBD;
var _local7:Level = GetCurrentLevel();
_local8 = bgScrollX;
_local9 = roadScrollX;
_local8 = (_local8 % 800);
_local9 = (_local9 % 800);
var _local10:int = farbgScrollX;
_local10 = (_local10 % 800);
_local1.fillRect(Defs.screenRect, 4280295456);
_local2 = GraphicObjects.GetIndexByName("sky");
GraphicObjects.RenderAt(_local2, 0, _local1, 0, 0);
bgFrame = (bgScrollX / 800);
bgFrame = (bgFrame % bgFrameList.length);
roadFrame = (roadScrollX / 800);
roadFrame = (roadFrame % roadFrameList.length);
_local13 = ((currentLevel / 4) % 4);
if (_local13 == 0){
_local11 = bgFrameList[bgFrame];
_local12 = bgFrameList[((bgFrame + 1) % bgFrameList.length)];
_local2 = GraphicObjects.GetIndexByName("FarBackgrounds");
GraphicObjects.RenderAt(_local2, _local11, _local1, -(_local8), 0);
GraphicObjects.RenderAt(_local2, _local12, _local1, (-(_local8) + 800), 0);
_local11 = roadFrameList[roadFrame];
_local12 = roadFrameList[((roadFrame + 1) % roadFrameList.length)];
_local2 = GraphicObjects.GetIndexByName("RoadBackgrounds");
GraphicObjects.RenderAt(_local2, _local11, _local1, -(_local9), 200);
GraphicObjects.RenderAt(_local2, _local12, _local1, (-(_local9) + 800), 200);
} else {
if (_local13 == 1){
_local11 = bgFrameList[bgFrame];
_local12 = bgFrameList[((bgFrame + 1) % bgFrameList.length)];
_local2 = GraphicObjects.GetIndexByName("subwayBackgrounds");
GraphicObjects.RenderAt(_local2, _local11, _local1, -(_local8), 200);
GraphicObjects.RenderAt(_local2, _local12, _local1, (-(_local8) + 800), 200);
} else {
if (_local13 == 2){
_local11 = roadFrameList[roadFrame];
_local12 = roadFrameList[((roadFrame + 1) % roadFrameList.length)];
_local2 = GraphicObjects.GetIndexByName("RoadFairgroundBackgrounds");
GraphicObjects.RenderAt(_local2, _local11, _local1, -(_local9), 200);
GraphicObjects.RenderAt(_local2, _local12, _local1, (-(_local9) + 800), 200);
} else {
if (_local13 == 3){
_local11 = bgFrameList[bgFrame];
_local12 = bgFrameList[((bgFrame + 1) % bgFrameList.length)];
_local2 = GraphicObjects.GetIndexByName("shoppingmall_background");
GraphicObjects.RenderAt(_local2, _local11, _local1, -(_local8), 200);
GraphicObjects.RenderAt(_local2, _local12, _local1, (-(_local8) + 800), 200);
};
};
};
};
GameObjects.Render(main.scrollScreenBD);
main.screenBD.copyPixels(main.scrollScreenBD, Defs.screenRect, Defs.pointZero, null, null, true);
RenderPanel();
}
public static function ResetGame(){
var _local1:Weapon;
currentScore = 0;
totalPickupsCollected = 0;
totalPickupsGenerated = 0;
currentLevel = 0;
for each (_local1 in weapons) {
_local1.available = false;
};
weapons[0].available = true;
weapons[1].available = true;
currentWeapon = 1;
secondaryWeapon = 0;
currentWeaponSlot = 0;
}
static function UpdateGenerators(){
var _local1:int;
var _local2:Array;
var _local3:int;
var _local4:int;
var _local5:GameObj;
var _local6:int;
vehicleGenTimer--;
if (vehicleGenTimer < 0){
if (CountZombies() < maxZombiesAllowed){
_local1 = currentLevel;
if (_local1 >= zombieLevelTypes.length){
_local1 = (zombieLevelTypes.length - 1);
};
_local2 = zombieLevelTypes[_local1];
_local3 = _local2[Utils.RandBetweenInt(0, _local2.length)];
if (_local3 == zt_A){
_local4 = Utils.RandBetweenInt(0, 1);
};
if (_local3 == zt_B){
_local4 = Utils.RandBetweenInt(2, 3);
};
if (_local3 == zt_C){
_local4 = Utils.RandBetweenInt(4, 5);
};
if (_local3 == zt_FAST){
_local4 = 6;
};
if (_local3 == zt_BIG){
_local4 = 7;
};
vehicleGenTimer = vehicleGenTimerMax;
_local5 = GameObjects.AddObj(0, 0, 0);
_local5.InitZombie(_local4);
};
};
blockerGenTimer--;
if (blockerGenTimer < 0){
_local6 = (150 - (currentLevel * 2));
if (_local6 < 90){
_local6 = 90;
};
blockerGenTimer = Utils.RandBetweenInt(_local6, (_local6 + 50));
_local5 = GameObjects.AddObj(0, 0, 0);
_local5.InitBlocker();
};
barrelGenTimer--;
if (barrelGenTimer < 0){
barrelGenTimer = Utils.RandBetweenInt(150, 200);
_local5 = GameObjects.AddObj(0, 0, 0);
if (currentLevel < 10){
_local5.InitBarrel();
} else {
if (currentLevel < 20){
if (Utils.RandBetweenInt(0, 1) == 0){
_local5.InitBarrel();
} else {
_local5.InitFireworks();
};
} else {
if (Utils.RandBetweenInt(0, 100) < 20){
_local5.InitBarrel();
} else {
_local5.InitFireworks();
};
};
};
};
pickupGenTimer--;
if (pickupGenTimer < 0){
pickupGenTimer = Utils.RandBetweenInt(20, 40);
_local5 = GameObjects.AddObj(0, 0, 0);
_local5.InitPickup();
};
}
static function InitVehicleGen(){
var _local1:Array;
vehicleGenTimer = 0;
vehicleGenTimerMax = 300;
pickupGenTimer = 0;
pickupGenTimerMax = 500;
blockerGenTimer = 0;
barrelGenTimer = 100;
blockerGenTimerMax = 500;
maxZombiesAllowed = 5;
zombieLevelTypes = new Array();
zombieLevelTypes.push(new Array(zt_A, zt_A));
zombieLevelTypes.push(new Array(zt_A, zt_B));
zombieLevelTypes.push(new Array(zt_A, zt_B, zt_A, zt_B, zt_C));
zombieLevelTypes.push(new Array(zt_A, zt_B, zt_C));
zombieLevelTypes.push(new Array(zt_A, zt_B, zt_C, zt_C));
zombieLevelTypes.push(new Array(zt_A, zt_B, zt_C, zt_FAST));
zombieLevelTypes.push(new Array(zt_A, zt_B, zt_C, zt_FAST, zt_FAST));
zombieLevelTypes.push(new Array(zt_A, zt_B, zt_C, zt_FAST, zt_FAST, zt_FAST));
zombieLevelTypes.push(new Array(zt_A, zt_B, zt_C, zt_FAST, zt_FAST, zt_FAST, zt_FAST));
zombieLevelTypes.push(new Array(zt_A, zt_B, zt_C, zt_FAST, zt_FAST, zt_FAST, zt_FAST, zt_FAST));
zombieLevelTypes.push(new Array(zt_A, zt_B, zt_C, zt_FAST, zt_FAST, zt_FAST, zt_FAST, zt_FAST));
zombieLevelTypes.push(new Array(zt_A, zt_B, zt_C, zt_A, zt_B, zt_C, zt_BIG));
zombieLevelTypes.push(new Array(zt_A, zt_B, zt_C, zt_A, zt_B, zt_C, zt_BIG));
zombieLevelTypes.push(new Array(zt_A, zt_B, zt_C, zt_A, zt_B, zt_C, zt_BIG));
zombieLevelTypes.push(new Array(zt_A, zt_B, zt_C, zt_A, zt_B, zt_C, zt_BIG));
zombieLevelTypes.push(new Array(zt_A, zt_B, zt_C, zt_A, zt_B, zt_C, zt_BIG));
zombieLevelTypes.push(new Array(zt_A, zt_B, zt_C, zt_A, zt_B, zt_C, zt_BIG));
zombieLevelTypes.push(new Array(zt_A, zt_B, zt_C, zt_A, zt_B, zt_C, zt_BIG, zt_FAST));
zombieLevelTypes.push(new Array(zt_A, zt_B, zt_C, zt_A, zt_B, zt_C, zt_BIG, zt_FAST));
zombieLevelTypes.push(new Array(zt_A, zt_B, zt_C, zt_A, zt_B, zt_C, zt_BIG, zt_FAST));
zombieLevelTypes.push(new Array(zt_A, zt_B, zt_C, zt_A, zt_B, zt_C, zt_BIG, zt_FAST));
zombieLevelTypes.push(new Array(zt_A, zt_B, zt_C, zt_A, zt_B, zt_C, zt_BIG, zt_FAST));
zombieLevelTypes.push(new Array(zt_A, zt_B, zt_C, zt_A, zt_B, zt_C, zt_BIG, zt_FAST));
zombieLevelTypes.push(new Array(zt_A, zt_B, zt_C, zt_A, zt_B, zt_C, zt_BIG, zt_FAST));
zombieLevelTypes.push(new Array(zt_A, zt_B, zt_C, zt_A, zt_B, zt_C, zt_BIG, zt_BIG, zt_FAST, zt_FAST));
zombieLevelTypes.push(new Array(zt_A, zt_B, zt_C, zt_A, zt_B, zt_C, zt_BIG, zt_BIG, zt_FAST, zt_FAST));
zombieLevelTypes.push(new Array(zt_A, zt_B, zt_C, zt_A, zt_B, zt_C, zt_BIG, zt_BIG, zt_FAST, zt_FAST));
zombieLevelTypes.push(new Array(zt_A, zt_B, zt_C, zt_A, zt_B, zt_C, zt_BIG, zt_BIG, zt_FAST, zt_FAST));
zombieLevelTypes.push(new Array(zt_A, zt_B, zt_C, zt_A, zt_B, zt_C, zt_BIG, zt_BIG, zt_FAST, zt_FAST));
zombieLevelTypes.push(new Array(zt_A, zt_B, zt_C, zt_A, zt_B, zt_C, zt_BIG, zt_BIG, zt_FAST, zt_FAST));
zombieLevelTypes.push(new Array(zt_A, zt_B, zt_C, zt_A, zt_B, zt_C, zt_BIG, zt_BIG, zt_FAST, zt_FAST));
zombieLevelTypes.push(new Array(zt_A, zt_B, zt_C, zt_A, zt_B, zt_C, zt_BIG, zt_BIG, zt_FAST, zt_FAST));
zombieLevelTypes.push(new Array(zt_A, zt_B, zt_C, zt_A, zt_B, zt_C, zt_BIG, zt_BIG, zt_FAST, zt_FAST));
}
static function PreUpdatePhysObjs():void{
var _local1:PhysObj_Instance;
for each (_local1 in physObjInstances.list) {
_local1.PreUpdate();
};
}
public static function RemoveObj_Pellet(_arg1:PhysObj_Instance){
physObjInstances.Remove(_arg1);
}
static function GetLevel(_arg1:int):Level{
if (_arg1 >= levels.length){
return (null);
};
return (levels[_arg1]);
}
static function RenderPanel(){
var _local2:Number;
var _local3:Number;
var _local4:String;
var _local5:Number;
var _local6:int;
var _local7:BitmapData;
var _local8:Number;
var _local9:Weapon;
var _local10:Number;
var _local11:Weapon;
var _local12:Weapon;
var _local1:Level = GetCurrentLevel();
_local7 = main.screenBD;
_local2 = 10;
_local3 = 10;
_local6 = GraphicObjects.GetIndexByName("PowerupMeter");
_local8 = Utils.ScaleTo(0, (GraphicObjects.GetNumFrames(_local6) - 1), goPlayer.maxHealth, 0, goPlayer.health);
GraphicObjects.RenderAt(_local6, int(_local8), _local7, _local2, _local3);
_local9 = GetCurrentWeapon();
_local2 = 330;
_local3 = 40;
_local4 = currentScore.toString();
GraphicObjects.RenderStringAt(_local7, GraphicObjects.gfx_font2, _local2, _local3, _local4, null, -1);
_local2 = 300;
_local3 = 30;
_local6 = GraphicObjects.GetIndexByName("LevelProgressIndicator");
GraphicObjects.RenderAt(_local6, 0, _local7, _local2, _local3);
_local10 = ((170 / scrollXMax) * scrollXPos);
_local2 = (_local2 + _local10);
_local6 = GraphicObjects.GetIndexByName("LevelProgressIndicatorMarker");
GraphicObjects.RenderAt(_local6, 0, _local7, _local2, _local3);
_local2 = 474;
_local3 = 32;
_local4 = int((currentLevel + 1)).toString();
GraphicObjects.RenderStringAt(_local7, GraphicObjects.gfx_font1, _local2, _local3, _local4, null, -1);
_local11 = GetCurrentWeapon();
_local12 = GetSecondaryWeapon();
_local2 = 630;
_local3 = 10;
_local6 = GraphicObjects.GetIndexByName("hud_weapon_bg");
_local8 = currentWeaponSlot;
GraphicObjects.RenderAt(_local6, _local8, _local7, _local2, _local3);
_local6 = GraphicObjects.GetIndexByName("hud_weapon");
if (currentWeaponSlot == 0){
GraphicObjects.RenderAt(_local6, _local11.frame, _local7, (_local2 + 117), (_local3 + 56));
if (secondaryWeapon != -1){
GraphicObjects.RenderAt(_local6, _local12.frame, _local7, (_local2 + 97), (_local3 + 100));
};
} else {
GraphicObjects.RenderAt(_local6, _local12.frame, _local7, (_local2 + 117), (_local3 + 56));
if (secondaryWeapon != -1){
GraphicObjects.RenderAt(_local6, _local11.frame, _local7, (_local2 + 97), (_local3 + 100));
};
};
if (goPlayer.swapWeaponTimer > 0){
_local2 = 612;
_local3 = -7;
_local6 = GraphicObjects.GetIndexByName("reloading_mc");
_local8 = Utils.ScaleTo(0, (GraphicObjects.GetNumFrames(_local6) - 1), 0, Game.swapTimerMax, goPlayer.swapWeaponTimer);
GraphicObjects.RenderAt(_local6, _local8, _local7, (_local2 + 117), (_local3 + 56));
GraphicObjects.RenderAt(_local6, _local8, _local7, (_local2 + 97), (_local3 + 100));
} else {
if (goPlayer.reloadingTimer == 0){
if (goPlayer.numBullets == 0){
_local2 = 400;
_local3 = 70;
_local4 = "RELOAD NOW";
GraphicObjects.RenderStringAt(_local7, GraphicObjects.gfx_font2, _local2, _local3, _local4, null, -1);
};
} else {
_local2 = 612;
_local3 = -7;
_local6 = GraphicObjects.GetIndexByName("reloading_mc");
_local8 = Utils.ScaleTo(0, (GraphicObjects.GetNumFrames(_local6) - 1), 0, goPlayer.reloadingTimerMax, goPlayer.reloadingTimer);
if (currentWeaponSlot == 0){
GraphicObjects.RenderAt(_local6, _local8, _local7, (_local2 + 117), (_local3 + 56));
} else {
GraphicObjects.RenderAt(_local6, _local8, _local7, (_local2 + 97), (_local3 + 100));
};
};
if (_local9.showAmmo){
_local2 = 630;
_local3 = 10;
_local4 = goPlayer.numBullets.toString();
if (goPlayer.reloadingTimer > 0){
_local8 = Utils.ScaleTo(_local9.clipSize, 0, 0, goPlayer.reloadingTimerMax, goPlayer.reloadingTimer);
_local4 = int(_local8).toString();
};
if (currentWeaponSlot == 0){
GraphicObjects.RenderStringAt(_local7, GraphicObjects.gfx_font1, (_local2 + 117), (_local3 + 56), _local4, null, -1);
} else {
GraphicObjects.RenderStringAt(_local7, GraphicObjects.gfx_font1, (_local2 + 97), (_local3 + 100), _local4, null, -1);
};
};
};
}
static function InitBox2D():void{
var _local1:b2AABB = new b2AABB();
_local1.lowerBound.Set(-250000, -250000);
_local1.upperBound.Set(250000, 250000);
var _local2:b2Vec2 = new b2Vec2(0, physGravity);
var _local3:Boolean;
world = new b2World(_local1, _local2, _local3);
groundBody = world.GetGroundBody();
groundBody.SetUserData(-1);
var _local4:ContactListener = new ContactListener();
world.SetContactListener(_local4);
}
public static function LoadLevels(){
var _local3:int;
levels = new Array();
var _local1:XML = ExternalData.xml;
var _local2:* = _local1.level.length();
_local3 = 0;
while (_local3 < _local2) {
LoadLevel(_local3);
_local3++;
};
_local3 = 0;
while (_local3 < levels.length) {
GetLevel(_local3).available = false;
GetLevel(_local3).complete = false;
_local3++;
};
GetLevel(0).available = true;
}
public static function LoadLevel(_arg1:int){
var _local4:int;
var _local5:int;
var _local6:XML;
var _local7:XML;
var _local8:int;
var _local9:String;
var _local10:int;
var _local11:PhysLine;
var _local12:XML;
var _local13:String;
var _local14:Array;
var _local15:Point;
var _local16:XML;
var _local17:String;
var _local18:Number;
var _local19:Number;
var _local20:Number;
var _local21:String;
var _local22:PhysObj_Instance;
var _local2:XML = ExternalData.xml;
_local2 = _local2.level[_arg1];
var _local3:Level = new Level();
_local3.name = XmlHelper.GetAttrString(_local2.@name, "undefined");
_local3.category = XmlHelper.GetAttrInt(_local2.@category, 0);
_local3.fillFrame = XmlHelper.GetAttrInt(_local2.@fillframe, 1);
_local3.surfaceFrame = XmlHelper.GetAttrInt(_local2.@surfaceframe, 2);
_local3.surfaceThickness = XmlHelper.GetAttrInt(_local2.@surfacethickness, 10);
_local3.eventType = XmlHelper.GetAttrString(_local2.@type, "race");
_local3.eventOpponentsString = XmlHelper.GetAttrString(_local2.@opponents, "1");
_local3.exclusiveChar = XmlHelper.GetAttrInt(_local2.@exclusivechar, -1);
_local3.eventWinParam = XmlHelper.GetAttrNumber(_local2.@win, 1);
_local3.goldTime = (XmlHelper.GetAttrNumber(_local2.times.@gold, 10) * Defs.fps);
_local3.silverTime = (XmlHelper.GetAttrNumber(_local2.times.@silver, 20) * Defs.fps);
_local4 = 0;
while (_local4 < _local2.helpscreen.length()) {
_local6 = _local2.helpscreen[_local4];
_local3.helpscreenFrames.push(XmlHelper.GetAttrInt(_local6.@frame, 0));
_local4++;
};
_local3.Calculate();
_local3.lines = new Array();
_local4 = 0;
while (_local4 < _local2.line.length()) {
_local7 = _local2.line[_local4];
_local8 = XmlHelper.GetAttrInt(_local7.@type, 0);
_local9 = XmlHelper.GetAttrString(_local7.@name, "");
_local10 = XmlHelper.GetAttrInt(_local7.@fill, 1);
_local11 = new PhysLine();
_local11.type = _local8;
_local11.name = _local9;
_local11.fill = _local10;
_local11.fillScaleX = XmlHelper.GetAttrNumber(_local7.@fillscale, 1);
_local11.fillScaleY = XmlHelper.GetAttrNumber(_local7.@fillscale, 1);
_local5 = 0;
while (_local5 < _local7.points.length()) {
_local12 = _local7.points[_local5];
_local13 = XmlHelper.GetAttrString(_local12.@a, "");
_local14 = Utils.PointArrayFromString(_local13);
for each (_local15 in _local14) {
_local11.points.push(_local15);
};
_local5++;
};
_local3.lines.push(_local11);
_local4++;
};
_local4 = 0;
while (_local4 < _local2.obj.length()) {
_local16 = _local2.obj[_local4];
_local17 = _local16.@type;
_local18 = Number(_local16.@x);
_local19 = Number(_local16.@y);
_local20 = Number(_local16.@rot);
_local21 = XmlHelper.GetAttrString(_local16.@params, "");
_local22 = CreatePhysObjInstanceAt(_local17, _local18, _local19, _local20, "", _local21);
_local3.instances.push(_local22);
_local4++;
};
levels.push(_local3);
}
static function InitPhysicsGO(_arg1:Number, _arg2:Number, _arg3:PhysObj_Graphic, _arg4:int=0, _arg5:int=0, _arg6:Number=1000, _arg7:Number=0, _arg8:String=""):int{
var _local9:GameObj;
_arg6 = (_arg6 + _arg3.zoffset);
if (_arg3 == null){
_local9 = GameObjects.AddObj((_arg1 * p2w), (_arg2 * p2w), (_arg6 + zsortoffset));
_local9.InitPhysicsObject(_arg4, _arg5, 0, 0, "", false, _arg8);
} else {
if (_arg3.goInitFuntion == ""){
_local9 = GameObjects.AddObj((_arg1 * p2w), (_arg2 * p2w), (_arg6 + zsortoffset));
_local9.InitPhysicsObject(_arg4, _arg5, _arg3.offset.x, _arg3.offset.y, _arg3.goInitFuntionVarString, _arg3.hasShadow, _arg8);
} else {
_local9 = GameObjects.AddObj((_arg1 * p2w), (_arg2 * p2w), (_arg6 + zsortoffset));
_local9.InitPhysicsObject(_arg4, _arg5, _arg3.offset.x, _arg3.offset.y, _arg3.goInitFuntionVarString, _arg3.hasShadow, _arg8);
var _local10 = _local9;
_local10[_arg3.goInitFuntion]();
_local9.dir = _arg7;
};
};
lastGeneratedGameObj = _local9;
return (GameObjects.lastGenIndex);
}
static function AddToBoost(_arg1:Number):Number{
boostLevel = (boostLevel + _arg1);
do {
if (boostLevel >= 1){
boostLevel = (boostLevel - 1);
InitBoost();
boostMultiplier++;
if (boostMultiplier > maxBoostMultiplier){
boostMultiplier = maxBoostMultiplier;
};
};
} while (boostLevel > 1);
return ((_arg1 * 100));
}
static function UpdateScrollStop(){
farbgScrollX = (farbgScrollX + (scrollXvel / 10));
bgScrollX = (bgScrollX + scrollXvel);
roadScrollX = (roadScrollX + scrollXvel);
scrollXPos = (scrollXPos + scrollXvel);
scrollXvel = (scrollXvel + 0.5);
if (scrollXvel >= 30){
scrollXvel = 30;
};
}
static function TestPlayerCollision(_arg1:BitmapData):Boolean{
var _local2:Number;
var _local3:Number;
var _local4:int;
var _local5:Bitmap;
var _local6:Number;
var _local7:Number;
_local2 = (goPlayer.xpos - scrollX);
_local3 = (goPlayer.ypos - scrollY);
_local4 = GraphicObjects.GetIndexByName("PlayerCollision");
_local5 = GraphicObjects.GetBitmap(_local4, 0);
_local6 = GraphicObjects.GetXoffset(_local4, 0);
_local7 = GraphicObjects.GetYoffset(_local4, 0);
return (_arg1.hitTest(new Point(0, 0), 50, _local5, new Point((_local2 + _local6), (_local3 + _local7))));
}
public static function UpdateGameplay():void{
if (pause){
return;
};
if (levelState == levelState_EndScreen){
return;
};
if (levelState == levelState_Editor){
PhysEditor.UpdateEditor();
return;
};
if (usedebug){
};
if (levelState == levelState_Null){
return;
};
if (mousetimer > 0){
mousetimer--;
};
if (PauseMenu.IsPaused() == false){
if (KeyReader.Pressed(KeyReader.KEY_P)){
PauseMenu.Pause();
};
};
if (LevelUpdateCallback != null){
LevelUpdateCallback();
};
var _local1 = 1;
if (usedebug){
if (KeyReader.Pressed(KeyReader.KEY_1)){
testMode++;
testMode = (testMode % 6);
};
if (KeyReader.Pressed(KeyReader.KEY_2)){
};
if (KeyReader.Pressed(KeyReader.KEY_3)){
Debug.debugMode = (Debug.debugMode ^ 1);
};
if (KeyReader.Pressed(KeyReader.KEY_4)){
playerType++;
if (playerType > 2){
playerType = 0;
};
};
if (KeyReader.Pressed(KeyReader.KEY_5)){
achievements.TestAll();
InitLevelState(levelState_Null);
TitleScreenState.InitLevelEndScreen();
};
if (KeyReader.Pressed(KeyReader.KEY_6)){
};
if (KeyReader.Pressed(KeyReader.KEY_7)){
Reload(InitLevel);
};
if (KeyReader.Pressed(KeyReader.KEY_8)){
DoEndLevelStuff();
currentLevel++;
DoEndLevelStuff();
currentLevel++;
DoEndLevelStuff();
currentLevel++;
DoEndLevelStuff();
currentLevel++;
DoEndLevelStuff();
currentLevel++;
DoEndLevelStuff();
TitleScreenState.InitBetweenLevelsScreen();
InitLevelState(levelState_Null);
};
if (KeyReader.Pressed(KeyReader.KEY_9)){
DoEndLevelStuff();
TitleScreenState.InitBetweenLevelsScreen();
InitLevelState(levelState_Null);
};
};
if (levelFinishedState == levelFinishedState_WON){
};
if (levelFinishedState == levelFinishedState_LOST){
};
if (levelState == levelState_Complete){
levelStateTimer--;
if (levelStateTimer <= 0){
DoEndLevelStuff();
SubmitStats();
TitleScreenState.InitBetweenLevelsScreen();
InitLevelState(levelState_Null);
};
GameObjects.Update();
Particles.Update(1);
UpdateScrollStop();
return;
};
if (levelState == levelState_Dead){
GameObjects.Update();
UpdateScroll();
levelStateTimer--;
if (levelStateTimer <= 0){
QuietAllSounds();
TitleScreenState.InitLevelFailScreen();
InitLevelState(levelState_Null);
};
return;
};
if (levelState == levelState_LevelStart){
GameObjects.Update();
Collision.Update();
UpdateScroll();
if (CountZombies() <= 0){
InitLevelState(levelState_Play);
};
};
if (levelState == levelState_Play){
if (levelStateTimer > 0){
levelStateTimer--;
};
levelTimer++;
UpdateGenerators();
GameObjects.Update();
Particles.Update(1);
Collision.Update();
if (powerupTimer > 0){
powerupTimer--;
if (powerupTimer <= 0){
currentPowerup = -1;
};
};
if (playerHitFloor){
};
UpdateScroll();
UpdateBackgroundSounds();
};
}
static function GetLastStartPoint(_arg1:Number):Point{
var _local3:Point;
var _local2:Point = startPoints[0];
var _local4:Number = -1000;
for each (_local3 in startPoints) {
if (_local3.x < _arg1){
if (_local3.x > _local4){
_local4 = _local3.x;
_local2 = _local3;
};
};
};
return (_local2);
}
public static function FrontWheelIsDown():void{
frontWheelDown = true;
}
static function InitRainbow(){
rainbow_dir = 1;
rainbow_dirchange = 0.032;
rainbow_starty = 0;
rainbow_timer0 = Utils.RandCircle();
rainbow_timer1 = Utils.RandCircle();
rainbow_timer2 = Utils.RandCircle();
rainbow_timer3 = Utils.RandCircle();
rainbow_timer4 = Utils.RandCircle();
}
public static function SwitchToBack(){
switchFlag = 1;
trace("SwitchToBack");
}
public static function InitLevel1(){
InitLevel2();
}
public static function InitLevel2(){
var _local1:GameObj;
KeyReader.InitOnce(main.stage);
Particles.Reset();
ObjectDefs.Init();
GameObjects.ClearAll();
levelFinishedState = levelFinishedState_NOT;
scrollX = 0;
scrollY = 0;
LevelUpdateCallback = null;
scrollW = 10000;
scrollH = 1000;
scrollMaxX = (scrollW - Defs.displayarea_w);
scrollMaxY = (scrollH - Defs.displayarea_h);
gravity = 0.2;
maxFallSpeed = 6;
polygonList = new Array();
startPoints = new Array();
InitBox2D();
levelTimer = 0;
levelTimerMax = (Defs.fps * 60);
physObjs = new PhysObjs();
physObjs.InitFromXml(ExternalData.xml);
scrollAcc = 0.01;
scrollVel = 0;
scrollMaxVel = 2;
physObjInstances = new PhysObj_Instances();
pause = false;
StartLevelPlay();
currentPowerup = -1;
powerupTimer = 0;
}
public static function RemoveObj_BallInWrongHopper(_arg1:PhysObj_Instance){
physObjInstances.Remove(_arg1);
}
public static function SwitchToFront(){
switchFlag = 2;
}
static function CycleWeapon(_arg1:int){
currentWeapon = (currentWeapon + _arg1);
if (currentWeapon >= weapons.length){
currentWeapon = 0;
};
if (currentWeapon < 0){
currentWeapon = (weapons.length - 1);
};
}
static function InitWeapons():void{
var _local1:Weapon;
weapons = new Array();
_local1 = new Weapon("crowbar");
_local1.frame = 0;
_local1.graphicName = "arm_crowbar_forward";
_local1.flashGraphicName = "";
_local1.maxRange = 50;
_local1.fireRate = 10;
_local1.loff = new Point(-45, -8);
_local1.roff = new Point(45, -8);
_local1.clipSize = 9999999;
_local1.reloadTime = 20;
_local1.damage = 3;
_local1.available = true;
_local1.displayLine = false;
_local1.shootSound = "sfx_crowbar";
_local1.reloadSound = "sfx_pistol_reload";
_local1.showAmmo = false;
weapons.push(_local1);
_local1 = new Weapon("pistol");
_local1.frame = 1;
_local1.shootFuncName = "FirePistol";
_local1.maxRange = 500;
_local1.graphicName = "arm_pistol_forward";
_local1.flashGraphicName = "pistol_flash";
_local1.fireRate = 7;
_local1.loff = new Point(-45, -8);
_local1.roff = new Point(45, -8);
_local1.clipSize = 10;
_local1.reloadTime = 20;
_local1.damage = 1;
_local1.available = true;
_local1.cartridgeFrame = 0;
_local1.cartridgeLoff = new Point(-31, -8);
_local1.cartridgeRoff = new Point(31, -8);
_local1.shootSound = "sfx_pistol_shot";
_local1.reloadSound = "sfx_pistol_reload";
_local1.shootLineGraphicName = "weapon_pistol_line";
weapons.push(_local1);
_local1 = new Weapon("uzi");
_local1.frame = 2;
_local1.maxRange = 400;
_local1.graphicName = "arm_uzi_forward";
_local1.flashGraphicName = "uzi_flash";
_local1.fireRate = 3;
_local1.loff = new Point(-46, -10);
_local1.roff = new Point(46, -10);
_local1.clipSize = 50;
_local1.reloadTime = 30;
_local1.damage = 1;
_local1.cartridgeFrame = 0;
_local1.cartridgeLoff = new Point(-34, -11);
_local1.cartridgeRoff = new Point(34, -11);
_local1.shootSound = "sfx_machinegun_shot";
_local1.reloadSound = "sfx_reload";
_local1.shootLineGraphicName = "weapon_uzi_line";
weapons.push(_local1);
_local1 = new Weapon("shotgun");
_local1.frame = 4;
_local1.graphicName = "arm_shotgun_forward";
_local1.shootFuncName = "FireShotgun";
_local1.flashGraphicName = "shotgun_flash";
_local1.fireRate = 10;
_local1.maxRange = 200;
_local1.loff = new Point(-78, -10);
_local1.roff = new Point(78, -10);
_local1.clipSize = 10;
_local1.reloadTime = 50;
_local1.damage = 3;
_local1.cartridgeFrame = 2;
_local1.cartridgeLoff = new Point(-37, -10);
_local1.cartridgeRoff = new Point(37, -10);
_local1.shootSound = "sfx_shotgun";
_local1.reloadSound = "sfx_reload";
_local1.shootLineGraphicName = "weapon_shotgun_line";
weapons.push(_local1);
_local1 = new Weapon("machinegun");
_local1.frame = 3;
_local1.maxRange = 400;
_local1.graphicName = "arm_smg_forward";
_local1.flashGraphicName = "machinegun_flash";
_local1.fireRate = 3;
_local1.loff = new Point(-63, -12);
_local1.roff = new Point(63, -12);
_local1.clipSize = 100;
_local1.reloadTime = 30;
_local1.damage = 5;
_local1.cartridgeFrame = 0;
_local1.cartridgeLoff = new Point(-30, -12);
_local1.cartridgeRoff = new Point(30, -12);
_local1.shootSound = "sfx_machinegun_shot_02";
_local1.reloadSound = "sfx_reload";
_local1.shootLineGraphicName = "weapon_machinegun_line";
weapons.push(_local1);
_local1 = new Weapon("flamethrower");
_local1.frame = 7;
_local1.graphicName = "arm_flamethrower_forward";
_local1.shootFuncName = "FireFlamethrower";
_local1.fireRate = 1;
_local1.loff = new Point(-68, -11);
_local1.roff = new Point(68, -11);
_local1.clipSize = 1000;
_local1.reloadTime = 40;
_local1.damage = 2.5;
_local1.displayLine = false;
_local1.shootSound = "";
_local1.reloadSound = "";
_local1.showAmmo = false;
weapons.push(_local1);
_local1 = new Weapon("rifle");
_local1.frame = 6;
_local1.maxRange = 800;
_local1.graphicName = "arm_rifle_forward";
_local1.flashGraphicName = "rifle_flash";
_local1.shootFuncName = "FireRifle";
_local1.fireRate = 10;
_local1.loff = new Point(-81, -9);
_local1.roff = new Point(81, -9);
_local1.clipSize = 30;
_local1.reloadTime = 40;
_local1.damage = 10;
_local1.cartridgeFrame = 1;
_local1.cartridgeLoff = new Point(-25, -11);
_local1.cartridgeRoff = new Point(25, -11);
_local1.shootSound = "sfx_rifle_shot";
_local1.reloadSound = "sfx_reload";
_local1.shootLineGraphicName = "weapon_pistol_line";
weapons.push(_local1);
_local1 = new Weapon("rocketlauncher");
_local1.frame = 5;
_local1.graphicName = "arm_rocketlauncher_forward";
_local1.shootFuncName = "FireRocket";
_local1.flashGraphicName = "shotgun_flash";
_local1.fireRate = 20;
_local1.loff = new Point(-51, -17);
_local1.roff = new Point(51, -17);
_local1.clipSize = 5;
_local1.reloadTime = 30;
_local1.damage = 10;
_local1.shootSound = "sfx_rocket";
_local1.reloadSound = "sfx_reload";
weapons.push(_local1);
_local1 = new Weapon("hmg");
_local1.frame = 9;
_local1.maxRange = 800;
_local1.graphicName = "arm_hmg_forward";
_local1.flashGraphicName = "rifle_flash";
_local1.fireRate = 3;
_local1.loff = new Point(-81, -9);
_local1.roff = new Point(81, -9);
_local1.clipSize = 100;
_local1.reloadTime = 40;
_local1.damage = 10;
_local1.cartridgeFrame = 1;
_local1.cartridgeLoff = new Point(-41, -11);
_local1.cartridgeRoff = new Point(41, -11);
_local1.shootSound = "sfx_machinegun_shot_03";
_local1.reloadSound = "sfx_reload";
_local1.shootLineGraphicName = "weapon_hmg_line";
weapons.push(_local1);
_local1 = new Weapon("chainsaw");
_local1.frame = 8;
_local1.graphicName = "arm_chainsaw_forward";
_local1.fireRate = 1;
_local1.maxRange = 50;
_local1.loff = new Point(-43, 0);
_local1.roff = new Point(43, 0);
_local1.clipSize = 1000;
_local1.reloadTime = 5;
_local1.damage = 20;
_local1.displayLine = false;
_local1.shootSound = "";
_local1.reloadSound = "";
_local1.constantSound = "chainsaw";
_local1.showAmmo = false;
weapons.push(_local1);
_local1 = new Weapon("laser");
_local1.frame = 10;
_local1.graphicName = "arm_laser_forward";
_local1.flashGraphicName = "laser_flash";
_local1.shootFuncName = "FireLaser";
_local1.fireRate = 5;
_local1.maxRange = 800;
_local1.loff = new Point(-50, -11);
_local1.roff = new Point(50, -11);
_local1.clipSize = 100;
_local1.reloadTime = 40;
_local1.damage = 30;
_local1.shootSound = "";
_local1.reloadSound = "";
_local1.shootSound = "sfx_laser";
_local1.shootLineGraphicName = "weapon_laser_line";
weapons.push(_local1);
}
static function QuietAllSounds(){
var _local1:SoundChannel;
_local1 = SoundPlayer.GetSoundChannelByName("crowd");
SoundPlayer.SetSoundChannelVolume(_local1, 0);
_local1 = SoundPlayer.GetSoundChannelByName("footstep");
SoundPlayer.SetSoundChannelVolume(_local1, 0);
_local1 = SoundPlayer.GetSoundChannelByName("chainsaw");
SoundPlayer.SetSoundChannelVolume(_local1, 0);
}
public static function CollideWithMagnet(_arg1:PhysObj_Instance){
_arg1.collideFunction = null;
_arg1.collidetimer = 0;
var _local2:b2Vec2 = _arg1.GetBodyWorldPos(0);
var _local3:b2Vec2 = _arg1.collideWithInstance.GetBodyWorldPos(0);
var _local4:Boolean = _arg1.collideWithInstance.magnet_polarity;
var _local5:Number = Utils.DistBetweenPoints(_local2.x, _local2.y, _local3.x, _local3.y);
_local5 = (_local5 * Game.p2w);
_local5 = Utils.LimitNumber(0, 110, _local5);
_local5 = (150 - _local5);
_local5 = Utils.ScaleTo(0, 1, 0, 110, _local5);
var _local6:Number = Math.atan2((_local3.y - _local2.y), (_local3.x - _local2.x));
var _local7:Number = (20 * _local5);
var _local8:Number = (Math.cos(_local6) * _local7);
var _local9:Number = (Math.sin(_local6) * _local7);
if (_local4 == true){
_arg1.ApplyForce(_local8, _local9);
} else {
_arg1.ApplyForce(-(_local8), -(_local9));
};
}
static function InitPlasma(){
var _local1:Number = 0;
var _local2:Number = 0xFF;
plasma_x0 = Utils.RandBetweenFloat(_local1, _local2);
plasma_y0 = Utils.RandBetweenFloat(_local1, _local2);
plasma_x1 = Utils.RandBetweenFloat(_local1, _local2);
plasma_y1 = Utils.RandBetweenFloat(_local1, _local2);
plasma_x2 = Utils.RandBetweenFloat(_local1, _local2);
plasma_y2 = Utils.RandBetweenFloat(_local1, _local2);
plasma_x3 = Utils.RandBetweenFloat(_local1, _local2);
plasma_y3 = Utils.RandBetweenFloat(_local1, _local2);
}
static function GetSecondaryWeapon():Weapon{
if (secondaryWeapon == -1){
return (null);
};
return (weapons[secondaryWeapon]);
}
public static function AddScore(_arg1:int):void{
currentScore = (currentScore + (_arg1 * multiplier));
}
public static function DoSwitchToBack(){
var _local1:PhysObj_Instance;
_local1 = GetPhysObjInstanceByName("player");
if (_local1 == null){
return;
};
_local1.SetBodyCollisionMask(-1, 7);
}
public static function RemoveObj_Gem(_arg1:PhysObj_Instance){
physObjInstances.Remove(_arg1);
}
public static function RemoveObj_Pickup(_arg1:PhysObj_Instance){
cash++;
physObjInstances.Remove(_arg1);
}
static function RenderPlasma(_arg1:BitmapData){
var _local8:Number;
var _local9:Number;
var _local10:Number;
var _local12:int;
var _local13:uint;
var _local2:BitmapData = main.plasmaScreenBD;
var _local3:Number = plasmaTime;
plasmaTime = (plasmaTime + 0.4);
_local2.lock();
var _local4:Number = 2;
var _local5:Number = 3;
var _local6:Number = 2;
var _local7:Number = 4;
_local8 = 0;
while (_local8 < 20) {
_local9 = 0;
while (_local9 < 20) {
_local10 = (((Math.sin((dist((_local8 + _local3), _local9, plasma_x0, plasma_y0) / _local4)) + Math.sin((dist(_local8, _local9, plasma_x1, plasma_y1) / _local5))) + Math.sin((dist(_local8, _local9, plasma_x2, plasma_y2) / _local6))) + Math.sin((dist(_local8, (_local9 + (_local3 / 7)), plasma_x3, plasma_y3) / _local7)));
_local12 = ((_local10 + 4) * 32);
_local13 = (1342177280 | _local12);
_local2.setPixel32(int(_local8), int(_local9), _local13);
_local9++;
};
_local8++;
};
_local2.unlock();
var _local11:Matrix = new Matrix();
_local11.identity();
_local11.scale(31, 31);
main.screenBD.draw(main.plasmaScreenBD, _local11, null, null, null, true);
}
static function QuietWeaponSounds(){
var _local1:SoundChannel;
_local1 = SoundPlayer.GetSoundChannelByName("chainsaw");
SoundPlayer.SetSoundChannelVolume(_local1, 0);
}
public static function StartLevelPlay():void{
StartLevelPlay2();
}
static function ExamineBox2D():void{
var _local1:int;
var _local2:b2Body;
var _local3:b2Vec2;
return;
}
public static function InitLevelPlayFromEditorObjects(){
var _local1:PhysObj_Instance;
zsortoffset = 0;
level_instances = GetCurrentLevelInstances();
for each (_local1 in level_instances) {
AddPhysObjAt(_local1.typeName, _local1.x, _local1.y, _local1.rot, _local1.instanceName, _local1.initParams);
zsortoffset = (zsortoffset + 0.01);
};
}
static function GetPhysObjInstanceByName(_arg1:String):PhysObj_Instance{
var _local2:PhysObj_Instance;
for each (_local2 in physObjInstances.list) {
if (_local2.instanceName == _arg1){
return (_local2);
};
};
return (null);
}
static function RestartLevel():void{
currentScore = 0;
StartLevelPlay();
}
static function UpdateGOsFromPhysics():void{
var _local2:GameObj;
var _local3:b2Body;
var _local4:PhysObj_BodyUserData;
var _local5:int;
var _local6:b2Vec2;
var _local7:Number;
var _local1:Number = p2w;
_local3 = world.GetBodyList();
while (_local3) {
_local4 = (_local3.GetUserData() as PhysObj_BodyUserData);
if (_local4 != null){
_local5 = _local4.gameObjectID;
if (_local5 != -1){
_local6 = _local3.GetPosition();
_local7 = _local3.GetAngle();
_local2 = GameObjects.objs[_local5];
_local2.xpos = ((_local6.x * _local1) + _local2.physObjOffsetX);
_local2.ypos = ((_local6.y * _local1) + _local2.physObjOffsetY);
_local2.dir = _local7;
};
};
_local3 = _local3.GetNext();
};
}
static function AddPhysObjAt1(_arg1:String, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:String="", _arg6:String=""):PhysObj_Instance{
var _local10:Number;
var _local11:Number;
var _local12:b2BodyDef;
var _local13:b2Body;
var _local14:b2PolygonDef;
var _local15:b2CircleDef;
var _local16:int;
var _local17:b2Joint;
var _local19:PhysObj_Body;
var _local20:PhysObj_Joint;
var _local21:Number;
var _local22:Number;
var _local23:Point;
var _local24:PhysObj_BodyUserData;
var _local25:PhysObj_Shape;
var _local26:PhysObj_Graphic;
var _local27:b2FilterData;
var _local28:Point;
var _local29:Number;
var _local30:Number;
var _local31:Point;
var _local32:int;
var _local33:int;
var _local34:b2Body;
var _local35:b2Body;
var _local36:b2RevoluteJointDef;
var _local37:b2PrismaticJointDef;
var _local38:Number;
var _local39:b2Vec2;
var _local40:b2DistanceJointDef;
var _local41:Number;
var _local42:Number;
var _local43:b2MouseJointDef;
var _local7:PhysObj = physObjs.FindByName(_arg1);
var _local8:PhysObj_Instance = new PhysObj_Instance();
_local8.typeName = _arg1;
_local8.x = _arg2;
_local8.y = _arg3;
_local8.rot = _arg4;
_local8.bodies = new Array();
_local8.instanceName = _arg5;
_local8.initParams = _arg6;
_local8.hitballsound = _local7.hitballsound;
physObjInstances.list.push(_local8);
_local8.Init();
var _local9:Number = Utils.DegToRad(_arg4);
_arg2 = (_arg2 * w2p);
_arg3 = (_arg3 * w2p);
var _local18:Matrix = new Matrix();
_local18.rotate(_local9);
for each (_local19 in _local7.bodies) {
_local12 = new b2BodyDef();
_local21 = (_local19.pos.x * w2p);
_local22 = (_local19.pos.y * w2p);
_local23 = new Point(_local21, _local22);
_local23 = _local18.transformPoint(_local23);
_local21 = _local23.x;
_local22 = _local23.y;
_local12.position.Set((_arg2 + _local21), (_arg3 + _local22));
_local12.angularDamping = _local19.angularDamping;
_local12.linearDamping = _local19.linearDamping;
_local12.angle = _local9;
_local13 = world.CreateBody(_local12);
_local24 = new PhysObj_BodyUserData();
_local24.type = _arg1;
_local24.bodyName = _local19.name;
_local24.instance = _local8;
_local13.SetUserData(_local24);
if (_local19.graphics.length != 0){
_local26 = _local19.graphics[0];
_local24.gameObjectID = InitPhysicsGO(_arg2, _arg3, _local26, _local26.graphicID, _local26.frame, 1000);
};
for each (_local25 in _local19.shapes) {
_local27 = new b2FilterData();
_local27.categoryBits = _local25.collisionCategory;
_local27.maskBits = _local25.collisionMask;
if (_local25.type == PhysObj_Shape.Type_Poly){
_local14 = new b2PolygonDef();
_local14.vertexCount = _local25.poly_points.length;
_local14.filter = _local27;
_local14.isSensor = _local19.sensor;
_local16 = 0;
while (_local16 < _local25.poly_points.length) {
_local28 = _local25.poly_points[_local16].clone();
_local29 = (_local28.x * w2p);
_local30 = (_local28.y * w2p);
if (_local19.fixed){
_local31 = AlignWithPreviousVerts(_local29, _local30, _arg2, _arg3, _local9);
if (_local31 != null){
_local29 = (_local29 + _local31.x);
_local30 = (_local30 + _local31.y);
};
};
_local14.vertices[_local16].Set(_local29, _local30);
_local16++;
};
_local14.friction = _local25.friction;
_local14.restitution = _local25.restitution;
_local14.density = _local25.density;
_local13.CreateShape(_local14);
} else {
if (_local25.type == PhysObj_Shape.Type_Circle){
_local15 = new b2CircleDef();
_local15.radius = (_local25.circle_radius * w2p);
_local15.filter = _local27;
_local15.isSensor = _local19.sensor;
_local15.localPosition.x = _local25.circle_pos.x;
_local15.localPosition.y = _local25.circle_pos.y;
_local15.friction = _local25.friction;
_local15.restitution = _local25.restitution;
_local15.density = _local25.density;
_local13.CreateShape(_local15);
};
};
};
if (_local19.fixed){
_local13.PutToSleep();
_local13.SetMass(new b2MassData());
} else {
_local13.SetMassFromShapes();
_local13.SetBullet(false);
};
_local8.bodies.push(_local13);
};
for each (_local20 in _local7.joints) {
_local32 = _local7.BodyIndexFromName(_local20.obj0Name);
_local33 = _local7.BodyIndexFromName(_local20.obj1Name);
_local34 = _local8.bodies[_local32];
_local35 = _local8.bodies[_local33];
if (_local20.type == PhysObj_Joint.Type_Rev){
_local36 = new b2RevoluteJointDef();
_local10 = (_local20.rev_pos.x * w2p);
_local11 = (_local20.rev_pos.y * w2p);
_local23 = new Point(_local10, _local11);
_local23 = _local18.transformPoint(_local23);
_local10 = _local23.x;
_local11 = _local23.y;
_local36.Initialize(_local34, _local35, new b2Vec2((_arg2 + _local10), (_arg3 + _local11)));
_local36.enableLimit = _local20.rev_enableLimit;
_local36.lowerAngle = _local20.rev_lowerAngle;
_local36.upperAngle = _local20.rev_upperAngle;
_local36.enableMotor = _local20.rev_enableMotor;
_local36.motorSpeed = _local20.rev_motorSpeed;
_local36.maxMotorTorque = _local20.rev_maxMotorTorque;
_local36.collideConnected = false;
_local17 = world.CreateJoint(_local36);
};
if (_local20.type == PhysObj_Joint.Type_Prismatic){
_local37 = new b2PrismaticJointDef();
_local10 = (_local20.prism_pos.x * w2p);
_local11 = (_local20.prism_pos.y * w2p);
_local23 = new Point(_local10, _local11);
_local23 = _local18.transformPoint(_local23);
_local10 = _local23.x;
_local11 = _local23.y;
_local38 = Utils.DegToRad(_local20.prism_axisangle);
_local38 = (_local38 + _local9);
_local39 = new b2Vec2(Math.cos(_local38), Math.sin(_local38));
_local37.Initialize(_local34, _local35, new b2Vec2((_arg2 + _local10), (_arg3 + _local11)), _local39);
_local37.enableLimit = _local20.prism_enableLimit;
_local37.lowerTranslation = (_local20.prism_lowerTranslation * w2p);
_local37.upperTranslation = (_local20.prism_upperTranslation * w2p);
_local37.enableMotor = _local20.prism_enableMotor;
_local37.motorSpeed = _local20.prism_motorSpeed;
_local37.maxMotorForce = _local20.prism_maxMotorForce;
_local37.collideConnected = false;
_local17 = world.CreateJoint(_local37);
};
if (_local20.type == PhysObj_Joint.Type_Distance){
_local40 = new b2DistanceJointDef();
_local10 = (_local20.dist_pos0.x * w2p);
_local11 = (_local20.dist_pos0.y * w2p);
_local41 = (_local20.dist_pos1.x * w2p);
_local42 = (_local20.dist_pos1.y * w2p);
_local23 = new Point(_local10, _local11);
_local23 = _local18.transformPoint(_local23);
_local10 = _local23.x;
_local11 = _local23.y;
_local23 = new Point(_local41, _local42);
_local23 = _local18.transformPoint(_local23);
_local41 = _local23.x;
_local42 = _local23.y;
_local40.Initialize(_local34, _local35, new b2Vec2((_arg2 + _local10), (_arg3 + _local11)), new b2Vec2((_arg2 + _local41), (_arg3 + _local42)));
_local40.length = (_local40.length + (_local20.dist_distance * w2p));
_local40.dampingRatio = 0.1;
_local40.collideConnected = false;
_local17 = world.CreateJoint(_local40);
};
if (_local20.type == PhysObj_Joint.Type_Mouse){
_local43 = new b2MouseJointDef();
_local43.target.Set(_local34.GetPosition().x, _local34.GetPosition().y);
_local43.body1 = world.GetGroundBody();
_local43.body2 = _local34;
_local43.maxForce = (30000 * _local34.GetMass());
_local43.dampingRatio = 0.7;
_local43.frequencyHz = 10;
_local43.timeStep = (1 / 60);
_local17 = world.CreateJoint(_local43);
mouseJoint = (_local17 as b2MouseJoint);
};
_local8.joints.push(_local17);
};
return (_local8);
}
static function UpdateShakeCam(_arg1:Number):void{
var _local2:Number;
shakeCamTimer--;
if (shakeCamTimer <= 0){
shakeCamTimer = Utils.RandBetweenInt(5, 20);
shakeCamTimerMax = shakeCamTimer;
_local2 = Utils.ScaleTo(2, 20, 0, 30, _arg1);
shakeCamToX = Utils.RandBetweenFloat(-(_local2), _local2);
shakeCamToY = Utils.RandBetweenFloat(-(_local2), _local2);
shakeCamDX = ((shakeCamToX - shakeCamX) / shakeCamTimer);
shakeCamDY = ((shakeCamToY - shakeCamY) / shakeCamTimer);
};
shakeCamX = (shakeCamX + shakeCamDX);
shakeCamY = (shakeCamY + shakeCamDY);
}
static function InitPhysicsFloorGO(_arg1:int, _arg2:Number, _arg3:Number, _arg4:Number):int{
var _local5:GameObj;
_local5 = GameObjects.AddObj(_arg2, _arg3, 1000);
_local5.InitPhysicsFloorObject(_arg1, _arg4);
return (GameObjects.lastGenIndex);
}
static function PrintPlayerPosition(){
var _local1:PhysObj_Instance;
_local1 = GetPhysObjInstanceByName("player");
if (_local1 == null){
return;
};
var _local2:b2Vec2 = _local1.GetBodyWorldPos(0);
trace((((("x=\"" + int((_local2.x * p2w))) + "\" y=\"") + int((_local2.y * p2w))) + "\""));
}
static function InitPlayerUpdateRot(){
playerRotLeaveGround = playerRot;
playerRotMode = 0;
playerRotCount = 0;
}
static function UpdateBackgroundSounds(){
backgroundSoundTimer--;
if (backgroundSoundTimer <= 0){
backgroundSoundTimer = Utils.RandBetweenInt(50, 100);
SoundPlayer.PlayRandomBetween("sfx_zombie", "sfx_zombie_03");
};
}
static function CountZombies():int{
var _local2:GameObj;
var _local1:int;
for each (_local2 in GameObjects.objs) {
if (((_local2.active) && (_local2.colFlag_isEnemy))){
_local1++;
};
};
return (_local1);
}
static function InitUpgrades(){
var _local1:Upgrade;
upgrades = new Array();
_local1 = new Upgrade("Rotation", 0.18, 0.25, 10, 100);
upgrades.push(_local1);
_local1 = new Upgrade("Acceleration", 0.3, 0.6, 10, 100);
upgrades.push(_local1);
_local1 = new Upgrade("Fire Rate", 12, 5, 7, 200);
upgrades.push(_local1);
_local1 = new Upgrade("Shot Speed", 5, 10, 10, 100);
upgrades.push(_local1);
_local1 = new Upgrade("Shot Spread", 0, 4, 5, 1000);
upgrades.push(_local1);
_local1 = new Upgrade("Shield Recharge", 0.2, 0.5, 10, 100);
upgrades.push(_local1);
_local1 = new Upgrade("Shield Power", 2, 0.5, 10, 100);
upgrades.push(_local1);
_local1 = new Upgrade("Shot Distance", 150, 300, 10, 100);
upgrades.push(_local1);
}
static function GetWeaponByName(_arg1):Weapon{
var _local2:Weapon;
for each (_local2 in weapons) {
if (_local2.name == _arg1){
return (_local2);
};
};
return (null);
}
static function SubmitStats(){
Kong.SubmitStat(currentScore, "score");
Kong.SubmitStat(numKills, "total_kills");
Kong.SubmitStat(numHeadshotKills, "total_headshots");
Kong.SubmitStat(totalPickupsCollected, "total_pickups");
Kong.SubmitStat((currentLevel + 1), "highest_level");
}
public static function RemoveObj_BallDie(_arg1:PhysObj_Instance){
physObjInstances.Remove(_arg1);
}
static function RenderRainbow():void{
var _local1:Array;
var _local2:int;
var _local3:Number;
var _local4:Number;
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:Number;
var _local9:Number;
var _local10:int;
var _local11:Number;
var _local12:Array;
var _local13:Graphics;
var _local14:Point;
var _local15:Number;
var _local16:uint;
rainbow_dir = (-0.5 + (Math.sin(rainbow_timer0) * 0.1));
rainbow_timer0 = (rainbow_timer0 + 0.006);
rainbow_starty = (300 + (Math.sin(rainbow_timer1) * 20));
rainbow_timer1 = (rainbow_timer1 + 0.006);
rainbow_dirchange = (0.03 + (Math.sin(rainbow_timer2) * 0.01));
rainbow_timer2 = (rainbow_timer2 + 0.006);
rainbow_startx = (-70 + (Math.sin(rainbow_timer3) * 40));
rainbow_timer3 = (rainbow_timer3 + 0.006);
rainbow_thickness = (30 + (Math.sin(rainbow_timer4) * 10));
rainbow_timer4 = (rainbow_timer4 + 0.006);
_local1 = new Array();
_local3 = rainbow_dir;
_local4 = rainbow_dirchange;
_local5 = rainbow_startx;
_local6 = rainbow_starty;
_local9 = 20;
_local10 = 100;
_local11 = rainbow_thickness;
_local2 = 0;
while (_local2 < _local10) {
_local1.push(new Point(_local5, _local6));
_local7 = (Math.cos(_local3) * _local9);
_local8 = (Math.sin(_local3) * _local9);
_local5 = (_local5 + _local7);
_local6 = (_local6 + _local8);
_local3 = (_local3 + _local4);
if (_local5 > 670){
_local2 = (_local10 + 1);
};
_local2++;
};
_local12 = new Array(4294901760, 4294944000, 4294967040, 4278222848, 4278190335, 4283105410, 4293821166);
_local13 = main.fillScreenMC.graphics;
_local15 = 0;
for each (_local16 in _local12) {
_local13.lineStyle(_local11, _local16, 1);
_local14 = _local1[0];
_local13.moveTo(_local14.x, _local14.y);
_local2 = 1;
while (_local2 < _local1.length) {
_local14 = _local1[_local2];
_local13.lineTo(_local14.x, (_local14.y + _local15));
_local2++;
};
_local13.moveTo(0, 0);
_local15 = (_local15 + (Math.cos(rainbow_dir) * (_local11 + 2)));
};
}
static function CaclulateScore(){
}
static function CountGameObjs():int{
var _local2:GameObj;
var _local1:int;
for each (_local2 in GameObjects.objs) {
if (((_local2.active) && (_local2.colFlag_isPlayer))){
_local1++;
};
};
return (_local1);
}
static function CountBodies():int{
var _local2:b2Body;
var _local1:int;
_local2 = world.GetBodyList();
while (_local2) {
_local1++;
_local2 = _local2.GetNext();
};
return (_local1);
}
public static function CollideWithPortal(_arg1:PhysObj_Instance){
DoPortal(_arg1);
_arg1.collideFunction = null;
_arg1.collidetimer = 0;
}
static function RenderEnemies(_arg1:BitmapData){
var _local2:GameObj;
for each (_local2 in GameObjects.objs) {
if (((((_local2.active) && (_local2.visible))) && (_local2.colFlag_isEnemy))){
_local2.Render(_arg1);
};
};
}
static function GetCurrentLevelInstances():Array{
return (levels[currentLevel].instances);
}
static function GetPhysObjInstanceByTypeName(_arg1:String):PhysObj_Instance{
var _local2:PhysObj_Instance;
for each (_local2 in physObjInstances.list) {
if (_local2.typeName == _arg1){
return (_local2);
};
};
return (null);
}
static function UpdatePlasma(_arg1:BitmapData){
}
static function InitMessageOverlay(_arg1:int){
var _local2:GameObj;
_local2 = GameObjects.AddObj(400, 100, 0);
_local2.InitMessageOverlay(_arg1);
}
public static function DoSwitchToFront(){
var _local1:PhysObj_Instance;
_local1 = GetPhysObjInstanceByName("player");
if (_local1 == null){
return;
};
_local1.SetBodyCollisionMask(-1, 3);
trace("SwitchToFront");
}
static function ResetBoost(){
boostMode = 0;
boostTimer = 0;
boostLevel = 0;
boostMultiplier = 0;
}
public static function DoSwitch(_arg1:String){
var _local2:PhysObj_Instance;
for each (_local2 in physObjInstances.list) {
if (_local2.switchFunction != null){
if (_local2.switchName == _arg1){
_local2.switchFunction();
};
if (_local2.switchName1 == _arg1){
_local2.switchFunction();
};
};
};
}
static function GetCurrentLevel():Level{
return (levels[currentLevel]);
}
public static function CollideWithMincer(_arg1:PhysObj_Instance){
_arg1.collideFunction = null;
_arg1.collidetimer = 0;
physObjInstances.Remove(_arg1);
numBallsActive--;
numPigsSacrificed++;
_arg1.collideWithInstance.TriggerPhysObj_Mincer();
}
public static function HaveAllAnimalsBeenBubbled():Boolean{
return (false);
}
static function RenderFloor():void{
var _local1:Number;
var _local2:Number;
var _local3:uint;
var _local4:uint;
var _local5:uint;
var _local6:uint;
var _local7:Graphics;
var _local8:Level;
var _local9:int;
var _local10:Point;
var _local11:Point;
var _local13:PhysLine;
var _local14:uint;
floorColorTimer = (floorColorTimer + 0.05);
floorColorTimer1 = (floorColorTimer1 + 0.03);
_local1 = ((128 + 64) + (Math.cos(floorColorTimer) * 16));
_local2 = (64 + (Math.sin(floorColorTimer1) * 16));
_local3 = uint(_local1);
_local4 = uint(_local2);
_local5 = (4278190080 + (_local3 << 8));
_local6 = (4278190080 + (_local4 << 8));
_local7 = main.fillScreenMC.graphics;
_local8 = GetCurrentLevel();
var _local12:Matrix = new Matrix();
for each (_local13 in _local8.lines) {
if (_local13.type == 0){
_local7.lineStyle(3, _local5, 1);
_local7.beginFill(_local6, 1);
_local11 = _local13.points[0].clone();
_local13.points[0].clone().x = (_local11.x - scrollX);
_local11.y = (_local11.y - scrollY);
_local7.moveTo(_local11.x, _local11.y);
_local9 = 1;
while (_local9 < _local13.points.length) {
_local10 = _local13.points[_local9].clone();
_local13.points[_local9].clone().x = (_local10.x - scrollX);
_local10.y = (_local10.y - scrollY);
_local7.lineTo(_local10.x, _local10.y);
_local9++;
};
_local7.endFill();
};
if (_local13.type == 1){
_local7.lineStyle(0, 0, 0);
_local7.beginFill(_local6, 1);
_local11 = _local13.points[0].clone();
_local13.points[0].clone().x = (_local11.x - scrollX);
_local11.y = (_local11.y - scrollY);
_local7.moveTo(_local11.x, _local11.y);
_local9 = 1;
while (_local9 < _local13.points.length) {
_local10 = _local13.points[_local9].clone();
_local13.points[_local9].clone().x = (_local10.x - scrollX);
_local10.y = (_local10.y - scrollY);
_local7.lineTo(_local10.x, _local10.y);
_local9++;
};
_local7.endFill();
};
if (_local13.type == 2){
_local7.lineStyle(3, _local5, 1);
_local7.beginFill(0, 0);
_local11 = _local13.points[0].clone();
_local13.points[0].clone().x = (_local11.x - scrollX);
_local11.y = (_local11.y - scrollY);
_local7.moveTo(_local11.x, _local11.y);
_local9 = 1;
while (_local9 < _local13.points.length) {
_local10 = _local13.points[_local9].clone();
_local13.points[_local9].clone().x = (_local10.x - scrollX);
_local10.y = (_local10.y - scrollY);
_local7.lineTo(_local10.x, _local10.y);
_local9++;
};
_local7.endFill();
};
};
return;
}
}
}//package
Section 171
//GameObj (GameObj)
package {
import flash.display.*;
import flash.events.*;
import flash.geom.*;
import flash.media.*;
import Box2D.Common.Math.*;
import Box2D.Collision.*;
import Box2D.Dynamics.*;
import Box2D.Dynamics.Joints.*;
import Box2D.Collision.Shapes.*;
import Box2D.Common.*;
import Box2D.Dynamics.Contacts.*;
public class GameObj {
var ccc:Boolean;
var paramValues:Array;
var bikeBodyGraphicID:int;
var bbb:Number;
public var xvel:Number;
var powerupMode:int;
var path:Poly;
public var todir:Number;
var extraXVel:Number;
var switchName1:String;
var fireTimerMax:int;
var aaa:Number;
var bd:BitmapData;
public var speed:Number;
public var colFlag_isEnemy:Boolean;
var objectDef:ObjectDef;
public var startx:Number;
public var ypos2:Number;
public var startz:Number;
public var ypos1:Number;
public var starty:Number;
public var colFlag_playercanbekilled:Boolean;
public var frame1:Number;
public var movementVec:Vec;
var bodyColBox:Rectangle;
var ct:ColorTransform;
public var visible:Boolean;
var weaponVolume:Number;
var shootLineFrame:Number;
var f1_attack:int;
public var yvel:Number;
var player_fireang:Number;
public var colFlag_isPhysObj:Boolean;
public var hitFunction:Function;
public var dir:Number;
public var radius:Number;
public var controlMode:int;
public var colFlag_isHose:Boolean;
public var colFlag_isBullet:Boolean;
var renderHealthBarTimer:int;
var lineSpeed:Number;
var EnemyUpdateFunctionCallback:Function;
var lineLoop:Boolean;
var EnemyHitByBulletFunctionCallback:Function;
var uniqueID:int;
var powerupTimer:int;
public var xpos1:Number;
public var xpos2:Number;
var f1_run:int;
public var colFlag_isPlatform:Boolean;
var maxHealth:Number;
public var zvel:Number;
var xflip:Boolean;
var trodInBloodTimer:int;
public var colFlag_killPlayer:Boolean;
var currentWeapon:int;
public var heightVel:Number;
var hopperIndex:int;
var currentPoly:Poly;
public var xacc:Number;
var powerupLevel:Number;
public var count:int;
var shotControllers:Array;
var xposmax:Number;
var reloadingTimer:int;
public var height:Number;
public var colFlag_isEnemyBullet:Boolean;
var flashTimer:int;
public var colFlag_jumpon:Boolean;
public var colFlag_isShootable:Boolean;
var lineIndex:int;
var maxSpeed:Number;
var scale:Number;
var numBullets:int;
var f0_run:int;
var alpha:Number;
public var yacc:Number;
public var frame:Number;
public var controlIndex:int;
public var subtype:int;
var firedFlag:Boolean;
public var oldxpos:Number;
public var timer1:Number;
var shieldLevel:Number;
public var toPosX:Number;
public var toPosY:Number;
var dist:Number;
public var driveVec:Vec;
public var main:Main;
var shieldLevelMax:Number;
var powerupLevelMax:Number;
var inFrontZone:Poly;
public var colFlag_isShop:Boolean;
var currentMaxSpeed:Number;
public var physObjOffsetY:Number;
public var oldypos:Number;
var playerSpeed:Number;
public var physObjOffsetX:Number;
var lane:int;
public var colFlag_isBlocker:Boolean;
public var graphicID:int;
var textMessage:String;
var speedmul:Number;
var headColBox:Rectangle;
var minFrame:int;
var muzzleflashFlag:Boolean;
var rotVel:Number;
public var yoffset:Number;
var waveDef:WaveDef;
public var colFlag_canBeShot:Boolean;
var health:Number;
var powerupTimerMax:int;
public var colFlag_isPowerup:Boolean;
var invincibleTimer:int;
var maxFrame:int;
public var physObjInitVarString:String;
public var colFlag_isPlayer:Boolean;
public var name:String;
var player_firex0:Number;
public var graphicID1:int;
var shootLineGraphicID:int;
public var colFlag_canBePickedUp:Boolean;
var player_firex1:Number;
public var colFlag_isCheckpoint:Boolean;
public var origspeed:Number;
var reloadingTimerMax:int;
var player_firey0:Number;
var lineResetAtEnd:Boolean;
var fireTimer:int;
var f1_diehead:int;
var initParams:String;
var paramNames:Array;
var player_firey1:Number;
var shootLineFlag:Boolean;
public var colFlag_isBackgroundObj:Boolean;
public var xpos:Number;
public var renderShadowFlag:Boolean;
var renderSmooth:Boolean;
var f1_die:int;
public var frameVel:Number;
var swapWeaponTimer:int;
var firedTimer:int;
var childGO:GameObj;
public var xoffset:Number;
public var active:Boolean;
var xvelmax:Number;
var healthBarY:Number;
var shieldOn:Boolean;
var player_firedir:int;
public var type:int;
public var ypos:Number;
public var frameVel1:Number;
public var timer:Number;
var f0_die:int;
var lineLinearPos:Number;
var flashFrame:Number;
var bulletTimer:int;
var door_timer:int;
var flashFlag:Boolean;
public var hitTimer:Number;
var bikeBodyOffsetY:Number;
var bikeBodyOffsetX:Number;
public var renderFunction:Function;
public var zpos:Number;
var f0_attack:int;
public var beenHitThisShot:Boolean;
public var colFlag_isBouncyPad:Boolean;
var f0_diehead:int;
var pickupIndex:int;
var lineMode:int;
var playerWeapons:Array;
public var updateFunction:Function;
public var additive:Boolean;
var numRepeats:int;
public var timerMax:Number;
var switchName:String;
var parentObj:GameObj;
var flashTimerMax:int;
var flashGraphicID:int;
var isPhysObj:Boolean;
public function GameObj(_arg1, _arg2, _arg3){
ct = new ColorTransform(0.1, 0.1, 0.1, 0.3);
super();
xpos = _arg2;
ypos = _arg3;
zpos = 1;
starty = _arg2;
startx = _arg2;
active = false;
main = _arg1;
zpos = 0;
graphicID = 0;
frame = 0;
frameVel = 0;
controlIndex = 0;
timer = 0;
timer1 = 0;
radius = 14;
minFrame = 0;
maxFrame = 0;
movementVec = new Vec();
}
function InitWheel():void{
renderSmooth = true;
}
public function InitEntrance(){
Game.goEntrance = this;
graphicID = GraphicObjects.GetIndexByName("Entrance");
frame = 0;
updateFunction = UpdateEntrance;
controlMode = 0;
}
function FireWeapon(){
var _local1:Weapon;
var _local2:Number;
var _local3:Number;
var _local4:Number;
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:Number;
var _local9:Number;
_local1 = Game.GetCurrentWeapon();
if (_local1.shootSound != ""){
SoundPlayer.Play(_local1.shootSound);
};
_local2 = MouseControl.x;
_local3 = MouseControl.y;
if (_local2 < xpos){
graphicID = GraphicObjects.GetIndexByName("player_backwards");
} else {
graphicID = GraphicObjects.GetIndexByName("player");
};
player_firedir = 1;
player_firex0 = (xpos - 4);
player_firey0 = ((ypos - 35) - 11);
if (_local2 < xpos){
player_firedir = 0;
_local2 = (xpos + (xpos - _local2));
};
_local4 = Math.atan2((_local3 - player_firey0), (_local2 - player_firex0));
player_fireang = _local4;
_local5 = 0.3;
if (player_fireang < -(_local5)){
player_fireang = -(_local5);
};
if (player_fireang > _local5){
player_fireang = _local5;
};
_local6 = player_firex0;
_local7 = player_firey0;
_local8 = (_local6 + (Math.cos(player_fireang) * _local1.maxRange));
_local9 = (_local7 + (Math.sin(player_fireang) * _local1.maxRange));
if (player_firedir == 0){
_local8 = (_local6 - (_local8 - _local6));
};
player_firex1 = _local8;
player_firey1 = _local9;
var _local10 = this;
_local10[_local1.shootFuncName]();
}
public function InitBase(){
colFlag_isEnemy = true;
graphicID = GraphicObjects.GetIndexByName("Base");
frame = 0;
updateFunction = UpdateBase;
hitFunction = HitBase;
GetParams();
fireTimerMax = (GetParamNumber("frequency", 3) * Defs.fps);
var _local1:Boolean = GetParamBool("randomstart", false);
fireTimer = 0;
if (_local1){
fireTimer = Utils.RandBetweenInt(fireTimer, fireTimerMax);
};
radius = 30;
}
function UpdateFireworks():void{
xpos = (xpos - Game.scrollXvel);
if (xpos < -30){
active = false;
};
if (controlMode == 1){
PlayAnimation();
};
}
function InitPlayerBullet_Rocket(_arg1:Number, _arg2:Number):void{
colFlag_isBullet = true;
graphicID = GraphicObjects.GetIndexByName("BulletRocket");
updateFunction = UpdatePlayerBullet_Rocket;
hitFunction = HitPlayerBullet_Rocket;
timer = 50;
movementVec.SetDxDy((_arg1 - xpos), (_arg2 - ypos), 20);
}
function InitPlayer():void{
var _local1:Weapon;
colFlag_isPhysObj = true;
colFlag_isPlayer = true;
updateFunction = UpdatePlayer;
renderFunction = RenderPlayer;
graphicID = GraphicObjects.GetIndexByName("player");
frame = 0;
frameVel = 1;
xpos = 400;
ypos = (200 + 150);
_local1 = Game.GetCurrentWeapon();
controlMode = 1;
fireTimer = 0;
fireTimerMax = _local1.fireRate;
health = (maxHealth = 100);
shootLineFlag = false;
shootLineFrame = 0;
shootLineGraphicID = 0;
muzzleflashFlag = false;
flashFrame = 0;
flashGraphicID = 0;
trodInBloodTimer = 0;
numBullets = _local1.clipSize;
reloadingTimer = 0;
swapWeaponTimer = 0;
firedTimer = 0;
weaponVolume = 0.5;
}
function RenderPlayer():void{
var _local1:Weapon;
var _local2:Number;
var _local3:Number;
var _local4:Number;
var _local5:int;
var _local6:Number;
var _local7:Number;
var _local8:Number;
var _local10:uint;
var _local11:int;
var _local12:Matrix;
var _local13:Point;
var _local14:int;
var _local15:Boolean;
var _local16:GameObj;
if (controlMode == 99){
RenderNormally();
return;
};
if (invincibleTimer > 0){
if ((invincibleTimer & 4) == 0){
return;
};
};
RenderNormally();
_local1 = Game.GetCurrentWeapon();
_local3 = (xpos - 4);
_local4 = (ypos - 35);
_local5 = 0;
if (player_firedir == 0){
_local5 = 1;
if (_local1.name == "crowbar"){
_local5 = 4;
};
};
if (_local1.name == "crowbar"){
if (firedTimer != 0){
_local14 = (firedTimer - 1);
firedTimer++;
if (_local14 > 3){
_local14 = 3;
firedTimer = 0;
};
};
_local5 = (_local5 + _local14);
};
if (player_firedir == 0){
_local6 = (xpos - 4);
_local7 = (ypos - 35);
_local2 = player_fireang;
_local2 = -(_local2);
RenderGraphicNormally(GraphicObjects.GetIndexByName(_local1.graphicName), _local5, _local6, _local7, 1, _local2);
};
if (player_firedir == 1){
_local6 = (xpos - 5);
_local7 = (ypos - 35);
_local2 = player_fireang;
RenderGraphicNormally(GraphicObjects.GetIndexByName(_local1.graphicName), _local5, _local6, _local7, 1, _local2);
};
_local6 = player_firex0;
_local7 = player_firey0;
_local8 = (_local6 + (Math.cos(player_fireang) * 400));
var _local9:Number = (_local7 + (Math.sin(player_fireang) * 400));
if (player_firedir == 0){
_local8 = (_local6 - (_local8 - _local6));
_local6 = (_local6 - (Math.cos(-(player_fireang)) * 70));
_local7 = (_local7 - (Math.sin(-(player_fireang)) * 70));
} else {
_local6 = (_local6 + (Math.cos(player_fireang) * 70));
_local7 = (_local7 + (Math.sin(player_fireang) * 70));
};
if (Game.levelState != Game.levelState_Play){
return;
};
_local10 = 4294901760;
_local11 = 100;
if (((_local1.displayLine) && ((firedFlag == false)))){
Utils.RenderDotLine(bd, _local6, _local7, player_firex1, player_firey1, _local11, _local10);
};
_local12 = new Matrix();
if (player_firedir == 0){
_local12.rotate(-(player_fireang));
_local13 = _local1.loff.clone();
_local13 = _local12.transformPoint(_local13);
} else {
_local12.rotate(player_fireang);
_local13 = _local1.roff.clone();
_local13 = _local12.transformPoint(_local13);
};
_local13.x = (_local13.x + _local3);
_local13.y = (_local13.y + _local4);
if (muzzleflashFlag){
_local15 = true;
if (player_firedir){
_local15 = false;
};
RenderGraphicNormally(flashGraphicID, int(flashFrame), _local13.x, _local13.y, 1, _local2, true, _local15);
};
if (trodInBloodTimer > 0){
if ((trodInBloodTimer & 2) == 0){
_local16 = GameObjects.AddObj(xpos, ypos, 0);
_local16.InitBloodyFootprint();
};
trodInBloodTimer--;
};
}
function InitCartridge(_arg1:Number, _arg2:int):void{
colFlag_isPhysObj = true;
updateFunction = UpdateCartridge;
renderFunction = RenderCartridge;
graphicID = GraphicObjects.GetIndexByName("Cartridges");
frame = _arg2;
height = (ypos - _arg1);
ypos = _arg1;
heightVel = -(Utils.RandBetweenFloat(10, 10));
xvel = Utils.RandBetweenFloat(-2, 2);
yvel = Utils.RandBetweenFloat(-2, 2);
rotVel = Utils.RandBetweenFloat(-0.5, 0.5);
}
function InitMiniBall():void{
updateFunction = UpdateMiniBall;
renderFunction = RenderMiniBall;
controlMode = 0;
frame1 = 0;
graphicID1 = GraphicObjects.GetIndexByName("Bubble");
}
function InitObj_Bouncer(){
xoffset = 0;
yoffset = 0;
updateFunction = UpdateBouncer;
renderFunction = RenderBouncer;
controlMode = 0;
timer = 0;
}
function UpdateSplatTimeOverlay(){
ypos = 250;
timer--;
if (timer <= 0){
active = false;
};
}
function UpdateSideFlower(){
var _local1:Number = Game.scrollY;
_local1 = (_local1 - 50);
if (ypos < _local1){
ypos = (ypos + 600);
};
if (ypos > (_local1 + 600)){
ypos = (ypos - 600);
};
if (controlMode == 0){
scale = 1;
timer--;
if (timer <= 0){
controlMode = 1;
timer = Utils.RandBetweenInt(100, 300);
};
} else {
if (controlMode == 1){
scale = (scale + 0.02);
if (scale >= 1.3){
controlMode = 2;
};
} else {
if (controlMode == 2){
scale = (scale - 0.02);
if (scale <= 1){
scale = 1;
controlMode = 0;
};
};
};
};
}
function GetParams():void{
var _local1:String;
var _local3:String;
var _local4:Array;
paramNames = new Array();
paramValues = new Array();
_local1 = Utils.RemoveWhiteSpace(initParams);
_local1 = _local1.toLowerCase();
var _local2:Array = _local1.split(",");
for each (_local3 in _local2) {
_local4 = _local3.split("=");
paramNames.push(_local4[0]);
paramValues.push(_local4[1]);
};
}
function GetLineIndexByName(_arg1:String):int{
var _local4:PhysLine;
var _local2:Level = Game.GetCurrentLevel();
var _local3:int;
for each (_local4 in _local2.lines) {
if (_local4.name == _arg1){
return (_local3);
};
_local3++;
};
return (-1);
}
function InPlayerRange(_arg1:Number):Boolean{
var _local2:* = (_arg1 * _arg1);
return ((Utils.Dist2BetweenPoints(xpos, ypos, Game.goPlayer.xpos, Game.goPlayer.ypos) < _local2));
}
function SetZombieType(_arg1=-1){
if (_arg1 == -1){
type = Utils.RandBetweenInt(0, 7);
} else {
type = _arg1;
};
bodyColBox = new Rectangle(-10, -60, 20, 60);
headColBox = new Rectangle(0, -80, 20, 20);
speedmul = 1;
health = (3 + (Number(Game.currentLevel) / 2.5));
healthBarY = -90;
if (type == 0){
f0_run = (1 - 1);
f1_run = (13 - 1);
f0_die = (14 - 1);
f1_die = (38 - 1);
f0_attack = (39 - 1);
f1_attack = (51 - 1);
f0_diehead = (52 - 1);
f1_diehead = (70 - 1);
graphicID = GraphicObjects.GetIndexByName("enemy1");
};
if (type == 1){
f0_run = (1 - 1);
f1_run = (13 - 1);
f0_die = (14 - 1);
f1_die = (38 - 1);
f0_attack = (39 - 1);
f1_attack = (51 - 1);
f0_diehead = (52 - 1);
f1_diehead = (70 - 1);
graphicID = GraphicObjects.GetIndexByName("enemy1_2");
};
if (type == 2){
f0_run = (1 - 1);
f1_run = (12 - 1);
f0_die = (13 - 1);
f1_die = (29 - 1);
f0_attack = (30 - 1);
f1_attack = (46 - 1);
f0_diehead = (47 - 1);
f1_diehead = (70 - 1);
graphicID = GraphicObjects.GetIndexByName("enemy2");
speedmul = 1.1;
health = (health * 2);
};
if (type == 3){
f0_run = (1 - 1);
f1_run = (12 - 1);
f0_die = (13 - 1);
f1_die = (29 - 1);
f0_attack = (30 - 1);
f1_attack = (46 - 1);
f0_diehead = (47 - 1);
f1_diehead = (70 - 1);
graphicID = GraphicObjects.GetIndexByName("enemy2_2");
speedmul = 1.1;
health = (health * 2);
};
if (type == 4){
f0_run = (1 - 1);
f1_run = (13 - 1);
f0_die = (14 - 1);
f1_die = (42 - 1);
f0_attack = (43 - 1);
f1_attack = (58 - 1);
f0_diehead = (59 - 1);
f1_diehead = (76 - 1);
graphicID = GraphicObjects.GetIndexByName("enemy5");
speedmul = 1.2;
health = (health * 3);
};
if (type == 5){
f0_run = (1 - 1);
f1_run = (13 - 1);
f0_die = (14 - 1);
f1_die = (42 - 1);
f0_attack = (43 - 1);
f1_attack = (58 - 1);
f0_diehead = (59 - 1);
f1_diehead = (76 - 1);
graphicID = GraphicObjects.GetIndexByName("enemy5_2");
speedmul = 1.2;
health = (health * 3);
};
if (type == 6){
f0_run = (1 - 1);
f1_run = (8 - 1);
f0_die = (21 - 1);
f1_die = (42 - 1);
f0_attack = (9 - 1);
f1_attack = (20 - 1);
f0_diehead = (21 - 1);
f1_diehead = (42 - 1);
graphicID = GraphicObjects.GetIndexByName("enemy3");
bodyColBox = new Rectangle(-35, -38, 70, 38);
headColBox = new Rectangle(19, -58, 20, 20);
speedmul = 2;
health = (health * 4);
healthBarY = -60;
};
if (type == 7){
f0_run = (1 - 1);
f1_run = (15 - 1);
f0_die = (39 - 1);
f1_die = (65 - 1);
f0_attack = (16 - 1);
f1_attack = (38 - 1);
f0_diehead = (66 - 1);
f1_diehead = (86 - 1);
graphicID = GraphicObjects.GetIndexByName("enemy4");
bodyColBox = new Rectangle(-20, -86, 37, 86);
headColBox = new Rectangle(-1, -111, 25, 25);
health = (health * 8);
healthBarY = -140;
};
maxHealth = health;
}
function UpdateEnemy_Path(){
var _local1:Point;
if (controlMode == 0){
_local1 = UpdateLine(0);
} else {
_local1 = UpdateLine(lineSpeed);
if (lineLoop == false){
if (lineLinearPos >= 1){
lineLinearPos = 1;
if (lineResetAtEnd){
lineLinearPos = 0;
};
controlMode = 0;
};
};
};
xpos = _local1.x;
ypos = _local1.y;
dir = Math.atan2((ypos - oldypos), (xpos - oldxpos));
}
function UpdateZombie():void{
var _local6:Boolean;
if (renderHealthBarTimer > 0){
renderHealthBarTimer--;
};
var _local1:GameObj = Game.goPlayer;
if (Game.playerHeadGO != null){
_local1 = Game.playerHeadGO;
};
var _local2:Number = Math.abs((_local1.xpos - xpos));
var _local3:Number = Math.abs((_local1.ypos - ypos));
var _local4:Number = (_local1.xpos - xpos);
var _local5:Number = (_local1.ypos - ypos);
xpos = (xpos + (Game.scrollXvelMax - Game.scrollXvel));
xacc = 0.3;
if (controlMode == 0){
xvel = (xvel + xacc);
if (xvel > xvelmax){
xvel = xvelmax;
};
CycleAnimationEx();
xpos = (xpos + xvel);
if (_local2 < 200){
if (_local5 > 10){
ypos = (ypos + yvel);
} else {
if (_local5 < -10){
ypos = (ypos - yvel);
};
};
};
if (xpos > _local1.xpos){
controlMode = 1;
yvel = Utils.RandBetweenFloat(0.3, 0.7);
};
} else {
if (controlMode == 1){
xvel = (xvel + xacc);
if (xvel > xvelmax){
xvel = xvelmax;
};
CycleAnimationEx();
xpos = (xpos + xvel);
if (_local2 > 100){
controlMode = 2;
aaa = Utils.RandBetweenFloat(0.8, 1.2);
bbb = Utils.RandBetweenFloat(-50, -120);
};
if (_local5 > 10){
ypos = (ypos + yvel);
} else {
if (_local5 < -10){
ypos = (ypos - yvel);
};
};
} else {
if (controlMode == 2){
xvel = (xvel - aaa);
if (xvel < -6){
xvel = -6;
};
CycleAnimationEx();
xpos = (xpos + xvel);
if (xpos < (_local1.xpos - bbb)){
controlMode = 0;
};
if (_local5 > 10){
ypos = (ypos + yvel);
} else {
if (_local5 < -10){
ypos = (ypos - yvel);
};
};
};
};
};
if (controlMode < 10){
if (_local2 < 40){
if (_local3 < 20){
xvel = 0;
minFrame = f0_attack;
maxFrame = f1_attack;
frame = minFrame;
controlMode = 10;
ccc = false;
};
};
extraXVel = (extraXVel * 0.9);
xpos = (xpos + extraXVel);
} else {
if (controlMode == 10){
if (_local5 > 10){
ypos = (ypos + yvel);
} else {
if (_local5 < -10){
ypos = (ypos - yvel);
};
};
_local6 = PlayAnimationEx();
if (ccc == false){
if (frame >= (minFrame + 5)){
Game.goPlayer.PlayerHit(40);
ccc = true;
};
};
if (_local6){
minFrame = f0_run;
maxFrame = f1_run;
frame = minFrame;
controlMode = 0;
xvel = -5;
};
extraXVel = (extraXVel * 0.9);
xpos = (xpos + extraXVel);
} else {
if (controlMode == 100){
PlayAnimationEx();
if (frame > (minFrame + 10)){
controlMode = 101;
};
} else {
if (controlMode == 101){
PlayAnimationEx();
xpos = (xpos - Game.scrollXvel);
if (xpos < -30){
active = false;
};
};
};
};
};
if (xpos > 820){
active = false;
};
if (Game.playerHeadGO != null){
if (Game.playerHeadGO.controlMode == 1){
if (Utils.DistBetweenPoints(xpos, ypos, Game.playerHeadGO.xpos, Game.playerHeadGO.ypos) < 30){
Game.playerHeadGO.HeadKicked();
};
};
};
}
function GameObj_UpdateCycleAnim():void{
CycleAnimation();
}
function RenderBlockCollision():void{
var _local1:Rectangle;
var _local2:Rectangle;
if ((Debug.debugMode & 4) == 0){
return;
};
if (objectDef == null){
return;
};
if (objectDef.colRects.length == 0){
return;
};
for each (_local2 in objectDef.colRects) {
_local1 = _local2.clone();
_local1.x = (_local1.x + xpos);
_local1.y = (_local1.y + ypos);
_local1.x = (_local1.x - Game.scrollX);
_local1.y = (_local1.y - Game.scrollY);
bd.fillRect(_local1, 1082163328);
};
for each (_local2 in objectDef.shieldColRects) {
_local1 = _local2.clone();
_local1.x = (_local1.x + xpos);
_local1.y = (_local1.y + ypos);
_local1.x = (_local1.x - Game.scrollX);
_local1.y = (_local1.y - Game.scrollY);
bd.fillRect(_local1, 1082163200);
};
}
function UpdateLine(_arg1:Number):Point{
lineLinearPos = (lineLinearPos + _arg1);
if (lineLinearPos > 1){
if (lineLoop == true){
lineLinearPos = (lineLinearPos - 1);
} else {
lineLinearPos = 1;
};
};
if (lineLinearPos < 0){
if (lineLoop == true){
lineLinearPos = (lineLinearPos + 1);
} else {
lineLinearPos = 0;
};
};
var _local2:PhysLine = Game.GetCurrentLevel().lines[lineIndex];
if (_local2 == null){
return (new Point(0, 0));
};
var _local3:Point = _local2.GetInterpolatedPoint(lineLinearPos, lineLoop, lineMode);
return (_local3);
}
function UpdateStartZombie():void{
CycleAnimationEx();
var _local1:GameObj = Game.goPlayer;
var _local2:Number = Math.abs((_local1.xpos - xpos));
var _local3:Number = Math.abs((_local1.ypos - ypos));
var _local4:Number = (_local1.xpos - xpos);
var _local5:Number = (_local1.ypos - ypos);
xpos = (xpos + (Game.scrollXvelMax - Game.scrollXvel));
if (controlMode == 0){
xpos = (xpos + xvel);
if (xpos >= xposmax){
controlMode = 1;
};
} else {
xpos = (xpos + xvel);
xvel = (xvel - 0.6);
if (xpos < -20){
active = false;
};
};
}
function RenderBouncer(){
var _local1:Number;
var _local2:Number;
_local1 = xpos;
_local2 = ypos;
xpos = (xpos + xoffset);
ypos = (ypos + yoffset);
RenderNormally();
xpos = _local1;
ypos = _local2;
}
function RenderNormally(_arg1:Boolean=true){
var _local4:String;
var _local2:Number = (xpos + xpos1);
var _local3:Number = (ypos + ypos1);
if (_arg1){
};
if (_local2 < -1000){
return;
};
if (_local2 > (Defs.displayarea_w + 500)){
return;
};
if (_local3 < -1000){
return;
};
if (_local3 > (Defs.displayarea_h + 500)){
return;
};
if (((!((scale == 1))) || (!((dir == 0))))){
GraphicObjects.RenderAtRotScaled(graphicID, frame, bd, _local2, _local3, false, scale, dir, null, renderSmooth);
} else {
if (additive){
GraphicObjects.RenderAtAdditive(graphicID, frame, bd, _local2, _local3, alpha);
} else {
GraphicObjects.RenderAt(graphicID, frame, bd, _local2, _local3, false);
};
};
if (Debug.IsSet(1)){
_local4 = ((("x:" + int(xpos)) + " y:") + int(ypos));
GraphicObjects.RenderStringAt(bd, GraphicObjects.gfx_font1, _local2, _local3, _local4, null, -1);
};
}
function InitAnimalLost():void{
graphicID = GraphicObjects.GetIndexByName("AnimalLost");
frame = 0;
frameVel = 1;
updateFunction = UpdateAnimalLost;
ypos = (Game.scrollY + 360);
if (xpos < 30){
xpos = 30;
};
if (xpos > (640 - 30)){
xpos = (640 - 30);
};
}
public function InitDoor_Timed(){
GetParams();
colFlag_isBackgroundObj = true;
graphicID = GraphicObjects.GetIndexByName("Door01");
updateFunction = UpdateDoor_Timed;
var _local1:int = GraphicObjects.GetNumFrames(graphicID);
minFrame = (_local1 - (_local1 * GetParamNumber("max", 1)));
maxFrame = _local1;
maxFrame--;
frame = minFrame;
door_timer = (Defs.fps * GetParamNumber("delay"));
timer = (Defs.fps * GetParamNumber("initialdelay", 0));
var _local2:Number = GetParamNumber("movetime", 1);
controlMode = 1;
frameVel = (((maxFrame - minFrame) / Defs.fps) * _local2);
frameVel = (frameVel * -1);
}
public function UpdateEnemy_AntiGraviton(){
var _local1:GameObj;
var _local2:Vec;
CycleAnimation();
if (InPlayerRange(120)){
_local1 = Game.goPlayer;
_local2 = new Vec();
_local2.SetDxDy((_local1.xpos - xpos), (_local1.ypos - ypos), 0.3);
_local1.movementVec.Add(_local2);
};
}
function PlayerSetStartMode():void{
controlMode = 100;
xpos = -20;
xvel = 15;
ypos = (200 + 125);
}
function UpdateCartridge():void{
if (controlMode == 0){
xpos = (xpos + xvel);
ypos = (ypos + yvel);
heightVel = (heightVel + 1);
height = (height + heightVel);
if (height >= 0){
height = 0;
controlMode = 1;
};
dir = (dir + rotVel);
} else {
xpos = (xpos - Game.scrollXvel);
if (xpos < -30){
active = false;
};
};
}
public function BaseFireBullet_StraightRocketLauncher(){
var _local1:GameObj;
var _local2:Number = dir;
var _local3:Number = xpos;
var _local4:Number = ypos;
_local3 = (_local3 + (Math.sin(_local2) * 25));
_local4 = (_local4 + (-(Math.cos(_local2)) * 25));
_local1 = GameObjects.AddObj(_local3, _local4, 0);
_local1.InitEnemyBullet(this, 1);
}
public function BaseFireBullet(){
var _local1:GameObj;
var _local2:Number = dir;
var _local3:Number = xpos;
var _local4:Number = ypos;
_local3 = (_local3 + (Math.sin(_local2) * 25));
_local4 = (_local4 + (-(Math.cos(_local2)) * 25));
_local1 = GameObjects.AddObj(_local3, _local4, 0);
_local1.InitEnemyBullet(this, 0);
}
function UpdateObj_Ship(){
var _local1:Number;
timer++;
_local1 = (Math.sin((timer * 0.1)) * 5);
ypos1 = _local1;
}
public function InitPinDisappear_Broken(){
health = 32;
frame = (health / 2);
}
public function InitMessage(_arg1:int):void{
updateFunction = UpdateMessage;
timer = (Defs.fps * 0.8);
frame = _arg1;
graphicID = GraphicObjects.GetIndexByName("StartRaceText");
}
function PlayerFireBullet(){
var _local1:GameObj;
var _local2:Number;
var _local3:Number;
var _local4:int;
_local2 = (xpos + (driveVec.GetUnitXComponent() * 20));
_local3 = (ypos + (driveVec.GetUnitYComponent() * 20));
_local4 = Game.upgrades[4].GetValue();
if (_local4 == 0){
_local1 = GameObjects.AddObj(_local2, _local3, 0);
_local1.InitBullet(this, 0, 0);
};
if (_local4 == 1){
_local1 = GameObjects.AddObj(_local2, _local3, 0);
_local1.InitBullet(this, -0.1, 0);
_local1 = GameObjects.AddObj(_local2, _local3, 0);
_local1.InitBullet(this, 0.1, 0);
};
if (_local4 == 2){
_local1 = GameObjects.AddObj(_local2, _local3, 0);
_local1.InitBullet(this, -0.15, 0);
_local1 = GameObjects.AddObj(_local2, _local3, 0);
_local1.InitBullet(this, 0, 0);
_local1 = GameObjects.AddObj(_local2, _local3, 0);
_local1.InitBullet(this, 0.15, 0);
};
if (_local4 == 3){
_local1 = GameObjects.AddObj(_local2, _local3, 0);
_local1.InitBullet(this, -0.2, 0);
_local1 = GameObjects.AddObj(_local2, _local3, 0);
_local1.InitBullet(this, -0.1, 0);
_local1 = GameObjects.AddObj(_local2, _local3, 0);
_local1.InitBullet(this, 0.1, 0);
_local1 = GameObjects.AddObj(_local2, _local3, 0);
_local1.InitBullet(this, 0.2, 0);
};
if (_local4 == 4){
_local1 = GameObjects.AddObj(_local2, _local3, 0);
_local1.InitBullet(this, -0.3, 0);
_local1 = GameObjects.AddObj(_local2, _local3, 0);
_local1.InitBullet(this, -0.15, 0);
_local1 = GameObjects.AddObj(_local2, _local3, 0);
_local1.InitBullet(this, 0, 0);
_local1 = GameObjects.AddObj(_local2, _local3, 0);
_local1.InitBullet(this, 0.15, 0);
_local1 = GameObjects.AddObj(_local2, _local3, 0);
_local1.InitBullet(this, 0.3, 0);
};
}
function InitBallBubble(_arg1:GameObj):void{
parentObj = _arg1;
updateFunction = UpdateBallBubble;
renderFunction = RenderBallBubble;
zpos = -1000;
}
function UpdateObj_Conveyor(){
CycleAnimation();
}
function PlayerShieldHitByBullet(_arg1:GameObj){
ApplyImpulse(_arg1.xvel, _arg1.yvel, 3);
}
function IsInWorld(_arg1:Number):Boolean{
if (xpos < (0 - _arg1)){
return (false);
};
if (ypos < (0 - _arg1)){
return (false);
};
if (xpos > (Defs.displayarea_w + _arg1)){
return (false);
};
if (ypos > (Defs.displayarea_h + _arg1)){
return (false);
};
return (true);
}
public function UpdatePickup(){
xpos = (xpos - Game.scrollXvel);
if (xpos < -30){
active = false;
};
}
function UpdateAsteroid():void{
dir = (dir + rotVel);
xpos = (xpos + xvel);
ypos = (ypos + yvel);
var _local1:Number = 500;
if (xpos < (Game.scrollX - _local1)){
active = false;
};
if (ypos < (Game.scrollY - _local1)){
active = false;
};
if (xpos > ((Game.scrollX + 600) + _local1)){
active = false;
};
if (ypos > ((Game.scrollY + 600) + _local1)){
active = false;
};
}
function InitBloodPuddle():void{
colFlag_isPhysObj = true;
updateFunction = UpdateBloodPuddle;
graphicID = GraphicObjects.GetIndexByName("BloodPuddle01");
frame = Utils.RandBetweenInt(0, 3);
xpos = (xpos + Utils.RandBetweenFloat(-10, 10));
}
function FireShotgun(){
var _local1:Number;
var _local2:int;
_local1 = -50;
_local2 = 0;
while (_local2 < 5) {
ShootBulletImmediate(player_firex0, player_firey0, player_firex1, (player_firey1 + _local1), false);
_local1 = (_local1 + 25);
_local2++;
};
}
function UpdateBlocker():void{
xpos = (xpos - Game.scrollXvel);
if (xpos < -100){
active = false;
};
if (Math.abs((Game.goPlayer.ypos - ypos)) < 20){
if (Math.abs((Game.goPlayer.xpos - xpos)) < 100){
Game.scrollXvel = 8;
if (type == 0){
Game.goPlayer.trodInBloodTimer = Game.trodInBloodMaxTime;
};
};
};
}
public function InitEnemy_Blocker(){
colFlag_isEnemy = true;
graphicID = GraphicObjects.GetIndexByName("Blocker");
frame = 0;
updateFunction = UpdateEnemy_Blocker;
hitFunction = HitBase;
radius = 30;
frame = 0;
frameVel = 0.5;
health = (maxHealth = 5);
}
function HitFireworks(_arg1:int, _arg2:Boolean=false):void{
colFlag_isShootable = false;
controlMode = 1;
DoExplosion(20, 400);
SoundPlayer.Play("sfx_fireworksexplosion");
}
function RenderBall():void{
RenderNormally();
}
function InitBloodyFootprint():void{
colFlag_isPhysObj = true;
updateFunction = UpdateBloodyFootprint;
graphicID = GraphicObjects.GetIndexByName("BloodyFootprints");
frame = Utils.RandBetweenInt(0, 2);
}
function PlayerHit(_arg1:Number):void{
var _local2:GameObj;
if (controlMode > 10){
return;
};
if (Game.levelState != Game.levelState_Play){
return;
};
if (invincibleTimer > 0){
return;
};
health = (health - _arg1);
if (health <= 0){
_local2 = GameObjects.AddObj(xpos, ypos, zpos);
_local2.InitPlayerHead((ypos + 60));
health = 0;
controlMode = 99;
SoundPlayer.Play("sfx_playerdie");
graphicID = GraphicObjects.GetIndexByName("playerdeath");
frame = 0;
frameVel = 1;
Game.InitLevelState(Game.levelState_Dead);
Lic.Newgrounds_UnlockMedal("Pansy");
} else {
SoundPlayer.PlayRandomBetween("sfx_playerhit01", "sfx_playerhit02");
};
invincibleTimer = (Defs.fps * 2);
}
public function Update():void{
oldxpos = xpos;
oldypos = ypos;
if (updateFunction != null){
updateFunction();
};
if (colFlag_isPhysObj){
zpos = (1000 - ypos);
};
}
public function HitBase(){
health--;
if (health <= 0){
health = 0;
EnemyHitParticles();
active = false;
SoundPlayer.Play("PickupSFX");
};
}
function FireRocket(){
ShootRocket(player_firex0, player_firey0, player_firex1, player_firey1);
}
public function InitEnemy_AntiGraviton(){
graphicID = GraphicObjects.GetIndexByName("AntiGraviton");
frame = 0;
frameVel = 1;
updateFunction = UpdateEnemy_AntiGraviton;
hitFunction = HitBase;
timer = 0;
controlMode = 0;
}
function HitBarrel(_arg1:int, _arg2:Boolean=false):void{
colFlag_isShootable = false;
controlMode = 1;
Game.numZombiesKilledWithBarrel = 0;
DoExplosion(10, 400);
trace(("Zombiekilled with barrel: " + Game.numZombiesKilledWithBarrel));
if (Game.numZombiesKilledWithBarrel >= 10){
Lic.Newgrounds_UnlockMedal("BOOM!");
};
SoundPlayer.Play("sfx_barrel_explode");
}
public function UpdateEnemy_Spewer(){
var _local1:GameObj;
timer--;
if (timer <= 0){
_local1 = GameObjects.AddObj(xpos, ypos, 0);
_local1.InitEnemyBullet(this, 3, dir);
timer = 30;
};
dir = (dir + rotVel);
if (dir >= (Math.PI * 2)){
dir = (dir - (Math.PI * 2));
};
}
function InitBarrel():void{
colFlag_isPhysObj = true;
colFlag_isShootable = true;
updateFunction = UpdateBarrel;
renderFunction = RenderBarrel;
hitFunction = HitBarrel;
xpos = (800 + 50);
ypos = (200 + Utils.RandBetweenFloat(0, 250));
frame = 0;
frameVel = 1;
graphicID = GraphicObjects.GetIndexByName("ExplosiveBarrel");
controlMode = 0;
bodyColBox = new Rectangle(-20, -63, 40, 63);
}
function RenderBarrel():void{
var _local1:Rectangle;
RenderNormally();
if (Debug.IsSet(1)){
_local1 = bodyColBox.clone();
_local1.x = (_local1.x + xpos);
_local1.y = (_local1.y + ypos);
Utils.RenderRectangle(bd, _local1, 4294901760);
};
}
function HitPlayerBullet_Rocket():void{
var _local1:Weapon;
var _local2:GameObj;
SoundPlayer.Play("sfx_explode");
_local1 = Game.GetWeaponByName("rocketlauncher");
DoExplosion(_local1.damage, 200);
_local2 = GameObjects.AddObj(xpos, ypos, 0);
_local2.InitRocketExplosion();
active = false;
}
function FireFlamethrower(){
var _local1:Weapon;
var _local2:Number;
var _local3:Number;
var _local4:Matrix;
var _local5:Point;
var _local6:Number;
_local1 = Game.GetCurrentWeapon();
_local2 = (xpos - 4);
_local3 = (ypos - 35);
_local4 = new Matrix();
if (player_firedir == 0){
_local4.rotate(-(player_fireang));
_local5 = _local1.loff.clone();
_local5 = _local4.transformPoint(_local5);
} else {
_local4.rotate(player_fireang);
_local5 = _local1.roff.clone();
_local5 = _local4.transformPoint(_local5);
};
_local5.x = (_local5.x + _local2);
_local5.y = (_local5.y + _local3);
_local6 = Utils.RandBetweenFloat(-20, 20);
ShootFlamethrower(_local5.x, _local5.y, player_firex1, (player_firey1 + _local6));
}
public function InitBase_HomingRocketLauncher(){
colFlag_isEnemy = true;
graphicID = GraphicObjects.GetIndexByName("HomingRocketLauncher");
frame = 0;
updateFunction = UpdateBase_HomingRocketLauncher;
hitFunction = HitBase;
GetParams();
fireTimerMax = (GetParamNumber("frequency", 5) * Defs.fps);
fireTimer = 0;
radius = 30;
}
function UpdateAnimalLost(){
ypos = (Game.scrollY + 360);
if (xpos < 30){
xpos = 30;
};
if (xpos > (640 - 30)){
xpos = (640 - 30);
};
if (PlayAnimation()){
active = false;
};
}
public function UpdateDoor_Timed(){
if (controlMode == 0){
if (PlayAnimationEx()){
controlMode = 1;
timer = door_timer;
};
} else {
if (controlMode == 1){
timer--;
if (timer <= 0){
controlMode = 0;
frameVel = (frameVel * -1);
};
};
};
}
function ShootFlamethrower(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number):void{
var _local5:GameObj;
_local5 = GameObjects.AddObj(_arg1, _arg2, zpos);
_local5.InitPlayerBullet_Flamethrower(_arg3, _arg4);
}
function GetParamNumber(_arg1:String, _arg2:Number=0):Number{
var _local3:int = paramNames.indexOf(_arg1);
if (_local3 != -1){
return (Number(paramValues[_local3]));
};
return (_arg2);
}
public function InitPhysicsObject(_arg1:int, _arg2:int, _arg3:Number=0, _arg4:Number=0, _arg5:String="", _arg6:Boolean=false, _arg7:String=""){
initParams = _arg7;
graphicID = _arg1;
frame = _arg2;
}
function UpdatePlayer():void{
var _local1:Boolean;
var _local2:Boolean;
var _local3:Boolean;
var _local4:Boolean;
var _local6:Boolean;
var _local7:Boolean;
var _local8:Boolean;
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:Weapon;
var _local18:Number;
var _local19:Number;
var _local20:Matrix;
var _local21:Point;
var _local22:GameObj;
var _local23:Point;
var _local24:Number;
var _local25:SoundChannel;
if (invincibleTimer > 0){
invincibleTimer--;
};
_local1 = false;
_local2 = false;
_local3 = false;
_local4 = false;
var _local5:Boolean;
_local6 = false;
_local7 = false;
_local8 = false;
if (KeyReader.Down(KeyReader.KEY_UP)){
_local1 = true;
};
if (KeyReader.Down(KeyReader.KEY_DOWN)){
_local2 = true;
};
if (KeyReader.Down(KeyReader.KEY_LEFT)){
_local3 = true;
};
if (KeyReader.Down(KeyReader.KEY_RIGHT)){
_local4 = true;
};
if (KeyReader.Down(KeyReader.KEY_W)){
_local1 = true;
};
if (KeyReader.Down(KeyReader.KEY_S)){
_local2 = true;
};
if (KeyReader.Down(KeyReader.KEY_A)){
_local3 = true;
};
if (KeyReader.Down(KeyReader.KEY_D)){
_local4 = true;
};
if (KeyReader.Pressed(KeyReader.KEY_R)){
_local7 = true;
};
if (KeyReader.Pressed(KeyReader.KEY_SPACE)){
_local8 = true;
};
if (KeyReader.Pressed(KeyReader.KEY_NUM_0)){
_local8 = true;
};
if (controlMode == 99){
if (PlayAnimation()){
xpos = (xpos - Game.scrollXvel);
};
return;
};
if (controlMode == 100){
xpos = (xpos + xvel);
if (xpos > 400){
xvel = (xvel - 0.8);
if (xvel <= 0){
xvel = 0;
controlMode = 0;
};
};
CycleAnimation();
} else {
if (controlMode == 101){
xpos = (xpos + 10);
if (xpos > 900){
xpos = 900;
};
CycleAnimation();
return;
} else {
if (_local6){
Game.CycleWeapon(1);
muzzleflashFlag = false;
shootLineFlag = false;
};
CycleAnimation();
yvel = 0;
xvel = 0;
if (_local1){
yvel = -6;
} else {
if (_local2){
yvel = 6;
};
};
if (_local3){
xvel = -4;
} else {
if (_local4){
xvel = 4;
};
};
xpos = (xpos + xvel);
ypos = (ypos + yvel);
if (xpos < 100){
xpos = 100;
};
if (xpos > 700){
xpos = 700;
};
if (ypos < 200){
ypos = 200;
};
if (ypos > 500){
ypos = 500;
};
};
};
_local9 = MouseControl.x;
_local10 = MouseControl.y;
if (_local9 < xpos){
graphicID = GraphicObjects.GetIndexByName("player_backwards");
} else {
graphicID = GraphicObjects.GetIndexByName("player");
};
player_firedir = 1;
player_firex0 = (xpos - 4);
player_firey0 = ((ypos - 35) - 11);
if (_local9 < xpos){
player_firedir = 0;
_local9 = (xpos + (xpos - _local9));
};
_local11 = Math.atan2((_local10 - player_firey0), (_local9 - player_firex0));
player_fireang = _local11;
_local12 = 0.3;
if (player_fireang < -(_local12)){
player_fireang = -(_local12);
};
if (player_fireang > _local12){
player_fireang = _local12;
};
_local13 = player_firex0;
_local14 = player_firey0;
_local15 = (_local13 + (Math.cos(player_fireang) * 700));
_local16 = (_local14 + (Math.sin(player_fireang) * 700));
if (player_firedir == 0){
_local15 = (_local13 - (_local15 - _local13));
};
player_firex1 = _local15;
player_firey1 = _local16;
firedFlag = false;
fireTimer--;
_local17 = Game.GetCurrentWeapon();
if (muzzleflashFlag){
flashFrame++;
if (flashFrame >= GraphicObjects.GetNumFrames(flashGraphicID)){
flashFrame = 0;
muzzleflashFlag = false;
};
};
if (shootLineFlag){
shootLineFrame++;
if (shootLineFrame >= GraphicObjects.GetNumFrames(shootLineGraphicID)){
shootLineFrame = 0;
shootLineFlag = false;
};
};
if (((_local8) && (!((Game.secondaryWeapon == -1))))){
swapWeaponTimer = Game.swapTimerMax;
};
if (_local7){
reloadingTimer = (reloadingTimerMax = _local17.reloadTime);
if (_local17.reloadSound != ""){
SoundPlayer.Play(_local17.reloadSound);
};
};
if (swapWeaponTimer > 0){
swapWeaponTimer--;
if (swapWeaponTimer == 0){
Game.SwapWeapons();
};
} else {
if (reloadingTimer > 0){
reloadingTimer--;
if (reloadingTimer <= 0){
reloadingTimer = 0;
numBullets = _local17.clipSize;
};
} else {
if (Game.levelState == Game.levelState_Play){
if (numBullets > 0){
if (fireTimer <= 0){
if (MouseControl.buttonPressed){
numBullets--;
fireTimer = _local17.fireRate;
FireWeapon();
firedFlag = true;
firedTimer = 1;
if (_local17.flashGraphicName != ""){
muzzleflashFlag = true;
flashGraphicID = GraphicObjects.GetIndexByName(_local17.flashGraphicName);
flashFrame = 0;
};
if (_local17.cartridgeFrame != -1){
_local18 = (xpos - 4);
_local19 = (ypos - 35);
_local20 = new Matrix();
if (player_firedir == 0){
_local20.rotate(-(player_fireang));
_local21 = _local17.cartridgeLoff.clone();
_local21 = _local20.transformPoint(_local21);
} else {
_local20.rotate(player_fireang);
_local21 = _local17.cartridgeRoff.clone();
_local21 = _local20.transformPoint(_local21);
};
_local21.x = (_local21.x + _local18);
_local21.y = (_local21.y + _local19);
_local22 = GameObjects.AddObj(_local21.x, _local21.y, zpos);
_local22.InitCartridge(ypos, _local17.cartridgeFrame);
};
if (_local17.shootLineGraphicName != ""){
_local18 = (xpos - 4);
_local19 = (ypos - 35);
_local20 = new Matrix();
if (player_firedir == 0){
_local20.rotate(-(player_fireang));
_local23 = _local17.loff.clone();
_local23 = _local20.transformPoint(_local23);
_local24 = -(player_fireang);
} else {
_local20.rotate(player_fireang);
_local23 = _local17.roff.clone();
_local23 = _local20.transformPoint(_local23);
_local24 = player_fireang;
};
_local23.x = (_local23.x + _local18);
_local23.y = (_local23.y + _local19);
_local22 = GameObjects.AddObj(_local23.x, _local23.y, zpos);
shootLineGraphicID = GraphicObjects.GetIndexByName(_local17.shootLineGraphicName);
_local22.InitBulletLine(shootLineGraphicID, (player_firedir == 0), _local24);
};
};
};
};
if (numBullets == 0){
reloadingTimer = (reloadingTimerMax = _local17.reloadTime);
if (_local17.reloadSound != ""){
SoundPlayer.Play(_local17.reloadSound);
};
};
};
};
};
if (firedFlag){
weaponVolume = 1;
} else {
weaponVolume = (weaponVolume - 0.1);
if (weaponVolume < 0.3){
weaponVolume = 0.3;
};
};
Game.QuietWeaponSounds();
if (_local17.constantSound != ""){
if (SoundPlayer.doSFX){
_local25 = SoundPlayer.GetSoundChannelByName(_local17.constantSound);
SoundPlayer.SetSoundChannelVolume(_local25, weaponVolume);
};
};
}
public function Init(_arg1:int):void{
var _local2:int;
var _local3:Number = 0;
type = _arg1;
controlMode = _local2;
xvel = _local3;
yvel = _local3;
frame = _local3;
frameVel = _local3;
timer = _local3;
hitTimer = _local3;
flashTimer = _local2;
flashFlag = false;
dir = 0;
todir = 0;
health = 1;
zvel = 0;
name = "";
scale = 1;
objectDef = null;
xflip = false;
hitFunction = null;
updateFunction = null;
renderFunction = null;
visible = true;
renderShadowFlag = false;
ClearColFlags();
isPhysObj = false;
additive = false;
alpha = 1;
xpos1 = 0;
ypos1 = 0;
renderSmooth = true;
height = 0;
renderHealthBarTimer = 0;
}
public function UpdateEnemy_ProximityMine(){
if (controlMode == 0){
timer = (timer + 0.1);
ypos = (starty + (Math.sin(timer) * 5));
frame = 0;
if (InPlayerRange(120)){
controlMode = 1;
timer = 0;
};
};
if (controlMode == 1){
timer++;
frame = ((timer / 4) % 2);
if (timer > (Defs.fps * 2)){
ProximityMine_Explode();
active = false;
};
};
}
function UpdateBallBubble():void{
controlMode = parentObj.controlMode;
frame1 = parentObj.frame1;
graphicID1 = parentObj.graphicID1;
xpos = parentObj.xpos;
ypos = parentObj.ypos;
dir = parentObj.dir;
}
public function UpdateNextPieceGO(){
var _local1:Number;
var _local2:Number;
_local1 = MouseControl.x;
_local2 = MouseControl.y;
xpos = (_local1 + Game.scrollX);
ypos = (_local2 + Game.scrollY);
if (MouseControl.delta != 0){
dir = (dir + (Number(MouseControl.delta) * 0.1));
MouseControl.delta = 0;
};
}
function HitAsteroid():void{
var _local1:GameObj;
var _local2:int;
var _local3:Particle;
if (type == 0){
Game.currentScore = (Game.currentScore + 50);
};
if (type == 1){
Game.currentScore = (Game.currentScore + 100);
};
if (type == 2){
Game.currentScore = (Game.currentScore + 200);
};
if (type == 0){
SoundPlayer.Play("explosion0");
};
if (type == 1){
SoundPlayer.Play("explosion1");
};
if (type == 2){
SoundPlayer.Play("explosion2");
};
if (type == 0){
_local1 = GameObjects.AddObj(xpos, ypos, 0);
_local1.InitAsteroid(1);
_local1 = GameObjects.AddObj(xpos, ypos, 0);
_local1.InitAsteroid(1);
};
if (type == 1){
_local1 = GameObjects.AddObj(xpos, ypos, 0);
_local1.InitAsteroid(2);
_local1 = GameObjects.AddObj(xpos, ypos, 0);
_local1.InitAsteroid(2);
};
_local1 = GameObjects.AddObj(xpos, (ypos - 20), 0);
_local1.InitScore(type);
active = false;
_local2 = 0;
while (_local2 < 20) {
_local3 = Particles.Add(xpos, ypos);
_local3.InitAsteroidExplosion();
_local2++;
};
}
function UpdateGameOverOverlay(){
xpos = (300 + Game.scrollX);
ypos = (300 + Game.scrollY);
PlayAnimation();
}
public function CycleAnimation():void{
var _local1:Number = frameVel;
var _local2:int = GraphicObjects.GetNumFrames(graphicID);
frame = (frame + _local1);
if (frame >= _local2){
frame = (frame - _local2);
};
if (frame < 0){
frame = (frame + _local2);
};
}
function GameObj_UpdateHoseSwitch():void{
if (controlMode == 0){
} else {
if (controlMode == 1){
frameVel = 1;
if (PlayAnimation()){
frame = 0;
controlMode = 0;
};
};
};
}
function UpdateTextMessage(){
timer--;
if (timer <= 0){
active = false;
};
}
function SetAnim(_arg1:int){
var _local2:int;
graphicID = _arg1;
_local2 = (GraphicObjects.GetNumFrames(graphicID) - 1);
if (frame >= _local2){
frame = 0;
};
}
function GameObj_InitSwitch():void{
updateFunction = GameObj_UpdateSwitch;
frameVel = 1;
controlMode = 0;
frame = 0;
}
public function BaseFireBullet_HomingRocketLauncher(){
var _local1:GameObj;
var _local2:Number = dir;
var _local3:Number = xpos;
var _local4:Number = ypos;
_local3 = (_local3 + (Math.sin(_local2) * 25));
_local4 = (_local4 + (-(Math.cos(_local2)) * 25));
_local1 = GameObjects.AddObj(_local3, _local4, 0);
_local1.InitEnemyBullet(this, 2);
}
function InitBulletLine(_arg1:int, _arg2:Boolean, _arg3:Number):void{
colFlag_isPhysObj = true;
updateFunction = UpdateBulletLine;
renderFunction = RenderBulletLine;
graphicID = _arg1;
frame = 0;
frameVel = 1;
dir = _arg3;
xflip = _arg2;
numRepeats = 4;
}
public function InitEnemy_ProximityMine(){
graphicID = GraphicObjects.GetIndexByName("ProximityMine");
frame = 0;
updateFunction = UpdateEnemy_ProximityMine;
hitFunction = HitBase;
fireTimer = 0;
radius = 10;
timer = Utils.RandCircle();
controlMode = 0;
}
function GameObj_InitCycleAnim():void{
updateFunction = GameObj_UpdateCycleAnim;
frameVel = 1;
}
function InitBloodSplat(_arg1:Number, _arg2:Number):void{
colFlag_isPhysObj = true;
updateFunction = UpdateBloodSplat;
graphicID = GraphicObjects.GetIndexByName("BloodSplat01");
graphicID = (graphicID + Utils.RandBetweenInt(0, 1));
frame = 0;
frameVel = 1;
}
function UpdateGore():void{
if (controlMode == 0){
xpos = (xpos + xvel);
ypos = (ypos + yvel);
heightVel = (heightVel + 1);
height = (height + heightVel);
if (height >= 0){
height = 0;
controlMode = 1;
};
dir = (dir + rotVel);
} else {
xpos = (xpos - Game.scrollXvel);
if (xpos < -30){
active = false;
};
};
}
public function UpdateExit(){
if (controlMode == 0){
if (Game.numPickupsActive == 0){
controlMode = 1;
Game.InitMessage("Get To The Exit", 10, 10);
};
} else {
if (controlMode == 1){
frame = 1;
if (Utils.DistBetweenPoints(xpos, ypos, Game.goPlayer.xpos, Game.goPlayer.ypos) < 40){
Game.InitLevelState(Game.levelState_Complete);
};
};
};
}
public function RenderMessageOverlay(){
RenderNormally(false);
}
public function Render(_arg1:BitmapData):void{
bd = _arg1;
if (visible == false){
return;
};
if (renderFunction != null){
renderFunction();
} else {
RenderNormally();
};
RenderBlockCollision();
RenderWallCollision();
}
public function UpdateEnemy_Blocker(){
CycleAnimation();
}
function RenderBallBubble():void{
var _local1:Point;
var _local2:Matrix;
if (controlMode == 2){
_local1 = new Point(0, 6);
_local2 = new Matrix();
_local2.rotate(dir);
_local1 = _local2.transformPoint(_local1);
GraphicObjects.RenderAt(graphicID1, frame1, bd, (xpos + _local1.x), (ypos + _local1.y), false);
};
}
function ApplyImpulse(_arg1:Number, _arg2:Number, _arg3:Number){
var _local4:Vec;
_local4 = new Vec();
_local4.Set(Math.atan2(_arg2, _arg1), _arg3);
movementVec.Add(_local4);
}
function InitPlayerHead(_arg1:Number):void{
Game.playerHeadGO = this;
colFlag_isPhysObj = true;
updateFunction = UpdatePlayerHead;
renderFunction = RenderPlayerHead;
graphicID = GraphicObjects.GetIndexByName("player_head");
frame = 0;
dir = 0;
height = (ypos - _arg1);
ypos = _arg1;
heightVel = -(Utils.RandBetweenFloat(10, 10));
xvel = Utils.RandBetweenFloat(3, 5);
yvel = Utils.RandBetweenFloat(-2, 2);
rotVel = Utils.RandBetweenFloat(-0.5, 0.5);
controlMode = 0;
}
public function PlayerHitEnemy(_arg1:GameObj){
}
function InitStartZombie():void{
colFlag_isPhysObj = true;
colFlag_isEnemy = true;
updateFunction = UpdateStartZombie;
SetZombieType();
minFrame = f0_run;
maxFrame = f1_run;
frame = 0;
frameVel = 1;
xpos = (-300 + Utils.RandBetweenFloat(-400, 0));
ypos = (200 + Utils.RandBetweenFloat(0, 300));
xvel = Utils.RandBetweenFloat(10, 15);
xvelmax = xvel;
xposmax = (((xpos + 300) + 200) + Utils.RandBetweenFloat(-50, 50));
controlMode = 0;
extraXVel = 0;
}
function UpdateBouncer(){
var _local1:Number;
if (controlMode == 1){
_local1 = (dir - (Math.PI * 0.5));
xoffset = ((Math.cos(_local1) * timer) * 2);
yoffset = ((Math.sin(_local1) * timer) * 2);
timer++;
if (timer > 3){
yoffset = 0;
xoffset = 0;
controlMode = 0;
};
};
}
function UpdateBulletLine():void{
if (PlayAnimation()){
active = false;
};
}
function UpdateBarrel():void{
xpos = (xpos - Game.scrollXvel);
if (xpos < -30){
active = false;
};
if (controlMode == 1){
PlayAnimation();
};
}
function BouncerBounce(){
if (controlMode == 0){
timer = 0;
controlMode = 1;
};
}
function InitObj_Ship(){
updateFunction = UpdateObj_Ship;
timer = 0;
}
function InitFloorLayer():void{
renderFunction = RenderFloorLayer;
}
function UpdateEnemyBullet_Homing():void{
xvel = movementVec.GetXComponent();
yvel = movementVec.GetYComponent();
xpos = (xpos + xvel);
ypos = (ypos + yvel);
toPosX = Game.goPlayer.xpos;
toPosY = Game.goPlayer.ypos;
RotateToRequiredRot(0.1);
dir = (movementVec.rot + (Math.PI / 2));
var _local1:Particle = Particles.Add(xpos, ypos);
_local1.InitTrail();
timer--;
if (timer < 0){
active = false;
};
if (Game.BackgroundPointCollision(xpos, ypos)){
active = false;
};
}
public function GetVelFromDir(_arg1:Number){
xvel = (Math.cos(dir) * _arg1);
yvel = (Math.sin(dir) * _arg1);
}
function UpdateEnemyBullet():void{
xpos = (xpos + xvel);
ypos = (ypos + yvel);
var _local1:Particle = Particles.Add(xpos, ypos);
_local1.InitTrail();
timer--;
if (timer < 0){
active = false;
};
if (Game.BackgroundPointCollision(xpos, ypos)){
active = false;
};
}
function HitEnemyBullet_Homing():void{
EnemyHitParticles();
active = false;
}
function UpdateVehicle(){
if (controlMode == 0){
ypos = (ypos + yvel);
xpos = (xpos - Game.goPlayer.playerSpeed);
xpos = (xpos + xvel);
} else {
if (controlMode == 1){
ypos = (ypos + yvel);
xpos = (xpos - xvel);
};
};
if ((((ypos < -100)) || ((ypos > 500)))){
active = false;
Game.numVehiclesActive--;
};
}
function InitAsteroid(_arg1:int):void{
type = _arg1;
colFlag_isEnemy = true;
updateFunction = UpdateAsteroid;
hitFunction = HitAsteroid;
graphicID = GraphicObjects.GetIndexByName("Asteroid");
frame = type;
if (type == 0){
radius = 30;
};
if (type == 1){
radius = 20;
};
if (type == 2){
radius = 10;
};
var _local2:Number = Utils.RandCircle();
var _local3:Number = Utils.RandBetweenFloat(2, 5);
xvel = (Math.sin(_local2) * _local3);
yvel = (Math.cos(_local2) * _local3);
rotVel = Utils.RandBetweenFloat(-0.2, 0.2);
}
function UpdateBloodSplat():void{
if (PlayAnimation()){
active = false;
};
}
function FireLaser(){
ShootBulletImmediate(player_firex0, player_firey0, player_firex1, player_firey1, true);
}
function FireRifle(){
ShootBulletImmediate(player_firex0, player_firey0, player_firex1, player_firey1, true);
}
public function UpdatePhysicsObject(){
}
function UpdatePlayerHead():void{
if (controlMode == 0){
xpos = (xpos + xvel);
ypos = (ypos + yvel);
heightVel = (heightVel + 1);
height = (height + heightVel);
if (height >= 0){
height = 0;
controlMode = 1;
};
dir = (dir + rotVel);
} else {
xpos = (xpos - Game.scrollXvel);
if (xpos < -30){
active = false;
};
};
}
public function InitBase_StraightRocketLauncher(){
colFlag_isEnemy = true;
graphicID = GraphicObjects.GetIndexByName("StraightRocketLauncher");
frame = 0;
updateFunction = UpdateBase_StraightRocketLauncher;
hitFunction = HitBase;
GetParams();
fireTimerMax = Game.GetCurrentWeapon().fireRate;
fireTimer = fireTimerMax;
radius = 30;
}
function UpdatePlayerBullet_Flamethrower():void{
PlayAnimation();
xpos = (xpos + movementVec.GetXComponent());
ypos = (ypos + movementVec.GetYComponent());
movementVec.speed = (movementVec.speed - 0.3);
if (movementVec.speed <= 0){
movementVec.speed = 0;
};
timer--;
if (timer <= 0){
active = false;
};
dir = (dir + rotVel);
}
function ClearColFlags(){
colFlag_jumpon = false;
colFlag_killPlayer = false;
colFlag_playercanbekilled = false;
colFlag_canBePickedUp = false;
colFlag_canBeShot = false;
colFlag_isBullet = false;
colFlag_isPlatform = false;
colFlag_isPowerup = false;
colFlag_isBouncyPad = false;
colFlag_isCheckpoint = false;
colFlag_isShop = false;
colFlag_isEnemyBullet = false;
colFlag_isEnemy = false;
colFlag_isShootable = false;
colFlag_isHose = false;
colFlag_isPlayer = false;
colFlag_isPhysObj = false;
colFlag_isBackgroundObj = false;
colFlag_isBlocker = false;
}
function InitGameOverOverlay():void{
graphicID = GraphicObjects.GetIndexByName("GameOverOverlay");
frame = 0;
frameVel = 1;
updateFunction = UpdateGameOverOverlay;
xpos = (300 + Game.scrollX);
ypos = (300 + Game.scrollY);
}
public function GetOffsetObjectRectangle():Rectangle{
var _local1:Rectangle;
_local1 = objectDef.colRects[0].clone();
_local1.x = (_local1.x + xpos);
_local1.y = (_local1.y + ypos);
return (_local1);
}
function InitBullet(_arg1:GameObj, _arg2:Number=0, _arg3:int=0):void{
type = _arg3;
colFlag_isBullet = true;
updateFunction = UpdateBullet;
renderFunction = RenderBullet;
graphicID = GraphicObjects.GetIndexByName("Bullet");
frame = type;
frameVel = 0;
var _local4:Number = 10;
_local4 = Game.upgrades[3].GetValue();
var _local5:Vec = new Vec();
_local5.CopyFrom(_arg1.driveVec);
_local5.AddRot(_arg2);
xvel = (_local5.GetUnitXComponent() * _local4);
yvel = (_local5.GetUnitYComponent() * _local4);
dir = _local5.rot;
var _local6:Number = Game.upgrades[7].GetValue();
timer = (_local6 / _local4);
}
function RenderBullet():void{
RenderNormally();
}
function ZombieShot(_arg1:int, _arg2:Boolean=false):void{
var _local3:GameObj;
var _local4:int;
var _local5:int;
var _local6:int;
var _local7:Weapon;
_local3 = GameObjects.AddObj(xpos, ypos, 0);
_local3.InitBloodSplat(xpos, ypos);
_local3 = GameObjects.AddObj(xpos, ypos, 0);
_local3.InitBloodPuddle();
renderHealthBarTimer = (Defs.fps * 2);
if (_arg2 == true){
_arg1 = (_arg1 * 2);
};
health = (health - _arg1);
if (health <= 0){
if (type == 7){
_local7 = Game.GetCurrentWeapon();
if (_local7.name == "crowbar"){
Lic.Newgrounds_UnlockMedal("Freeman");
};
};
Game.numZombiesKilledWithBarrel++;
renderHealthBarTimer = 0;
_local4 = (10 * (Game.currentLevel + 1));
if (_arg2){
minFrame = f0_diehead;
maxFrame = f1_diehead;
Game.InitMessageOverlay(0);
Game.AddScore((_local4 * 2));
SoundPlayer.Play("sfx_headshot");
Game.numHeadshotKills++;
Game.numLevelHeadshotKills++;
Game.numKills++;
Game.numLevelKills++;
} else {
minFrame = f0_die;
maxFrame = f1_die;
Game.AddScore(_local4);
SoundPlayer.PlayRandomBetween("sfx_impact01", "sfx_bullethit02");
Game.numKills++;
Game.numLevelKills++;
};
if (Game.numKills == 50){
Lic.Newgrounds_UnlockMedal("Professional");
};
if (Game.numKills == 100){
Lic.Newgrounds_UnlockMedal("Relentless");
};
if (Game.numKills == 500){
Lic.Newgrounds_UnlockMedal("Massacre");
};
if (Game.numKills == 1000){
Lic.Newgrounds_UnlockMedal("Zombie Holocaust");
};
if (Game.numHeadshotKills == 10){
Lic.Newgrounds_UnlockMedal("Bullseye");
};
if (Game.numHeadshotKills == 100){
Lic.Newgrounds_UnlockMedal("Sureshot!");
};
frame = minFrame;
controlMode = 100;
_local6 = Utils.RandBetweenInt(0, 3);
_local5 = 0;
while (_local5 < _local6) {
_local3 = GameObjects.AddObj((xpos + Utils.RandBetweenFloat(-5, 5)), (ypos + Utils.RandBetweenFloat(-30, -60)), zpos);
_local3.InitGore(ypos);
_local5++;
};
} else {
SoundPlayer.PlayRandomBetween("sfx_impact01", "sfx_whiz");
if (Game.goPlayer.xpos < xpos){
extraXVel = 5;
} else {
extraXVel = -5;
};
};
}
function InitGore(_arg1:Number):void{
colFlag_isPhysObj = true;
updateFunction = UpdateGore;
renderFunction = RenderGore;
graphicID = GraphicObjects.GetIndexByName("gorybits_mc");
frame = Utils.RandBetweenInt(0, (GraphicObjects.GetNumFrames(graphicID) - 1));
height = (ypos - _arg1);
ypos = _arg1;
heightVel = -(Utils.RandBetweenFloat(10, 10));
xvel = Utils.RandBetweenFloat(-2, 2);
yvel = Utils.RandBetweenFloat(-2, 2);
rotVel = Utils.RandBetweenFloat(-0.5, 0.5);
}
function RenderBulletLine():void{
var _local6:int;
var _local1:Number = (GraphicObjects.GetWidth(graphicID, 0) - 8);
var _local2:Number = (Math.cos(dir) * _local1);
var _local3:Number = (Math.sin(dir) * _local1);
if (xflip){
_local2 = -(_local2);
_local3 = -(_local3);
};
var _local4:Number = xpos;
var _local5:Number = ypos;
_local6 = 0;
while (_local6 < numRepeats) {
RenderGraphicNormally(graphicID, frame, _local4, _local5, 1, dir, true, xflip);
_local4 = (_local4 + _local2);
_local5 = (_local5 + _local3);
_local6++;
};
}
public function InitExit(){
Game.goExit = this;
colFlag_isCheckpoint = true;
colFlag_canBePickedUp = false;
graphicID = GraphicObjects.GetIndexByName("Exit");
frame = 0;
updateFunction = UpdateExit;
hitFunction = HitExit;
controlMode = 0;
}
function HitEnemy_Path(){
EnemyHitParticles();
active = false;
}
function RenderWallCollision():void{
var _local2:Number;
var _local3:Number;
var _local4:Number;
if ((Debug.debugMode & 8) == 0){
return;
};
if (objectDef == null){
return;
};
if (objectDef.collisionCircleOffsets.length == 0){
return;
};
var _local1:int;
while (_local1 < objectDef.collisionCircleOffsets.length) {
_local2 = objectDef.collisionCircleOffsets[_local1].x;
_local3 = objectDef.collisionCircleOffsets[_local1].y;
_local4 = objectDef.collisionCircleRadii[_local1];
_local2 = (_local2 + xpos);
_local2 = (_local2 - Game.scrollX);
_local3 = (_local3 + ypos);
_local3 = (_local3 - Game.scrollY);
Utils.RenderCircle(bd, _local2, _local3, _local4, 4294967295);
_local1++;
};
}
function RenderCartridge():void{
RenderGraphicNormally(graphicID, frame, xpos, (ypos + height), scale, dir);
}
function UpdateRocketExplosion():void{
if (PlayAnimation()){
active = false;
};
}
function RenderScore(){
RenderNormally(false);
}
public function RenderShadow():void{
if (renderShadowFlag == false){
return;
};
if (visible == false){
return;
};
var _local1:Number = (xpos - Game.scrollX);
var _local2:Number = (ypos - Game.scrollY);
GraphicObjects.RenderAtRotScaled(graphicID, frame, bd, (_local1 + 5), (_local2 + 5), true, 1, dir);
}
public function PlayerHitEnemyBullet(_arg1:GameObj){
}
function GetParamBool(_arg1:String, _arg2:Boolean=false):Boolean{
var _local4:String;
var _local3:int = paramNames.indexOf(_arg1);
if (_local3 != -1){
_local4 = paramValues[_local3];
if (_local4 == "true"){
return (true);
};
return (false);
};
return (_arg2);
}
function RenderTextMessage(){
var _local1:int = Utils.RandBetweenInt(0, timer);
if (_local1 < 2){
return;
};
var _local2:Number = GraphicObjects.GetStringWidth(bd, GraphicObjects.gfx_font2, xpos, ypos, textMessage, null);
_local2 = 0;
GraphicObjects.RenderStringAt(bd, GraphicObjects.gfx_font2, (xpos - (_local2 / 2)), ypos, textMessage, null);
}
function UpdateBall():void{
if (controlMode == 0){
};
if (controlMode == 1){
frameVel = 0.5;
PlayAnimation();
if (frame >= 22){
SoundPlayer.Play("blowwav");
controlMode = 2;
};
} else {
if (controlMode == 2){
frameVel = 0.5;
PlayAnimation();
frameVel1 = 1;
PlayAnimation1();
if (frame1 >= 40){
visible = false;
controlMode = 3;
SoundPlayer.Play("popwav");
};
} else {
if (controlMode == 3){
if (PlayAnimation1()){
childGO.active = false;
};
};
};
};
}
function RotateToRequiredRot(_arg1:Number):Boolean{
var _local2:Number = Math.atan2((toPosY - ypos), (toPosX - xpos));
var _local3:Number = (_local2 + (Math.PI / 2));
var _local4:Number = Utils.DotProduct(Math.cos(movementVec.rot), Math.sin(movementVec.rot), Math.cos(_local3), Math.sin(_local3));
if (movementVec.NearRot(_local2, _arg1)){
movementVec.rot = _local2;
return (true);
};
if (_local4 < 0){
movementVec.AddRot(_arg1);
} else {
movementVec.AddRot(-(_arg1));
};
return (false);
}
public function InitSparks(_arg1:Boolean){
if (_arg1){
graphicID = GraphicObjects.GetIndexByName("portalINsparks");
} else {
graphicID = GraphicObjects.GetIndexByName("portalOUTsparks");
};
frame = 0;
frameVel = 1;
updateFunction = UpdateSparks;
}
public function PlayAnimation():Boolean{
var _local1:int = (GraphicObjects.GetNumFrames(graphicID) - 1);
frame = (frame + frameVel);
if (frame >= _local1){
frame = _local1;
return (true);
};
if (frame <= 0){
frame = 0;
return (true);
};
return (false);
}
public function GetDirBetween(_arg1, _arg2, _arg3, _arg4):Number{
var _local5:* = Math.atan2((_arg4 - _arg2), (_arg3 - _arg1));
return (_local5);
}
function InitObj_Conveyor(){
frame = 0;
frameVel = 0.5;
updateFunction = UpdateObj_Conveyor;
}
public function InitNextPieceGO(){
subtype = 0;
frame = subtype;
updateFunction = UpdateNextPieceGO;
dir = 0;
}
function InitSplatTimeOverlay():void{
graphicID = GraphicObjects.GetIndexByName("SplatTimeOverlay");
frame = 0;
frameVel = 1;
updateFunction = UpdateSplatTimeOverlay;
xpos = 400;
ypos = 250;
timer = 50;
}
function InitBlocker():void{
colFlag_isPhysObj = true;
colFlag_isBlocker = true;
updateFunction = UpdateBlocker;
xpos = (Defs.displayarea_w + 100);
ypos = (200 + Utils.RandBetweenFloat(0, 250));
graphicID = GraphicObjects.GetIndexByName("Blocker");
frame = 0;
type = Utils.RandBetweenInt(0, 1);
frame = type;
}
public function CycleAnimationEx():Boolean{
var _local1:Boolean;
frame = (frame + frameVel);
var _local2:* = (maxFrame - minFrame);
if (frame > maxFrame){
frame = (frame - _local2);
_local1 = true;
};
if (frame < minFrame){
frame = (frame + _local2);
_local1 = true;
};
return (_local1);
}
function RenderPlayerHead():void{
RenderGraphicNormally(graphicID, frame, xpos, (ypos + height), 1, dir);
}
function DoExplosion(_arg1:int, _arg2:Number){
var _local3:GameObj;
var _local4:Number;
var _local5:Number;
var _local6:Number;
for each (_local3 in GameObjects.objs) {
if (((((_local3.active) && (_local3.colFlag_isEnemy))) && ((_local3.controlMode < 100)))){
_local4 = (_local3.ypos - 20);
_local5 = _local3.xpos;
_local6 = _arg2;
_local6 = (_arg2 * _local6);
if (Utils.Dist2BetweenPoints(xpos, ypos, _local5, _local4) < _local6){
if (_local3.hitFunction != null){
_local3.hitFunction(_arg1);
};
};
};
};
}
public function UpdateEntrance(){
if (controlMode == 0){
visible = true;
frame = 0;
} else {
if (controlMode == 1){
visible = false;
frame = 1;
};
};
}
public function InitEnemy_Spewer(){
colFlag_isEnemy = true;
graphicID = GraphicObjects.GetIndexByName("Spewer");
frame = 0;
updateFunction = UpdateEnemy_Spewer;
hitFunction = HitBase;
fireTimer = 0;
radius = 10;
timer = 0;
dir = Utils.RandCircle();
rotVel = 0.02;
health = (maxHealth = 5);
}
public function InitTextMessage(_arg1:String, _arg2:Number, _arg3:Number):void{
textMessage = _arg1;
updateFunction = UpdateTextMessage;
renderFunction = RenderTextMessage;
timer = 100;
xpos = _arg2;
ypos = _arg3;
}
function RenderMiniBall():void{
RenderNormally();
if (controlMode == 1){
GraphicObjects.RenderAt(graphicID1, frame1, bd, xpos, ypos, false);
};
}
public function UpdateBase_StraightRocketLauncher(){
if (fireTimer > 0){
fireTimer--;
};
if (InPlayerRange(500)){
if (fireTimer <= 0){
BaseFireBullet_StraightRocketLauncher();
fireTimer = fireTimerMax;
};
};
}
function RenderHomingBullet(){
GraphicObjects.RenderAtRotScaled(graphicID, frame, main.screenBD, xpos, ypos, false, scale, movementVec.rot);
}
function ShootBulletImmediate(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Boolean):void{
var _local6:Weapon;
var _local7:GameObj;
var _local8:int;
var _local9:int;
var _local12:Number;
var _local13:Number;
var _local14:Number;
var _local15:Number;
var _local16:Number;
_local6 = Game.GetCurrentWeapon();
for each (_local7 in GameObjects.objs) {
if (((((_local7.active) && (_local7.colFlag_isEnemy))) && ((_local7.controlMode < 100)))){
_local7.beenHitThisShot = false;
};
};
var _local10:Number = _arg1;
var _local11:Number = _arg2;
_local12 = 16;
_local9 = ((Math.abs((_arg3 - _arg1)) / _local12) + 1);
_local13 = ((_arg3 - _arg1) / Number(_local9));
_local14 = ((_arg4 - _arg2) / Number(_local9));
_local8 = 0;
while (_local8 < _local9) {
_arg1 = (_arg1 + _local13);
_arg2 = (_arg2 + _local14);
for each (_local7 in GameObjects.objs) {
_local15 = (_arg1 - _local7.xpos);
_local16 = (_arg2 - _local7.ypos);
if (((((((_local7.active) && (_local7.colFlag_isEnemy))) && ((_local7.controlMode < 100)))) && ((_local7.beenHitThisShot == false)))){
if (_local7.headColBox.contains(_local15, _local16)){
_local7.beenHitThisShot = true;
if (_local7.hitFunction != null){
_local7.hitFunction(_local6.damage, true);
};
if (_arg5 == false){
return;
};
};
if (_local7.bodyColBox.contains(_local15, _local16)){
_local7.beenHitThisShot = true;
if (_local7.hitFunction != null){
_local7.hitFunction(_local6.damage, false);
};
if (_arg5 == false){
return;
};
};
};
if (((_local7.active) && (_local7.colFlag_isShootable))){
if (_local7.bodyColBox.contains(_local15, _local16)){
if (_local7.hitFunction != null){
_local7.hitFunction(_local6.damage, false);
};
if (_arg5 == false){
return;
};
};
};
};
_local8++;
};
}
function InitCheckpoint():void{
Game.startPoints.push(new Point(xpos, ypos));
}
public function ProximityMine_Explode(){
var _local1:GameObj;
var _local2:Number = dir;
var _local3:Number = xpos;
var _local4:Number = ypos;
_local2 = 0;
while (_local2 < (Math.PI * 2)) {
_local1 = GameObjects.AddObj(_local3, _local4, 0);
_local1.InitEnemyBullet(this, 3, _local2);
_local2 = (_local2 + ((Math.PI * 2) / 14));
};
}
function UpdateMessage(){
xpos = (320 + Game.scrollX);
ypos = (100 + Game.scrollY);
timer--;
if (timer <= 0){
active = false;
};
}
public function GetObjectRectangle():Rectangle{
return (objectDef.colRects[0]);
}
public function InitPinDisappear(){
health = 0;
frame = (health / 2);
}
public function UpdateEnemy_Graviton(){
var _local3:Number;
var _local4:Number;
var _local5:GameObj;
var _local6:Vec;
CycleAnimation();
var _local1:Number = 120;
var _local2:Number = 30;
if (InPlayerRange(_local1)){
_local3 = GetPlayerDist();
_local3 = Utils.LimitNumber(_local2, _local1, _local3);
_local4 = Utils.ScaleTo(0.2, 0.1, _local2, _local1, _local3);
_local5 = Game.goPlayer;
_local6 = new Vec();
_local6.SetDxDy((xpos - _local5.xpos), (ypos - _local5.ypos), _local4);
_local5.movementVec.Add(_local6);
};
}
function GetParam(_arg1:String, _arg2:String=""):String{
var _local3:int = paramNames.indexOf(_arg1);
if (_local3 != -1){
return (paramValues[_local3]);
};
return (_arg2);
}
function PressedThrust(){
var _local1:int;
var _local2:Particle;
var _local3:Number;
var _local4:Number;
var _local5:int;
var _local6:Vec;
_local1 = 0;
while (_local1 < 3) {
_local2 = Particles.Add(xpos, ypos);
_local2.InitThrust();
_local3 = Utils.RandBetweenFloat(-2, -7);
_local4 = Utils.RandBetweenFloat(-10, -20);
_local5 = Utils.RandBetweenInt(0, 3);
if (_local5 == 0){
_local2.color = 2164195328;
};
if (_local5 == 1){
_local2.color = 2163081216;
};
if (_local5 == 2){
_local2.color = 2161967104;
};
if (_local5 == 3){
_local2.color = 2160852992;
};
_local6 = new Vec();
_local6.CopyFrom(driveVec);
_local6.AddRot(Utils.RandBetweenFloat(-0.6, 0.6));
_local2.xpos = (xpos + (_local6.GetUnitXComponent() * _local4));
_local2.ypos = (ypos + (_local6.GetUnitYComponent() * _local4));
_local2.xvel = (_local6.GetUnitXComponent() * _local3);
_local2.yvel = (_local6.GetUnitYComponent() * _local3);
_local2.xvel = (_local2.xvel + movementVec.GetUnitXComponent());
_local2.yvel = (_local2.yvel + movementVec.GetUnitYComponent());
_local1++;
};
}
function RenderFloorLayer():void{
bd.copyPixels(main.layerScreenBD, Defs.screenRect, Defs.pointZero, null, null, true);
}
function UpdateMiniBall():void{
if (controlMode == 1){
frameVel1 = 1;
PlayAnimation1();
if (frame1 >= 40){
visible = false;
controlMode = 2;
};
} else {
if (controlMode == 2){
PlayAnimation1();
};
};
}
public function InitEnemy_Graviton(){
graphicID = GraphicObjects.GetIndexByName("Graviton");
frame = 0;
frameVel = 1;
updateFunction = UpdateEnemy_Graviton;
hitFunction = HitBase;
timer = 0;
controlMode = 0;
}
function RenderHealthBar(_arg1:Number, _arg2:Number){
if (renderHealthBarTimer == 0){
return;
};
var _local3:BitmapData = Game.main.scrollScreenBD;
var _local4:Rectangle = new Rectangle(-15, 0, 30, 6);
new Rectangle(-15, 0, 30, 6).x = (_local4.x + (xpos + _arg1));
_local4.y = (_local4.y + (ypos + _arg2));
_local3.fillRect(_local4, 4294967295);
_local4.width = Utils.ScaleTo(0, 30, 0, maxHealth, health);
_local3.fillRect(_local4, 4294901760);
}
public function PinDisappearHit():Boolean{
health++;
frame = (health / 2);
if (health > 40){
health = 40;
frame = (health / 2);
return (true);
};
return (false);
}
public function RenderPellet(){
}
public function InitPhysicsFloorObject(_arg1:int, _arg2:Number){
frame = _arg1;
}
function RenderEnemyBullet(){
}
function VehicleBeenHit(_arg1:GameObj){
var _local3:Particle;
SoundPlayer.PlayRandomBetween("squish01", "squish04");
var _local2:int;
while (_local2 < 30) {
_local3 = Particles.Add(xpos, ypos);
_local3.InitExplo01();
_local2++;
};
frame = 1;
if (_arg1.yvel < 0){
yvel = -10;
} else {
if (_arg1.yvel > 0){
yvel = 10;
} else {
if (Utils.RandBetweenInt(0, 100) < 50){
yvel = 10;
} else {
yvel = -10;
};
};
};
xvel = Utils.RandBetweenFloat(-4, 4);
controlMode = 1;
}
function RenderGraphicNormally(_arg1:int, _arg2:int, _arg3:Number, _arg4:Number, _arg5:Number=1, _arg6:Number=0, _arg7:Boolean=true, _arg8:Boolean=false){
var _local9:Number = _arg3;
var _local10:Number = _arg4;
if (_arg7){
_local9 = (_local9 - Game.scrollX);
_local10 = (_local10 - Game.scrollY);
};
if (_local9 < -1000){
return;
};
if (_local9 > (Defs.displayarea_w + 500)){
return;
};
if (_local10 < -1000){
return;
};
if (_local10 > (Defs.displayarea_h + 500)){
return;
};
if (((!((_arg5 == 1))) || (!((_arg6 == 0))))){
GraphicObjects.RenderAtRotScaled(_arg1, _arg2, bd, _local9, _local10, _arg8, _arg5, _arg6, null, renderSmooth);
} else {
GraphicObjects.RenderAt(_arg1, _arg2, bd, _local9, _local10, _arg8);
};
}
function UpdateScore(){
ypos--;
timer--;
if (timer <= 0){
active = false;
};
}
public function HitExit(){
active = false;
SoundPlayer.Play("PickupSFX");
}
function InitScore(_arg1:int):void{
graphicID = GraphicObjects.GetIndexByName("Scores");
frame = _arg1;
frameVel = 1;
updateFunction = UpdateScore;
renderFunction = RenderScore;
timer = 40;
xpos = (xpos - Game.scrollX);
ypos = (ypos - Game.scrollY);
}
function UpdateBullet():void{
var _local1:Particle;
var _local2:int;
xpos = (xpos + xvel);
ypos = (ypos + yvel);
_local1 = Particles.Add(xpos, ypos);
_local1.InitTrail();
timer--;
if (timer < 0){
active = false;
};
if (Game.BackgroundPointCollision(xpos, ypos)){
active = false;
_local2 = 0;
while (_local2 < 10) {
_local1 = Particles.Add(xpos, ypos);
_local1.InitBulletWallExplosion();
_local2++;
};
};
}
function InitBall():void{
updateFunction = UpdateBall;
renderFunction = RenderBall;
controlMode = 0;
frame1 = 0;
graphicID1 = GraphicObjects.GetIndexByName("Bubble");
var _local1:int = GameObjects.lastGenIndex;
childGO = GameObjects.AddObj(xpos, ypos, -1000);
childGO.InitBallBubble(this);
GameObjects.lastGenIndex = _local1;
}
function InitRocketExplosion():void{
updateFunction = UpdateRocketExplosion;
graphicID = GraphicObjects.GetIndexByName("rocketlauncher_explosion");
frame = 0;
frameVel = 1;
}
function InitAnimal():void{
zpos = (zpos + Game.zposOffset);
Game.zposOffset = (Game.zposOffset + 0.001);
}
public function UpdateBase(){
if (fireTimer > 0){
fireTimer--;
};
if (InPlayerRange(300)){
if (fireTimer <= 0){
BaseFireBullet();
fireTimer = fireTimerMax;
};
};
}
function DoScale():void{
var _local1:Number = Game.lanePositions[0];
var _local2:Number = Game.lanePositions[(Game.lanePositions.length - 1)];
scale = Utils.ScaleTo(0.9, 1, _local1, _local2, ypos);
}
function InitEnemyBullet(_arg1:GameObj, _arg2:int, _arg3:Number=0):void{
var _local6:Number;
type = _arg2;
var _local4:Number = Game.goPlayer.xpos;
var _local5:Number = Game.goPlayer.ypos;
colFlag_isEnemyBullet = true;
var _local7:Vec = new Vec();
timer = 100;
frameVel = 0;
frame = 0;
if (type == 0){
_local6 = 4;
timer = 100;
updateFunction = UpdateEnemyBullet;
graphicID = GraphicObjects.GetIndexByName("EnemyBullet");
_local7.Set(Math.atan2((_local5 - ypos), (_local4 - xpos)), _local6);
};
if (type == 1){
_local6 = 2;
timer = 300;
updateFunction = UpdateEnemyBullet;
graphicID = GraphicObjects.GetIndexByName("StraightRocket");
_local7.Set((_arg1.dir - (Math.PI / 2)), _local6);
dir = (_local7.rot + (Math.PI / 2));
};
if (type == 2){
radius = 10;
_local6 = 2;
timer = 300;
updateFunction = UpdateEnemyBullet_Homing;
hitFunction = HitEnemyBullet_Homing;
graphicID = GraphicObjects.GetIndexByName("HomingRocket");
_local7.Set((_arg1.dir - (Math.PI / 2)), _local6);
dir = (_local7.rot + (Math.PI / 2));
movementVec.CopyFrom(_local7);
};
if (type == 3){
_local6 = 5;
timer = 30;
updateFunction = UpdateEnemyBullet;
graphicID = GraphicObjects.GetIndexByName("EnemyBullet");
_local7.Set(_arg3, _local6);
};
xvel = (_local7.GetUnitXComponent() * _local6);
yvel = (_local7.GetUnitYComponent() * _local6);
}
public function PlayAnimationEx():Boolean{
var _local1:Boolean;
frame = (frame + frameVel);
var _local2:* = (maxFrame - minFrame);
if (frame >= maxFrame){
frame = maxFrame;
_local1 = true;
};
if (frame <= minFrame){
frame = minFrame;
_local1 = true;
};
return (_local1);
}
function Anim_FromVel():void{
var _local1:int = GraphicObjects.GetNumFrames(graphicID);
var _local2:Number = xvel;
var _local3:Number = yvel;
var _local4:* = Math.atan2(_local3, _local2);
frame = ((_local1 / (Math.PI * 2)) * -(_local4));
if (frame < 0){
frame = (frame + _local1);
};
if (frame > _local1){
frame = (frame - _local1);
};
frame = (frame + (_local1 / 2));
if (frame > _local1){
frame = (frame - _local1);
};
}
function FirePistol(){
ShootBulletImmediate(player_firex0, player_firey0, player_firex1, player_firey1, false);
}
function UpdateBloodPuddle():void{
xpos = (xpos - Game.scrollXvel);
if (xpos < -30){
active = false;
};
if (Math.abs((Game.goPlayer.ypos - ypos)) < 20){
if (Math.abs((Game.goPlayer.xpos - xpos)) < 50){
Game.scrollXvel = 11;
Game.goPlayer.trodInBloodTimer = Game.trodInBloodMaxTime;
};
};
}
function RenderEnemy(){
if (movementVec == null){
RenderNormally();
return;
};
GraphicObjects.RenderAtRotScaled(graphicID, frame, bd, xpos, ypos, false, scale, movementVec.rot);
}
public function UpdateBase_HomingRocketLauncher(){
if (fireTimer > 0){
fireTimer--;
};
if (InPlayerRange(500)){
if (fireTimer <= 0){
BaseFireBullet_HomingRocketLauncher();
fireTimer = fireTimerMax;
};
};
}
function InitZombie(_arg1:int):void{
colFlag_isPhysObj = true;
colFlag_isEnemy = true;
updateFunction = UpdateZombie;
renderFunction = RenderZombie;
hitFunction = ZombieShot;
yvel = Utils.RandBetweenFloat(2, 3);
SetZombieType(_arg1);
minFrame = f0_run;
maxFrame = f1_run;
frame = 0;
frameVel = 1;
xpos = -20;
ypos = (200 + Utils.RandBetweenFloat(0, 300));
xvel = Utils.RandBetweenFloat(2, 5);
xvel = (xvel * speedmul);
xvelmax = xvel;
controlMode = 0;
extraXVel = 0;
}
function GameObj_InitHoseSwitch():void{
updateFunction = GameObj_UpdateHoseSwitch;
graphicID = GraphicObjects.GetIndexByName("SnakeEnd");
frame = 0;
controlMode = 0;
}
function UpdateSparks():void{
if (PlayAnimation()){
active = false;
};
}
function HeadKicked():void{
SoundPlayer.PlayRandomBetween("sfx_bullethit01", "sfx_bullethit02");
SoundPlayer.PlayRandomBetween("sfx_playerhit01", "sfx_playerhit02");
heightVel = -(Utils.RandBetweenFloat(10, 15));
xvel = Utils.RandBetweenFloat(3, 5);
if (ypos < (200 + 150)){
yvel = Utils.RandBetweenFloat(0, 2);
} else {
yvel = Utils.RandBetweenFloat(-2, 0);
};
controlMode = 0;
rotVel = Utils.RandBetweenFloat(-0.5, 0.5);
}
function RenderZombie():void{
var _local1:Rectangle;
RenderNormally();
if (Debug.IsSet(1)){
_local1 = bodyColBox.clone();
_local1.x = (_local1.x + xpos);
_local1.y = (_local1.y + ypos);
Utils.RenderRectangle(bd, _local1, 4294901760);
_local1 = headColBox.clone();
_local1.x = (_local1.x + xpos);
_local1.y = (_local1.y + ypos);
Utils.RenderRectangle(bd, _local1, 4294967040);
};
RenderHealthBar(0, healthBarY);
}
public function UpdateMessageOverlay(){
if (PlayAnimation()){
active = false;
};
}
public function InitMessageOverlay(_arg1:int){
updateFunction = UpdateMessageOverlay;
renderFunction = RenderMessageOverlay;
graphicID = GraphicObjects.GetIndexByName("TextBits");
graphicID = GraphicObjects.GetIndexByName("TextBits_HeadShot");
frame = 0;
frameVel = 1;
}
public function PlayAnimation1():Boolean{
var _local1:int = (GraphicObjects.GetNumFrames(graphicID1) - 1);
frame1 = (frame1 + frameVel1);
if (frame1 >= _local1){
frame1 = _local1;
return (true);
};
return (false);
}
function PlayerResetWhenDead(){
controlMode = -1;
timer = 50;
}
function ShootRocket(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number):void{
var _local5:GameObj;
_local5 = GameObjects.AddObj(_arg1, _arg2, zpos);
_local5.InitPlayerBullet_Rocket(_arg3, _arg4);
}
function InitFireworks():void{
colFlag_isPhysObj = true;
colFlag_isShootable = true;
updateFunction = UpdateFireworks;
hitFunction = HitFireworks;
xpos = (800 + 50);
ypos = (200 + Utils.RandBetweenFloat(0, 250));
frame = 0;
frameVel = 1;
graphicID = GraphicObjects.GetIndexByName("fireworks");
controlMode = 0;
bodyColBox = new Rectangle(-20, -63, 40, 63);
}
function UpdatePlayerBullet_Rocket():void{
xpos = (xpos + movementVec.GetXComponent());
ypos = (ypos + movementVec.GetYComponent());
dir = movementVec.rot;
timer--;
if (timer <= 0){
active = false;
};
}
public function HitPickup(){
active = false;
Game.AddScore((10 * (Game.currentLevel + 1)));
Game.numPickupsCollected++;
Game.totalPickupsCollected++;
if (Game.numPickupsCollected == 10){
Lic.Newgrounds_UnlockMedal("Collector");
};
SoundPlayer.Play("sfx_pickup");
Game.goPlayer.health++;
if (Game.goPlayer.health > Game.goPlayer.maxHealth){
Game.goPlayer.health = Game.goPlayer.maxHealth;
};
}
public function InitPickup(){
type = 0;
colFlag_canBePickedUp = true;
colFlag_isPhysObj = true;
graphicID = GraphicObjects.GetIndexByName("Pickup");
frame = Utils.RandBetweenInt(0, (GraphicObjects.GetNumFrames(graphicID) - 1));
updateFunction = UpdatePickup;
hitFunction = HitPickup;
xpos = (800 + 50);
ypos = (200 + Utils.RandBetweenFloat(0, 250));
Game.numPickupsGenerated++;
Game.totalPickupsGenerated++;
}
function UpdateBloodyFootprint():void{
xpos = (xpos - Game.scrollXvel);
if (xpos < -100){
active = false;
};
}
function InitVehicle():void{
invincibleTimer = 0;
colFlag_isPhysObj = true;
colFlag_isEnemy = true;
updateFunction = UpdateVehicle;
renderFunction = RenderPlayer;
graphicID = GraphicObjects.GetIndexByName("Car01");
var _local1:int = Utils.RandBetweenInt(0, (Game.aiCarTypes.length - 1));
graphicID = (graphicID + Game.aiCarTypes[_local1]);
frame = 0;
frameVel = 0;
playerSpeed = 0;
xvel = 0;
xpos = 900;
lane = Utils.RandBetweenInt(0, (Game.lanePositions.length - 1));
ypos = Game.lanePositions[lane];
ypos = (ypos + Utils.RandBetweenFloat(-1, 1));
xvel = Utils.RandBetweenFloat(10, 15);
xvel = Utils.RandBetweenFloat(0, (Game.minspeed - 2));
controlMode = 0;
Game.numVehiclesActive++;
DoScale();
}
function InitSideFlower():void{
graphicID = GraphicObjects.GetIndexByName("Flower01");
graphicID = (graphicID + Utils.RandBetweenInt(0, 1));
frame = 0;
updateFunction = UpdateSideFlower;
xpos = (xpos + Utils.RandBetweenFloat(-5, 5));
controlMode = 0;
timer = Utils.RandBetweenInt(0, 300);
}
function InitPlayerBullet_Flamethrower(_arg1:Number, _arg2:Number):void{
colFlag_isBullet = true;
graphicID = GraphicObjects.GetIndexByName("BulletFlame");
updateFunction = UpdatePlayerBullet_Flamethrower;
timer = 30;
movementVec.SetDxDy((_arg1 - xpos), (_arg2 - ypos), 10);
frame = 0;
frameVel = Utils.RandBetweenFloat(0.3, 0.6);
dir = Utils.RandCircle();
rotVel = Utils.RandBetweenFloat(-0.1, 0.1);
}
function EnemyHitParticles(){
var _local1:int;
var _local2:Particle;
_local1 = 0;
while (_local1 < 50) {
_local2 = Particles.Add(xpos, ypos);
_local2.InitEnemyExplosion();
_local1++;
};
}
function InitEnemy_Path(){
GetParams();
colFlag_isEnemy = true;
lineIndex = GetLineIndexByName(GetParam("line"));
var _local1:Number = GetParamNumber("time", 5);
lineLinearPos = GetParamNumber("start", 0);
var _local2:PhysLine = Game.GetCurrentLevel().lines[lineIndex];
lineSpeed = (1 / (_local1 * Defs.fps));
lineLoop = GetParamBool("loop", false);
lineResetAtEnd = false;
lineMode = 1;
controlMode = 1;
updateFunction = UpdateEnemy_Path;
hitFunction = HitEnemy_Path;
}
function RenderGore():void{
RenderGraphicNormally(graphicID, frame, xpos, (ypos + height), scale, dir);
}
public function UpdatePellet(){
}
function GameObj_UpdateSwitch():void{
if (controlMode == 0){
} else {
if (controlMode == 1){
frameVel = 1;
if (PlayAnimation()){
controlMode = 0;
};
} else {
if (controlMode == 2){
frameVel = -1;
if (PlayAnimation()){
controlMode = 0;
};
} else {
if (controlMode == 3){
frame = 0;
controlMode = 0;
};
};
};
};
}
function GetPlayerDist():Number{
return (Utils.DistBetweenPoints(xpos, ypos, Game.goPlayer.xpos, Game.goPlayer.ypos));
}
}
}//package
Section 172
//GameObjects (GameObjects)
package {
import flash.display.*;
import flash.events.*;
class GameObjects {
static var spareObj:GameObj;
public static var numobjs;
static var m:Main;
public static var zorder:Array;
public static var objs:Array;
public static var lastGenIndex:int;
public function GameObjGroup(){
}
public static function Update():void{
var _local1:int;
_local1 = 0;
while (_local1 < objs.length) {
if (objs[_local1].active == true){
objs[_local1].Update();
};
_local1++;
};
}
public static function Render(_arg1:BitmapData):void{
var _local2:GameObj;
var _local3:Array = new Array();
for each (_local2 in objs) {
if (((_local2.active) && (_local2.visible))){
_local3.push(_local2);
};
};
_local3.sortOn("zpos", (Array.NUMERIC | Array.DESCENDING));
for each (_local2 in _local3) {
_local2.Render(_arg1);
};
}
public static function InitOnce(_arg1:Main, _arg2:int){
var _local3:*;
numobjs = _arg2;
m = _arg1;
objs = new Array();
zorder = new Array(numobjs);
_local3 = 0;
while (_local3 < numobjs) {
objs.push(new GameObj(m, 0, 0));
_local3++;
};
spareObj = new GameObj(m, 0, 0);
}
public static function CountActive():int{
var _local2:int;
var _local1:int;
_local2 = 0;
while (_local2 < objs.length) {
if (objs[_local2].active == true){
_local1++;
};
_local2++;
};
return (_local1);
}
public static function AddObj(_arg1:Number, _arg2:Number, _arg3:Number):GameObj{
var _local4:int;
var _local5:GameObj;
_local4 = 0;
while (_local4 < numobjs) {
if (objs[_local4].active == false){
_local5 = objs[_local4];
_local5.active = true;
_local5.zpos = _arg3;
_local5.xpos = _arg1;
_local5.ypos = _arg2;
_local5.startx = _arg1;
_local5.starty = _arg2;
_local5.startz = _arg3;
_local5.Init(0);
lastGenIndex = _local4;
return (objs[_local4]);
};
_local4++;
};
trace("ERROR! NO FREE OBJECTS");
lastGenIndex = -1;
return (spareObj);
}
public static function ForEachActive(_arg1:Function):void{
var _local2:GameObj;
var _local3:Array = new Array();
for each (_local2 in objs) {
if (_local2.active){
_arg1(_local2);
};
};
}
public static function ClearAll(){
var _local1:int;
_local1 = 0;
while (_local1 < numobjs) {
objs[_local1].active = false;
_local1++;
};
}
public static function GetGOByIndex(_arg1:int):GameObj{
return (objs[_arg1]);
}
}
}//package
Section 173
//gorybits_mc (gorybits_mc)
package {
import flash.display.*;
public dynamic class gorybits_mc extends MovieClip {
}
}//package
Section 174
//GraphicObjects (GraphicObjects)
package {
import flash.display.*;
import flash.geom.*;
import flash.text.*;
import flash.utils.*;
public class GraphicObjects {
public static var gfx_font1:int;
public static var gfx_fills:int;
static var count:int;
public static var stringCharBitmap:Bitmap;
public static var gfx_font2black:int;
public static var stringCharX:Number;
static var main:Main;
public static var gfx_backgrounds:int;
public static var stringCharY:Number;
static var nameList:Array;
public static var gfx_fontblack:int;
static var graphicobjs:Array;
static var nextID:int;
static var idList:Array;
public static var gfx_outlines:int;
public static var gfx_font2:int;
public static function Add(_arg1:String, _arg2:int):int{
var _local3:* = nextID;
nextID++;
var _local4:Class = (getDefinitionByName(_arg1) as Class);
var _local5:MovieClip = (new (_local4) as MovieClip);
Add1(_local3, new DisplayObj(_local5, 1, _arg2), _arg1);
return (_local3);
}
public static function GetBitmap(_arg1:int, _arg2:int):Bitmap{
var _local3:int = idList[_arg1];
return (graphicobjs[_local3].frames[_arg2].bitmaps[0]);
}
public static function RenderAt(_arg1:int, _arg2:int, _arg3:BitmapData, _arg4:Number, _arg5:Number, _arg6:Boolean=false){
var _local7:int = idList[_arg1];
graphicobjs[_local7].frames[_arg2].RenderAt(_arg3, _arg4, _arg5, _arg6);
}
public static function RenderAtRot(_arg1:int, _arg2:int, _arg3:BitmapData, _arg4:Number, _arg5:Number, _arg6:Number, _arg7:Boolean){
var _local8:int = idList[_arg1];
if (_arg7){
graphicobjs[_local8].frames[_arg2].RenderAtRotBurned(_arg3, _arg4, _arg5, _arg6);
} else {
graphicobjs[_local8].frames[_arg2].RenderAtRot(_arg3, _arg4, _arg5, _arg6);
};
}
public static function RenderAtSplit(_arg1:int, _arg2:int, _arg3:BitmapData, _arg4:Number, _arg5:Number){
var _local6:int = idList[_arg1];
graphicobjs[_local6].frames[_arg2].RenderAtSplit(_arg3, _arg4, _arg5);
}
public static function RenderAtRotScaled(_arg1:int, _arg2:int, _arg3:BitmapData, _arg4:Number, _arg5:Number, _arg6:Boolean=false, _arg7:Number=1, _arg8:Number=0, _arg9:ColorTransform=null, _arg10:Boolean=false){
var _local11:int = idList[_arg1];
graphicobjs[_local11].frames[_arg2].RenderAtRotScaled(_arg3, _arg4, _arg5, _arg6, _arg7, _arg8, _arg9, _arg10);
}
public static function GetStringWidth(_arg1:BitmapData, _arg2:int, _arg3:Number, _arg4:Number, _arg5:String, _arg6:Object=null, _arg7:int=0):int{
var _local9:int;
var _local10:int;
stringCharX = _arg3;
stringCharY = _arg4;
var _local8:int;
_local9 = 0;
while (_local9 < _arg5.length) {
_local10 = int(_arg5.charCodeAt(_local9));
if (_local10 < 0){
_local10 = 0;
};
if (_local10 > 127){
_local10 = 127;
};
stringCharBitmap = GetBitmap(_arg2, _local10);
if (_arg6 != null){
} else {
_local8 = (_local8 + (stringCharBitmap.width - 3));
_local8 = (_local8 + _arg7);
};
_local9++;
};
return (_local8);
}
public static function RenderStringAt(_arg1:BitmapData, _arg2:int, _arg3:Number, _arg4:Number, _arg5:String, _arg6:Object=null, _arg7:int=0){
var _local8:int;
var _local9:int;
stringCharX = _arg3;
stringCharY = _arg4;
_local8 = 0;
while (_local8 < _arg5.length) {
_local9 = int(_arg5.charCodeAt(_local8));
if (_local9 < 0){
_local9 = 0;
};
if (_local9 > 127){
_local9 = 127;
};
RenderAt((_arg2 + 1), _local9, _arg1, (stringCharX + 1), (stringCharY + 1));
RenderAt(_arg2, _local9, _arg1, stringCharX, stringCharY);
stringCharBitmap = GetBitmap(_arg2, _local9);
if (_arg6 != null){
_arg6();
} else {
stringCharX = (stringCharX + (stringCharBitmap.width - 3));
stringCharX = (stringCharX + _arg7);
};
_local8++;
};
}
public static function GetWidth(_arg1:int, _arg2:int):int{
var _local3:int = idList[_arg1];
return (graphicobjs[_local3].frames[_arg2].bitmaps[0].width);
}
public static function RenderNumberAt(_arg1:BitmapData, _arg2:int, _arg3:Number, _arg4:Number, _arg5:int){
var _local8:int;
var _local10:int;
var _local11:int;
var _local12:Bitmap;
var _local6:Array = new Array();
var _local7:int = _arg5;
_local8 = 0;
while (_local8 < 11) {
_local10 = (_local7 % 10);
_local6.push(_local10);
_local7 = (_local7 / 10);
_local8++;
};
var _local9:Boolean;
_local8 = (_local6.length - 1);
while (_local8--) {
_local11 = _local6[_local8];
if ((((_local9 == false)) && (!((_local11 == 0))))){
_local9 = true;
};
if (_local9){
RenderAt(_arg2, (_local11 + 48), _arg1, _arg3, _arg4);
_local12 = GetBitmap(_arg2, (_local11 + 48));
_arg3 = (_arg3 + _local12.width);
};
(_local8 >= 0);
};
return (_arg3);
}
public static function GetNumFrames(_arg1:int):int{
var _local2:int = idList[_arg1];
return (graphicobjs[_local2].frames.length);
}
public static function RenderAtCT(_arg1:int, _arg2:int, _arg3:BitmapData, _arg4:Number, _arg5:Number, _arg6:Boolean=false, _arg7:ColorTransform=null){
var _local8:int = idList[_arg1];
graphicobjs[_local8].frames[_arg2].RenderAtColTrans(_arg3, _arg4, _arg5, _arg7, _arg6);
}
public static function GetYoffset(_arg1:int, _arg2:int):Number{
var _local3:int = idList[_arg1];
return (graphicobjs[_local3].frames[_arg2].yoffsets[0]);
}
public static function RenderAtScaled(_arg1:int, _arg2:int, _arg3:BitmapData, _arg4:Number, _arg5:Number, _arg6:Boolean=false, _arg7:Number=1){
var _local8:int = idList[_arg1];
graphicobjs[_local8].frames[_arg2].RenderAtScaled(_arg3, _arg4, _arg5, _arg6, _arg7);
}
public static function Add1(_arg1:int, _arg2:DisplayObj, _arg3:String=""):void{
idList[_arg1] = count;
nameList[_arg1] = _arg3;
graphicobjs.push(_arg2);
count++;
}
public static function InitOnce(_arg1:Main):void{
var _local2:int;
main = _arg1;
graphicobjs = new Array();
idList = new Array(200);
nameList = new Array(200);
_local2 = 0;
while (_local2 < 200) {
idList[_local2] = int(0);
nameList[_local2] = String("");
_local2++;
};
count = 0;
nextID = 0;
gfx_font1 = AddFont(main.tf_scorespr);
gfx_fontblack = AddFont(main.tf_scoresprblack);
gfx_font2 = AddFont(main.tf_scorespr1);
gfx_font2black = AddFont(main.tf_scorespr2);
Add("PowerupMeter", 0);
Add("FarBackgrounds", 0);
Add("RoadBackgrounds", 0);
Add("subwayBackgrounds", 0);
Add("shoppingmall_background", 0);
Add("RoadFairgroundBackgrounds", 0);
Add("enemy1", 0);
Add("enemy1_2", 0);
Add("enemy2", 0);
Add("enemy2_2", 0);
Add("enemy3", 0);
Add("enemy4", 0);
Add("enemy5", 0);
Add("enemy5_2", 0);
Add("player", 0);
Add("player_backwards", 0);
Add("arm_chainsaw_forward", 0);
Add("arm_crowbar_forward", 0);
Add("arm_hmg_forward", 0);
Add("arm_flamethrower_forward", 0);
Add("arm_laser_forward", 0);
Add("arm_smg_forward", 0);
Add("arm_rifle_forward", 0);
Add("arm_uzi_forward", 0);
Add("arm_pistol_forward", 0);
Add("arm_shotgun_forward", 0);
Add("arm_rocketlauncher_forward", 0);
Add("sky", 0);
Add("ExplosiveBarrel", 0);
Add("Blocker", 0);
Add("BulletRocket", 0);
Add("BulletFlame", 0);
Add("flame", 2);
Add("laser_flash", 2);
Add("machinegun_flash", 2);
Add("pistol_flash", 2);
Add("rifle_flash", 2);
Add("rocketlauncher_explosion", 0);
Add("shotgun_flash", 2);
Add("uzi_flash", 2);
Add("weapon_hmg_line", 2);
Add("weapon_laser_line", 2);
Add("weapon_machinegun_line", 2);
Add("weapon_pistol_line", 2);
Add("weapon_shotgun_line", 2);
Add("weapon_uzi_line", 2);
Add("reloading_mc", 0);
Add("BloodSplat01", 0);
Add("BloodSplat02", 0);
Add("BloodPuddle01", 0);
Add("LevelProgressIndicator", 0);
Add("LevelProgressIndicatorMarker", 0);
Add("TextBits", 0);
Add("TextBits_HeadShot", 0);
Add("BloodyFootprints", 0);
Add("Pickup", 0);
Add("hud_weapon_bg", 0);
Add("hud_weapon", 0);
Add("Cartridges", 0);
Add("fireworks", 0);
Add("gorybits_mc", 0);
Add("playerdeath", 0);
Add("player_head", 0);
}
public static function GetPixelAt(_arg1:int, _arg2:int, _arg3:int, _arg4:int):uint{
var _local5:int = idList[_arg1];
var _local6:Bitmap = graphicobjs[_local5].frames[_arg2].bitmaps[0];
var _local7:uint = _local6.bitmapData.getPixel32(_arg3, _arg4);
return (_local7);
}
public static function RenderAtAlpha(_arg1:int, _arg2:int, _arg3:BitmapData, _arg4:Number, _arg5:Number, _arg6:Number){
var _local7:int = idList[_arg1];
graphicobjs[_local7].frames[_arg2].RenderAtAlpha(_arg3, _arg4, _arg5, _arg6);
}
public static function GetIndexByName(_arg1:String):int{
var _local3:String;
var _local2:int;
for each (_local3 in nameList) {
if (_local3 == _arg1){
return (_local2);
};
_local2++;
};
trace(("cant find graphic obj by name: " + _arg1));
return (0);
}
public static function AddFont(_arg1:TextFormat):int{
var _local2:* = nextID;
nextID++;
var _local3:DisplayObj = new DisplayObj(null, 0, 0);
_local3.CreateFont(_arg1);
idList[_local2] = count;
graphicobjs.push(_local3);
count++;
return (_local2);
}
public static function GetHeught(_arg1:int, _arg2:int):int{
var _local3:int = idList[_arg1];
return (graphicobjs[_local3].frames[_arg2].bitmaps[0].height);
}
public static function GetXoffset(_arg1:int, _arg2:int):Number{
var _local3:int = idList[_arg1];
return (graphicobjs[_local3].frames[_arg2].xoffsets[0]);
}
public static function RenderAtAdditive(_arg1:int, _arg2:int, _arg3:BitmapData, _arg4:Number, _arg5:Number, _arg6:Number){
var _local7:int = idList[_arg1];
graphicobjs[_local7].frames[_arg2].RenderAtAdditive(_arg3, _arg4, _arg5, _arg6);
}
}
}//package
Section 175
//HelpScreen (HelpScreen)
package {
import flash.display.*;
public dynamic class HelpScreen extends MovieClip {
public var buttonContinue:SimpleButton;
}
}//package
Section 176
//hud_weapon (hud_weapon)
package {
import flash.display.*;
public dynamic class hud_weapon extends MovieClip {
}
}//package
Section 177
//hud_weapon_bg (hud_weapon_bg)
package {
import flash.display.*;
public dynamic class hud_weapon_bg extends MovieClip {
}
}//package
Section 178
//Intro_AddictingGames (Intro_AddictingGames)
package {
import flash.display.*;
public dynamic class Intro_AddictingGames extends MovieClip {
public var agBtn:SimpleButton;
public function Intro_AddictingGames(){
addFrameScript(0, frame1, 341, frame342);
}
function frame342(){
MovieClip(parent).play();
stop();
}
function frame1(){
agBtn.useHandCursor = false;
}
}
}//package
Section 179
//Intro_Andkon (Intro_Andkon)
package {
import flash.display.*;
import flash.events.*;
public dynamic class Intro_Andkon extends MovieClip {
public function Intro_Andkon(){
addFrameScript(0, frame1, 99, frame100);
}
function frame100(){
stop();
MovieClip(parent).play();
}
function frame1(){
addEventListener(MouseEvent.CLICK, Lic.Link_Andkon);
}
}
}//package
Section 180
//Intro_ArmorGames (Intro_ArmorGames)
package {
import flash.display.*;
public dynamic class Intro_ArmorGames extends MovieClip {
public function Intro_ArmorGames(){
addFrameScript(215, frame216);
}
function frame216(){
stop();
MovieClip(parent).play();
}
}
}//package
Section 181
//Intro_BubbleBox (Intro_BubbleBox)
package {
import flash.display.*;
public dynamic class Intro_BubbleBox extends MovieClip {
public var play_latest_text:MovieClip;
public var link:MovieClip;
public function Intro_BubbleBox(){
addFrameScript(0, frame1, 150, frame151, 160, frame161);
}
function frame151(){
MovieClip(parent).stop();
}
function frame1(){
}
function frame161(){
stop();
MovieClip(parent).play();
}
}
}//package
Section 182
//Intro_FOG (Intro_FOG)
package {
import flash.display.*;
import flash.events.*;
import flash.geom.*;
import flash.media.*;
import flash.text.*;
import flash.utils.*;
import flash.net.*;
import flash.filters.*;
import flash.system.*;
import flash.ui.*;
import flash.errors.*;
import adobe.utils.*;
import flash.accessibility.*;
import flash.external.*;
import flash.printing.*;
import flash.profiler.*;
import flash.sampler.*;
import flash.xml.*;
public dynamic class Intro_FOG extends MovieClip {
public var stagewidth:Number;
public var fogHolder:MovieClip;
public var okToPlay:Boolean;
public var debug:Boolean;
public var gameName:String;
public var mcLogo:MovieClip;
public var stageheight:Number;
public var Furl:String;
public var pre1:MovieClip;
public var btnFoggy:SimpleButton;
public function Intro_FOG(){
addFrameScript(0, frame1, 1, frame2, 2, frame3);
}
public function buttonClicked(_arg1:MouseEvent):void{
navigateToURL(new URLRequest(("http://www.freeonlinegames.com/?" + gameName)), "_blank");
}
public function showProgress(_arg1:Event):void{
pre1.procent.text = Math.floor(((loaderInfo.bytesLoaded / loaderInfo.bytesTotal) * 100));
pre1.gotoAndStop(pre1.procent.text);
if (Number(pre1.procent.text) > 99){
Furl = loaderInfo.url;
stage.removeEventListener(Event.ENTER_FRAME, showProgress);
stage.removeEventListener(Event.ENTER_FRAME, loadingBar);
play();
};
}
function frame1(){
debug = true;
gameName = "nameofthegame";
stop();
Furl = "";
okToPlay = false;
fscommand("showmenu", "false");
stagewidth = stage.stageWidth;
stageheight = stage.stageHeight;
btnFoggy.width = stagewidth;
btnFoggy.height = stageheight;
stage.addEventListener(Event.ENTER_FRAME, showProgress);
stage.addEventListener(Event.ENTER_FRAME, loadingBar);
btnFoggy.addEventListener(MouseEvent.CLICK, buttonClicked);
}
function frame2(){
stop();
trace("FOG stopped");
MovieClip(parent).play();
}
function frame3(){
if (!okToPlay){
gotoAndStop(2);
btnFoggy.removeEventListener(MouseEvent.CLICK, buttonClicked);
};
}
public function FOGFly(_arg1:Event):void{
var _local2:* = _arg1.currentTarget;
_local2.x = (_local2.x + (((_local2.targetX - _local2.x) / _local2.speed) * 0.5));
_local2.y = (_local2.y + (((_local2.targetY - _local2.y) / _local2.speed) * 0.5));
_local2.speed = (_local2.speed * 0.99);
_local2.scaleX = (_local2.scaleY = (_local2.scaleY + (_local2.grow * 2)));
if ((((_local2.alpha < 1)) && (!(_local2.fade)))){
_local2.alpha = (_local2.alpha + 0.02);
};
if ((((((((((_local2.x < -50)) || ((_local2.y < -50)))) || ((_local2.x > (stagewidth + 50))))) || ((_local2.y > (stageheight + 50))))) || ((_local2.scaleX > 2)))){
_local2.fade = true;
};
if (_local2.fade){
_local2.alpha = (_local2.alpha - 0.05);
if (_local2.alpha <= 0){
_local2.removeEventListener(Event.ENTER_FRAME, FOGFly);
_local2.parent.removeChild(_local2);
};
};
}
public function loadingBar(_arg1:Event):void{
var _local3:*;
var _local2:* = Math.random();
if (_local2 < ((loaderInfo.bytesLoaded / loaderInfo.bytesTotal) / 5)){
_local3 = new fog_1();
_local3.cacheAsBitmap = true;
_local3.x = (stagewidth / 2);
_local3.y = (stageheight / 2);
_local3.scaleX = (_local3.scaleY = 0);
_local3.gotoAndStop(((Math.random() * 10) + 1));
_local3.speed = 100;
_local3.alpha = 0;
_local3.grow = (Math.random() / 100);
_local3.fade = false;
_local3.targetX = (Math.random() * 10);
if (_local3.targetX < 5){
_local3.targetX = (Math.random() * 10);
if (_local3.targetX < 5){
_local3.targetX = -100;
} else {
_local3.targetX = (stagewidth + 100);
};
_local3.targetY = (Math.random() * stageheight);
} else {
_local3.targetY = (Math.random() * 10);
if (_local3.targetY < 5){
_local3.targetY = -100;
} else {
_local3.targetY = (stageheight + 100);
};
_local3.targetX = (Math.random() * stagewidth);
};
fogHolder.addChild(_local3);
_local3.addEventListener(Event.ENTER_FRAME, FOGFly);
};
}
}
}//package
Section 183
//Intro_Kongregate (Intro_Kongregate)
package {
import flash.display.*;
import flash.events.*;
public dynamic class Intro_Kongregate extends MovieClip {
public function Intro_Kongregate(){
addFrameScript(0, frame1, 197, frame198);
}
function frame198(){
trace("stopping kong intro");
stop();
MovieClip(parent).play();
}
function frame1(){
addEventListener(MouseEvent.CLICK, Lic.Link_Kongregate);
}
}
}//package
Section 184
//Intro_LongAnimals (Intro_LongAnimals)
package {
import flash.display.*;
import flash.events.*;
public dynamic class Intro_LongAnimals extends MovieClip {
public function Intro_LongAnimals(){
addFrameScript(0, frame1, 85, frame86);
}
function frame86(){
stop();
MovieClip(parent).play();
}
function frame1(){
addEventListener(MouseEvent.CLICK, Lic.Link_LongAnimals);
}
}
}//package
Section 185
//Intro_MaxGames (Intro_MaxGames)
package {
import flash.display.*;
import flash.events.*;
public dynamic class Intro_MaxGames extends MovieClip {
public function Intro_MaxGames(){
addFrameScript(0, frame1, 239, frame240);
}
function frame240(){
MovieClip(parent).play();
stop();
}
function frame1(){
addEventListener(MouseEvent.CLICK, Lic.Link_MaxGames);
}
}
}//package
Section 186
//Intro_MiniJuegos (Intro_MiniJuegos)
package {
import flash.display.*;
public dynamic class Intro_MiniJuegos extends MovieClip {
public function Intro_MiniJuegos(){
addFrameScript(99, frame100);
}
function frame100(){
stop();
MovieClip(parent).play();
}
}
}//package
Section 187
//Intro_MouseBreaker (Intro_MouseBreaker)
package {
import flash.display.*;
public dynamic class Intro_MouseBreaker extends MovieClip {
public var exp:MovieClip;
public function Intro_MouseBreaker(){
addFrameScript(0, frame1, 105, frame106);
}
function frame106(){
MovieClip(parent).play();
stop();
}
function frame1(){
}
}
}//package
Section 188
//Intro_Newgrounds (Intro_Newgrounds)
package {
import flash.display.*;
import flash.events.*;
public dynamic class Intro_Newgrounds extends MovieClip {
public function Intro_Newgrounds(){
addFrameScript(0, frame1, 99, frame100);
}
function frame100(){
stop();
MovieClip(parent).play();
}
function frame1(){
addEventListener(MouseEvent.CLICK, Lic.Link_Andkon);
}
}
}//package
Section 189
//Intro_RobotJam (Intro_RobotJam)
package {
import flash.display.*;
public dynamic class Intro_RobotJam extends MovieClip {
public function Intro_RobotJam(){
addFrameScript(106, frame107);
}
function frame107(){
stop();
MovieClip(parent).play();
}
}
}//package
Section 190
//KeyReader (KeyReader)
package {
import flash.display.*;
import flash.events.*;
public class KeyReader {
static const KEY_LEFT = 37;
static const KEY_HASH = 222;
static const KEY_LEFTSQUAREBRACKET = 219;
static const KEY_0 = 58;
static const KEY_1 = 49;
static const KEY_2 = 50;
static const KEY_3 = 51;
static const KEY_4 = 52;
static const KEY_5 = 53;
static const KEY_7 = 55;
static const KEY_8 = 56;
static const KEY_9 = 57;
static const KEY_6 = 54;
static const KEY_A = 65;
static const KEY_B = 66;
static const KEY_C = 67;
static const KEY_E = 69;
static const KEY_F = 70;
static const KEY_G = 71;
static const KEY_H = 72;
static const KEY_I = 73;
static const KEY_J = 74;
static const KEY_D = 68;
static const KEY_L = 76;
static const KEY_M = 77;
static const KEY_N = 78;
static const KEY_O = 79;
static const KEY_P = 80;
static const KEY_Q = 81;
static const KEY_R = 82;
static const KEY_S = 83;
static const KEY_T = 84;
static const KEY_U = 85;
static const KEY_V = 86;
static const KEY_W = 87;
static const KEY_X = 88;
static const KEY_Y = 89;
static const KEY_K = 75;
static const KEY_RIGHTSQUAREBRACKET = 221;
static const KEY_Z = 90;
static const KEY_SHIFT = 16;
static const KEY_CONTROL = 17;
static const KEY_SEMICOLON = 186;
static const KEY_NUM_0 = 96;
static const KEY_NUM_2 = 98;
static const KEY_UP = 38;
static const KEY_NUM_6 = 102;
static const KEY_NUM_1 = 97;
static const KEY_NUM_3 = 99;
static const KEY_DOWN = 40;
static const KEY_NUM_5 = 101;
static const KEY_NUM_7 = 103;
static const KEY_NUM_9 = 105;
static const KEY_NUM_4 = 100;
static const KEY_NUM_8 = 104;
static const KEY_TOPLEFT = 223;
static const KEY_BACKSLASH = 220;
static const KEY_FORWARDSLASH = 191;
static const KEY_SPACE = 32;
static const KEY_RIGHT = 39;
static var keysPressed:Array;
static var keysDown:Array;
public static function Pressed(_arg1:int):Boolean{
return (keysPressed[_arg1]);
}
static function keyUpListener(_arg1:KeyboardEvent):void{
var _local2:int = _arg1.keyCode;
keysDown[_local2] = 0;
}
static function keyDownListener(_arg1:KeyboardEvent):void{
var _local2:int = _arg1.keyCode;
var _local3 = keysDown;
var _local4 = _local2;
var _local5 = (_local3[_local4] + 1);
_local3[_local4] = _local5;
}
public static function UpdateOncePerFrame():void{
var _local1:int;
_local1 = 0;
while (_local1 < 0x0100) {
if (keysDown[_local1] == 1){
keysPressed[_local1] = true;
var _local2 = keysDown;
var _local3 = _local1;
var _local4 = (_local2[_local3] + 1);
_local2[_local3] = _local4;
} else {
keysPressed[_local1] = false;
};
_local1++;
};
}
public static function Down(_arg1:int):Boolean{
return (!((keysDown[_arg1] == 0)));
}
public static function InitOnce(_arg1:Stage){
var _local2:int;
_arg1.addEventListener(KeyboardEvent.KEY_DOWN, keyDownListener);
_arg1.addEventListener(KeyboardEvent.KEY_UP, keyUpListener);
_arg1.focus = _arg1;
keysDown = new Array(0x0100);
keysPressed = new Array(0x0100);
_local2 = 0;
while (_local2 < 0x0100) {
keysDown[_local2] = int(0);
keysPressed[_local2] = Boolean(false);
_local2++;
};
}
}
}//package
Section 191
//Kong (Kong)
package {
import flash.display.*;
import flash.events.*;
import flash.net.*;
public class Kong {
static var root:Object;
static var kongregate;
public static function InitOnce(_arg1:Object){
if (Lic.IsAtKongregate() == false){
return;
};
root = _arg1;
var _local2:Object = root.loaderInfo.loader;
var _local3:Object = LoaderInfo(root.loaderInfo).parameters;
var _local4:String = ((_local3.api_path) || ("http://www.kongregate.com/flash/API_AS3_Local.swf"));
trace(("API path: " + _local4));
var _local5:URLRequest = new URLRequest(_local4);
var _local6:Loader = new Loader();
_local6.contentLoaderInfo.addEventListener(Event.COMPLETE, loadComplete);
_local6.load(_local5);
root.addChild(_local6);
}
public static function SubmitScore(_arg1:Number, _arg2:String){
trace(((("Kong Score: " + _arg2) + " ") + _arg1));
if (Lic.IsAtKongregate() == false){
return;
};
kongregate.scores.submit(_arg1, _arg2);
}
public static function SubmitStat(_arg1:Number, _arg2:String){
trace(((("Kong Stat: " + _arg2) + " ") + _arg1));
if (Lic.IsAtKongregate() == false){
return;
};
kongregate.stats.submit(_arg2, _arg1);
}
static function loadComplete(_arg1:Event):void{
kongregate = _arg1.target.content;
kongregate.services.connect();
trace(("\n" + kongregate.services));
trace(("\n" + kongregate.user));
trace(("\n" + kongregate.scores));
trace(("\n" + kongregate.stats));
}
}
}//package
Section 192
//laser_flash (laser_flash)
package {
import flash.display.*;
public dynamic class laser_flash extends MovieClip {
}
}//package
Section 193
//Level (Level)
package {
public class Level {
var surfaceFrame:uint;
var lastTimeTotal:int;
var instances:Array;
var available:Boolean;
var lastTime:int;
var name:String;
var surfaceThickness:int;
var bestTime:int;
var exclusiveChar:int;
var goldTime:int;
var eventWinParam:Number;
var silverTime:int;
var fillFrame:int;
var eventOpponentsString:String;
var helpscreenFrames:Array;
var eventType:String;
var complete:Boolean;
var bestTimeTotal:int;
var category:int;
var lines:Array;
public function Level(){
name = "";
instances = new Array();
helpscreenFrames = new Array();
lines = new Array();
category = 0;
fillFrame = 1;
surfaceFrame = 5;
surfaceThickness = 10;
available = false;
complete = false;
eventType = "none";
eventOpponentsString = "";
eventWinParam = 1;
exclusiveChar = 1;
lastTime = 9999999;
lastTimeTotal = 9999999;
bestTime = 9999999;
bestTimeTotal = 9999999;
goldTime = (10 * Defs.fps);
silverTime = (20 * Defs.fps);
}
public function Calculate(){
}
}
}//package
Section 194
//LevelProgressIndicator (LevelProgressIndicator)
package {
import flash.display.*;
public dynamic class LevelProgressIndicator extends MovieClip {
}
}//package
Section 195
//LevelProgressIndicatorMarker (LevelProgressIndicatorMarker)
package {
import flash.display.*;
public dynamic class LevelProgressIndicatorMarker extends MovieClip {
}
}//package
Section 196
//Lic (Lic)
package {
import com.newgrounds.*;
import flash.display.*;
import flash.events.*;
import flash.utils.*;
import flash.net.*;
import CPMStar.*;
import com.newgrounds.components.*;
import flash.system.*;
public class Lic {
public static const LICENSOR_GAMENINJA = 17;
public static const LICENSOR_ANDKON = 5;
public static const LICENSOR_LONGANIMALS = 21;
public static const LICENSOR_ROBOTJAM = 23;
public static const LICENSOR_ADDICTINGGAMES = 19;
public static const LICENSOR_KING = 10;
public static const LICENSOR_MOUSEBREAKER = 16;
public static const ADTYPE_NONE = 0;
public static const LICENSOR_DEVELOPMENT = 0;
public static const ADTYPE_CPMSTAR = 3;
public static const LICENSOR_NOBRANDING = 12;
public static const LICENSOR_SIKIDS = 14;
public static const LICENSOR_BIGFISH = 6;
public static const ADTYPE_MOCHI_VC = 2;
public static const LICENSOR_KONGREGATE = 1;
public static const LICENSOR_MAXGAMES = 20;
public static const LICENSOR_MINDJOLT = 4;
public static const LICENSOR_ARMORGAMES = 8;
public static const LICENSOR_MINIJUEGOS = 15;
public static const LICENSOR_LONGANIMALS_SITELOCKED = 22;
public static const ADTYPE_MOCHI = 1;
public static const LICENSOR_SHOCKWAVE = 11;
public static const LICENSOR_KIBA = 13;
public static const ADTYPE_NEWGROUNDS = 4;
public static const LICENSOR_NEWGROUNDS = 26;
public static const LICENSOR_MINICLIP = 2;
public static const LICENSOR_BUBBLEBOX = 7;
public static const LICENSOR_GAMEZHERO = 9;
public static const LICENSOR_FOG = 25;
public static const LICENSOR_SPIL = 18;
public static const LICENSOR_FGL = 24;
static var agi;
static var devKey:String = "57e6ffa35f343197fbd276da0a94ccbb";
static var cpmStarLoadTimer:int;
static var SubmitHighscore_Newgrounds_Callback:Function;
static var gameKey:String = "zomgies";
static var stg:MovieClip;
static var ad:DisplayObject = null;
static var Newgrounds_HighScoreTable:ScoreTable;
static var ng_timer:Timer;
static var cpmStarTimer:Timer;
static var CPMStarContentSpotIDs:Array = new Array();
static var urlLoader:Loader;
static var intro:MovieClip;
static var cx:int;
static var cy:int;
static var cpmStarLoaderCounter:int;
static var ng_ad:AdDisplay;
static var highscore_callback:Function;
static var licensor:int = 26;
static var MindJoltAPI:Object;
static var oldFrameRate:int = 0;
static var CPMStarFixedTime:int = 8;
static var referral:String = "zomgies";
static var localTest:Boolean = false;
static var domain:String;
static var skus:Array;
public static function ViewHighScoresDone_Newgrounds(_arg1:MouseEvent):void{
if (!(_arg1.target is SimpleButton)){
stg.removeChild(Newgrounds_HighScoreTable);
Newgrounds_HighScoreTable = null;
SubmitHighscore_Newgrounds_Callback();
};
}
public static function LoadMindjoltAPI(){
var _local1:Object = LoaderInfo(stg.loaderInfo).parameters;
Security.allowDomain("static.mindjolt.com", "devstatic.mindjolt.com");
urlLoader = new Loader();
urlLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, MJloadFinished);
var _local2:String = ((_local1.mjPath) || ("http://static.mindjolt.com/api/as3/scoreapi_as3_local.swf"));
urlLoader.load(new URLRequest(_local2));
stg.stage.addChild(urlLoader);
}
public static function IsAtKongregate():Boolean{
if (domain == "kongregate.com"){
return (true);
};
return (false);
}
static function InitHighScores_ArmorGames():void{
var _local1 = "http://agi.armorgames.com/assets/agi/AGI.swf";
Security.allowDomain(_local1);
Security.allowInsecureDomain(_local1);
var _local2:URLRequest = new URLRequest(_local1);
var _local3:Loader = new Loader();
_local3.contentLoaderInfo.addEventListener(Event.COMPLETE, InitHighScores_ArmorGames_LoadComplete);
_local3.load(_local2);
}
public static function Link_RobotJam(_arg1:MouseEvent, _arg2:String="intro"){
navigateToURL(new URLRequest("http://www.robotjamgames.com"), "_blank");
}
static function InitHighScores_ArmorGames_LoadComplete(_arg1:Event):void{
agi = _arg1.currentTarget.content;
stg.addChild(agi);
agi.init(devKey, gameKey);
}
public static function SubmitHighscore_Newgrounds(_arg1:Number, _arg2:Function):void{
SubmitHighscore_Newgrounds_Callback = _arg2;
trace("Submit high score - newgrounds");
NewgroundsAPI.postScore("Scores", _arg1);
NewgroundsAPI.addEventListener(APIEvent.SCORE_POSTED, SubmitHighscore_Newgrounds_Done);
}
static function SkuModify():void{
if (localTest == true){
return;
};
if ((((licensor == LICENSOR_NEWGROUNDS)) && (((!((domain == "newgrounds.com"))) && (!((domain == "ungrounded.net"))))))){
licensor = LICENSOR_ARMORGAMES;
};
if ((((licensor == LICENSOR_ADDICTINGGAMES)) && (!((domain == "addictinggames.com"))))){
licensor = LICENSOR_ARMORGAMES;
};
if ((((licensor == LICENSOR_ROBOTJAM)) && (!((domain == "robotjamgames.com"))))){
licensor = LICENSOR_ARMORGAMES;
};
}
public static function SubmitHighScoresDone_Newgrounds(_arg1:MouseEvent):void{
if (!(_arg1.target is SimpleButton)){
stg.removeChild(Newgrounds_HighScoreTable);
Newgrounds_HighScoreTable = null;
SubmitHighscore_Newgrounds_Callback();
};
}
public static function IsAtMindjolt():Boolean{
if (domain == "mindjolt.com"){
return (true);
};
return (false);
}
public static function Link_LongAnimals(_arg1:MouseEvent, _arg2:String="intro"){
navigateToURL(new URLRequest(("http://www.longanimalsgames.com?referral=" + referral)), "_blank");
}
public static function GetSku(_arg1:int):LicSku{
var _local2:LicSku;
for each (_local2 in skus) {
if (_local2.id == _arg1){
return (_local2);
};
};
trace(("GetSku invalid SKU: " + _arg1));
return (null);
}
public static function ShowAd():Boolean{
var _local1:int = GetSku(licensor).adtype;
if (_local1 == ADTYPE_NONE){
return (false);
};
if (_local1 == ADTYPE_MOCHI_VC){
return (false);
};
if (_local1 == ADTYPE_MOCHI){
ShowMochiAd();
return (true);
};
if (_local1 == ADTYPE_CPMSTAR){
if (FilterAdForSites() == false){
ShowCPMStarAd();
return (true);
};
return (false);
};
if (_local1 == ADTYPE_NEWGROUNDS){
Newgrounds_ShowAd();
return (true);
};
return (false);
}
static function ShowSitelockedScreen(){
intro = new SitelockedScreen();
intro.x = cx;
intro.y = cy;
stg.addChild(intro);
intro.addEventListener(MouseEvent.CLICK, SitelockScreen_Clicked);
}
public static function ShowIntro_MiniJuegos():void{
AddIntro("Intro_MiniJuegos");
}
static function SubmitHighscore_ArmorGames_CloseHandler():void{
stg.removeChild(agi);
if (highscore_callback != null){
highscore_callback();
};
}
static function MainLogo(_arg1:MovieClip):void{
var _local3:SimpleButton;
if (_arg1 == null){
return;
};
var _local2:LicSku = GetSku(licensor);
var _local4:int = _arg1.numChildren;
var _local5:int;
while (_local5 < _local4) {
_local3 = (_arg1.getChildAt(_local5) as SimpleButton);
if (_local3 != null){
_local3.visible = false;
} else {
trace("Lic: MainLogo Error. Null child found. (not a button?)");
};
_local5++;
};
if (_local2.mainLogoName != ""){
_local3 = (_arg1.getChildByName(_local2.mainLogoName) as SimpleButton);
if (_local3 != null){
_local3.visible = true;
if (_local2.linkFunction != null){
_local3.addEventListener(MouseEvent.CLICK, _local2.linkFunction, false, 0, true);
} else {
_local3.useHandCursor = false;
};
} else {
trace(("Lic: MainLogo Error. Can't find logo: " + _local2.mainLogoName));
};
};
}
static function CPMStarLoadingEventCallback(_arg1:Event){
var _local2:* = stg.stage.loaderInfo.bytesTotal;
var _local3:* = stg.stage.loaderInfo.bytesLoaded;
RenderLoaderBar(100);
if (_local3 >= _local2){
stg.removeEventListener(Event.ENTER_FRAME, CPMStarLoadingEventCallback);
cpmStarLoaderCounter++;
CPMStarCompleteCallback();
};
}
public static function Link_ArmorGames(_arg1:MouseEvent, _arg2:String="intro"){
navigateToURL(new URLRequest("http://www.armorgames.com"), "_blank");
}
public static function ShowCPMStarAd(){
var _local1:String;
var _local3:int;
intro = new CPMStarLoaderScreen();
intro.x = cx;
intro.y = cy;
stg.addChild(intro);
intro.buttonSkipCPMStarAd.visible = false;
intro.buttonSkipCPMStarAd.addEventListener(MouseEvent.CLICK, buttonSkipCPMStarAdPressed);
var _local2:int = CPMStarContentSpotIDs.length;
if (_local2 == 1){
_local1 = CPMStarContentSpotIDs[0];
};
if (_local2 == 2){
_local3 = Utils.RandBetweenInt(0, 1000);
if (_local3 < 500){
_local1 = CPMStarContentSpotIDs[0];
} else {
_local1 = CPMStarContentSpotIDs[1];
};
};
trace(("CPMStar ID " + _local1));
ad = new AdLoader(_local1);
intro.adBox.addChild(ad);
cpmStarLoadTimer = 0;
cpmStarLoaderCounter = 0;
stg.addEventListener(Event.ENTER_FRAME, CPMStarLoadingEventCallback);
cpmStarTimer = new Timer(1000);
cpmStarTimer.addEventListener(TimerEvent.TIMER, CPMStarTimerCallback);
cpmStarTimer.start();
}
public static function ShowIntro_Newgrounds():void{
trace(" ShowIntro_Newgrounds ");
AddIntro("Intro_Newgrounds");
}
public static function Link_AddictingGames(_arg1:MouseEvent, _arg2:String="intro"){
navigateToURL(new URLRequest("http://www.addictinggames.com"), "_blank");
}
public static function Link_Andkon(_arg1:MouseEvent, _arg2:String="intro"){
navigateToURL(new URLRequest("http://www.andkon.com/arcade/"), "_blank");
}
public static function SubmitScore_LongAnimals(_arg1:int, _arg2:String){
var s = _arg1;
var name = _arg2;
var key:int = s;
key = (key + 84563);
key = (key * 7);
key = (key - 276483);
trace(((("submit score " + s) + " key=") + key));
var path = "http://www.longanimalsgames.com/ViewHighScore.php";
var vars:URLVariables = new URLVariables();
vars.game = referral;
vars.submit = 1;
vars.score = s;
vars.key = key;
vars.name = name;
var request:URLRequest = new URLRequest(path);
request.method = URLRequestMethod.POST;
request.data = vars;
trace("Stats sent to server");
trace(request);
try {
sendToURL(request);
} catch(e:Error) {
trace(e.message);
};
}
public static function Link_Kongregate(_arg1:MouseEvent, _arg2:String="intro"){
navigateToURL(new URLRequest("http://www.kongregate.com/games/LongAnimals/cyclomaniacs?gamereferral=cyclomaniacs"), "_blank");
}
public static function ViewScore_LongAnimals(){
navigateToURL(new URLRequest(("http://www.longanimalsgames.com/ViewHighScore.php?game=" + referral)), "_blank");
}
public static function InitSkus():void{
var _local1:LicSku;
skus = new Array();
_local1 = new LicSku(LICENSOR_DEVELOPMENT, "Development");
skus.push(_local1);
_local1 = new LicSku(LICENSOR_KONGREGATE, "Kongregate");
_local1.introFunction = ShowIntro_Kongregate;
_local1.mainLogoName = "kongregate";
_local1.linkFunction = Link_Kongregate;
skus.push(_local1);
_local1 = new LicSku(LICENSOR_MINICLIP, "Miniclip");
_local1.AddSiteLock("miniclip.com");
skus.push(_local1);
_local1 = new LicSku(LICENSOR_MINDJOLT, "Mindjolt");
skus.push(_local1);
_local1 = new LicSku(LICENSOR_ANDKON, "Andkon");
_local1.AddSiteLock("andkon.com");
_local1.introFunction = ShowIntro_Andkon;
_local1.mainLogoName = "andkon";
_local1.linkFunction = Link_Andkon;
skus.push(_local1);
_local1 = new LicSku(LICENSOR_BIGFISH, "BigFish");
_local1.AddSiteLock("bigfishgames.de");
_local1.AddSiteLock("bigfishgames.fr");
_local1.AddSiteLock("bigfishgames.es");
_local1.AddSiteLock("bigfishgames.mx");
_local1.AddSiteLock("bigfishgames.jp");
skus.push(_local1);
_local1 = new LicSku(LICENSOR_BUBBLEBOX, "BubbleBox");
_local1.AddSiteLock("bubblebox.com");
_local1.introFunction = ShowIntro_BubbleBox;
_local1.mainLogoName = "bubbleBox";
_local1.linkFunction = Link_BubbleBox;
skus.push(_local1);
_local1 = new LicSku(LICENSOR_ARMORGAMES, "Armor Games");
_local1.introFunction = ShowIntro_ArmorGames;
_local1.adtype = ADTYPE_CPMSTAR;
_local1.mainLogoName = "armorGames";
_local1.linkFunction = Link_ArmorGames;
skus.push(_local1);
_local1 = new LicSku(LICENSOR_GAMEZHERO, "GamezHero");
_local1.AddSiteLock("gamezhero.com");
skus.push(_local1);
_local1 = new LicSku(LICENSOR_KING, "King");
_local1.AddSiteLock("king.com");
_local1.AddSiteLock("midasplayer.com");
skus.push(_local1);
_local1 = new LicSku(LICENSOR_SHOCKWAVE, "Shockwave");
_local1.AddSiteLock("shockwave.com");
skus.push(_local1);
_local1 = new LicSku(LICENSOR_NOBRANDING, "No branding");
skus.push(_local1);
_local1 = new LicSku(LICENSOR_KIBA, "Kiba");
skus.push(_local1);
_local1 = new LicSku(LICENSOR_SIKIDS, "SI Kids");
_local1.AddSiteLock("timeforkids.com");
_local1.AddSiteLock("sikids.com");
_local1.mainLogoName = "siKids";
_local1.linkFunction = Link_SIKids;
skus.push(_local1);
_local1 = new LicSku(LICENSOR_MINIJUEGOS, "MiniJuegos");
_local1.AddSiteLock("minijuegos.com");
_local1.AddSiteLock("minijuegosgratis.com");
_local1.AddSiteLock("72.36.157.12", true);
_local1.AddSiteLock("72.36.157.13", true);
_local1.AddSiteLock("72.36.157.16", true);
_local1.AddSiteLock("72.36.157.14", true);
_local1.AddSiteLock("72.36.157.26", true);
_local1.AddSiteLock("72.36.157.50", true);
_local1.AddSiteLock("72.36.157.11", true);
_local1.AddSiteLock("72.36.157.10", true);
_local1.AddSiteLock("72.36.157.9", true);
_local1.AddSiteLock("72.36.157.8", true);
_local1.introFunction = ShowIntro_MiniJuegos;
_local1.mainLogoName = "miniJuegos";
_local1.linkFunction = Link_MiniJuegos;
skus.push(_local1);
_local1 = new LicSku(LICENSOR_MOUSEBREAKER, "MouseBreaker");
_local1.AddSiteLock("mousebreaker.com");
_local1.introFunction = ShowIntro_MouseBreaker;
skus.push(_local1);
_local1 = new LicSku(LICENSOR_GAMENINJA, "GameNinja");
_local1.AddSiteLock("gameninja.com");
skus.push(_local1);
_local1 = new LicSku(LICENSOR_SPIL, "Spil");
skus.push(_local1);
_local1 = new LicSku(LICENSOR_ADDICTINGGAMES, "Addicting Games");
_local1.introFunction = ShowIntro_AddictingGames;
_local1.mainLogoName = "addictingGames";
_local1.linkFunction = Link_AddictingGames;
_local1.AddSiteLock("addictinggames.com");
skus.push(_local1);
_local1 = new LicSku(LICENSOR_MAXGAMES, "MaxGames");
_local1.AddSiteLock("maxgames.com");
_local1.introFunction = ShowIntro_MaxGames;
_local1.mainLogoName = "maxGames";
_local1.linkFunction = Link_MaxGames;
skus.push(_local1);
_local1 = new LicSku(LICENSOR_LONGANIMALS, "LongAnimals");
_local1.introFunction = ShowIntro_LongAnimals;
_local1.adtype = ADTYPE_CPMSTAR;
_local1.mainLogoName = "longAnimals";
_local1.linkFunction = Link_LongAnimals;
skus.push(_local1);
_local1 = new LicSku(LICENSOR_LONGANIMALS_SITELOCKED, "LongAnimalsSitelocked");
_local1.AddSiteLock("longanimalsgames.com");
_local1.AddSiteLock("longanimals.com");
_local1.introFunction = ShowIntro_LongAnimals;
_local1.mainLogoName = "longAnimals";
_local1.linkFunction = Link_LongAnimals;
skus.push(_local1);
_local1 = new LicSku(LICENSOR_ROBOTJAM, "RobotJam");
_local1.AddSiteLock("robotjam.com");
_local1.AddSiteLock("robotjamgames.com");
_local1.introFunction = ShowIntro_RobotJam;
_local1.scaleIntroToStage = true;
_local1.mainLogoName = "robotJam";
_local1.linkFunction = Link_RobotJam;
_local1.adtype = ADTYPE_CPMSTAR;
skus.push(_local1);
_local1 = new LicSku(LICENSOR_FGL, "FlashGameLicense");
_local1.AddSiteLock("flashgamelicense.com");
skus.push(_local1);
_local1 = new LicSku(LICENSOR_FOG, "Free Online Games (FOG)");
_local1.introFunction = ShowIntro_FOG;
skus.push(_local1);
_local1 = new LicSku(LICENSOR_NEWGROUNDS, "Newgrounds");
_local1.initFunction = InitFunction_Newgrounds;
_local1.introFunction = ShowIntro_Newgrounds;
_local1.mainLogoName = "newgrounds";
_local1.adtype = ADTYPE_NEWGROUNDS;
skus.push(_local1);
}
static function IsOnCorrectSite():Boolean{
var _local2:String;
if (localTest == true){
return (true);
};
var _local1:LicSku = GetSku(licensor);
if (_local1.sitelocks.length == 0){
return (true);
};
for each (_local2 in _local1.sitelocks) {
if (_local2 == domain){
return (true);
};
};
return (false);
}
static function NewgroundsAdTimerCallback1(_arg1:MouseEvent){
trace("NG ad NewgroundsAdTimerCallback1");
stg.removeChild(intro);
intro = null;
cpmStarTimer.stop();
cpmStarTimer.removeEventListener(TimerEvent.TIMER, NewgroundsAdTimerCallback);
cpmStarTimer = null;
stg.removeChild(ng_ad);
ng_ad = null;
trace("NG ad finished");
ShowIntro();
}
static function MoreGames(_arg1:SimpleButton):void{
if (_arg1 == null){
return;
};
var _local2:LicSku = GetSku(licensor);
if (_local2.linkFunction == null){
_arg1.visible = false;
return;
};
_arg1.addEventListener(MouseEvent.CLICK, _local2.linkFunction, false, 0, true);
}
public static function ShowIntro_RobotJam():void{
AddIntro("Intro_RobotJam");
}
public static function SubmitHighscore_Newgrounds_Done(_arg1:APIEvent):void{
trace("NG Highscore submitted");
Newgrounds_HighScoreTable = new ScoreTable();
Newgrounds_HighScoreTable.board_name = "Scores";
Newgrounds_HighScoreTable.x = ((Defs.displayarea_w / 2) - 150);
Newgrounds_HighScoreTable.y = ((Defs.displayarea_h / 2) - 125);
stg.addChild(Newgrounds_HighScoreTable);
Newgrounds_HighScoreTable.addEventListener(MouseEvent.CLICK, SubmitHighScoresDone_Newgrounds);
}
public static function ShowIntro():void{
if (IsOnCorrectSite() == false){
ShowSitelockedScreen();
return;
};
if (GetSku(licensor).introFunction != null){
stg.stop();
GetSku(licensor).introFunction();
} else {
stg.play();
};
}
public static function Link_MaxGames(_arg1:MouseEvent, _arg2:String="intro"){
navigateToURL(new URLRequest("http://www.maxgames.com"), "_blank");
}
static function NewgroundsAdWaitTimerCallback(_arg1:TimerEvent){
if (NewgroundsAPI.adsApproved){
intro = new NGAdScreen();
intro.x = (Defs.displayarea_w / 2);
intro.y = (Defs.displayarea_h / 2);
stg.addChild(intro);
intro.buttonSkipAd.visible = false;
ng_timer.stop();
ng_timer.removeEventListener(TimerEvent.TIMER, NewgroundsAdWaitTimerCallback);
ng_timer = null;
cpmStarTimer = new Timer((CPMStarFixedTime * 1000));
cpmStarTimer.addEventListener(TimerEvent.TIMER, NewgroundsAdTimerCallback);
cpmStarTimer.start();
ng_ad = NewgroundsAPI.createAd();
ng_ad.x = ((Defs.displayarea_w / 2) - 150);
ng_ad.y = ((Defs.displayarea_h / 2) - 125);
stg.addChild(ng_ad);
trace("Add Newgrounds ad");
} else {
ng_timer.start();
};
}
public static function ShowIntro_AddictingGames():void{
AddIntro("Intro_AddictingGames");
}
public static function ShowIntro_Andkon():void{
AddIntro("Intro_Andkon");
}
static function AddIntro(_arg1:String){
var _local2:LicSku = GetSku(licensor);
var _local3:Class = (getDefinitionByName(_arg1) as Class);
var _local4:MovieClip = (new (_local3) as MovieClip);
oldFrameRate = stg.stage.frameRate;
stg.stage.frameRate = 30;
intro = _local4;
stg.addChild(intro);
intro.x = cx;
intro.y = cy;
if (_local2.scaleIntroToStage){
if (Defs.displayarea_w < 640){
intro.scaleX = (intro.scaleY = (640 / intro.width));
};
};
intro.gotoAndPlay(1);
}
public static function Link_MiniJuegos(_arg1:MouseEvent, _arg2:String="intro"){
navigateToURL(new URLRequest("http://www.minijuegos.com"), "_blank");
}
static function Newgrounds_ShowAd():void{
ng_timer = new Timer(200, 999999);
ng_timer.addEventListener(TimerEvent.TIMER, NewgroundsAdWaitTimerCallback);
ng_timer.start();
}
public static function Newgrounds_UnlockMedal_Confirmed(_arg1:APIEvent){
var _local2:Medal = _arg1.data;
if (_local2 != null){
trace(("NG Medal unlocked confirmed " + _local2.name));
};
}
static function NewgroundsAdTimerCallback(_arg1:TimerEvent){
trace("NG ad NewgroundsAdTimerCallback");
intro.buttonSkipAd.visible = true;
intro.buttonSkipAd.addEventListener(MouseEvent.CLICK, NewgroundsAdTimerCallback1);
}
static function buttonSkipCPMStarAdPressed(_arg1:MouseEvent){
intro.buttonSkipCPMStarAd.removeEventListener(MouseEvent.CLICK, buttonSkipCPMStarAdPressed);
if (ad != null){
intro.adBox.removeChild(ad);
};
stg.removeChild(intro);
intro = null;
ShowIntro();
}
public static function InitFromTimeLine(_arg1:MovieClip):void{
oldFrameRate = 0;
stg = _arg1;
domain = GetDomain();
SkuModify();
trace(("Domain: " + domain));
InitSkus();
if (GetSku(licensor).initFunction != null){
GetSku(licensor).initFunction();
};
InitHighscores();
intro = null;
cx = (Defs.displayarea_w / 2);
cy = (Defs.displayarea_h / 2);
stg.stop();
if (ShowAd() == false){
ShowIntro();
};
}
public static function SubmitScore_MindJolt(_arg1:int):void{
MindJoltAPI.service.submitScore(_arg1);
}
static function ViewScore_ArmorGames(_arg1:Function=null){
highscore_callback = _arg1;
stg.addChild(agi);
agi.initAGUI({onClose:SubmitHighscore_ArmorGames_CloseHandler});
agi.showScoreboardList();
}
public static function ShowIntro_BubbleBox():void{
AddIntro("Intro_BubbleBox");
}
public static function GetDomain():String{
var _local1:String = stg.loaderInfo.url;
var _local2:Number = (_local1.indexOf("://") + 3);
var _local3:Number = _local1.indexOf("/", _local2);
var _local4:String = _local1.substring(_local2, _local3);
var _local5:Number = (_local4.lastIndexOf(".") - 1);
var _local6:Number = (_local4.lastIndexOf(".", _local5) + 1);
_local4 = _local4.substring(_local6, _local4.length);
return (_local4);
}
public static function InitHighscores(){
if (Lic.IsAtMindjolt()){
LoadMindjoltAPI();
};
if (licensor == LICENSOR_ARMORGAMES){
InitHighScores_ArmorGames();
};
}
public static function ShowMochiAd(){
MochiAd.showPreGameAd({clip:stg, id:"f26b6fbcebd54ddc", res:"640x480", ad_finished:MochiAdFinished});
}
public static function Link_BubbleBox(_arg1:MouseEvent, _arg2:String="intro"){
navigateToURL(new URLRequest("http://www.bubblebox.com"), "_blank");
}
public static function ShowIntro_FOG():void{
AddIntro("Intro_FOG");
}
public static function ShowIntro_MouseBreaker():void{
AddIntro("Intro_MouseBreaker");
}
static function CPMStarCompleteCallback(){
if (cpmStarLoaderCounter >= 2){
intro.loader.visible = false;
intro.buttonSkipCPMStarAd.visible = true;
};
}
public static function Link_SIKids(_arg1:MouseEvent, _arg2:String="intro"){
navigateToURL(new URLRequest("http://www.sikids.com"), "_blank");
}
static function SubmitHighscore_ArmorGames(_arg1:int, _arg2:Function=null){
highscore_callback = _arg2;
stg.addChild(agi);
agi.initAGUI({onClose:SubmitHighscore_ArmorGames_CloseHandler});
agi.showScoreboardSubmit(_arg1);
}
public static function Newgrounds_UnlockMedal(_arg1:String){
if (licensor != LICENSOR_NEWGROUNDS){
return;
};
NewgroundsAPI.unlockMedalByName(_arg1);
trace(("unlocking Newgrounds medal: " + _arg1));
NewgroundsAPI.addEventListener(APIEvent.MEDAL_UNLOCKED, Newgrounds_UnlockMedal_Confirmed);
}
private static function MJloadFinished(_arg1:Event){
MindJoltAPI = _arg1.currentTarget.content;
MindJoltAPI.service.connect();
stg.stage.removeChild(urlLoader);
trace("Minjolt Initialised successfully");
}
static function InitFunction_Newgrounds():void{
trace("Init Newgrounds");
NewgroundsAPI.connectMovie(stg.loaderInfo, "10255", "qLtf9ILktQBzQITDW1xs8eJAzAiZO8HL");
}
public static function ShowIntro_LongAnimals():void{
AddIntro("Intro_LongAnimals");
}
public static function FilterAdForSites():Boolean{
if (domain == "kongregate.com"){
return (true);
};
if (domain == "agame.com"){
return (true);
};
if (domain == "armorgames.com"){
return (true);
};
return (false);
}
public static function ShowIntro_ArmorGames():void{
AddIntro("Intro_ArmorGames");
}
static function CPMStarTimerCallback(_arg1:TimerEvent){
cpmStarLoadTimer++;
RenderLoaderBar(100);
if (cpmStarLoadTimer >= CPMStarFixedTime){
cpmStarLoaderCounter++;
trace("timer complete");
cpmStarTimer.stop();
CPMStarCompleteCallback();
} else {
cpmStarTimer.start();
};
}
public static function TimeLineComplete():void{
if (oldFrameRate != 0){
stg.stage.frameRate = oldFrameRate;
};
trace("Timeline complete");
if (intro != null){
stg.removeChild(intro);
intro = null;
trace("Timeline complete 1");
};
}
public static function ShowIntro_MaxGames():void{
AddIntro("Intro_MaxGames");
}
public static function ViewHighScores_Newgrounds(_arg1:Function):void{
trace("ViewHighScores_Newgrounds");
SubmitHighscore_Newgrounds_Callback = _arg1;
Newgrounds_HighScoreTable = new ScoreTable();
Newgrounds_HighScoreTable.board_name = "Scores";
Newgrounds_HighScoreTable.x = ((Defs.displayarea_w / 2) - 150);
Newgrounds_HighScoreTable.y = ((Defs.displayarea_h / 2) - 125);
stg.addChild(Newgrounds_HighScoreTable);
Newgrounds_HighScoreTable.addEventListener(MouseEvent.CLICK, ViewHighScoresDone_Newgrounds);
}
public static function ShowIntro_Kongregate():void{
AddIntro("Intro_Kongregate");
}
public static function MochiAdFinished(){
ShowIntro();
}
static function RenderLoaderBar(_arg1:Number){
}
static function SitelockScreen_Clicked(_arg1:MouseEvent){
Link_LongAnimals(null);
}
public static function GetLicensor():int{
return (licensor);
}
CPMStarContentSpotIDs.push(String("1267QE02431A2"));
CPMStarContentSpotIDs.push(String("1269Q19D37AEF"));
}
}//package
Section 197
//LicSku (LicSku)
package {
public class LicSku {
var sitelocks:Array;
var introFunction:Function;
var name:String;
var mainLogoName:String;
var scaleIntroToStage:Boolean;
var linkFunction:Function;
var initFunction:Function;
var id:int;
var adtype:int;
public function LicSku(_arg1:int, _arg2:String){
id = _arg1;
name = _arg2;
introFunction = null;
sitelocks = new Array();
adtype = 0;
mainLogoName = "";
linkFunction = null;
scaleIntroToStage = false;
initFunction = null;
}
public function AddSiteLock(_arg1:String, _arg2:Boolean=false){
sitelocks.push(_arg1);
}
}
}//package
Section 198
//Line (Line)
package {
import flash.geom.*;
public class Line {
public var udx:Number;
public var udy:Number;
public var ny:Number;
public var dir:Number;
public var nx:Number;
public var dy:Number;
public var y0:Number;
public var y1:Number;
public var dx:Number;
public var normalDir:Number;
public var length:Number;
public var boundingRect:Rectangle;
public var x0:Number;
public var x1:Number;
public function Line(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number){
x0 = _arg1;
y0 = _arg2;
x1 = _arg3;
y1 = _arg4;
CalcNormal();
CalcBoundingRect();
}
function CalcNormal():void{
dir = Math.atan2((y1 - y0), (x1 - x0));
normalDir = (dir - (Math.PI * 0.5));
nx = Math.cos(normalDir);
ny = Math.sin(normalDir);
dx = (x1 - x0);
dy = (y1 - y0);
length = Math.sqrt(((dx * dx) + (dy * dy)));
udx = Math.cos(dir);
udy = Math.sin(dir);
}
function CalcBoundingRect():void{
var _local1:Number;
var _local2:Number;
var _local3:Number;
var _local4:Number;
_local1 = x0;
_local2 = x1;
if (_local1 > _local2){
_local1 = x1;
_local2 = x0;
};
_local3 = y0;
_local4 = y1;
if (_local3 > _local4){
_local3 = y1;
_local4 = y0;
};
boundingRect = new Rectangle(_local1, _local3, ((_local2 - _local1) + 1), ((_local4 - _local3) + 1));
}
}
}//package
Section 199
//machinegun_flash (machinegun_flash)
package {
import flash.display.*;
public dynamic class machinegun_flash extends MovieClip {
}
}//package
Section 200
//Main (Main)
package {
import flash.display.*;
import flash.events.*;
import flash.text.*;
import flash.utils.*;
import flash.ui.*;
public class Main extends MovieClip {
var levelTimerMax:Number;
public var plasmaScreenBD:BitmapData;
var cheatMode:Boolean;
public var tf_scorespr:TextFormat;
public var scrollScreenBD:BitmapData;
public var layerScreenBD:BitmapData;
var levelTimer:Number;
public var tf_scorespr2:TextFormat;
public var fillScreenMC:MovieClip;
public var tf_scorespr1:TextFormat;
public var screenBD:BitmapData;
var ftime:Number;
public var plasmaScreenB:Bitmap;
public var mochiScores;
var gameState:int;// = 0
public var layerScreenB:Bitmap;
public var scrollScreenB:Bitmap;
public var fillScreenMC1:MovieClip;
public var backgroundMC:MovieClip;
public var screenB:Bitmap;
var scrollY:Number;// = 0
var currentTime:Number;// = 0
public var fps:Number;
public var tf_scoresprblack:TextFormat;
var framecounter:int;// = 0
var secondCounter:Number;// = 0
static const gameState_HIGHSCORES = 5;
static const gameState_TITLE = 0;
static const gameState_LEVEL_PLAY = 2;
public static var theStage:Stage;
static var theRoot:MovieClip;
public function Main(){
theRoot = this;
theStage = this.root.stage;
SetEverythingUpOnce();
}
function calcFrameTime(){
var _local1:Number = currentTime;
currentTime = getTimer();
if (currentTime < _local1){
_local1 = (currentTime - 100);
};
if (currentTime > (_local1 + (100 * 10))){
_local1 = (100 * 10);
};
ftime = ((1 / (1000 / Defs.fps)) * (currentTime - _local1));
framecounter++;
secondCounter = (secondCounter + (currentTime - _local1));
if (secondCounter > 1000){
fps = ((Number(framecounter) / secondCounter) * 1000);
framecounter = 0;
secondCounter = 0;
};
ftime = 1;
}
function run(_arg1:Event):void{
KeyReader.UpdateOncePerFrame();
SoundPlayer.UpdateOncePerFrame();
MusicPlayer.UpdateOncePerFrame();
if (Lic.IsOnCorrectSite() == false){
return;
};
calcFrameTime();
switch (gameState){
case gameState_TITLE:
TitleScreenState.Update(this);
break;
case gameState_HIGHSCORES:
break;
case gameState_LEVEL_PLAY:
RunLevel();
break;
};
}
private function CreateTextField(_arg1:TextFormat, _arg2:Number, _arg3:Number, _arg4:String):TextField{
var _local5:TextField = new TextField();
_local5.selectable = false;
_local5.embedFonts = true;
_local5.autoSize = TextFieldAutoSize.CENTER;
_local5.x = _arg2;
_local5.y = _arg3;
_local5.text = _arg4;
_local5.setTextFormat(_arg1);
addChild(_local5);
return (_local5);
}
function InitStageNoBackground(){
var _local1:int;
_local1 = (this.numChildren - 1);
while (_local1 >= 0) {
removeChildAt(_local1);
_local1--;
};
}
function addedToStage(_arg1:Event){
SetEverythingUpOnce2();
}
function SetGameState(_arg1:int):void{
gameState = _arg1;
switch (gameState){
case gameState_TITLE:
Mouse.show();
TitleScreenState.Init(this);
break;
case gameState_HIGHSCORES:
break;
case gameState_LEVEL_PLAY:
InitLevel();
break;
};
}
function AddMovieClip(_arg1:Number, _arg2:Number, _arg3:MovieClip):MovieClip{
_arg3.x = _arg1;
_arg3.y = _arg2;
addChild(_arg3);
return (_arg3);
}
function SetEverythingUpOnce3(){
InitStage();
Game.Init(this);
addEventListener(Event.ENTER_FRAME, run);
SetGameState(gameState_TITLE);
}
function RunTitle(){
}
function InitDrawScreen():void{
screenBD = new BitmapData(Defs.displayarea_w, Defs.displayarea_h, true, 0);
screenB = new Bitmap(screenBD);
scrollScreenBD = new BitmapData(Defs.displayarea_w, Defs.displayarea_w, true, 0);
scrollScreenB = new Bitmap(scrollScreenBD);
layerScreenBD = new BitmapData(Defs.displayarea_w, Defs.displayarea_w, true, 0);
layerScreenB = new Bitmap(layerScreenBD);
plasmaScreenBD = new BitmapData(50, 50, true, 0);
plasmaScreenB = new Bitmap(plasmaScreenBD);
fillScreenMC = new MovieClip();
fillScreenMC.x = 0;
fillScreenMC.y = 0;
fillScreenMC1 = new MovieClip();
fillScreenMC1.x = 0;
fillScreenMC1.y = 0;
}
function SetEverythingUpOnce2():void{
Kong.InitOnce(root);
MusicPlayer.InitOnce();
KeyReader.InitOnce(theStage);
MouseControl.InitOnce(theStage);
SoundPlayer.InitOnce(this);
PauseMenu.InitOnce(this);
Particles.InitOnce(this, 500);
GameObjects.InitOnce(this, 1000);
InitDrawScreen();
InitFonts();
GraphicObjects.InitOnce(this);
Stats.InitOnce();
Game.achievements = new Achievements();
Game.InitUpgrades();
ExternalData.Load(SetEverythingUpOnce3);
}
function SetEverythingUpOnce():void{
if (stage == null){
addEventListener(Event.ADDED_TO_STAGE, addedToStage);
} else {
SetEverythingUpOnce2();
};
}
function InitFonts():void{
var _local1:Font = new Font20();
tf_scorespr = new TextFormat();
tf_scorespr1 = new TextFormat();
tf_scorespr2 = new TextFormat();
tf_scoresprblack = new TextFormat();
tf_scorespr.font = _local1.fontName;
tf_scorespr.size = 12;
tf_scorespr.color = 4294967295;
tf_scorespr1.font = _local1.fontName;
tf_scorespr1.size = 30;
tf_scorespr1.color = 4294967295;
tf_scorespr2.font = _local1.fontName;
tf_scorespr2.size = 30;
tf_scorespr2.color = 0;
tf_scoresprblack.font = _local1.fontName;
tf_scoresprblack.size = 12;
tf_scoresprblack.color = 0;
}
function InitStage(){
var _local1:int;
_local1 = (this.numChildren - 1);
while (_local1 >= 0) {
removeChildAt(_local1);
_local1--;
};
addChild(screenB);
screenB.x = 0;
screenB.y = 0;
}
function Render(){
this.x = 0;
this.y = 0;
Game.Render();
}
function InitLevel(){
InitStageForGame();
Particles.Reset();
MouseControl.Reset();
Particles.Reset();
GameObjects.ClearAll();
Game.InitLevel();
}
function InitStageForGame(){
var _local1:int;
_local1 = (this.numChildren - 1);
while (_local1 >= 0) {
removeChildAt(_local1);
_local1--;
};
addChild(screenB);
screenB.x = 0;
screenB.y = 0;
}
function RunLevel(){
if (PauseMenu.IsPaused() == false){
Game.UpdateGameplay();
};
Render();
}
}
}//package
Section 201
//MainLogo (MainLogo)
package {
import flash.display.*;
public dynamic class MainLogo extends MovieClip {
public var armorGames:SimpleButton;
public var siKids:SimpleButton;
public var addictingGames:SimpleButton;
public var miniJuegos:SimpleButton;
public var longAnimals:SimpleButton;
public var robotJam:SimpleButton;
public var bubbleBox:SimpleButton;
public var andkon:SimpleButton;
public var kongregate:SimpleButton;
public var newgrounds:SimpleButton;
public var maxGames:SimpleButton;
}
}//package
Section 202
//MochiAd (MochiAd)
package {
import flash.display.*;
import flash.events.*;
import flash.utils.*;
import flash.net.*;
import flash.system.*;
public class MochiAd {
public static function getVersion():String{
return ("2.3");
}
public static function showTimedAd(_arg1:Object):void{
trace("[MochiAd] DEPRECATED: showTimedAd was renamed to showInterLevelAd in 2.0");
MochiAd.showInterLevelAd(_arg1);
}
public static function _allowDomains(_arg1:String):String{
var _local2:String = _arg1.split("/")[2].split(":")[0];
Security.allowDomain("*");
Security.allowDomain(_local2);
Security.allowInsecureDomain("*");
Security.allowInsecureDomain(_local2);
return (_local2);
}
public static function load(_arg1:Object):MovieClip{
var clip:Object;
var mc:MovieClip;
var k:String;
var server:String;
var hostname:String;
var lc:LocalConnection;
var name:String;
var loader:Loader;
var f:Function;
var g:Function;
var req:URLRequest;
var v:Object;
var options = _arg1;
var DEFAULTS:Object = {server:"http://x.mochiads.com/srv/1/", method:"load", depth:10333, id:"_UNKNOWN_"};
options = MochiAd._parseOptions(options, DEFAULTS);
options.swfv = 9;
options.mav = MochiAd.getVersion();
clip = options.clip;
if (!MochiAd._isNetworkAvailable()){
return (null);
};
try {
if (clip._mochiad_loaded){
return (null);
};
} catch(e:Error) {
throw (new Error("MochiAd requires a clip that is an instance of a dynamic class. If your class extends Sprite or MovieClip, you must make it dynamic."));
};
var depth:Number = options.depth;
delete options.depth;
mc = createEmptyMovieClip(clip, "_mochiad", depth);
var wh:Array = MochiAd._getRes(options, clip);
options.res = ((wh[0] + "x") + wh[1]);
options.server = (options.server + options.id);
delete options.id;
clip._mochiad_loaded = true;
if (clip.loaderInfo.loaderURL.indexOf("http") == 0){
options.as3_swf = clip.loaderInfo.loaderURL;
};
var lv:URLVariables = new URLVariables();
for (k in options) {
v = options[k];
if (!(v is Function)){
lv[k] = v;
};
};
server = lv.server;
delete lv.server;
hostname = _allowDomains(server);
lc = new LocalConnection();
lc.client = mc;
name = ["", Math.floor(new Date().getTime()), Math.floor((Math.random() * 999999))].join("_");
lc.allowDomain("*", "localhost");
lc.allowInsecureDomain("*", "localhost");
lc.connect(name);
mc.lc = lc;
lv.lc = name;
lv.st = getTimer();
loader = new Loader();
f = function (_arg1:Object):void{
_arg1.target.removeEventListener(_arg1.type, arguments.callee);
mc._mochiad_ctr_failed = true;
};
loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, f);
g = function (_arg1:Object):void{
_arg1.target.removeEventListener(_arg1.type, arguments.callee);
MochiAd.unload(clip);
};
loader.contentLoaderInfo.addEventListener(Event.UNLOAD, g);
req = new URLRequest((server + ".swf"));
req.contentType = "application/x-www-form-urlencoded";
req.method = URLRequestMethod.POST;
req.data = lv;
loader.load(req);
mc.addChild(loader);
mc._mochiad_ctr = loader;
return (mc);
}
public static function sendHighScore(_arg1:Object, _arg2:Object, _arg3:Object=null):Boolean{
var _local4:MovieClip = MochiAd._loadCommunicator({clip:_arg1.clip, id:_arg1.id});
if (!_local4){
return (false);
};
_local4.doSend(["sendHighScore", _arg1], _arg2, _arg3);
return (true);
}
public static function _parseOptions(_arg1:Object, _arg2:Object):Object{
var _local4:String;
var _local5:Array;
var _local6:Number;
var _local7:Array;
var _local3:Object = {};
for (_local4 in _arg2) {
_local3[_local4] = _arg2[_local4];
};
if (_arg1){
for (_local4 in _arg1) {
_local3[_local4] = _arg1[_local4];
};
};
if (_local3.clip == undefined){
throw (new Error("MochiAd is missing the 'clip' parameter. This should be a MovieClip, Sprite or an instance of a class that extends MovieClip or Sprite."));
};
_arg1 = _local3.clip.loaderInfo.parameters.mochiad_options;
if (_arg1){
_local5 = _arg1.split("&");
_local6 = 0;
while (_local6 < _local5.length) {
_local7 = _local5[_local6].split("=");
_local3[unescape(_local7[0])] = unescape(_local7[1]);
_local6++;
};
};
if (_local3.id == "test"){
trace("[MochiAd] WARNING: Using the MochiAds test identifier, make sure to use the code from your dashboard, not this example!");
};
return (_local3);
}
public static function _isNetworkAvailable():Boolean{
return (!((Security.sandboxType == "localWithFile")));
}
public static function _cleanup(_arg1:Object):void{
var k:String;
var lc:LocalConnection;
var f:Function;
var mc = _arg1;
if (("lc" in mc)){
lc = mc.lc;
f = function ():void{
try {
lc.client = null;
lc.close();
} catch(e:Error) {
};
};
setTimeout(f, 0);
};
var idx:Number = DisplayObjectContainer(mc).numChildren;
while (idx > 0) {
idx = (idx - 1);
DisplayObjectContainer(mc).removeChildAt(idx);
};
for (k in mc) {
delete mc[k];
};
}
public static function unload(_arg1:Object):Boolean{
if (((_arg1.clip) && (_arg1.clip._mochiad))){
_arg1 = _arg1.clip;
};
if (!_arg1._mochiad){
return (false);
};
if (_arg1._mochiad.onUnload){
_arg1._mochiad.onUnload();
};
delete _arg1._mochiad_loaded;
delete _arg1._mochiad;
return (true);
}
public static function showInterLevelAd(_arg1:Object):void{
var clip:Object;
var mc:MovieClip;
var chk:MovieClip;
var options = _arg1;
var DEFAULTS:Object = {ad_timeout:2000, fadeout_time:250, regpt:"o", method:"showTimedAd", ad_started:function ():void{
if ((this.clip is MovieClip)){
this.clip.stop();
} else {
throw (new Error("MochiAd.showInterLevelAd requires a clip that is a MovieClip or is an instance of a class that extends MovieClip. If your clip is a Sprite, then you must provide custom ad_started and ad_finished handlers."));
};
}, ad_finished:function ():void{
if ((this.clip is MovieClip)){
this.clip.play();
} else {
throw (new Error("MochiAd.showInterLevelAd requires a clip that is a MovieClip or is an instance of a class that extends MovieClip. If your clip is a Sprite, then you must provide custom ad_started and ad_finished handlers."));
};
}, ad_loaded:function (_arg1:Number, _arg2:Number):void{
}, ad_failed:function ():void{
trace("[MochiAd] Couldn't load an ad, make sure your game's local security sandbox is configured for Access Network Only and that you are not using ad blocking software");
}};
options = MochiAd._parseOptions(options, DEFAULTS);
clip = options.clip;
var ad_msec:Number = 11000;
var ad_timeout:Number = options.ad_timeout;
delete options.ad_timeout;
var fadeout_time:Number = options.fadeout_time;
delete options.fadeout_time;
if (!MochiAd.load(options)){
options.ad_failed();
options.ad_finished();
return;
};
options.ad_started();
mc = clip._mochiad;
mc["onUnload"] = function ():void{
MochiAd._cleanup(mc);
options.ad_finished();
};
var wh:Array = MochiAd._getRes(options, clip);
var w:Number = wh[0];
var h:Number = wh[1];
mc.x = (w * 0.5);
mc.y = (h * 0.5);
chk = createEmptyMovieClip(mc, "_mochiad_wait", 3);
chk.ad_msec = ad_msec;
chk.ad_timeout = ad_timeout;
chk.started = getTimer();
chk.showing = false;
chk.fadeout_time = fadeout_time;
chk.fadeFunction = function ():void{
if (!this.parent){
delete this.onEnterFrame;
delete this.fadeFunction;
return;
};
var _local1:Number = (100 * (1 - ((getTimer() - this.fadeout_start) / this.fadeout_time)));
if (_local1 > 0){
this.parent.alpha = (_local1 * 0.01);
} else {
MochiAd.unload(clip);
delete this["onEnterFrame"];
};
};
mc.unloadAd = function ():void{
MochiAd.unload(clip);
};
mc.adLoaded = options.ad_loaded;
mc.adjustProgress = function (_arg1:Number):void{
var _local2:Object = mc._mochiad_wait;
_local2.server_control = true;
_local2.showing = true;
_local2.started = getTimer();
_local2.ad_msec = (_arg1 - 250);
};
chk["onEnterFrame"] = function ():void{
var _local4:Number;
if (!this.parent){
delete this.onEnterFrame;
delete this.fadeFunction;
return;
};
var _local1:Object = this.parent._mochiad_ctr;
var _local2:Number = (getTimer() - this.started);
var _local3:Boolean;
if (!chk.showing){
_local4 = _local1.loaderInfo.bytesTotal;
if ((((_local4 > 0)) || (("number" == "undefined")))){
chk.showing = true;
chk.started = getTimer();
} else {
if (_local2 > chk.ad_timeout){
options.ad_failed();
_local3 = true;
};
};
};
if (this.parent._mochiad_ctr_failed){
options.ad_failed();
_local3 = true;
};
if (_local2 > chk.ad_msec){
_local3 = true;
};
if (_local3){
if (this.server_control){
delete this.onEnterFrame;
} else {
this.fadeout_start = getTimer();
this.onEnterFrame = this.fadeFunction;
};
};
};
doOnEnterFrame(chk);
}
public static function _getRes(_arg1:Object, _arg2:Object):Array{
var _local6:Array;
var _local3:Object = _arg2.getBounds(_arg2.root);
var _local4:Number = 0;
var _local5:Number = 0;
if (typeof(_arg1.res) != "undefined"){
_local6 = _arg1.res.split("x");
_local4 = parseFloat(_local6[0]);
_local5 = parseFloat(_local6[1]);
} else {
_local4 = (_local3.xMax - _local3.xMin);
_local5 = (_local3.yMax - _local3.yMin);
};
if ((((_local4 == 0)) || ((_local5 == 0)))){
_local4 = _arg2.stage.stageWidth;
_local5 = _arg2.stage.stageHeight;
};
return ([_local4, _local5]);
}
public static function createEmptyMovieClip(_arg1:Object, _arg2:String, _arg3:Number):MovieClip{
var _local4:MovieClip = new MovieClip();
if (((false) && (_arg3))){
_arg1.addChildAt(_local4, _arg3);
} else {
_arg1.addChild(_local4);
};
_arg1[_arg2] = _local4;
_local4["_name"] = _arg2;
return (_local4);
}
public static function _loadCommunicator(_arg1:Object):MovieClip{
var mc:MovieClip;
var k:String;
var lc:LocalConnection;
var name:String;
var req:URLRequest;
var loader:Loader;
var options = _arg1;
var DEFAULTS:Object = {com_server:"http://x.mochiads.com/com/1/", method:"loadCommunicator", depth:10337, id:"_UNKNOWN_"};
options = MochiAd._parseOptions(options, DEFAULTS);
options.swfv = 9;
options.mav = MochiAd.getVersion();
var clip:Object = options.clip;
var clipname:String = ("_mochiad_com_" + options.id);
if (!MochiAd._isNetworkAvailable()){
return (null);
};
if (clip[clipname]){
return (clip[clipname]);
};
var server:String = (options.com_server + options.id);
MochiAd._allowDomains(server);
delete options.id;
delete options.com_server;
var depth:Number = options.depth;
delete options.depth;
mc = createEmptyMovieClip(clip, clipname, depth);
var lv:URLVariables = new URLVariables();
for (k in options) {
lv[k] = options[k];
};
lc = new LocalConnection();
lc.client = mc;
name = ["", Math.floor(new Date().getTime()), Math.floor((Math.random() * 999999))].join("_");
lc.allowDomain("*", "localhost");
lc.allowInsecureDomain("*", "localhost");
lc.connect(name);
mc.name = name;
mc.lc = lc;
lv.lc = name;
mc._id = 0;
mc._queue = [];
mc.rpcResult = function (_arg1:Object):void{
_arg1 = parseInt(_arg1.toString());
var _local3:Array = mc._callbacks[_arg1];
if (typeof(_local3) == "undefined"){
return;
};
delete mc._callbacks[_arg1];
var _local4:Array = [];
var _local5:Number = 2;
while (_local5 < _local3.length) {
_local4.push(_local3[_local5]);
_local5++;
};
_local5 = 1;
while (_local5 < arguments.length) {
_local4.push(arguments[_local5]);
_local5++;
};
var _local6:Object = _local3[1];
var _local7:Object = _local3[0];
if (((_local7) && ((typeof(_local6) == "string")))){
_local6 = _local7[_local6];
};
if (typeof(_local6) == "function"){
_local6.apply(_local7, _local4);
};
};
mc._didConnect = function (_arg1:String):void{
var _local5:Array;
mc._endpoint = _arg1;
var _local2:Array = mc._queue;
delete mc._queue;
var _local3:Function = mc.doSend;
var _local4:Number = 0;
while (_local4 < _local2.length) {
_local5 = _local2[_local4];
_local3.apply(this, _local5);
_local4++;
};
};
mc.doSend = function (_arg1:Array, _arg2:Object, _arg3:Object):void{
var _local7:Array;
var _local8:Number;
if (mc._endpoint == null){
_local7 = [];
_local8 = 0;
while (_local8 < arguments.length) {
_local7.push(arguments[_local8]);
_local8++;
};
mc._queue.push(_local7);
return;
};
mc._id = (mc._id + 1);
var _local5:Number = mc._id;
mc._callbacks[_local5] = [_arg2, ((_arg3) || (_arg2))];
var _local6:LocalConnection = new LocalConnection();
_local6.send(mc._endpoint, "rpc", _local5, _arg1);
};
mc._callbacks = {};
mc._callbacks[0] = [mc, "_didConnect"];
lv.st = getTimer();
req = new URLRequest((server + ".swf"));
req.contentType = "application/x-www-form-urlencoded";
req.method = URLRequestMethod.POST;
req.data = lv;
loader = new Loader();
loader.load(req);
mc.addChild(loader);
mc._mochiad_com = loader;
return (mc);
}
public static function showPreGameAd(_arg1:Object):void{
var clip:Object;
var ad_timeout:Number;
var fadeout_time:Number;
var mc:MovieClip;
var chk:MovieClip;
var complete:Boolean;
var unloaded:Boolean;
var r:MovieClip;
var options = _arg1;
var DEFAULTS:Object = {ad_timeout:3000, fadeout_time:250, regpt:"o", method:"showPreloaderAd", color:0xFF8A00, background:16777161, outline:13994812, ad_started:function ():void{
if ((this.clip is MovieClip)){
this.clip.stop();
} else {
throw (new Error("MochiAd.showPreGameAd requires a clip that is a MovieClip or is an instance of a class that extends MovieClip. If your clip is a Sprite, then you must provide custom ad_started and ad_finished handlers."));
};
}, ad_finished:function ():void{
if ((this.clip is MovieClip)){
this.clip.play();
} else {
throw (new Error("MochiAd.showPreGameAd requires a clip that is a MovieClip or is an instance of a class that extends MovieClip. If your clip is a Sprite, then you must provide custom ad_started and ad_finished handlers."));
};
}, ad_loaded:function (_arg1:Number, _arg2:Number):void{
}, ad_failed:function ():void{
trace("[MochiAd] Couldn't load an ad, make sure your game's local security sandbox is configured for Access Network Only and that you are not using ad blocking software");
}};
options = MochiAd._parseOptions(options, DEFAULTS);
if ("5cc6f7dfb67f2f08341c831480f7c2a7".length == 0){
options.ad_started();
options.ad_finished();
return;
};
clip = options.clip;
var ad_msec:Number = 11000;
ad_timeout = options.ad_timeout;
delete options.ad_timeout;
fadeout_time = options.fadeout_time;
delete options.fadeout_time;
if (!MochiAd.load(options)){
options.ad_failed();
options.ad_finished();
return;
};
options.ad_started();
mc = clip._mochiad;
mc["onUnload"] = function ():void{
MochiAd._cleanup(mc);
var fn:Function = function ():void{
options.ad_finished();
};
setTimeout(fn, 100);
};
var wh:Array = MochiAd._getRes(options, clip);
var w:Number = wh[0];
var h:Number = wh[1];
mc.x = (w * 0.5);
mc.y = (h * 0.5);
chk = createEmptyMovieClip(mc, "_mochiad_wait", 3);
chk.x = (w * -0.5);
chk.y = (h * -0.5);
var bar:MovieClip = createEmptyMovieClip(chk, "_mochiad_bar", 4);
bar.x = 10;
bar.y = (h - 20);
var bar_color:Number = options.color;
delete options.color;
var bar_background:Number = options.background;
delete options.background;
var bar_outline:Number = options.outline;
delete options.outline;
var backing_mc:MovieClip = createEmptyMovieClip(bar, "_outline", 1);
var backing:Object = backing_mc.graphics;
backing.beginFill(bar_background);
backing.moveTo(0, 0);
backing.lineTo((w - 20), 0);
backing.lineTo((w - 20), 10);
backing.lineTo(0, 10);
backing.lineTo(0, 0);
backing.endFill();
var inside_mc:MovieClip = createEmptyMovieClip(bar, "_inside", 2);
var inside:Object = inside_mc.graphics;
inside.beginFill(bar_color);
inside.moveTo(0, 0);
inside.lineTo((w - 20), 0);
inside.lineTo((w - 20), 10);
inside.lineTo(0, 10);
inside.lineTo(0, 0);
inside.endFill();
inside_mc.scaleX = 0;
var outline_mc:MovieClip = createEmptyMovieClip(bar, "_outline", 3);
var outline:Object = outline_mc.graphics;
outline.lineStyle(0, bar_outline, 100);
outline.moveTo(0, 0);
outline.lineTo((w - 20), 0);
outline.lineTo((w - 20), 10);
outline.lineTo(0, 10);
outline.lineTo(0, 0);
chk.ad_msec = ad_msec;
chk.ad_timeout = ad_timeout;
chk.started = getTimer();
chk.showing = false;
chk.last_pcnt = 0;
chk.fadeout_time = fadeout_time;
chk.fadeFunction = function ():void{
var _local1:Number = (100 * (1 - ((getTimer() - this.fadeout_start) / this.fadeout_time)));
if (_local1 > 0){
this.parent.alpha = (_local1 * 0.01);
} else {
MochiAd.unload(clip);
delete this["onEnterFrame"];
};
};
complete = false;
unloaded = false;
var f:Function = function (_arg1:Event):void{
_arg1.target.removeEventListener(_arg1.type, arguments.callee);
complete = true;
if (unloaded){
MochiAd.unload(clip);
};
};
clip.loaderInfo.addEventListener(Event.COMPLETE, f);
if ((clip.root is MovieClip)){
r = (clip.root as MovieClip);
if (r.framesLoaded >= r.totalFrames){
complete = true;
};
};
mc.unloadAd = function ():void{
unloaded = true;
if (complete){
MochiAd.unload(clip);
};
};
mc.adLoaded = options.ad_loaded;
mc.adjustProgress = function (_arg1:Number):void{
var _local2:Object = mc._mochiad_wait;
_local2.server_control = true;
_local2.showing = true;
_local2.started = getTimer();
_local2.ad_msec = _arg1;
};
chk["onEnterFrame"] = function ():void{
var _local11:Number;
if (((!(this.parent)) || (!(this.parent.parent)))){
delete this["onEnterFrame"];
return;
};
var _local1:Object = this.parent.parent.root;
var _local2:Object = this.parent._mochiad_ctr;
var _local3:Number = (getTimer() - this.started);
var _local4:Boolean;
var _local5:Number = _local1.loaderInfo.bytesTotal;
var _local6:Number = _local1.loaderInfo.bytesLoaded;
if (complete){
_local6 = Math.max(1, _local6);
_local5 = _local6;
};
var _local7:Number = ((100 * _local6) / _local5);
var _local8:Number = ((100 * _local3) / chk.ad_msec);
var _local9:Object = this._mochiad_bar._inside;
var _local10:Number = Math.min(100, Math.min(((_local7) || (0)), _local8));
_local10 = Math.max(this.last_pcnt, _local10);
this.last_pcnt = _local10;
_local9.scaleX = (_local10 * 0.01);
if (!chk.showing){
_local11 = _local2.loaderInfo.bytesTotal;
if ((((_local11 > 0)) || (("number" == "undefined")))){
chk.showing = true;
chk.started = getTimer();
} else {
if (_local3 > chk.ad_timeout){
options.ad_failed();
_local4 = true;
};
};
};
if (this.parent._mochiad_ctr_failed){
options.ad_failed();
_local4 = true;
};
if (_local3 > chk.ad_msec){
_local4 = true;
};
if (((complete) && (_local4))){
if (this.server_control){
delete this.onEnterFrame;
} else {
this.fadeout_start = getTimer();
this.onEnterFrame = chk.fadeFunction;
};
};
};
doOnEnterFrame(chk);
}
public static function showPreloaderAd(_arg1:Object):void{
trace("[MochiAd] DEPRECATED: showPreloaderAd was renamed to showPreGameAd in 2.0");
MochiAd.showPreGameAd(_arg1);
}
public static function fetchHighScores(_arg1:Object, _arg2:Object, _arg3:Object=null):Boolean{
var _local4:MovieClip = MochiAd._loadCommunicator({clip:_arg1.clip, id:_arg1.id});
if (!_local4){
return (false);
};
_local4.doSend(["fetchHighScores", _arg1], _arg2, _arg3);
return (true);
}
public static function doOnEnterFrame(_arg1:MovieClip):void{
var mc = _arg1;
var f:Function = function (_arg1:Object):void{
if (((("onEnterFrame" in mc)) && (mc.onEnterFrame))){
mc.onEnterFrame();
} else {
_arg1.target.removeEventListener(_arg1.type, arguments.callee);
};
};
mc.addEventListener(Event.ENTER_FRAME, f);
}
}
}//package
Section 203
//MouseControl (MouseControl)
package {
import flash.display.*;
import flash.events.*;
public class MouseControl {
public static var mouseVelX:Number = 0;
public static var mouseVelY:Number = 0;
public static var ox:Number = 0;
public static var oy:Number = 0;
public static var buttonReleased:Boolean = false;
public static var buttonPressed:Boolean = false;
public static var x:Number = 0;
public static var y:Number = 0;
public static var delta:int = 0;
public static function MouseHandler(_arg1:MouseEvent):void{
x = _arg1.stageX;
y = _arg1.stageY;
mouseVelX = (x - ox);
mouseVelY = (y - oy);
ox = x;
oy = y;
}
public static function MouseUpHandler(_arg1:MouseEvent):void{
buttonPressed = false;
buttonReleased = true;
}
public static function MouseClickHandler(_arg1:MouseEvent):void{
buttonPressed = true;
buttonReleased = false;
}
public static function InitOnce(_arg1:Stage):void{
_arg1.addEventListener(MouseEvent.MOUSE_MOVE, MouseHandler);
_arg1.addEventListener(MouseEvent.MOUSE_DOWN, MouseClickHandler);
_arg1.addEventListener(MouseEvent.MOUSE_UP, MouseUpHandler);
_arg1.addEventListener(MouseEvent.MOUSE_WHEEL, MouseWheelHandler);
}
public static function MouseWheelHandler(_arg1:MouseEvent):void{
delta = _arg1.delta;
}
public static function Reset():void{
buttonPressed = false;
buttonReleased = false;
}
}
}//package
Section 204
//MusicPlayer (MusicPlayer)
package {
import flash.media.*;
import flash.utils.*;
public class MusicPlayer {
static var musicSound1:Sound;
static var volumeMod:Number = 1;
static var lastMusicID = -1;
static var musicSoundTransform1:SoundTransform;
static var musicChannel1:SoundChannel = null;
static var currentMusicID:int = -1;
static var doMusic:Boolean;
static var musicChannel:SoundChannel = null;
static var streamChannelFlags:Array;
static var musicSoundTransform:SoundTransform;
static var musicSound:Sound;
static var streamSound:Sound = null;
static var streamChannels:Array;
static var streamChannelVolumes:Array;
public static var currentStreamID:int = -1;
public static function StartMusic(_arg1:String){
var classRef:Class;
var m:Sound;
var musicName = _arg1;
if (doMusic == false){
return;
};
if (musicChannel != null){
musicChannel.stop();
};
try {
classRef = (getDefinitionByName(musicName) as Class);
} catch(e:Object) {
classRef = null;
};
if (classRef == null){
trace(("Music Error: Can't find sound " + musicName));
} else {
m = (new (classRef) as Sound);
musicSoundTransform = new SoundTransform(1, 0);
musicSound = m;
musicChannel = musicSound.play(0, 999999, musicSoundTransform);
};
lastMusicID = 0;
}
public static function InitOnce():void{
doMusic = Game.soundon;
lastMusicID = -1;
currentMusicID = -1;
streamChannels = new Array();
streamChannelFlags = new Array();
streamChannelVolumes = new Array();
}
public static function StopMusic(){
var _local1:int;
var _local2:SoundChannel;
var _local3:int;
_local1 = 0;
while (_local1 < streamChannels.length) {
_local3 = streamChannelFlags[_local1];
if ((((_local3 == 0)) || ((_local3 == 1)))){
_local3 = 2;
};
streamChannelFlags[_local1] = _local3;
_local1++;
};
if (musicChannel != null){
musicChannel.stop();
};
}
public static function ToggleMute(){
doMusic = (doMusic == false);
}
public static function StartStream(_arg1:int){
var _local3:Class;
if (doMusic == false){
return;
};
var _local2 = "";
_local2 = "Tune01";
_local3 = (getDefinitionByName(_local2) as Class);
var _local4:Sound = (new (_local3) as Sound);
var _local5:SoundTransform = new SoundTransform(0);
streamChannels.push(_local4.play(0, 999999, _local5));
streamChannelFlags.push(int(0));
streamChannelVolumes.push(Number(0));
}
public static function UpdateOncePerFrame(){
var _local3:SoundTransform;
var _local4:int;
var _local5:SoundChannel;
var _local6:int;
var _local7:Number;
var _local8:*;
var _local9:*;
var _local10:*;
var _local1:Number = 0.02;
var _local2:Boolean;
_local4 = 0;
while (_local4 < streamChannels.length) {
_local5 = streamChannels[_local4];
_local6 = streamChannelFlags[_local4];
_local7 = streamChannelVolumes[_local4];
if (_local6 == 0){
_local3 = _local5.soundTransform;
_local7 = (_local7 + _local1);
if (_local7 >= 1){
_local7 = 1;
_local6 = 1;
};
_local3.volume = (_local7 * volumeMod);
_local5.soundTransform = _local3;
} else {
if (_local6 == 1){
_local3 = _local5.soundTransform;
_local3.volume = (_local7 * volumeMod);
_local5.soundTransform = _local3;
} else {
if (_local6 == 2){
_local3 = _local5.soundTransform;
_local7 = (_local7 - _local1);
if (_local7 <= 0){
_local5.stop();
_local6 = 3;
_local2 = true;
};
_local3.volume = (_local7 * volumeMod);
_local5.soundTransform = _local3;
} else {
if (_local6 == 3){
};
};
};
};
streamChannelFlags[_local4] = _local6;
streamChannels[_local4] = _local5;
streamChannelVolumes[_local4] = _local7;
if (!doMusic){
_local3 = _local5.soundTransform;
_local3.volume = 0;
_local5.soundTransform = _local3;
};
_local4++;
};
if (_local2){
_local8 = new Array();
_local9 = new Array();
_local10 = new Array();
_local4 = 0;
while (_local4 < streamChannels.length) {
_local5 = streamChannels[_local4];
_local6 = streamChannelFlags[_local4];
_local7 = streamChannelVolumes[_local4];
if (_local6 != 3){
_local8.push(_local6);
_local9.push(_local5);
_local10.push(_local7);
};
_local4++;
};
streamChannelFlags = _local8;
streamChannels = _local9;
streamChannelVolumes = _local10;
};
if (!doMusic){
if (musicChannel != null){
_local3 = musicChannel.soundTransform;
_local3.volume = 0;
musicChannel.soundTransform = _local3;
};
} else {
if (musicChannel != null){
_local3 = musicChannel.soundTransform;
_local3.volume = 1;
musicChannel.soundTransform = _local3;
};
};
}
}
}//package
Section 205
//NGAdScreen (NGAdScreen)
package {
import flash.display.*;
public dynamic class NGAdScreen extends MovieClip {
public var buttonSkipAd:SimpleButton;
}
}//package
Section 206
//ObjectDef (ObjectDef)
package {
import flash.geom.*;
public class ObjectDef {
var type:int;
var animNames:Array;
var animIDs:Array;
var exportName:String;
var particleExplodeID:int;
var initFuncName:String;
var maxHealth:Number;
var colRects:Array;
var pathAnimType:int;
var collisionCircleRadii:Array;
var shieldColRects:Array;
var shotControllers:Array;
var collisionCircleOffsets:Array;
public function ObjectDef(_arg1:String, _arg2:int, _arg3:Rectangle){
animNames = new Array();
animIDs = new Array();
colRects = new Array();
shieldColRects = new Array();
collisionCircleOffsets = new Array();
collisionCircleRadii = new Array();
exportName = _arg1;
type = _arg2;
colRects.push(_arg3.clone());
maxHealth = 1;
initFuncName = "";
shotControllers = new Array();
}
public function AddColRect(_arg1:Rectangle){
colRects.push(_arg1.clone());
}
public function GetAnimIDFromName(_arg1:String):int{
var _local3:int;
var _local2:int = animNames.length;
_local3 = 0;
while (_local3 < _local2) {
if (animNames[_local3] == _arg1){
return (animIDs[_local3]);
};
_local3++;
};
trace(((("ERROR: Can't find anim name " + _arg1) + " on object ") + exportName));
return (40);
}
public function SetPathAnimType(_arg1:int){
pathAnimType = _arg1;
}
public function DoesAnimIDExist(_arg1:String):Boolean{
var _local3:int;
var _local2:int = animNames.length;
_local3 = 0;
while (_local3 < _local2) {
if (animNames[_local3] == _arg1){
return (true);
};
_local3++;
};
return (false);
}
public function AddShieldColRect(_arg1:Rectangle){
shieldColRects.push(_arg1.clone());
}
public function SetInitFunc(_arg1:String){
initFuncName = _arg1;
}
public function AddCollisionCircle(_arg1:Number, _arg2:Number, _arg3:Number){
collisionCircleOffsets.push(new Point(_arg1, _arg2));
collisionCircleRadii.push(_arg3);
}
public function SetParticle(_arg1:int){
particleExplodeID = _arg1;
}
public function SetHealth(_arg1:Number){
maxHealth = _arg1;
}
public function AddAnim(_arg1:String, _arg2:int){
animNames.push(_arg1);
animIDs.push(_arg2);
}
}
}//package
Section 207
//ObjectDefs (ObjectDefs)
package {
import flash.geom.*;
public class ObjectDefs {
static var list:Array;
public static function Init(){
var _local1:ObjectDef;
list = new Array();
_local1 = new ObjectDef("Player", 0, new Rectangle(-10, -30, 20, 40));
_local1.AddCollisionCircle(0, -17, 15);
_local1.AddCollisionCircle(0, -31, 15);
_local1.AddCollisionCircle(0, -45, 15);
list.push(_local1);
}
public static function GetObjectDefByExportName(_arg1:String){
var _local2:ObjectDef;
var _local3:int;
var _local4:int = list.length;
_local3 = 0;
while (_local3 < _local4) {
_local2 = list[_local3];
if (_local2.exportName == _arg1){
return (_local2);
};
_local3++;
};
trace(("ERROR: ObjectDefs can't find object exportname " + _arg1));
return (null);
}
}
}//package
Section 208
//Particle (Particle)
package {
class Particle {
var graphicID:int;
public var yvel:Number;
var active:Boolean;
var maxframe:int;
var dir:Number;
var velmod1:Number;
var mode:int;
public var xvel:Number;
var ypos:Number;
var updateFunction:Function;
var timer:Number;
var speed:Number;
var angle:Number;
var velmod:Number;
var startx:Number;
var starty:Number;
var xpos:Number;
var alpha:Number;
var color:uint;
var alphaAdd:Number;
var frame:Number;
var frameVel:Number;
var visible:Boolean;
var counter:int;
function CycleAnimation():Boolean{
frame = (frame + frameVel);
if (frame >= maxframe){
frame = 0;
return (true);
};
return (false);
}
public function InitSlime():void{
var _local1:Number = (Utils.RandBetweenFloat(-1, 1) - (Math.PI * 0.5));
var _local2:Number = Utils.RandBetweenFloat(11, 19);
xvel = (Math.cos(_local1) * _local2);
yvel = (Math.sin(_local1) * _local2);
frame = 0;
graphicID = 0;
updateFunction = UpdateSlime;
mode = 0;
}
public function UpdatePlayerExplosion():void{
xpos = (xpos + xvel);
ypos = (ypos + yvel);
timer--;
if (timer < 0){
active = false;
};
}
public function InitPowerup():void{
var _local1:Number = Utils.RandCircle();
var _local2:Number = Utils.RandBetweenFloat(10, 20);
xvel = (Math.cos(_local1) * _local2);
yvel = (Math.sin(_local1) * _local2);
frame = 0;
updateFunction = UpdatePowerup;
graphicID = GraphicObjects.GetIndexByName("Particle_Splat");
frame = Utils.RandBetweenInt(0, 2);
color = 4278255360;
timer = Utils.RandBetweenInt(5, 10);
velmod = Utils.RandBetweenFloat(0.9, 0.99);
velmod1 = Utils.RandBetweenFloat(0.9, 0.99);
}
public function InitExplo01():void{
var _local1:Number = Utils.RandBetweenFloat(0, Math.PI);
_local1 = (_local1 + Math.PI);
var _local2:Number = Utils.RandBetweenFloat(5, 10);
mode = 0;
starty = ypos;
starty = (starty + Utils.RandBetweenFloat(-15, 15));
xpos = (xpos + Utils.RandBetweenFloat(-20, 20));
ypos = (ypos - Utils.RandBetweenFloat(5, 15));
xvel = (Math.cos(_local1) * _local2);
yvel = (Math.sin(_local1) * _local2);
frame = 0;
updateFunction = UpdateExplo01;
graphicID = GraphicObjects.GetIndexByName("Particle_Splat");
frame = Utils.RandBetweenInt(0, 2);
}
function PlayAnimation():Boolean{
frame = (frame + frameVel);
if (frame >= maxframe){
frame = maxframe;
return (true);
};
return (false);
}
public function InitPickupAnimation():void{
updateFunction = UpdatePickupAnimation;
var _local1:Number = Game.goPlayer.xpos;
var _local2:Number = Game.goPlayer.ypos;
var _local3:Number = Math.atan2((_local2 - ypos), (_local1 - xpos));
_local3 = (_local3 + Utils.RandBetweenFloat(-0.4, 0.4));
var _local4:Number = Utils.RandBetweenFloat(3, 6);
xvel = (Math.cos(_local3) * _local4);
yvel = (Math.sin(_local3) * _local4);
timer = Utils.RandBetweenInt(10, 20);
color = 4278255360;
}
public function UpdateTrail():void{
xpos = (xpos + xvel);
ypos = (ypos + yvel);
timer--;
if (timer < 0){
active = false;
};
}
function UpdateVelsTimer(){
xpos = (xpos + xvel);
ypos = (ypos + yvel);
timer--;
if (timer <= 0){
active = false;
};
}
public function UpdateThrust():void{
xpos = (xpos + xvel);
ypos = (ypos + yvel);
alpha = (alpha + alphaAdd);
if (alpha < 0){
alpha = 0;
active = false;
};
}
public function InitThrust():void{
updateFunction = UpdateThrust;
alpha = 0.5;
frame = 0;
frameVel = 0.4;
alphaAdd = Utils.RandBetweenFloat(-0.01, -0.03);
}
public function InitPickupExplosion():void{
updateFunction = UpdatePickupExplosion;
var _local1:Number = Utils.RandBetweenFloat(1, 8);
var _local2:Number = Utils.RandCircle();
xvel = (Math.cos(_local2) * _local1);
yvel = (Math.sin(_local2) * _local1);
timer = Utils.RandBetweenInt(20, 40);
xpos = (xpos + (xvel * timer));
ypos = (ypos + (yvel * timer));
color = 4278255360;
}
public function UpdateAsteroidExplosion():void{
xpos = (xpos + xvel);
ypos = (ypos + yvel);
timer--;
if (timer < 0){
active = false;
};
}
public function UpdateWater():void{
xpos = (xpos + xvel);
ypos = (ypos + yvel);
yvel = (yvel + 0.3);
timer--;
if (timer <= 0){
};
frame++;
if (frame >= 29){
frame = 29;
active = false;
};
}
public function UpdateEnemyExplosion():void{
xpos = (xpos + xvel);
ypos = (ypos + yvel);
timer--;
if (timer < 0){
active = false;
};
}
public function UpdatePowerup():void{
xpos = (xpos + xvel);
ypos = (ypos + yvel);
xvel = (xvel * velmod);
yvel = (yvel * velmod1);
timer--;
if (timer <= 0){
active = false;
};
}
public function InitBulletWallExplosion():void{
updateFunction = UpdateBulletWallExplosion;
var _local1:Number = Utils.RandBetweenFloat(2, 4);
var _local2:Number = Utils.RandCircle();
xvel = (Math.cos(_local2) * _local1);
yvel = (Math.sin(_local2) * _local1);
timer = Utils.RandBetweenInt(5, 10);
color = 4294901760;
}
public function InitTrail():void{
updateFunction = UpdateTrail;
color = 4278255615;
var _local1:Number = Utils.RandCircle();
var _local2:Number = Utils.RandBetweenFloat(1, 3);
xvel = (Math.sin(_local1) * _local2);
yvel = (Math.cos(_local1) * _local2);
timer = Utils.RandBetweenInt(5, 10);
}
public function UpdatePickupAnimation():void{
xpos = (xpos + xvel);
ypos = (ypos + yvel);
timer--;
if (timer < 0){
active = false;
};
}
public function InitEnemyExplosion():void{
updateFunction = UpdateEnemyExplosion;
var _local1:Number = Utils.RandBetweenFloat(3, 10);
var _local2:Number = Utils.RandCircle();
xvel = (Math.cos(_local2) * _local1);
yvel = (Math.sin(_local2) * _local1);
timer = Utils.RandBetweenInt(20, 30);
color = 4294967040;
}
public function UpdatePickup():void{
xpos = (xpos + xvel);
ypos = (ypos + yvel);
timer--;
if (timer <= 0){
active = false;
};
}
public function InitWater():void{
var _local1:Number = Utils.RandCircle();
var _local2:Number = Utils.RandBetweenFloat(3, 5);
xvel = (Math.cos(_local1) * _local2);
yvel = (Math.sin(_local1) * _local2);
frame = 0;
updateFunction = UpdateWater;
mode = 0;
color = 4278190335;
timer = 10;
frame = 20;
}
public function UpdatePickupExplosion():void{
xpos = (xpos - xvel);
ypos = (ypos - yvel);
timer--;
if (timer < 0){
active = false;
};
}
public function InitAsteroidExplosion():void{
updateFunction = UpdateAsteroidExplosion;
var _local1:Number = Utils.RandBetweenFloat(3, 10);
var _local2:Number = Utils.RandCircle();
xvel = (Math.cos(_local2) * _local1);
yvel = (Math.sin(_local2) * _local1);
timer = Utils.RandBetweenInt(10, 20);
color = 4294967040;
}
public function InitPickup(_arg1:Number):void{
var _local2:Number = Utils.RandBetweenFloat(10, 20);
xvel = Math.cos(_arg1);
yvel = Math.sin(_arg1);
frame = 0;
updateFunction = UpdatePickup;
frame = 0;
graphicID = GraphicObjects.GetIndexByName("Particle_Pickup");
xpos = (xpos + (xvel * 50));
ypos = (ypos + (yvel * 50));
xvel = (xvel * -2);
yvel = (yvel * -2);
color = 4294967295;
timer = 20;
}
function UpdateSlime():void{
}
public function UpdateExplo01():void{
if (mode == 0){
xpos = (xpos + xvel);
ypos = (ypos + yvel);
yvel = (yvel + 0.5);
if ((((yvel > 0)) && ((ypos >= starty)))){
mode = 1;
};
} else {
xpos = (xpos - Game.goPlayer.playerSpeed);
if (xpos < -10){
active = false;
};
};
}
public function UpdateBulletWallExplosion():void{
xpos = (xpos + xvel);
ypos = (ypos + yvel);
timer--;
if (timer < 0){
active = false;
};
}
public function InitPlayerExplosion():void{
updateFunction = UpdatePlayerExplosion;
var _local1:Number = Utils.RandBetweenFloat(2, 20);
var _local2:Number = Utils.RandCircle();
xvel = (Math.cos(_local2) * _local1);
yvel = (Math.sin(_local2) * _local1);
timer = Utils.RandBetweenInt(50, 200);
var _local3:int = Utils.RandBetweenInt(0, 6);
if (_local3 == 0){
color = 4294901760;
};
if (_local3 == 1){
color = 4294905872;
};
if (_local3 == 2){
color = 4294909984;
};
if (_local3 == 3){
color = 4294914096;
};
if (_local3 == 4){
color = 4294918208;
};
if (_local3 == 5){
color = 4294922320;
};
if (_local3 == 6){
color = 4294967295;
};
}
function UpdateAnimAndStop(){
xpos = (xpos + xvel);
ypos = (ypos + yvel);
if (PlayAnimation()){
active = false;
};
}
}
}//package
Section 209
//Particles (Particles)
package {
import flash.display.*;
import flash.geom.*;
public class Particles {
public static const type_dust = 0;
static var max:int;
static var list:Array;
static var main:Main;
static var fakeParticle:Particle;
static var nextIndex:int;
public function Particles():void{
}
public static function Add(_arg1:Number, _arg2:Number):Particle{
var _local3:Number;
var _local4:Number;
if ((((((((_arg1 < (Game.scrollX - 150))) || ((_arg2 < (Game.scrollY - 150))))) || ((_arg1 > ((Game.scrollX + 150) + 600))))) || ((_arg2 > ((Game.scrollY + 150) + 600))))){
return (fakeParticle);
};
var _local5:Particle = list[nextIndex];
nextIndex++;
if (nextIndex >= max){
nextIndex = 0;
};
_local5.active = true;
_local5.timer = 0;
_local5.alpha = 1;
_local5.alphaAdd = 0;
_local5.visible = true;
_local5.xpos = _arg1;
_local5.ypos = _arg2;
_local5.angle = 0;
return (_local5);
}
public static function GetNextIndex():int{
return (nextIndex);
}
public static function Reset(){
var _local1:int;
nextIndex = 0;
_local1 = 0;
while (_local1 < max) {
list[_local1].active = false;
_local1++;
};
}
public static function Update(_arg1:Number){
var _local2:int;
var _local3:Particle;
_local2 = 0;
while (_local2 < max) {
_local3 = list[_local2];
if (_local3.active == true){
_local3.updateFunction();
};
_local2++;
};
}
public static function InitOnce(_arg1:Main, _arg2:int):void{
var _local3:int;
var _local4:int;
main = _arg1;
max = _arg2;
nextIndex = 0;
list = new Array(max);
_local3 = 0;
while (_local3 < max) {
list[_local3] = new Particle();
list[_local3].active = false;
_local3++;
};
fakeParticle = new Particle();
}
public static function CountActive():int{
var _local2:int;
var _local1:int;
_local2 = 0;
while (_local2 < max) {
if (list[_local2].active){
_local1++;
};
_local2++;
};
return (_local1);
}
public static function Render(_arg1:BitmapData){
var _local8:int;
var _local9:int;
var _local10:Particle;
var _local11:Number;
var _local12:Number;
var _local2:Number = (0 - 16);
var _local3:Number = (Defs.displayarea_w + 16);
var _local4:Number = (0 - 16);
var _local5:Number = (Defs.displayarea_h + 16);
var _local6:Number = Game.scrollX;
var _local7:Number = Game.scrollY;
_arg1.lock();
_local8 = 0;
while (_local8 < max) {
_local10 = list[_local8];
if (((_local10.active) && (_local10.visible))){
_local11 = (_local10.xpos - _local6);
_local12 = (_local10.ypos - _local7);
_arg1.setPixel32(_local11, _local12, _local10.color);
_arg1.setPixel32((_local11 + 1), _local12, _local10.color);
_arg1.setPixel32((_local11 - 1), _local12, _local10.color);
_arg1.setPixel32(_local11, (_local12 + 1), _local10.color);
_arg1.setPixel32(_local11, (_local12 - 1), _local10.color);
};
_local8++;
};
_arg1.unlock();
}
}
}//package
Section 210
//pause_screen (pause_screen)
package {
import flash.display.*;
public dynamic class pause_screen extends MovieClip {
public var buttonQuit:SimpleButton;
public var buttonSFX:SimpleButton;
public var tickSFX:MovieClip;
public var buttonContinue:SimpleButton;
}
}//package
Section 211
//PauseMenu (PauseMenu)
package {
import flash.display.*;
import flash.events.*;
import flash.geom.*;
import flash.text.*;
import flash.net.*;
import flash.ui.*;
public class PauseMenu {
static var active:Boolean;
static var pauseMC:MovieClip;
static var main:Main;
public function PauseMenu():void{
}
public static function pressed_buttonRestartLevel(_arg1:MouseEvent){
Unpause();
Game.StartLevelPlay();
}
public static function pressed_buttonMusic(_arg1:MouseEvent){
MusicPlayer.ToggleMute();
SetTicks();
}
public static function IsPaused():Boolean{
return (active);
}
public static function pressed_buttonContinue(_arg1:MouseEvent){
Unpause();
}
public static function pressed_buttonHelp(_arg1:MouseEvent){
}
public static function InitOnce(_arg1:Main):void{
main = _arg1;
active = false;
}
static function SetTicks(){
if (SoundPlayer.doSFX){
pauseMC.tickSFX.gotoAndStop(1);
} else {
pauseMC.tickSFX.gotoAndStop(2);
};
}
public static function Unpause():void{
active = false;
main.removeChild(pauseMC);
pauseMC = null;
KeyReader.InitOnce(Game.main.stage);
}
public static function pressed_buttonSFX(_arg1:MouseEvent){
SoundPlayer.ToggleMute();
if (SoundPlayer.doSFX == false){
Game.QuietAllSounds();
} else {
Game.StartLevelSounds();
};
SetTicks();
}
public static function Pause():void{
pauseMC = AddMovieClip(0, 0, new pause_screen());
main.addChild(pauseMC);
pauseMC.buttonSFX.addEventListener(MouseEvent.CLICK, pressed_buttonSFX);
pauseMC.buttonQuit.addEventListener(MouseEvent.CLICK, pressed_buttonQuit);
pauseMC.buttonContinue.addEventListener(MouseEvent.CLICK, pressed_buttonContinue);
active = true;
SetTicks();
}
public static function pressed_buttonQuit(_arg1:MouseEvent){
Unpause();
Game.main.SetGameState(Main.gameState_TITLE);
}
static function AddMovieClip(_arg1:Number, _arg2:Number, _arg3:MovieClip):MovieClip{
_arg3.x = _arg1;
_arg3.y = _arg2;
main.addChild(_arg3);
return (_arg3);
}
}
}//package
Section 212
//PhysEditor (PhysEditor)
package {
import flash.display.*;
import flash.geom.*;
import flash.ui.*;
public class PhysEditor {
static const editMode_Commands1:int = 4;
static const editMode_Library:int = 1;
static const editMode_Normal:int = 0;
static const editMode_PickPiece:int = 7;
static const editMode_Eraser:int = 2;
static const editMode_Commands:int = 3;
static const editMode_Adjust:int = 5;
static const editMode_Lines:int = 6;
static var boxNumW:Number = 5;
static var boxNumH:Number = 4;
static var editor_currentPiece:int = 0;
static var currentLevel:int = 0;
static var renderMiniMap:Boolean = true;
static var library_page:int = 0;
static var renderObjects:Boolean = true;
static var prevEditMode:int = 0;
static var scrollX:Number = 0;
static var scrollY:Number = 0;
static var currentLineIndex:int;
public static var currentAdjustObject:PhysObj_Instance;
static var editMode:int = 0;
static var editor_currentPieceRot:Number = 0;
static var boxSizeH:Number = (Defs.displayarea_h / boxNumH);
static var guideLines:Array;
static var boxSizeW:Number = (Defs.displayarea_w / boxNumW);
static var currentPointIndex:int;
static var updateTimer:int = 0;
public static function Editor_PreviousLevel():void{
currentLevel--;
if (currentLevel < 0){
currentLevel = 0;
};
currentLineIndex = -1;
currentPointIndex = -1;
}
static function Editor_GetNearbyGuidelines(_arg1:PhysObj_Instance, _arg2:Number, _arg3:Number, _arg4:Number=50){
var _local6:PhysObj_Body;
var _local7:PhysObj_Shape;
var _local8:Point;
var _local9:Point;
var _local13:PhysObj_Instance;
var _local14:PhysObj;
var _local15:Point;
var _local16:Point;
var _local17:PhysObj;
var _local18:Point;
var _local19:Number;
var _local20:Number;
var _local21:Boolean;
var _local22:PhysEd_GuideLine;
var _local5:Number = 3;
var _local10:Array = GetCurrentLevelInstances();
var _local11:Matrix = new Matrix();
var _local12:Array = new Array();
if (_arg1 != null){
_local14 = Game.physObjs.FindByName(_arg1.typeName);
if (_local14 != null){
for each (_local6 in _local14.bodies) {
for each (_local7 in _local6.shapes) {
if (_local7.type == PhysObj_Shape.Type_Poly){
for each (_local8 in _local7.poly_points) {
_local11.identity();
_local11.rotate(Utils.DegToRad(_arg1.rot));
_local15 = new Point(_local8.x, _local8.y);
_local15 = _local11.transformPoint(_local15);
_local16 = new Point(((_local15.x + _arg1.x) + _local6.pos.x), ((_local15.y + _arg1.y) + _local6.pos.y));
_local12.push(_local16);
};
};
};
};
};
} else {
_local12.push(new Point(_arg2, _arg3));
};
guideLines = new Array();
for each (_local13 in _local10) {
if (_local13 != _arg1){
_local17 = Game.physObjs.FindByName(_local13.typeName);
if (_local17 != null){
for each (_local6 in _local17.bodies) {
for each (_local7 in _local6.shapes) {
if (_local7.type == PhysObj_Shape.Type_Poly){
for each (_local8 in _local7.poly_points) {
_local11.identity();
_local11.rotate(Utils.DegToRad(_local13.rot));
_local15 = new Point(_local8.x, _local8.y);
_local15 = _local11.transformPoint(_local15);
_local18 = new Point(((_local15.x + _local13.x) + _local6.pos.x), ((_local15.y + _local13.y) + _local6.pos.y));
for each (_local9 in _local12) {
_local19 = Math.abs((_local18.x - _local9.x));
_local20 = Math.abs((_local18.y - _local9.y));
_local21 = false;
if ((((_local20 < _local5)) && ((_local19 < _arg4)))){
_local21 = false;
if (Math.floor(_local18.y) == Math.floor(_local9.y)){
_local21 = true;
};
_local22 = new PhysEd_GuideLine((_local18.x - 100), (_local18.x + 100), _local18.y, 0, _local21);
guideLines.push(_local22);
};
if ((((_local19 < _local5)) && ((_local20 < _arg4)))){
_local21 = false;
if (Math.floor(_local18.x) == Math.floor(_local9.x)){
_local21 = true;
};
_local22 = new PhysEd_GuideLine((_local18.y - 100), (_local18.y + 100), _local18.x, 1, _local21);
guideLines.push(_local22);
};
};
};
};
};
};
};
};
};
}
static function Library_PickPiece(){
var _local11:PhysObj;
var _local1:int = MouseControl.x;
var _local2:int = MouseControl.y;
var _local3:int = (_local1 / boxSizeW);
var _local4:int = (_local2 / boxSizeH);
var _local5:int = (_local3 + (_local4 * boxNumW));
var _local6:int = (boxNumW * boxNumH);
_local5 = (_local5 + (library_page * _local6));
var _local7:int = (Game.physObjs.GetNum() - 1);
if (_local5 > _local7){
_local5 = _local7;
};
var _local8:int;
var _local9:int;
var _local10:int;
for each (_local11 in Game.physObjs.list) {
if (_local8 == _local5){
_local10 = _local9;
};
if (_local11.displayInLibrary){
_local8++;
};
_local9++;
};
editor_currentPiece = _local10;
editor_currentPieceRot = 0;
}
static function Editor_RenderLineToCursor(){
var _local1:Level = GetCurrentLevel();
if (currentLineIndex == -1){
return;
};
var _local2:PhysLine = _local1.lines[currentLineIndex];
var _local3:int = MouseControl.x;
var _local4:int = MouseControl.y;
var _local5:int = (_local2.points.length - 1);
var _local6:Point = _local2.points[_local5].clone();
_local2.points[_local5].clone().x = (_local6.x - scrollX);
_local6.y = (_local6.y - scrollY);
var _local7:BitmapData = Game.main.screenBD;
Utils.RenderDotLine(_local7, _local3, _local4, _local6.x, _local6.y, 200, 4278255615);
}
static function Lines_SelectLine(_arg1:Number, _arg2:Number){
var _local5:PhysLine;
var _local6:Point;
var _local3:Level = GetCurrentLevel();
var _local4:int;
currentLineIndex = -1;
for each (_local5 in _local3.lines) {
for each (_local6 in _local5.points) {
if (Utils.DistBetweenPoints(_local6.x, _local6.y, _arg1, _arg2) < 3){
currentLineIndex = _local4;
return;
};
};
_local4++;
};
}
static function Lines_ChangeType(){
if (currentLineIndex == -1){
return;
};
var _local1:Level = GetCurrentLevel();
var _local2:PhysLine = _local1.lines[currentLineIndex];
_local2.type++;
_local2.type = (_local2.type % 8);
}
static function Lines_MovePoints(_arg1:Number, _arg2:Number){
var _local6:Number;
var _local7:Point;
if (currentLineIndex == -1){
return;
};
var _local3:Level = GetCurrentLevel();
var _local4:Array = _local3.lines[currentLineIndex].points;
var _local5:Number = 100;
for each (_local7 in _local4) {
_local6 = Utils.DistBetweenPoints(_local7.x, _local7.y, _arg1, _arg2);
if (_local6 < _local5){
_local6 = (_local5 - _local6);
_local6 = Utils.ScaleTo(0, 5, 0, _local5, _local6);
if (_local7.y < _arg2){
_local7.y = (_local7.y - _local6);
} else {
if (_local7.y > _arg2){
_local7.y = (_local7.y + _local6);
};
};
};
};
}
static function Lines_ScrollToLastPointOfSelectedLine(){
if (currentLineIndex == -1){
return;
};
var _local1:Level = GetCurrentLevel();
var _local2:Array = _local1.lines[currentLineIndex].points;
var _local3:Point = _local2[(_local2.length - 1)];
scrollX = (_local3.x - (Defs.displayarea_w * 0.5));
scrollY = (_local3.y - (Defs.displayarea_h * 0.5));
}
static function UpdateScroll(){
var _local1:Number;
var _local2:Number;
var _local3:Number;
if (KeyReader.Down(KeyReader.KEY_SHIFT) == false){
_local1 = 50;
_local2 = 0;
_local3 = 0;
if (KeyReader.Down(KeyReader.KEY_CONTROL)){
_local1 = (_local1 * 0.2);
};
if (KeyReader.Down(KeyReader.KEY_LEFT)){
_local2 = -(_local1);
};
if (KeyReader.Down(KeyReader.KEY_RIGHT)){
_local2 = _local1;
};
if (KeyReader.Down(KeyReader.KEY_UP)){
_local3 = -(_local1);
};
if (KeyReader.Down(KeyReader.KEY_DOWN)){
_local3 = _local1;
};
scrollX = (scrollX + _local2);
scrollY = (scrollY + _local3);
};
}
static function GetCurrentLevelInstances():Array{
return (Game.levels[currentLevel].instances);
}
static function Editor_RenderNearbyGuidelines(){
var _local2:PhysEd_GuideLine;
var _local3:uint;
var _local1:BitmapData = Game.main.screenBD;
for each (_local2 in guideLines) {
_local3 = 4294901760;
if (_local2.level){
_local3 = 4278255615;
};
Utils.RenderDotLine(_local1, (_local2.x0 - scrollX), (_local2.y0 - scrollY), (_local2.x1 - scrollX), (_local2.y1 - scrollY), 100, _local3);
};
}
static function SetCurrentLevelInstances(_arg1:Array):void{
Game.levels[currentLevel].instances = _arg1;
}
public static function UpdateEditor():void{
var _local5:PhysObj;
var _local7:PhysObj_Instance;
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:Point;
var _local17:String;
var _local18:Array;
var _local19:Number;
var _local20:Number;
var _local21:Point;
updateTimer++;
var _local1:int = MouseControl.x;
var _local2:int = MouseControl.y;
var _local3:int = (MouseControl.x + scrollX);
var _local4:int = (MouseControl.y + scrollY);
var _local6:Level = GetCurrentLevel();
if (editMode == editMode_Commands){
if (KeyReader.Pressed(KeyReader.KEY_1)){
editMode = editMode_Normal;
};
if (KeyReader.Pressed(KeyReader.KEY_2)){
editMode = editMode_Library;
library_page++;
if (library_page >= GetNumLibraryPages()){
library_page = 0;
};
};
if (KeyReader.Pressed(KeyReader.KEY_3)){
editMode = editMode_Eraser;
};
if (KeyReader.Pressed(KeyReader.KEY_5)){
currentAdjustObject = null;
editMode = editMode_Adjust;
};
if (KeyReader.Pressed(KeyReader.KEY_6)){
editMode = editMode_Lines;
};
if (KeyReader.Pressed(KeyReader.KEY_7)){
editMode = editMode_PickPiece;
};
if (KeyReader.Pressed(KeyReader.KEY_SPACE)){
editMode = editMode_Commands1;
};
return;
};
if (editMode == editMode_Commands1){
if (KeyReader.Pressed(KeyReader.KEY_1)){
Editor_ClearLevel();
editMode = prevEditMode;
};
if (KeyReader.Pressed(KeyReader.KEY_2)){
Editor_AddLevel();
editMode = prevEditMode;
};
if (KeyReader.Pressed(KeyReader.KEY_9)){
Game.StartLevelPlay();
return;
};
if (KeyReader.Pressed(KeyReader.KEY_4)){
ExportLevelAsXml();
editMode = prevEditMode;
};
if (KeyReader.Pressed(KeyReader.KEY_5)){
ExportAllLevelsAsXml();
editMode = prevEditMode;
};
if (KeyReader.Pressed(KeyReader.KEY_SPACE)){
editMode = prevEditMode;
};
if (KeyReader.Pressed(KeyReader.KEY_8)){
Editor_PreviousLevel();
};
if (KeyReader.Pressed(KeyReader.KEY_9)){
Editor_NextLevel();
};
return;
};
if (KeyReader.Pressed(KeyReader.KEY_X)){
renderMiniMap = (renderMiniMap == false);
};
if (KeyReader.Pressed(KeyReader.KEY_SPACE)){
prevEditMode = editMode;
editMode = editMode_Commands;
};
if (editMode == editMode_Library){
if (MouseControl.buttonPressed){
MouseControl.buttonPressed = false;
Library_PickPiece();
editMode = editMode_Normal;
};
if (KeyReader.Pressed(KeyReader.KEY_DOWN)){
library_page++;
if (library_page >= GetNumLibraryPages()){
library_page = 0;
};
};
if (KeyReader.Pressed(KeyReader.KEY_UP)){
library_page--;
if (library_page < 0){
library_page = (GetNumLibraryPages() - 1);
};
};
return;
};
if (editMode == editMode_PickPiece){
if (MouseControl.buttonPressed){
MouseControl.buttonPressed = false;
_local7 = HitTestPhysObjGraphics(_local1, _local2);
if (_local7){
editor_currentPiece = Game.physObjs.FindIndexByName(_local7.typeName);
editor_currentPieceRot = 0;
editMode = editMode_Normal;
};
};
UpdateScroll();
return;
};
if (editMode == editMode_Eraser){
if (MouseControl.buttonPressed){
MouseControl.buttonPressed = false;
_local7 = HitTestPhysObjGraphics(_local1, _local2);
if (_local7){
RemoveFromLevelInstances(_local7);
};
};
UpdateScroll();
return;
};
if (editMode == editMode_Adjust){
if (MouseControl.buttonPressed){
MouseControl.buttonPressed = false;
_local7 = HitTestPhysObjGraphics(_local1, _local2);
if (_local7){
currentAdjustObject = _local7;
} else {
currentAdjustObject = null;
};
};
if (currentAdjustObject != null){
_local8 = 1;
_local9 = 1;
_local10 = 0;
_local11 = 0;
_local12 = 0;
if (KeyReader.Down(KeyReader.KEY_CONTROL)){
_local8 = (_local8 * 10);
_local9 = (_local9 * 10);
};
if (KeyReader.Down(KeyReader.KEY_SHIFT)){
if (KeyReader.Down(KeyReader.KEY_LEFT)){
_local11 = -(_local8);
};
if (KeyReader.Down(KeyReader.KEY_RIGHT)){
_local11 = _local8;
};
if (KeyReader.Down(KeyReader.KEY_UP)){
_local12 = -(_local8);
};
if (KeyReader.Down(KeyReader.KEY_DOWN)){
_local12 = _local8;
};
currentAdjustObject.x = (currentAdjustObject.x + _local11);
currentAdjustObject.y = (currentAdjustObject.y + _local12);
};
if (KeyReader.Down(KeyReader.KEY_6)){
_local10 = -(_local9);
};
if (KeyReader.Down(KeyReader.KEY_7)){
_local10 = _local9;
};
currentAdjustObject.rot = (currentAdjustObject.rot + _local10);
};
UpdateScroll();
return;
};
if (editMode == editMode_Lines){
if (MouseControl.buttonPressed){
if (KeyReader.Down(KeyReader.KEY_7)){
Lines_MovePoints(_local3, _local4);
return;
};
MouseControl.buttonPressed = false;
if (KeyReader.Down(KeyReader.KEY_1)){
Lines_SelectLine(_local3, _local4);
return;
};
if (KeyReader.Down(KeyReader.KEY_2)){
Lines_DeletePoint(_local3, _local4);
return;
};
if (KeyReader.Down(KeyReader.KEY_3)){
Lines_InsertPoint(_local3, _local4);
return;
};
if (KeyReader.Down(KeyReader.KEY_4)){
Lines_SelectPoint(_local3, _local4);
return;
};
if (KeyReader.Down(KeyReader.KEY_5)){
Lines_NewLine();
};
if (KeyReader.Down(KeyReader.KEY_6)){
Lines_Subdivide(_local3, _local4);
return;
};
Lines_AddPoint(_local3, _local4);
};
if (KeyReader.Pressed(KeyReader.KEY_8)){
Lines_ChangeType();
return;
};
if (KeyReader.Pressed(KeyReader.KEY_LEFTSQUAREBRACKET)){
Lines_ScrollToFirstPointOfSelectedLine();
};
if (KeyReader.Pressed(KeyReader.KEY_RIGHTSQUAREBRACKET)){
Lines_ScrollToLastPointOfSelectedLine();
};
if (((!((currentLineIndex == -1))) && (!((currentPointIndex == -1))))){
_local13 = 1;
_local14 = 0;
_local15 = 0;
if (KeyReader.Down(KeyReader.KEY_CONTROL)){
_local13 = (_local13 * 10);
};
if (KeyReader.Down(KeyReader.KEY_SHIFT)){
if (KeyReader.Down(KeyReader.KEY_LEFT)){
_local14 = -(_local13);
};
if (KeyReader.Down(KeyReader.KEY_RIGHT)){
_local14 = _local13;
};
if (KeyReader.Down(KeyReader.KEY_UP)){
_local15 = -(_local13);
};
if (KeyReader.Down(KeyReader.KEY_DOWN)){
_local15 = _local13;
};
};
_local16 = _local6.lines[currentLineIndex].points[currentPointIndex];
_local6.lines[currentLineIndex].points[currentPointIndex].x = (_local16.x + _local14);
_local16.y = (_local16.y + _local15);
};
UpdateScroll();
return;
};
if (editMode == editMode_Normal){
if (KeyReader.Down(KeyReader.KEY_SHIFT) == true){
if (KeyReader.Pressed(KeyReader.KEY_UP)){
editor_currentPiece++;
if (editor_currentPiece > (Game.physObjs.GetNum() - 1)){
editor_currentPiece = 0;
};
};
if (KeyReader.Pressed(KeyReader.KEY_DOWN)){
editor_currentPiece--;
if (editor_currentPiece < 0){
editor_currentPiece = (Game.physObjs.GetNum() - 1);
};
};
_local9 = 1;
if (KeyReader.Down(KeyReader.KEY_CONTROL) == false){
_local9 = (_local9 * 10);
};
if (KeyReader.Down(KeyReader.KEY_LEFT)){
editor_currentPieceRot = (editor_currentPieceRot - _local9);
};
if (KeyReader.Down(KeyReader.KEY_RIGHT)){
editor_currentPieceRot = (editor_currentPieceRot + _local9);
};
};
_local5 = Game.physObjs.GetByIndex(editor_currentPiece);
_local17 = _local5.name;
if (MouseControl.buttonPressed){
MouseControl.buttonPressed = false;
_local18 = GetCurrentLevelInstances();
_local19 = _local3;
_local20 = _local4;
if (KeyReader.Down(KeyReader.KEY_1)){
_local21 = SnapToObjects(_local3, _local4);
if (_local21 != null){
trace(((((((("snapped to point :" + _local3) + " ") + _local4) + " -> ") + _local21.x) + " ") + _local21.y));
_local19 = _local21.x;
_local20 = _local21.y;
};
};
_local18.push(Game.CreatePhysObjInstanceAt(_local17, _local19, _local20, editor_currentPieceRot, ""));
SetCurrentLevelInstances(_local18);
};
UpdateScroll();
};
}
static function Editor_RenderLines(){
var _local4:PhysLine;
var _local5:uint;
var _local6:int;
var _local7:Point;
var _local8:Point;
var _local9:Rectangle;
var _local1:Level = GetCurrentLevel();
var _local2:BitmapData = Game.main.screenBD;
var _local3:int;
for each (_local4 in _local1.lines) {
_local5 = 4290822336;
if (_local3 == currentLineIndex){
_local5 = 4294967295;
};
if (_local4.points.length >= 2){
_local6 = 0;
while (_local6 < (_local4.points.length - 1)) {
_local7 = _local4.points[_local6].clone();
_local8 = _local4.points[(_local6 + 1)].clone();
Utils.RenderDotLine(_local2, (_local7.x - scrollX), (_local7.y - scrollY), (_local8.x - scrollX), (_local8.y - scrollY), 200, _local5);
_local6++;
};
};
_local6 = 0;
while (_local6 < _local4.points.length) {
_local5 = 4294901760;
if ((((_local3 == currentLineIndex)) && ((currentPointIndex == _local6)))){
_local5 = 4294967040;
};
_local9 = new Rectangle(((_local4.points[_local6].x - 2) - scrollX), ((_local4.points[_local6].y - 2) - scrollY), 4, 4);
Utils.RenderRectangle(_local2, _local9, _local5);
_local6++;
};
_local3++;
};
}
public static function InitEditor():void{
Mouse.show();
Game.InitBox2D();
GameObjects.ClearAll();
updateTimer = 0;
editMode = editMode_Normal;
currentLineIndex = -1;
currentPointIndex = -1;
var _local1:Level = GetCurrentLevel();
currentLineIndex = (_local1.lines.length - 1);
}
static function Editor_RenderMiniMap(){
var _local4:PhysObj_Instance;
var _local5:PhysObj;
var _local1:Number = (1 / 20);
var _local2:Array = GetCurrentLevelInstances();
var _local3:BitmapData = Game.main.screenBD;
for each (_local4 in _local2) {
_local5 = Game.physObjs.FindByName(_local4.typeName);
if (_local5 != null){
PhysObj.RenderAt(_local5, (_local4.x - scrollX), ((_local4.y - scrollY) + (240 / _local1)), _local4.rot, _local3, false, _local1);
};
};
Editor_RenderLines_MiniMap();
}
static function Lines_Subdivide(_arg1:Number, _arg2:Number){
var _local7:PhysLine;
var _local8:int;
var _local9:Point;
var _local10:int;
var _local11:int;
var _local12:Array;
var _local13:int;
var _local14:Array;
var _local15:Array;
var _local16:int;
var _local17:Point;
var _local18:Point;
var _local19:Point;
if ((((currentLineIndex == -1)) || ((currentPointIndex == -1)))){
return;
};
var _local3:Level = GetCurrentLevel();
var _local4:int;
var _local5 = -1;
var _local6 = -1;
for each (_local7 in _local3.lines) {
_local8 = 0;
for each (_local9 in _local7.points) {
if (Utils.DistBetweenPoints(_local9.x, _local9.y, _arg1, _arg2) < 3){
_local5 = _local4;
_local6 = _local8;
};
_local8++;
};
_local4++;
};
if (((!((_local5 == -1))) && (!((_local6 == -1))))){
if (_local6 == currentPointIndex){
return;
};
_local10 = currentPointIndex;
_local11 = _local6;
if (_local11 < _local10){
_local16 = _local10;
_local11 = _local10;
_local10 = _local16;
};
_local12 = new Array();
_local14 = _local3.lines[_local5].points;
_local13 = _local10;
while (_local13 < _local11) {
_local17 = _local14[_local13].clone();
_local18 = _local14[(_local13 + 1)].clone();
_local19 = new Point(((_local17.x + _local18.x) / 2), ((_local17.y + _local18.y) / 2));
_local12.push(_local19);
_local12.push(_local18);
_local13++;
};
_local15 = new Array();
_local13 = 0;
while (_local13 <= _local10) {
_local15.push(_local14[_local13].clone());
_local13++;
};
for each (_local19 in _local12) {
_local15.push(_local19.clone());
};
_local13 = (_local11 + 1);
while (_local13 < _local14.length) {
_local15.push(_local14[_local13].clone());
_local13++;
};
_local3.lines[_local5].points = _local15;
};
}
public static function Editor_ClearLevel():void{
var _local1:Array = new Array();
Game.levels[currentLevel].instances = _local1;
currentLineIndex = -1;
currentPointIndex = -1;
}
static function RenderEditor(){
var _local1:int;
var _local2:int;
var _local3:Number;
var _local4:String;
var _local10:int;
var _local11:int;
var _local12:int;
var _local13:int;
var _local14:int;
var _local15:int;
var _local16:int;
var _local17:PhysObj;
var _local18:PhysObj;
var _local19:PhysObj_Instance;
var _local5:BitmapData = Game.main.screenBD;
var _local6:int = MouseControl.x;
var _local7:int = MouseControl.y;
var _local8:int = (MouseControl.x + scrollX);
var _local9:int = (MouseControl.y + scrollY);
if (editMode == editMode_Commands){
_local5.fillRect(Defs.screenRect, 4285542576);
};
if (editMode == editMode_Commands1){
_local5.fillRect(Defs.screenRect, 4285542592);
};
if (editMode == editMode_Library){
_local5.fillRect(Defs.screenRect, 4284498112);
_local10 = 0;
_local11 = 0;
_local10 = 0;
while (_local10 < Defs.displayarea_w) {
Utils.RenderDotLine(_local5, _local10, 0, _local10, 640, 100, 4282433600);
_local10 = (_local10 + boxSizeW);
};
_local10 = 0;
while (_local10 < Defs.displayarea_h) {
Utils.RenderDotLine(_local5, 0, _local10, 640, _local10, 100, 4282433600);
_local10 = (_local10 + boxSizeH);
};
_local12 = (boxNumW * boxNumH);
_local13 = (library_page * _local12);
_local14 = (_local13 + (_local12 - 1));
_local10 = 0;
_local11 = 0;
_local15 = Game.physObjs.GetNum();
_local16 = 0;
for each (_local17 in Game.physObjs.list) {
if (_local17.displayInLibrary){
if ((((_local16 >= _local13)) && ((_local16 <= _local14)))){
PhysObj.RenderAt(_local17, (_local10 + (boxSizeW / 2)), (_local11 + (boxSizeH / 2)), 0, _local5);
_local4 = _local17.name;
GraphicObjects.RenderStringAt(_local5, GraphicObjects.gfx_font1, (_local10 + 8), ((_local11 + boxSizeH) - 16), _local4, null);
_local10 = (_local10 + boxSizeW);
if (_local10 >= Defs.displayarea_w){
_local10 = 0;
_local11 = (_local11 + boxSizeH);
};
};
};
_local16++;
};
};
if (editMode == editMode_Eraser){
_local5.fillRect(Defs.screenRect, 4281549909);
GraphicObjects.RenderAt(GraphicObjects.gfx_backgrounds, 0, _local5, -(scrollX), -(scrollY));
if (renderObjects){
Editor_RenderObjects();
};
if (renderMiniMap){
Editor_RenderMiniMap();
};
Editor_RenderLines();
};
if (editMode == editMode_PickPiece){
_local5.fillRect(Defs.screenRect, 4281549909);
GraphicObjects.RenderAt(GraphicObjects.gfx_backgrounds, 0, _local5, -(scrollX), -(scrollY));
if (renderObjects){
Editor_RenderObjects();
};
if (renderMiniMap){
Editor_RenderMiniMap();
};
Editor_RenderLines();
};
if (editMode == editMode_Normal){
_local5.fillRect(Defs.screenRect, 4282668390);
GraphicObjects.RenderAt(GraphicObjects.gfx_backgrounds, 0, _local5, -(scrollX), -(scrollY));
if (renderObjects){
Editor_RenderObjects();
};
if (renderMiniMap){
Editor_RenderMiniMap();
};
Editor_RenderLines();
_local18 = Game.physObjs.GetByIndex(editor_currentPiece);
PhysObj.RenderAt(_local18, _local6, _local7, editor_currentPieceRot, _local5);
if (_local18 != null){
_local19 = Game.CreatePhysObjInstanceAt(_local18.name, _local8, _local9, editor_currentPieceRot, "");
Editor_GetNearbyGuidelines(_local19, 0, 0);
Editor_RenderNearbyGuidelines();
};
};
if (editMode == editMode_Adjust){
_local5.fillRect(Defs.screenRect, 4282668390);
GraphicObjects.RenderAt(GraphicObjects.gfx_backgrounds, 0, _local5, -(scrollX), -(scrollY));
if (renderObjects){
Editor_RenderObjects_AdjustMode();
};
if (renderMiniMap){
Editor_RenderMiniMap();
};
Editor_RenderLines();
if (currentAdjustObject != null){
Editor_GetNearbyGuidelines(currentAdjustObject, 0, 0);
Editor_RenderNearbyGuidelines();
};
};
if (editMode == editMode_Lines){
_local5.fillRect(Defs.screenRect, 4282668390);
GraphicObjects.RenderAt(GraphicObjects.gfx_backgrounds, 0, _local5, -(scrollX), -(scrollY));
if (renderObjects){
Editor_RenderObjects();
};
if (renderMiniMap){
Editor_RenderMiniMap();
};
Editor_RenderLines();
Editor_RenderLineToCursor();
};
RenderPanel_Editor();
}
public static function HitTestPhysObjGraphics(_arg1:Number, _arg2:Number):PhysObj_Instance{
var _local4:PhysObj_Instance;
var _local5:BitmapData;
var _local6:PhysObj;
var _local7:uint;
var _local3:Array = GetCurrentLevelInstances();
for each (_local4 in _local3) {
_local5 = Game.main.screenBD;
_local5.fillRect(Defs.screenRect, 0);
_local6 = Game.physObjs.FindByName(_local4.typeName);
PhysObj.RenderAt(_local6, (_local4.x - scrollX), (_local4.y - scrollY), _local4.rot, _local5);
_local7 = _local5.getPixel32(_arg1, _arg2);
if (_local7 != 0){
return (_local4);
};
};
return (null);
}
static function Lines_NewLine(){
var _local1:PhysLine = new PhysLine();
var _local2:Level = GetCurrentLevel();
_local2.lines.push(_local1);
currentLineIndex = (_local2.lines.length - 1);
}
static function Lines_ScrollToFirstPointOfSelectedLine(){
if (currentLineIndex == -1){
return;
};
var _local1:Level = GetCurrentLevel();
var _local2:Array = _local1.lines[currentLineIndex].points;
var _local3:Point = _local2[0];
scrollX = (_local3.x - (Defs.displayarea_w * 0.5));
scrollY = (_local3.y - (Defs.displayarea_h * 0.5));
}
static function SnapToObjects(_arg1:Number, _arg2:Number):Point{
var _local3:PhysObj;
var _local9:PhysEd_GuideLine;
var _local10:Point;
_local3 = Game.physObjs.GetByIndex(editor_currentPiece);
if (_local3 == null){
return (null);
};
var _local4:PhysObj_Instance = Game.CreatePhysObjInstanceAt(_local3.name, _arg1, _arg2, editor_currentPieceRot, "");
Editor_GetNearbyGuidelines(null, _arg1, _arg2, 20);
trace(("guidelines: " + guideLines.length));
var _local5:BitmapData = Game.main.screenBD;
var _local6 = 99999999;
var _local7:Number = _local6;
var _local8:Number = _local6;
for each (_local9 in guideLines) {
if (_local9.type == 1){
if (Math.abs((_local9.x0 - _arg1)) < _local7){
_local7 = _local9.x0;
};
} else {
if (Math.abs((_local9.y0 - _arg2)) < _local8){
_local8 = _local9.y0;
};
};
};
if (((!((_local7 == _local6))) && (!((_local8 == _local6))))){
_local10 = new Point(_local7, _local8);
return (_local10);
};
return (null);
}
static function CountLibraryPieces():int{
var _local2:PhysObj;
var _local1:int;
for each (_local2 in Game.physObjs.list) {
if (_local2.displayInLibrary){
_local1++;
};
};
return (_local1);
}
static function Editor_RenderObjects_AdjustMode(){
var _local3:PhysObj_Instance;
var _local4:PhysObj;
var _local1:Array = GetCurrentLevelInstances();
var _local2:BitmapData = Game.main.screenBD;
for each (_local3 in _local1) {
_local4 = Game.physObjs.FindByName(_local3.typeName);
if (_local3 == currentAdjustObject){
if ((updateTimer & 2)){
PhysObj.RenderAt(_local4, (_local3.x - scrollX), (_local3.y - scrollY), _local3.rot, _local2);
};
} else {
PhysObj.RenderAt(_local4, (_local3.x - scrollX), (_local3.y - scrollY), _local3.rot, _local2);
};
};
}
public static function ExportLevelAsXml(){
var _local4:int;
var _local5:Array;
var _local6:PhysObj_Instance;
var _local7:Point;
var _local8:PhysLine;
var _local9:int;
var _local10:int;
var _local11:Array;
var _local12:int;
var _local13:int;
var _local14:int;
var _local15:int;
var _local16:int;
var _local17:String;
var _local1:Level = GetCurrentLevel();
var _local2 = "";
var _local3 = "";
_local2 = (("<level name=\"" + _local1.name) + "\"");
_local2 = (_local2 + ((" category=\"" + _local1.category.toString()) + "\""));
_local2 = (_local2 + ((" fillframe=\"" + _local1.fillFrame.toString()) + "\""));
_local2 = (_local2 + ((" surfaceframe=\"" + _local1.surfaceFrame.toString()) + "\""));
_local2 = (_local2 + ((" surfacethickness=\"" + _local1.surfaceThickness.toString()) + "\""));
_local2 = (_local2 + ((" type=\"" + _local1.eventType.toString()) + "\""));
_local2 = (_local2 + ((" opponents=\"" + _local1.eventOpponentsString.toString()) + "\""));
_local2 = (_local2 + ((" win=\"" + _local1.eventWinParam.toString()) + "\""));
_local2 = (_local2 + ((" exclusivechar=\"" + _local1.exclusiveChar.toString()) + "\""));
_local2 = (_local2 + " >");
_local3 = (_local3 + (_local2 + "\n"));
trace(_local2);
_local2 = (((("<times gold=\"" + (_local1.goldTime / Defs.fps)) + "\" silver=\"") + (_local1.silverTime / Defs.fps)) + "\" />");
_local3 = (_local3 + (_local2 + "\n"));
trace(_local2);
for each (_local4 in _local1.helpscreenFrames) {
_local2 = (("<helpscreen frame=\"" + _local4) + "\" />");
_local3 = (_local3 + (_local2 + "\n"));
trace(_local2);
};
_local5 = GetCurrentLevelInstances();
for each (_local6 in _local5) {
_local2 = (((((((((("<obj type=\"" + _local6.typeName) + "\" x=\"") + _local6.x) + "\" y=\"") + _local6.y) + "\" rot=\"") + _local6.rot) + "\" params=\"") + _local6.initParams) + "\" />");
_local3 = (_local3 + (_local2 + "\n"));
trace(_local2);
};
for each (_local8 in _local1.lines) {
_local2 = (((((((("<line type=\"" + _local8.type) + "\" name=\"") + _local8.name) + "\" fill=\"") + _local8.fill) + "\" fillscale=\"") + _local8.fillScaleX) + "\">");
_local3 = (_local3 + (_local2 + "\n"));
trace(_local2);
_local11 = _local8.points;
_local12 = _local11.length;
_local13 = 10;
_local14 = (_local12 / _local13);
_local15 = (_local12 % _local13);
_local16 = 0;
_local9 = 0;
while (_local9 < _local14) {
_local17 = "<points a=\"";
_local10 = 0;
while (_local10 < _local13) {
var _temp1 = _local16;
_local16 = (_local16 + 1);
_local7 = _local11[_temp1];
_local17 = (_local17 + ((_local7.x + ",") + _local7.y));
if (_local10 != (_local13 - 1)){
_local17 = (_local17 + ", ");
};
_local10++;
};
_local17 = (_local17 + "\" />");
_local2 = _local17;
_local3 = (_local3 + (_local2 + "\n"));
trace(_local2);
_local9++;
};
if (_local15 != 0){
_local17 = "<points a=\"";
_local10 = 0;
while (_local10 < _local15) {
var _temp2 = _local16;
_local16 = (_local16 + 1);
_local7 = _local11[_temp2];
_local17 = (_local17 + ((_local7.x + ",") + _local7.y));
if (_local10 != (_local15 - 1)){
_local17 = (_local17 + ", ");
};
_local10++;
};
_local17 = (_local17 + "\" />");
_local2 = _local17;
_local3 = (_local3 + (_local2 + "\n"));
trace(_local2);
};
_local2 = "</line>";
_local3 = (_local3 + (_local2 + "\n"));
trace(_local2);
};
_local2 = "</level>";
_local3 = (_local3 + (_local2 + "\n"));
trace(_local2);
ExternalData.OutputString(_local3);
}
static function Lines_InsertPoint(_arg1:Number, _arg2:Number){
var _local7:PhysLine;
var _local8:int;
var _local9:Point;
var _local10:Array;
var _local11:Point;
var _local12:Point;
var _local13:Point;
var _local3:Level = GetCurrentLevel();
var _local4:int;
var _local5 = -1;
var _local6 = -1;
for each (_local7 in _local3.lines) {
_local8 = 0;
for each (_local9 in _local7.points) {
if (Utils.DistBetweenPoints(_local9.x, _local9.y, _arg1, _arg2) < 3){
_local5 = _local4;
_local6 = _local8;
};
_local8++;
};
_local4++;
};
if (((!((_local5 == -1))) && (!((_local6 == -1))))){
_local10 = _local3.lines[_local5].points;
if (_local6 == (_local10.length - 1)){
return;
};
_local11 = _local10[_local6].clone();
_local12 = _local10[(_local6 + 1)].clone();
_local13 = new Point(0, 0);
_local13.x = ((_local11.x + _local12.x) * 0.5);
_local13.y = ((_local11.y + _local12.y) * 0.5);
_local10.splice((_local6 + 1), 0, _local13);
_local3.lines[_local5].points = _local10;
};
}
static function GetNumLibraryPages():int{
var _local1:int = (boxNumW * boxNumH);
var _local2:int = CountLibraryPieces();
var _local3:int = (_local2 / _local1);
var _local4:int = (_local2 % _local1);
if (_local4 != 0){
_local3++;
};
return (_local3);
}
static function Editor_RenderObjects(){
var _local3:PhysObj_Instance;
var _local4:PhysObj;
var _local1:Array = GetCurrentLevelInstances();
var _local2:BitmapData = Game.main.screenBD;
for each (_local3 in _local1) {
_local4 = Game.physObjs.FindByName(_local3.typeName);
if (_local4 != null){
PhysObj.RenderAt(_local4, (_local3.x - scrollX), (_local3.y - scrollY), _local3.rot, _local2);
};
};
}
static function Editor_RenderLines_MiniMap(){
var _local5:PhysLine;
var _local6:uint;
var _local7:int;
var _local8:Point;
var _local9:Point;
var _local1:Number = (1 / 20);
var _local2:Level = GetCurrentLevel();
var _local3:BitmapData = Game.main.screenBD;
var _local4:int;
for each (_local5 in _local2.lines) {
_local6 = 4290822336;
if (_local4 == currentLineIndex){
_local6 = 4294967295;
};
if (_local5.points.length >= 2){
_local7 = 0;
while (_local7 < (_local5.points.length - 1)) {
_local8 = _local5.points[_local7].clone();
_local9 = _local5.points[(_local7 + 1)].clone();
_local8.x = (_local8.x * _local1);
_local8.y = (_local8.y * _local1);
_local9.x = (_local9.x * _local1);
_local9.y = (_local9.y * _local1);
_local8.y = (_local8.y + 240);
_local9.y = (_local9.y + 240);
Utils.RenderDotLine(_local3, (_local8.x - (scrollX * _local1)), (_local8.y - (scrollY * _local1)), (_local9.x - (scrollX * _local1)), (_local9.y - (scrollY * _local1)), 200, _local6);
_local7++;
};
};
_local4++;
};
}
static function Lines_DeletePoint(_arg1:Number, _arg2:Number){
var _local7:PhysLine;
var _local8:int;
var _local9:Point;
var _local10:Array;
var _local11:Array;
var _local12:int;
var _local13:Array;
var _local3:Level = GetCurrentLevel();
var _local4:int;
var _local5 = -1;
var _local6 = -1;
for each (_local7 in _local3.lines) {
_local8 = 0;
for each (_local9 in _local7.points) {
if (Utils.DistBetweenPoints(_local9.x, _local9.y, _arg1, _arg2) < 3){
_local5 = _local4;
_local6 = _local8;
};
_local8++;
};
_local4++;
};
if (((!((_local5 == -1))) && (!((_local6 == -1))))){
_local10 = _local3.lines[_local5].points;
_local11 = new Array();
_local12 = 0;
while (_local12 < _local10.length) {
if (_local12 != _local6){
_local11.push(_local10[_local12].clone());
};
_local12++;
};
_local3.lines[_local5].points = _local11;
_local13 = new Array();
for each (_local7 in _local3.lines) {
if (_local7.points.length != 0){
_local13.push(_local7.Clone());
} else {
currentLineIndex = -1;
};
};
_local3.lines = _local13;
currentPointIndex = -1;
};
}
static function Lines_AddPoint(_arg1:Number, _arg2:Number){
if (currentLineIndex == -1){
return;
};
var _local3:Level = GetCurrentLevel();
var _local4:Point = new Point(_arg1, _arg2);
var _local5:Array = _local3.lines[currentLineIndex].points;
_local5.push(_local4);
_local3.lines[currentLineIndex].points = _local5;
}
public static function ExportAllLevelsAsXml(){
var _local1:int;
var _local2:int = currentLevel;
_local1 = 0;
while (_local1 < Game.levels.length) {
currentLevel = _local1;
ExportLevelAsXml();
_local1++;
};
currentLevel = _local2;
}
static function Lines_SelectPoint(_arg1:Number, _arg2:Number){
var _local5:PhysLine;
var _local6:int;
var _local7:Point;
var _local3:Level = GetCurrentLevel();
var _local4:int;
currentLineIndex = -1;
currentPointIndex = -1;
for each (_local5 in _local3.lines) {
_local6 = 0;
for each (_local7 in _local5.points) {
if (Utils.DistBetweenPoints(_local7.x, _local7.y, _arg1, _arg2) < 3){
currentLineIndex = _local4;
currentPointIndex = _local6;
return;
};
_local6++;
};
_local4++;
};
}
public static function Editor_AddLevel():void{
var _local1:Level = new Level();
currentLevel = Game.levels.length;
Game.levels.push(_local1);
currentLineIndex = -1;
currentPointIndex = -1;
}
static function RemoveFromLevelInstances(_arg1:PhysObj_Instance){
var _local4:PhysObj_Instance;
var _local2:Array = GetCurrentLevelInstances();
var _local3:Array = new Array();
for each (_local4 in _local2) {
if (_local4 == _arg1){
} else {
_local3.push(_local4);
};
};
_local2 = _local3;
Game.levels[currentLevel].instances = _local2;
}
static function GetCurrentLevel():Level{
return (Game.levels[currentLevel]);
}
static function RenderPanel_Editor(){
var _local1:Number;
var _local2:Number;
var _local3:String;
var _local5:PhysLine;
var _local4:BitmapData = Game.main.screenBD;
if (editMode == editMode_Commands){
_local3 = "Editor: Mode = Commands";
_local1 = 10;
_local2 = 10;
GraphicObjects.RenderStringAt(_local4, GraphicObjects.gfx_font1, _local1, _local2, _local3, null);
_local1 = 50;
_local2 = 50;
_local3 = "1: Place Pieces";
GraphicObjects.RenderStringAt(_local4, GraphicObjects.gfx_font1, _local1, _local2, _local3, null);
_local2 = (_local2 + 15);
_local3 = "2: Library (cycle)";
GraphicObjects.RenderStringAt(_local4, GraphicObjects.gfx_font1, _local1, _local2, _local3, null);
_local2 = (_local2 + 15);
_local3 = "3: Eraser";
GraphicObjects.RenderStringAt(_local4, GraphicObjects.gfx_font1, _local1, _local2, _local3, null);
_local2 = (_local2 + 15);
_local3 = "4: Commands";
GraphicObjects.RenderStringAt(_local4, GraphicObjects.gfx_font1, _local1, _local2, _local3, null);
_local2 = (_local2 + 15);
_local3 = "5: Adjust Placement";
GraphicObjects.RenderStringAt(_local4, GraphicObjects.gfx_font1, _local1, _local2, _local3, null);
_local2 = (_local2 + 15);
_local3 = "6: Edit Lines";
GraphicObjects.RenderStringAt(_local4, GraphicObjects.gfx_font1, _local1, _local2, _local3, null);
_local2 = (_local2 + 15);
_local3 = "7: Pick Piece";
GraphicObjects.RenderStringAt(_local4, GraphicObjects.gfx_font1, _local1, _local2, _local3, null);
_local2 = (_local2 + 15);
_local3 = "8: Prev Level";
GraphicObjects.RenderStringAt(_local4, GraphicObjects.gfx_font1, _local1, _local2, _local3, null);
_local2 = (_local2 + 15);
_local3 = "9: Next Level";
GraphicObjects.RenderStringAt(_local4, GraphicObjects.gfx_font1, _local1, _local2, _local3, null);
_local2 = (_local2 + 15);
return;
};
if (editMode == editMode_Commands1){
_local3 = "Editor: Mode = Commands1";
_local1 = 10;
_local2 = 10;
GraphicObjects.RenderStringAt(_local4, GraphicObjects.gfx_font1, _local1, _local2, _local3, null);
_local1 = 50;
_local2 = 50;
_local3 = "1: Erase Level";
GraphicObjects.RenderStringAt(_local4, GraphicObjects.gfx_font1, _local1, _local2, _local3, null);
_local2 = (_local2 + 15);
_local3 = "2: Add New Level (at end)";
GraphicObjects.RenderStringAt(_local4, GraphicObjects.gfx_font1, _local1, _local2, _local3, null);
_local2 = (_local2 + 15);
_local3 = "4: Export current level";
GraphicObjects.RenderStringAt(_local4, GraphicObjects.gfx_font1, _local1, _local2, _local3, null);
_local2 = (_local2 + 15);
_local3 = "5: Export all levels";
GraphicObjects.RenderStringAt(_local4, GraphicObjects.gfx_font1, _local1, _local2, _local3, null);
_local2 = (_local2 + 15);
_local3 = "9: Quit To Game";
GraphicObjects.RenderStringAt(_local4, GraphicObjects.gfx_font1, _local1, _local2, _local3, null);
_local2 = (_local2 + 15);
return;
};
_local3 = "Editor: Mode = ";
if (editMode == editMode_Normal){
_local3 = (_local3 + "Placement");
};
if (editMode == editMode_Library){
_local3 = (_local3 + ((("Library Page " + int((library_page + 1)).toString()) + " / ") + int(GetNumLibraryPages()).toString()));
};
if (editMode == editMode_Eraser){
_local3 = (_local3 + "Eraser");
};
if (editMode == editMode_Adjust){
_local3 = (_local3 + "Adjust");
};
if (editMode == editMode_Lines){
_local3 = (_local3 + "Lines");
};
if (editMode == editMode_PickPiece){
_local3 = (_local3 + "PickPiece");
};
_local1 = 10;
_local2 = 10;
GraphicObjects.RenderStringAt(_local4, GraphicObjects.gfx_font1, _local1, _local2, _local3, null);
_local2 = (_local2 + 15);
if (editMode == editMode_Lines){
_local3 = "1: Select Line (hold and click on point)";
GraphicObjects.RenderStringAt(_local4, GraphicObjects.gfx_font1, _local1, _local2, _local3, null);
_local2 = (_local2 + 15);
_local3 = "2: Delete Point (hold and click to delete)";
GraphicObjects.RenderStringAt(_local4, GraphicObjects.gfx_font1, _local1, _local2, _local3, null);
_local2 = (_local2 + 15);
_local3 = "3: Insert Point after clicked point";
GraphicObjects.RenderStringAt(_local4, GraphicObjects.gfx_font1, _local1, _local2, _local3, null);
_local2 = (_local2 + 15);
_local3 = "4: Select Point for editing with arrow keys";
GraphicObjects.RenderStringAt(_local4, GraphicObjects.gfx_font1, _local1, _local2, _local3, null);
_local2 = (_local2 + 15);
_local3 = "5: New line (hold and click new point)";
GraphicObjects.RenderStringAt(_local4, GraphicObjects.gfx_font1, _local1, _local2, _local3, null);
_local2 = (_local2 + 15);
_local3 = "6: Subdivide between this point and selected point";
GraphicObjects.RenderStringAt(_local4, GraphicObjects.gfx_font1, _local1, _local2, _local3, null);
_local2 = (_local2 + 15);
_local3 = "7: Push line points";
GraphicObjects.RenderStringAt(_local4, GraphicObjects.gfx_font1, _local1, _local2, _local3, null);
_local2 = (_local2 + 15);
_local3 = "8: Change Type";
GraphicObjects.RenderStringAt(_local4, GraphicObjects.gfx_font1, _local1, _local2, _local3, null);
_local2 = (_local2 + 15);
_local3 = "[ and ]: Move to first / last point of selected line";
GraphicObjects.RenderStringAt(_local4, GraphicObjects.gfx_font1, _local1, _local2, _local3, null);
_local2 = (_local2 + 15);
_local3 = ((("ScrollPos: " + scrollX) + " ") + scrollY);
GraphicObjects.RenderStringAt(_local4, GraphicObjects.gfx_font1, _local1, _local2, _local3, null);
_local2 = (_local2 + 15);
_local3 = ((("CursorPos: " + int((MouseControl.x + scrollX))) + " ") + int((MouseControl.y + scrollY)));
GraphicObjects.RenderStringAt(_local4, GraphicObjects.gfx_font1, _local1, _local2, _local3, null);
_local2 = (_local2 + 15);
if (currentLineIndex != -1){
_local5 = GetCurrentLevel().lines[currentLineIndex];
_local3 = ("Type: " + _local5.type);
GraphicObjects.RenderStringAt(_local4, GraphicObjects.gfx_font1, _local1, _local2, _local3, null);
_local2 = (_local2 + 15);
};
};
if (editMode == editMode_Adjust){
_local3 = "Shift + Arrows: Move Piece";
GraphicObjects.RenderStringAt(_local4, GraphicObjects.gfx_font1, _local1, _local2, _local3, null);
_local2 = (_local2 + 15);
_local3 = "6: Rotate Left";
GraphicObjects.RenderStringAt(_local4, GraphicObjects.gfx_font1, _local1, _local2, _local3, null);
_local2 = (_local2 + 15);
_local3 = "7: Rotate Right";
GraphicObjects.RenderStringAt(_local4, GraphicObjects.gfx_font1, _local1, _local2, _local3, null);
_local2 = (_local2 + 15);
};
if (editMode == editMode_Normal){
_local3 = ((("ScrollPos: " + scrollX) + " ") + scrollY);
GraphicObjects.RenderStringAt(_local4, GraphicObjects.gfx_font1, _local1, _local2, _local3, null);
_local2 = (_local2 + 15);
_local3 = ((("CursorPos: " + int((MouseControl.x + scrollX))) + " ") + int((MouseControl.y + scrollY)));
GraphicObjects.RenderStringAt(_local4, GraphicObjects.gfx_font1, _local1, _local2, _local3, null);
_local2 = (_local2 + 15);
_local3 = "1: Snap to nearby objects";
GraphicObjects.RenderStringAt(_local4, GraphicObjects.gfx_font1, _local1, _local2, _local3, null);
_local2 = (_local2 + 15);
};
if (editMode == editMode_Adjust){
if (currentAdjustObject != null){
_local3 = ((((("Pos: " + currentAdjustObject.x) + " ") + currentAdjustObject.y) + " Rot: ") + currentAdjustObject.rot);
GraphicObjects.RenderStringAt(_local4, GraphicObjects.gfx_font1, _local1, _local2, _local3, null);
_local2 = (_local2 + 15);
};
};
_local1 = 350;
_local3 = ("Level=" + currentLevel.toString());
GraphicObjects.RenderStringAt(_local4, GraphicObjects.gfx_font1, _local1, _local2, _local3, null);
}
public static function Editor_NextLevel():void{
currentLevel++;
if (currentLevel > (Game.levels.length - 1)){
currentLevel = (Game.levels.length - 1);
};
currentLineIndex = -1;
currentPointIndex = -1;
}
}
}//package
class PhysEd_GuideLine {
private var level:Boolean;
private var y1:Number;
private var y0:Number;
private var x0:Number;
private var x1:Number;
private var type:int;
private function PhysEd_GuideLine(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Boolean){
type = _arg4;
level = _arg5;
if (type == 0){
x0 = _arg1;
x1 = _arg2;
y0 = _arg3;
y1 = _arg3;
} else {
y0 = _arg1;
y1 = _arg2;
x0 = _arg3;
x1 = _arg3;
};
}
}
Section 213
//PhysLine (PhysLine)
package {
import flash.display.*;
import flash.geom.*;
public class PhysLine {
var fill:int;
public var points:Array;
var name:String;
var fillScaleX:Number;
var fillScaleY:Number;
var type:int;
var catmullRomLength:Number;
public function PhysLine(){
name = "undefined";
type = 0;
points = new Array();
fill = 0;
fillScaleX = 1;
fillScaleY = 1;
}
function PointOnCurve(_arg1:Number, _arg2:Point, _arg3:Point, _arg4:Point, _arg5:Point):Point{
var _local6:Point = new Point();
var _local7:Number = (_arg1 * _arg1);
var _local8:Number = (_local7 * _arg1);
_local6.x = (0.5 * ((((2 * _arg3.x) + ((-(_arg2.x) + _arg4.x) * _arg1)) + (((((2 * _arg2.x) - (5 * _arg3.x)) + (4 * _arg4.x)) - _arg5.x) * _local7)) + ((((-(_arg2.x) + (3 * _arg3.x)) - (3 * _arg4.x)) + _arg5.x) * _local8)));
_local6.y = (0.5 * ((((2 * _arg3.y) + ((-(_arg2.y) + _arg4.y) * _arg1)) + (((((2 * _arg2.y) - (5 * _arg3.y)) + (4 * _arg4.y)) - _arg5.y) * _local7)) + ((((-(_arg2.y) + (3 * _arg3.y)) - (3 * _arg4.y)) + _arg5.y) * _local8)));
return (_local6);
}
public function DrawCatmullRom(_arg1:BitmapData, _arg2:uint, _arg3:Number, _arg4:Number){
var _local6:Number;
var _local7:Point;
var _local5:int = GetNumPoints();
if (_local5 < 4){
return;
};
_local6 = 0;
while (_local6 < 1) {
_local7 = GetPointOnCatmullRom(_local6);
_arg1.setPixel32((_local7.x + _arg3), (_local7.y + _arg4), _arg2);
_local6 = (_local6 + 0.001);
};
}
public function GetPointOnCatmullRom(_arg1:Number):Point{
var _local4:Point;
var _local5:Point;
var _local6:Point;
var _local7:Point;
return (GetPointOnCatmullRomLoop(_arg1));
}
public function GetPointOnCatmullRomLoop(_arg1:Number):Point{
var _local4:Point;
var _local5:Point;
var _local6:Point;
var _local7:Point;
var _local2:uint = GetNumPoints();
if (_local2 < 4){
return (new Point(0, 0));
};
var _local3:int = _local2;
var _local8:Number = (Number(_local3) * _arg1);
var _local9:int = _local8;
var _local10:int = (_local9 - 1);
var _local11:int = _local9;
var _local12:int = (_local9 + 1);
var _local13:int = (_local9 + 2);
if (_local10 < 0){
_local10 = (_local10 + _local2);
};
if (_local12 >= _local2){
_local12 = (_local12 - _local2);
};
if (_local13 >= _local2){
_local13 = (_local13 - _local2);
};
_local4 = points[_local10];
_local5 = points[_local11];
_local6 = points[_local12];
_local7 = points[_local13];
var _local14:int = (_local9 + 1);
var _local15:Number = ((1 / Number(_local3)) * _local9);
var _local16:Number = ((1 / Number(_local3)) * _local14);
var _local17:Number = ((1 / (_local16 - _local15)) * (_arg1 - _local15));
var _local18:Point = PointOnCurve(_local17, _local4, _local5, _local6, _local7);
return (_local18);
}
public function GetNumPoints():int{
return (points.length);
}
public function GetInterpolatedPoint(_arg1:Number, _arg2:Boolean, _arg3:int):Point{
var _local4:int;
var _local5:Number;
var _local6:int;
var _local7:int;
var _local8:Number;
var _local9:Number;
var _local10:Number;
var _local11:Number;
var _local12:Point;
if (_arg3 == 1){
if (_arg2){
return (GetPointOnCatmullRomLoop(_arg1));
};
return (GetPointOnCatmullRom(_arg1));
};
if (_arg2 == true){
_local4 = points.length;
_local5 = (1 / _local4);
_local6 = Math.floor((_local4 * _arg1));
_local7 = ((_local6 + 1) % _local4);
_local8 = (_local6 * _local5);
_local9 = ((_local6 + 1) * _local5);
_local10 = Utils.ScaleTo(points[_local6].x, points[_local7].x, _local8, _local9, _arg1);
_local11 = Utils.ScaleTo(points[_local6].y, points[_local7].y, _local8, _local9, _arg1);
_local12 = new Point(_local10, _local11);
return (_local12);
};
_local4 = points.length;
_local5 = (1 / (_local4 - 1));
_local6 = Math.floor(((_local4 - 1) * _arg1));
_local7 = ((_local6 + 1) % _local4);
_local8 = (_local6 * _local5);
_local9 = ((_local6 + 1) * _local5);
_local10 = Utils.ScaleTo(points[_local6].x, points[_local7].x, _local8, _local9, _arg1);
_local11 = Utils.ScaleTo(points[_local6].y, points[_local7].y, _local8, _local9, _arg1);
_local12 = new Point(_local10, _local11);
return (_local12);
}
public function SetPointArray(_arg1:Array){
points = _arg1;
}
public function Clone():PhysLine{
var _local2:Point;
var _local1:PhysLine = new PhysLine();
_local1.name = name;
_local1.type = type;
_local1.fill = fill;
_local1.fillScaleX = fillScaleX;
_local1.fillScaleY = fillScaleY;
for each (_local2 in points) {
_local1.points.push(_local2.clone());
};
return (_local1);
}
public function CalculateCatmullRomLength(){
var _local2:int;
var _local4:Number;
var _local5:Point;
var _local6:Point;
var _local7:Point;
var _local1:Array = new Array();
var _local3:int = GetNumPoints();
if (_local3 < 4){
catmullRomLength = 0;
} else {
_local4 = 0;
while (_local4 < 1) {
_local5 = GetPointOnCatmullRom(_local4);
_local1.push(_local5);
_local4 = (_local4 + 0.025);
};
};
catmullRomLength = 0;
_local2 = 0;
while (_local2 < (_local1.length - 2)) {
_local6 = _local1[_local2];
_local7 = _local1[(_local2 + 1)];
catmullRomLength = (catmullRomLength + Utils.DistBetweenPoints(_local6.x, _local6.y, _local7.x, _local7.y));
_local2++;
};
_local1 = null;
}
}
}//package
Section 214
//PhysObj (PhysObj)
package {
import flash.display.*;
import flash.geom.*;
import Box2D.Common.Math.*;
public class PhysObj {
public var bodies:Array;
public var joints:Array;
public var name:String;
public var initFunctionName:String;
public var displayInLibrary:Boolean;
public var hitballsound:int;
public function PhysObj(){
hitballsound = 0;
}
function PointFromString(_arg1:String):Point{
var _local2:Array = _arg1.split(",");
var _local3:Point = new Point(0, 0);
if (_local2.length != 2){
trace(((("PointfromString. Error, numpoints=" + _local2.length) + " ") + _arg1));
return (_local3);
};
_local3.x = Number(_local2[0]);
_local3.y = Number(_local2[1]);
return (_local3);
}
function PointArrayFromString(_arg1:String):Array{
var _local4:int;
var _local6:Point;
var _local2:Array = new Array();
var _local3:Array = _arg1.split(",");
if ((((_local3.length < 2)) || (((_local3.length % 2) == 1)))){
trace(((("PointArrayFromString. Error, numpoints=" + _local3.length) + " , string= ") + _arg1));
return (_local2);
};
var _local5:int = (_local3.length / 2);
_local4 = 0;
while (_local4 < _local5) {
_local6 = new Point(0, 0);
_local6.x = Number(_local3[((_local4 * 2) + 0)]);
_local6.y = Number(_local3[((_local4 * 2) + 1)]);
_local2.push(_local6);
_local4++;
};
return (_local2);
}
public function BodyIndexFromName(_arg1:String):int{
var _local3:PhysObj_Body;
var _local2:int;
while (_local2 < bodies.length) {
_local3 = bodies[_local2];
if (_local3.name == _arg1){
return (_local2);
};
_local2++;
};
trace(("ERROR PhysObj BodyIndexFromName " + _arg1));
return (0);
}
function BooleanFromString(_arg1:String):Boolean{
var _local2:Boolean;
_arg1 = _arg1.toUpperCase();
if (_arg1 == "1"){
_local2 = true;
};
if (_arg1 == "TRUE"){
_local2 = true;
};
return (_local2);
}
public function JointIndexFromName(_arg1:String):int{
var _local3:PhysObj_Joint;
var _local2:int;
while (_local2 < joints.length) {
_local3 = joints[_local2];
if (_local3.name == _arg1){
return (_local2);
};
_local2++;
};
trace(("ERROR PhysObj JointIndexFromName " + _arg1));
return (0);
}
public function FromXml(_arg1:XML):void{
var _local2:int;
var _local3:int;
var _local4:int;
var _local5:String;
var _local6:XML;
var _local7:PhysObj_Body;
var _local8:XML;
var _local9:PhysObj_Graphic;
var _local10:XML;
var _local11:PhysObj_Shape;
var _local12:Point;
var _local13:XML;
var _local14:PhysObj_Joint;
bodies = new Array();
joints = new Array();
name = _arg1.@name;
displayInLibrary = XmlHelper.GetAttrBoolean(_arg1.@inlibrary, false);
initFunctionName = XmlHelper.GetAttrString(_arg1.@initfunction, null);
_local2 = 0;
while (_local2 < _arg1.sound.length()) {
hitballsound = int(_arg1.sound[_local2].@hitball);
_local2++;
};
_local2 = 0;
while (_local2 < _arg1.body.length()) {
_local6 = _arg1.body[_local2];
_local7 = new PhysObj_Body();
_local7.name = _local6.@name;
_local7.fixed = BooleanFromString(_local6.@fixed);
_local7.sensor = BooleanFromString(_local6.@sensor);
_local7.pos = PointFromString(_local6.@pos);
_local7.linearDamping = XmlHelper.GetAttrNumber(_local6.@lineardamping, _local7.linearDamping);
_local7.angularDamping = XmlHelper.GetAttrNumber(_local6.@angulardamping, _local7.angularDamping);
_local3 = 0;
while (_local3 < _local6.graphic.length()) {
_local8 = _local6.graphic[_local3];
_local9 = new PhysObj_Graphic();
_local9.goInitFuntion = _local8.@gameobjfunction;
_local9.goInitFuntionVarString = _local8.@gameobjvars;
_local9.graphicName = _local8.@clip;
_local9.graphicID = 0;
_local9.frame = (XmlHelper.GetAttrInt(_local8.@frame) - 1);
_local9.offset = PointFromString(_local8.@pos);
_local9.zoffset = XmlHelper.GetAttrNumber(_local8.@zoffset, 0);
_local9.hasShadow = XmlHelper.GetAttrBoolean(_local8.@shadow, true);
_local9.rot = Number(_local8.@rot);
_local9.Calculate();
_local7.graphics.push(_local9);
_local3++;
};
_local3 = 0;
while (_local3 < _local6.shape.length()) {
_local10 = _local6.shape[_local3];
_local11 = new PhysObj_Shape();
_local11.name = _local10.@name;
_local5 = _local10.@type;
_local12 = PointFromString(_local10.@col);
_local11.collisionCategory = XmlHelper.GetAttrInt(_local12.x);
_local11.collisionMask = XmlHelper.GetAttrInt(_local12.y);
_local11.density = XmlHelper.GetAttrNumber(_local10.@density);
_local11.friction = XmlHelper.GetAttrNumber(_local10.@friction);
_local11.restitution = XmlHelper.GetAttrNumber(_local10.@restitution);
if (_local5 == "circle"){
_local11.type = PhysObj_Shape.Type_Circle;
_local11.circle_pos = PointFromString(_local10.@pos);
_local11.circle_radius = XmlHelper.GetAttrNumber(_local10.@radius);
} else {
if (_local5 == "poly"){
_local11.type = PhysObj_Shape.Type_Poly;
_local11.poly_points = PointArrayFromString(_local10.@vertices);
_local11.poly_rot = Utils.DegToRad(XmlHelper.GetAttrNumber(_local10.@rot));
};
};
_local11.Caclulate();
_local7.shapes.push(_local11);
_local3++;
};
bodies.push(_local7);
_local2++;
};
_local2 = 0;
while (_local2 < _arg1.joint.length()) {
_local13 = _arg1.joint[_local2];
_local14 = new PhysObj_Joint();
_local14.name = _local13.@name;
_local14.obj0Name = _local13.@body0;
_local14.obj1Name = _local13.@body1;
_local5 = _local13.@type;
if (_local5 == "rev"){
_local14.type = PhysObj_Joint.Type_Rev;
_local14.rev_pos = PointFromString(_local13.@pos);
_local14.rev_enableLimit = BooleanFromString(_local13.@enablelimit);
_local14.rev_lowerAngle = Utils.DegToRad(XmlHelper.GetAttrNumber(_local13.@lowerangle));
_local14.rev_upperAngle = Utils.DegToRad(XmlHelper.GetAttrNumber(_local13.@upperangle));
_local14.rev_enableMotor = BooleanFromString(_local13.@enablemotor);
_local14.rev_motorSpeed = Number(_local13.@motorspeed);
_local14.rev_maxMotorTorque = Number(_local13.@maxmotortorque);
} else {
if (_local5 == "distance"){
_local14.type = PhysObj_Joint.Type_Distance;
_local14.dist_pos0 = PointFromString(_local13.@pos);
_local14.dist_pos1 = PointFromString(_local13.@pos1);
_local14.dist_distance = Number(_local13.@distance);
} else {
if (_local5 == "mouse"){
_local14.type = PhysObj_Joint.Type_Mouse;
} else {
if (_local5 == "prismatic"){
_local14.type = PhysObj_Joint.Type_Prismatic;
_local14.prism_pos = PointFromString(_local13.@pos);
_local14.prism_enableLimit = BooleanFromString(_local13.@enablelimit);
_local14.prism_lowerTranslation = Number(_local13.@lowertranslation);
_local14.prism_upperTranslation = Number(_local13.@uppertranslation);
_local14.prism_enableMotor = BooleanFromString(_local13.@enablemotor);
_local14.prism_axisangle = (Number(_local13.@axisangle) - Number(90));
_local14.prism_motorSpeed = Number(_local13.@motorspeed);
_local14.prism_maxMotorForce = Number(_local13.@maxmotorforce);
};
};
};
};
joints.push(_local14);
_local2++;
};
}
public function BodyFromName(_arg1:String):PhysObj_Body{
var _local3:PhysObj_Body;
var _local2:int;
while (_local2 < bodies.length) {
_local3 = bodies[_local2];
if (_local3.name == _arg1){
return (_local3);
};
_local2++;
};
trace(("ERROR PhysObj BodyFromName " + _arg1));
return (null);
}
public static function RenderAt(_arg1:PhysObj, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:BitmapData, _arg6:Boolean=true, _arg7:Number=1){
var _local10:Number;
var _local11:Number;
var _local12:Matrix;
var _local13:PhysObj_Body;
var _local14:PhysObj_Graphic;
var _local15:Point;
var _local16:Matrix;
var _local17:Number;
var _local18:int;
var _local19:int;
var _local20:PhysObj_Shape;
var _local21:Number;
var _local22:Array;
var _local23:int;
var _local24:b2Vec2;
var _local25:b2Vec2;
var _local26:Matrix;
var _local27:Point;
var _local28:Point;
var _local8:Boolean = _arg6;
var _local9:Number = _arg7;
_local10 = _arg2;
_local11 = _arg3;
for each (_local13 in _arg1.bodies) {
for each (_local14 in _local13.graphics) {
_local15 = new Point((_local13.pos.x + _local14.offset.x), (_local13.pos.y + _local14.offset.y));
_local16 = new Matrix();
_local16.rotate(Utils.DegToRad(_arg4));
_local16.scale(_local9, _local9);
_local15 = _local16.transformPoint(_local15);
_local10 = ((_arg2 * _local9) + _local15.x);
_local11 = ((_arg3 * _local9) + _local15.y);
_local17 = Utils.DegToRad((_arg4 + _local14.rot));
GraphicObjects.RenderAtRotScaled(_local14.graphicID, _local14.frame, _arg5, _local10, _local11, false, _local9, _local17);
};
if (_local8){
for each (_local20 in _local13.shapes) {
if (_local20.type == PhysObj_Shape.Type_Circle){
_local21 = _local20.circle_radius;
Utils.RenderCircle(_arg5, (_arg2 + _local20.circle_pos.x), (_arg3 + _local20.circle_pos.y), _local21, 4294967295);
};
if (_local20.type == PhysObj_Shape.Type_Poly){
_local22 = _local20.poly_points;
_local23 = _local20.poly_points.length;
_local18 = 0;
while (_local18 < _local23) {
_local19 = (_local18 + 1);
if (_local19 >= _local23){
_local19 = 0;
};
_local24 = new b2Vec2(_local22[_local18].x, _local22[_local18].y);
_local25 = new b2Vec2(_local22[_local19].x, _local22[_local19].y);
_local26 = new Matrix();
_local26.rotate(Utils.DegToRad(_arg4));
_local27 = new Point(_local24.x, _local24.y);
_local28 = new Point(_local25.x, _local25.y);
_local27 = _local26.transformPoint(_local27);
_local28 = _local26.transformPoint(_local28);
_local24.x = _local27.x;
_local24.y = _local27.y;
_local25.x = _local28.x;
_local25.y = _local28.y;
_local24.x = (_local24.x + _arg2);
_local25.x = (_local25.x + _arg2);
_local24.y = (_local24.y + _arg3);
_local25.y = (_local25.y + _arg3);
Utils.RenderDotLine(_arg5, _local24.x, _local24.y, _local25.x, _local25.y, 50, 4294967295);
_local18++;
};
};
};
};
};
}
}
}//package
Section 215
//PhysObj_Body (PhysObj_Body)
package {
import flash.geom.*;
public class PhysObj_Body {
public var angularDamping:Number;
public var name:String;
public var graphics:Array;
public var pos:Point;
public var shapes:Array;
public var fixed:Boolean;
public var sensor:Boolean;
public var linearDamping:Number;
public function PhysObj_Body(){
shapes = new Array();
graphics = new Array();
name = "";
pos = new Point();
fixed = true;
sensor = false;
linearDamping = 0.1;
angularDamping = 0.1;
}
}
}//package
Section 216
//PhysObj_BodyUserData (PhysObj_BodyUserData)
package {
public class PhysObj_BodyUserData {
public var type:String;
public var instance:PhysObj_Instance;
public var gameObjectID:int;
public var bodyName:String;
public function PhysObj_BodyUserData(){
type = "";
bodyName = "";
gameObjectID = -1;
instance = null;
}
}
}//package
Section 217
//PhysObj_Graphic (PhysObj_Graphic)
package {
import flash.geom.*;
public class PhysObj_Graphic {
public var offset:Point;
public var graphicID:int;
public var hasShadow:Boolean;
public var graphicName:String;
public var frame:int;
public var rot:Number;
public var goInitFuntion:String;
public var zoffset:Number;
public var goInitFuntionVarString:String;
public function PhysObj_Graphic(){
graphicName = "";
graphicID = 0;
frame = 0;
offset = new Point(0, 0);
rot = 0;
goInitFuntion = "";
goInitFuntionVarString = "";
zoffset = 0;
hasShadow = true;
}
public function Calculate(){
graphicID = GraphicObjects.GetIndexByName(graphicName);
if (frame < 0){
trace("ERROR: PhysObj Graphic has negative frame. Are you counting from 0 or 1?");
frame = 0;
};
}
}
}//package
Section 218
//PhysObj_Instance (PhysObj_Instance)
package {
import flash.geom.*;
import Box2D.Common.Math.*;
import Box2D.Collision.*;
import Box2D.Dynamics.*;
import Box2D.Dynamics.Joints.*;
import Box2D.Collision.Shapes.*;
import Box2D.Common.*;
import Box2D.Dynamics.Contacts.*;
public class PhysObj_Instance {
var paramValues:Array;
public var removeFlag:Boolean;
var generator_object:String;
var switchName1:String;
public var collideFunction:Function;
var gateTime:int;
public var hitballsound:int;
var stopcount:int;
var hosedir:int;// = 0
var hoseID:int;// = 0
public var x:Number;
public var y:Number;
var switch_timer:int;
var magnet_time:int;
public var doSwitchFunction:Function;
var controlMode:int;
var posy:Number;
var posx:Number;
var lineResetAtEnd:Boolean;
var lineSpeed:Number;
public var initParams:String;
var generator_time:int;
var paramNames:Array;
var animal_velX:Number;
var lineLoop:Boolean;
public var instanceName:String;
var gateVel:Number;
var animal_index:int;
public var collideWithInstance:PhysObj_Instance;
var guineaPig_type:int;
var mover_xvel:Number;
public var typeName:String;
var animal_posX:Number;
var animal_posY:Number;
var cannon_firing:Boolean;
var mover_x0:Number;
var mover_x1:Number;
var cannon_angvel:Number;
var colflags:int;
var gateMode:String;
var animal_rot:Number;
var portalName:String;
public var joints:Array;
var oldx:Number;
var oldy:Number;
public var switchFunction:Function;
public var type:int;
var lineIndex:int;
public var preUpdateFunction:Function;
public var timer:int;
var mincer_numtogenerate:int;
var magnet_mode:String;
var lineLinearPos:Number;
var cannon_maxang:Number;
var cannon_ang:Number;
var ball_hitcount:int;
var cannon_mode:String;
public var bodies:Array;
public var updateFunction:Function;
public var collidetimer:int;
public var rot:Number;
var cannon_minang:Number;
var magnet_polarity:Boolean;
var switchName:String;
public var updateFunctionName:String;
public function PhysObj_Instance(){
bodies = new Array();
joints = new Array();
timer = 0;
collidetimer = 0;
collideFunction = null;
updateFunction = null;
preUpdateFunction = null;
switchFunction = null;
doSwitchFunction = null;
hitballsound = 0;
removeFlag = false;
updateFunctionName = null;
initParams = "";
type = 0;
}
public function SetLinearVelocity(_arg1:Number, _arg2:Number):void{
var _local3:b2Body;
for each (_local3 in bodies) {
_local3.SetLinearVelocity(new b2Vec2(_arg1, _arg2));
};
}
function UpdatePhysObj_Mover(){
var _local1:b2Vec2 = GetBodyWorldPos(0);
this.ApplyForce(mover_xvel, 0);
this.LimitLinearVelocity(10);
if (mover_xvel > 0){
if (_local1.x > mover_x1){
mover_xvel = (mover_xvel * -1);
};
} else {
if (_local1.x < mover_x0){
mover_xvel = (mover_xvel * -1);
};
};
}
function SwitchFunction_Path_2way(){
if (controlMode == 0){
controlMode = 1;
} else {
if (controlMode == 1){
controlMode = 2;
} else {
controlMode = 1;
};
};
}
function UpdatePhysObj_Path_2way(){
var _local1:Point;
if (controlMode == 0){
_local1 = UpdateLine(0);
SetBodyXForm(0, (_local1.x * Game.w2p), (_local1.y * Game.w2p), 0);
} else {
if (controlMode == 1){
_local1 = UpdateLine(lineSpeed);
SetBodyXForm(0, (_local1.x * Game.w2p), (_local1.y * Game.w2p), 0);
} else {
if (controlMode == 2){
_local1 = UpdateLine(-(lineSpeed));
SetBodyXForm(0, (_local1.x * Game.w2p), (_local1.y * Game.w2p), 0);
};
};
};
}
function SwitchedPhysObj_Switch():Boolean{
var _local1:GameObj = GetGameObject(0);
if (_local1.controlMode == 0){
SoundPlayer.Play("switchwav");
_local1.controlMode = 1;
return (true);
};
return (false);
}
function InitPhysObj_Generator(){
updateFunction = UpdatePhysObj_Generator;
GetParams(initParams);
generator_time = (GetParamNumber("delay") * Defs.fps);
generator_object = GetParam("object");
timer = generator_time;
}
function InitPhysObj_Breakable(){
colflags = 2;
updateFunction = UpdatePhysObj_Breakable;
}
public function SetXForm(_arg1:Number, _arg2:Number, _arg3:Number):void{
var _local5:b2Body;
var _local4:b2Vec2 = new b2Vec2(_arg1, _arg2);
for each (_local5 in bodies) {
_local5.SetXForm(_local4, _arg3);
};
}
function UpdatePhysObj_TwoWaySwitch(){
var _local1:GameObj = GetGameObject(0);
if (controlMode == 0){
_local1.controlMode = 2;
} else {
_local1.controlMode = 1;
};
}
public function ApplyForce(_arg1:Number, _arg2:Number):void{
var _local3:b2Body;
for each (_local3 in bodies) {
_local3.ApplyForce(new b2Vec2(_arg1, _arg2), _local3.GetWorldCenter());
};
}
function GetLineIndexByName(_arg1:String):int{
var _local4:PhysLine;
var _local2:Level = Game.GetCurrentLevel();
var _local3:int;
for each (_local4 in _local2.lines) {
if (_local4.name == _arg1){
return (_local3);
};
_local3++;
};
return (-1);
}
public function SetAngularVelocity(_arg1:int, _arg2:Number):void{
var _local3:b2Body;
if (_arg1 == -1){
for each (_local3 in bodies) {
_local3.SetAngularVelocity(_arg2);
};
} else {
_local3 = bodies[_arg1];
_local3.SetAngularVelocity(_arg2);
};
}
public function GetNumBodies():int{
return (bodies.length);
}
function GetParams(_arg1:String):void{
var _local3:String;
var _local4:Array;
paramNames = new Array();
paramValues = new Array();
_arg1 = Utils.RemoveWhiteSpace(_arg1);
_arg1 = _arg1.toLowerCase();
var _local2:Array = _arg1.split(",");
trace(_local2.length);
for each (_local3 in _local2) {
_local4 = _local3.split("=");
paramNames.push(_local4[0]);
paramValues.push(_local4[1]);
};
}
function UpdatePhysObj_Animal(){
var _local2:Number;
var _local3:b2Vec2;
var _local4:Number;
var _local5:int;
var _local6:GameObj;
var _local1:b2Vec2 = GetBodyWorldPos(0);
if (controlMode == 0){
animal_posY = ((Game.scrollY + 40) * Game.w2p);
SetBodyXForm(-1, animal_posX, animal_posY, animal_rot);
animal_posX = (animal_posX + animal_velX);
_local2 = (700 * Game.w2p);
if (animal_posX >= _local2){
Game.numAnimalsReady--;
Game.numBallsActive--;
collideFunction = Game.RemoveObj_Standard;
collidetimer = 10;
};
};
if (controlMode == 1){
timer--;
if (timer <= 0){
timer = 0;
_local3 = GetBodyLinearVelocity(0);
if (_local3.Length() < 0.2){
SetBodyFixed(-1, true);
controlMode = 2;
};
};
};
if (controlMode == 2){
_local4 = (_local1.y * Game.p2w);
if (_local4 < Game.currentHighestPoint){
Game.currentHighestPoint = _local4;
};
};
if (controlMode == 2){
if (_local1.y > ((Game.scrollY + 900) * Game.w2p)){
Game.numBallsActive--;
collideFunction = Game.RemoveObj_Standard;
collidetimer = 10;
trace("Animal Removed");
};
};
if (controlMode == 1){
if (_local1.y > ((Game.scrollY + 800) * Game.w2p)){
Game.numBallsActive--;
collideFunction = Game.RemoveObj_Standard;
collidetimer = 10;
_local5 = SoundPlayer.GetId("snd_b01");
_local5 = (_local5 + animal_index);
SoundPlayer.PlayById(_local5, 0.5);
trace("Animal Lost");
Game.numAnimalsLost++;
_local6 = GameObjects.AddObj((_local1.x * Game.p2w), Game.scrollY, 0);
_local6.InitAnimalLost();
};
};
}
function InitPhysObj_Animal(){
type = 1;
updateFunction = UpdatePhysObj_Animal;
controlMode = 0;
animal_posX = (-50 * Game.w2p);
animal_posY = (20 * Game.w2p);
animal_velX = (4 * Game.w2p);
Game.numBallsActive++;
animal_rot = Utils.RandCircle();
}
function UpdatePhysObj_BubbleSplat(){
timer--;
if (timer <= 0){
collideFunction = Game.RemoveObj_Standard;
collidetimer = 10;
};
}
function UpdatePhysObj_Springboard(){
var _local1:GameObj = GetGameObject(0);
if (controlMode == 0){
_local1.frame = 0;
};
if (controlMode == 1){
if (_local1.PlayAnimation()){
controlMode = 0;
};
};
}
function UpdateLine(_arg1:Number):Point{
lineLinearPos = (lineLinearPos + _arg1);
if (lineLinearPos > 1){
if (lineLoop == true){
lineLinearPos = (lineLinearPos - 1);
} else {
lineLinearPos = 1;
};
};
if (lineLinearPos < 0){
if (lineLoop == true){
lineLinearPos = (lineLinearPos + 1);
} else {
lineLinearPos = 0;
};
};
var _local2:PhysLine = Game.GetCurrentLevel().lines[lineIndex];
if (_local2 == null){
return (new Point(0, 0));
};
var _local3:Point = _local2.GetInterpolatedPoint(lineLinearPos, lineLoop, 0);
return (_local3);
}
function SwitchedPhysObj_TimedSwitch():Boolean{
var _local1:GameObj = GetGameObject(0);
var _local2:Boolean;
if (controlMode == 0){
_local1.controlMode = 1;
controlMode = 1;
timer = switch_timer;
SoundPlayer.Play("switchwav");
_local2 = true;
} else {
_local2 = false;
};
return (_local2);
}
function InitPhysObj_Hose(){
colflags = 1;
updateFunction = UpdatePhysObj_Hose;
hosedir = 1;
controlMode = 0;
guineaPig_type = Utils.RandBetweenInt(0, 2);
}
public function GetBodyAngleFromLinearVelocity(_arg1:int):Number{
var _local2:b2Vec2 = new b2Vec2(0, 0);
var _local3:b2Body = bodies[_arg1];
var _local4:b2Vec2 = _local3.GetLinearVelocity();
var _local5:Number = Math.atan2(_local4.y, _local4.x);
return (_local5);
}
function GetParamBool(_arg1:String, _arg2:Boolean=false):Boolean{
var _local4:String;
var _local3:int = paramNames.indexOf(_arg1);
if (_local3 != -1){
_local4 = paramValues[_local3];
if (_local4 == "true"){
return (true);
};
return (false);
};
return (_arg2);
}
function UpdatePhysObj_MiniBall(){
var _local2:GameObj;
var _local4:Number;
var _local5:int;
var _local6:PhysObj_Instance;
var _local7:Number;
var _local8:Number;
var _local1:PhysObj_BodyUserData = (bodies[0].GetUserData() as PhysObj_BodyUserData);
_local2 = GameObjects.objs[_local1.gameObjectID];
var _local3:b2Vec2 = GetBodyWorldPos(0);
posx = _local3.x;
posy = _local3.y;
if (_local2.controlMode == 0){
_local4 = Utils.DistBetweenPoints(oldx, oldy, posx, posy);
if (_local4 < 0.01){
stopcount++;
if (stopcount > 10){
_local2.controlMode = 1;
_local2.timer = 0;
SetAngularVelocity(0, 0);
SetLinearVelocity(0, 0);
};
} else {
stopcount = 0;
};
};
if (_local2.controlMode == 2){
Game.ApplyImpulseToObjectsFromPoint(this, _local3.x, _local3.y, 20, (200 * Game.w2p));
_local5 = 0;
while (_local5 < 20) {
_local6 = Game.AddPhysObjAt("bubblesplat", (_local3.x * Game.p2w), (_local3.y * Game.p2w), 0, "");
_local7 = (_local5 * ((Math.PI * 2) / 20));
_local8 = Utils.RandBetweenFloat(0.3, 0.4);
_local6.ApplyImpulse((Math.cos(_local7) * _local8), (Math.sin(_local7) * _local8));
_local5++;
};
collideFunction = Game.RemoveObj_Standard;
collidetimer = 10;
};
}
public function SetBodyCollisionMask(_arg1:int, _arg2:int):void{
var _local3:b2Body;
var _local4:b2Shape;
var _local5:b2FilterData;
if (_arg1 == -1){
for each (_local3 in bodies) {
_local4 = _local3.GetShapeList();
while (_local4) {
_local5 = _local4.GetFilterData();
_local5.maskBits = _arg2;
_local4.SetFilterData(_local5);
Game.world.Refilter(_local4);
_local4 = _local4.GetNext();
};
};
} else {
_local3 = bodies[_arg1];
_local4 = _local3.GetShapeList();
while (_local4) {
_local5 = _local4.GetFilterData();
_local5.maskBits = _arg2;
_local4.SetFilterData(_local5);
Game.world.Refilter(_local4);
_local4 = _local4.GetNext();
};
};
}
public function Remove(){
var _local1:b2Joint;
var _local2:b2Body;
var _local3:PhysObj_BodyUserData;
var _local4:int;
var _local5:GameObj;
for each (_local1 in joints) {
Game.world.DestroyJoint(_local1);
};
for each (_local2 in bodies) {
_local3 = (_local2.GetUserData() as PhysObj_BodyUserData);
if (_local3 != null){
_local4 = _local3.gameObjectID;
if (_local4 != -1){
_local5 = GameObjects.objs[_local4];
_local5.active = false;
};
};
Game.world.DestroyBody(_local2);
};
}
public function SetPos(_arg1:Number, _arg2:Number):void{
var _local3:b2Body;
var _local4:b2Vec2;
var _local5:Number;
var _local6:b2Vec2;
x = _arg1;
y = _arg2;
for each (_local3 in bodies) {
_local4 = _local3.GetPosition();
_local5 = Utils.DistBetweenPoints(x, y, _local4.x, _local4.y);
if (_local5 > 1){
_local5 = 1;
};
_local6 = new b2Vec2(((x - _local4.x) * 0.1), ((y - _local4.y) * 0.01));
_local3.ApplyImpulse(_local6, new b2Vec2(0, 0));
};
}
public function SetBodyXForm(_arg1:int, _arg2:Number, _arg3:Number, _arg4:Number):void{
var _local6:b2Body;
var _local5:b2Vec2 = new b2Vec2(_arg2, _arg3);
if (_arg1 != -1){
_local6 = bodies[_arg1];
_local6.SetXForm(_local5, _arg4);
} else {
for each (_local6 in bodies) {
_local6.SetXForm(_local5, _arg4);
};
};
}
function UpdatePhysObj_Hose(){
var _local1:b2Body;
var _local2:PhysObj_BodyUserData;
var _local3:GameObj;
_local3 = GetGameObject((bodies.length - 2));
_local3.graphicID = GraphicObjects.GetIndexByName("Objects");
_local3.frame = 1;
_local3 = GetGameObject((bodies.length - 1));
if (guineaPig_type == 0){
_local3.graphicID = GraphicObjects.GetIndexByName("guinea_pig_hanging");
};
if (guineaPig_type == 1){
_local3.graphicID = GraphicObjects.GetIndexByName("guinea_pig2_hanging");
};
if (guineaPig_type == 2){
_local3.graphicID = GraphicObjects.GetIndexByName("guinea_pig3_hanging");
};
_local3.frameVel = 0.2;
_local3.CycleAnimation();
if (controlMode == 1){
_local3.visible = false;
} else {
_local3.visible = true;
};
if (controlMode == 1){
timer--;
if (timer <= 0){
timer = 0;
if (Game.numBallsActive < Game.numBallsActiveMax){
controlMode = 2;
guineaPig_type = Utils.RandBetweenInt(0, 2);
_local3.scale = 0.1;
};
};
} else {
if (controlMode == 2){
_local3.scale = (_local3.scale + 0.05);
if (_local3.scale >= 1){
_local3.scale = 1;
controlMode = 0;
};
};
};
}
function UpdatePhysObj_TimedSwitch(){
var _local1:GameObj;
if (controlMode == 1){
timer--;
if (timer <= 0){
SoundPlayer.Play("switchwav");
_local1 = GetGameObject(0);
_local1.controlMode = 2;
controlMode = 0;
};
};
}
function InitPhysObj_BubbleSplat(){
colflags = 1;
timer = 10;
updateFunction = UpdatePhysObj_BubbleSplat;
}
function InitPhysObj_Springboard(){
GetParams(initParams);
updateFunction = UpdatePhysObj_Springboard;
controlMode = 0;
}
public function SetBodyFixed(_arg1:int, _arg2:Boolean):void{
var _local3:b2Body;
if (_arg2 == false){
if (_arg1 != -1){
_local3 = bodies[_arg1];
_local3.SetMassFromShapes();
} else {
for each (_local3 in bodies) {
_local3.SetMassFromShapes();
};
};
} else {
if (_arg1 != -1){
_local3 = bodies[_arg1];
_local3.PutToSleep();
_local3.SetMass(new b2MassData());
} else {
for each (_local3 in bodies) {
_local3.PutToSleep();
_local3.SetMass(new b2MassData());
};
};
};
}
function PreUpdatePhysObj_MiniBall(){
var _local1:b2Vec2 = GetBodyWorldPos(0);
oldx = _local1.x;
oldy = _local1.y;
}
function InitPhysObj_MiniBall(){
colflags = 1;
ball_hitcount = 0;
updateFunction = UpdatePhysObj_MiniBall;
preUpdateFunction = PreUpdatePhysObj_MiniBall;
timer = (Defs.fps * 3);
posx = 0;
oldx = 100;
posy = 0;
oldy = 100;
stopcount = 0;
}
public function Update(){
if (updateFunction != null){
updateFunction();
};
}
function PreUpdatePhysObj_Ball(){
var _local1:b2Vec2 = GetBodyWorldPos(0);
oldx = _local1.x;
oldy = _local1.y;
}
function InitPhysObj_Ball(){
colflags = 1;
Game.numBallsActive++;
ball_hitcount = 0;
updateFunction = UpdatePhysObj_Ball;
preUpdateFunction = PreUpdatePhysObj_Ball;
timer = (Defs.fps * 3);
posx = 0;
oldx = 100;
posy = 0;
oldy = 100;
stopcount = 0;
}
function BreakObject(_arg1:Number){
if ((_arg1 * Game.p2w) > 100){
return;
};
var _local2:PhysObj_BodyUserData = (bodies[0].GetUserData() as PhysObj_BodyUserData);
var _local3:GameObj = GameObjects.objs[_local2.gameObjectID];
_local3.frame++;
var _local4:int = GraphicObjects.GetNumFrames(_local3.graphicID);
if (_local3.frame >= _local4){
_local3.frame = (_local4 - 1);
collideFunction = Game.RemoveObj_Standard;
collidetimer = 10;
};
SoundPlayer.Play("objectbreakwav");
}
function GetParam(_arg1:String, _arg2:String=""):String{
var _local3:int = paramNames.indexOf(_arg1);
if (_local3 != -1){
return (paramValues[_local3]);
};
return (_arg2);
}
function InitPhysObj_Path(){
GetParams(initParams);
var _local1:String = GetParam("line", "");
if (_local1 == ""){
lineIndex = -1;
} else {
lineIndex = GetLineIndexByName(_local1);
};
if (lineIndex == -1){
updateFunction = null;
};
trace(("lineIndex" + lineIndex));
lineSpeed = Number(GetParam("speed"));
lineLoop = GetParamBool("loop");
switchName = GetParam("switch", "");
lineResetAtEnd = GetParamBool("endreset");
lineLinearPos = 0;
var _local2:Number = GetParamNumber("startpos", 0);
lineLinearPos = _local2;
var _local3:Boolean = GetParamBool("2way");
controlMode = 1;
switchFunction = null;
updateFunction = null;
if (lineIndex != -1){
if (switchName != ""){
controlMode = 0;
switchFunction = SwitchFunction_Path;
} else {
controlMode = 1;
};
updateFunction = UpdatePhysObj_Path;
};
if (_local3){
if (switchName != ""){
switchFunction = SwitchFunction_Path_2way;
};
updateFunction = UpdatePhysObj_Path_2way;
};
}
function InitPhysObj_Mover(){
updateFunction = UpdatePhysObj_Mover;
mover_x0 = (249 * Game.w2p);
mover_x1 = (250 * Game.w2p);
mover_xvel = 350;
}
function GetParamNumber(_arg1:String, _arg2:Number=0):Number{
var _local3:int = paramNames.indexOf(_arg1);
if (_local3 != -1){
return (Number(paramValues[_local3]));
};
return (_arg2);
}
function UpdatePhysObj_Mincer(){
var _local1:b2Vec2;
var _local2:int;
if (mincer_numtogenerate > 0){
timer--;
if (timer <= 0){
mincer_numtogenerate--;
timer = 10;
_local1 = GetBodyWorldPos(0);
_local2 = (-27 + ((mincer_numtogenerate % 4) * 17));
trace(((mincer_numtogenerate + " : ") + _local2));
SoundPlayer.Play("mincerplopwav");
Game.AddPhysObjAt("miniguineapig", ((_local1.x * Game.p2w) + _local2), (_local1.y * Game.p2w), 0, "", "");
};
};
}
function UpdatePhysObj_Ball(){
var _local3:Number;
var _local4:int;
var _local5:PhysObj_Instance;
var _local6:Number;
var _local7:Number;
var _local1:GameObj = GetGameObject(0);
if (guineaPig_type == 0){
_local1.graphicID = GraphicObjects.GetIndexByName("guinea_pig");
};
if (guineaPig_type == 1){
_local1.graphicID = GraphicObjects.GetIndexByName("guinea_pig2");
};
if (guineaPig_type == 2){
_local1.graphicID = GraphicObjects.GetIndexByName("guinea_pig3");
};
var _local2:b2Vec2 = GetBodyWorldPos(0);
posx = _local2.x;
posy = _local2.y;
if (_local1.controlMode == 0){
_local3 = Utils.DistBetweenPoints(oldx, oldy, posx, posy);
if (_local3 < 0.01){
stopcount++;
if (stopcount > 10){
_local1.controlMode = 1;
_local1.timer = 0;
SetAngularVelocity(0, 0);
SetLinearVelocity(0, 0);
};
} else {
stopcount = 0;
};
};
if (_local1.controlMode == 3){
Game.ApplyImpulseToObjectsFromPoint(this, _local2.x, _local2.y, 20, (200 * Game.w2p));
_local4 = 0;
while (_local4 < 20) {
_local5 = Game.AddPhysObjAt("bubblesplat", (_local2.x * Game.p2w), (_local2.y * Game.p2w), 0, "");
_local6 = (_local4 * ((Math.PI * 2) / 20));
_local7 = Utils.RandBetweenFloat(0.3, 0.4);
_local5.ApplyImpulse((Math.cos(_local6) * _local7), (Math.sin(_local6) * _local7));
_local4++;
};
Game.numBallsActive--;
Game.numPigsSacrificed++;
collideFunction = Game.RemoveObj_Standard;
collidetimer = 10;
};
if (posy > (800 * Game.w2p)){
SoundPlayer.PlayRandomBetween("guineadie01", "guineadie03", 1);
Game.numBallsActive--;
Game.numPigsSacrificed++;
collideFunction = Game.RemoveObj_Standard;
collidetimer = 10;
};
}
function InitPhysObj_Mincer(){
updateFunction = UpdatePhysObj_Mincer;
GetParams(initParams);
mincer_numtogenerate = 0;
timer = 0;
}
public function PreUpdate(){
if (preUpdateFunction != null){
preUpdateFunction();
};
}
public function Init(){
switchName = "";
switchName1 = "";
colflags = 0;
var _local1:PhysObj = Game.physObjs.FindByName(typeName);
if (_local1.initFunctionName != null){
var _local2 = this;
_local2[_local1.initFunctionName]();
};
}
function UpdatePhysObj_BadguyTimed(){
timer--;
if (timer <= 0){
collideFunction = Game.RemoveObj_Standard;
collidetimer = 10;
};
}
function InitPhysObj_PortalEntry(){
GetParams(initParams);
}
public function GetBodyLinearVelocity(_arg1:int):b2Vec2{
var _local2:b2Vec2 = new b2Vec2(0, 0);
var _local3:b2Body = bodies[_arg1];
var _local4:b2Vec2 = _local3.GetLinearVelocity();
return (_local4);
}
function SwitchedPhysObj_TwoWaySwitch():Boolean{
var _local1:GameObj = GetGameObject(0);
SoundPlayer.Play("switchwav");
if (controlMode == 0){
controlMode = 1;
return (true);
};
controlMode = 0;
return (true);
}
function UpdatePhysObj_Path(){
var _local1:Point;
if (controlMode == 0){
_local1 = UpdateLine(0);
SetBodyXForm(0, (_local1.x * Game.w2p), (_local1.y * Game.w2p), 0);
} else {
_local1 = UpdateLine(lineSpeed);
SetBodyXForm(0, (_local1.x * Game.w2p), (_local1.y * Game.w2p), 0);
if (lineLoop == false){
if (lineLinearPos >= 1){
lineLinearPos = 1;
if (lineResetAtEnd){
lineLinearPos = 0;
};
controlMode = 0;
};
};
};
}
function UpdatePhysObj_Cannonball(){
timer--;
if (timer <= 0){
collideFunction = Game.RemoveObj_Standard;
collidetimer = 10;
};
}
function UpdatePhysObj_Cannon(){
if (controlMode == 0){
} else {
if (controlMode == 1){
cannon_ang = (cannon_ang + cannon_angvel);
} else {
if (controlMode == 2){
cannon_ang = (cannon_ang - cannon_angvel);
};
};
};
if (cannon_ang >= cannon_maxang){
cannon_ang = cannon_maxang;
};
if (cannon_ang <= cannon_minang){
cannon_ang = cannon_minang;
};
var _local1:b2Body = bodies[0];
var _local2:b2Vec2 = GetBodyWorldPos(0);
_local1.SetXForm(_local2, cannon_ang);
var _local3:GameObj = GetGameObject(0);
if (cannon_firing){
_local3.frameVel = 1;
if (_local3.PlayAnimation()){
cannon_firing = false;
_local3.frame = 1;
};
};
}
function TriggerPhysObj_Springboard(){
controlMode = 1;
var _local1:GameObj = GetGameObject(0);
_local1.frame = 0;
_local1.frameVel = 1;
SoundPlayer.Play("springboardwav");
}
function InitPhysObj_Cannon(){
GetParams(initParams);
updateFunction = UpdatePhysObj_Cannon;
switchFunction = SwitchFunction_Cannon;
cannon_minang = Utils.DegToRad(GetParamNumber("minang"));
cannon_maxang = Utils.DegToRad(GetParamNumber("maxang"));
cannon_angvel = GetParamNumber("speed");
switchName = GetParam("switch");
cannon_mode = GetParam("mode");
cannon_ang = cannon_minang;
cannon_firing = false;
controlMode = 0;
}
function SwitchFunction_Cannon(){
if (controlMode == 0){
controlMode = 1;
} else {
if (controlMode == 1){
controlMode = 2;
} else {
if (controlMode == 2){
controlMode = 1;
};
};
};
}
public function GetBodyWorldPos(_arg1:int):b2Vec2{
var _local4:b2Body;
var _local2:b2Vec2 = new b2Vec2(0, 0);
var _local3:int;
for each (_local4 in bodies) {
if (_local3 == _arg1){
_local2 = _local4.GetWorldCenter().Copy();
};
_local3++;
};
return (_local2);
}
public function WakeUp():void{
var _local1:b2Body;
for each (_local1 in bodies) {
_local1.WakeUp();
};
}
function ClickAnimal(){
Game.numAnimalsReady--;
controlMode = 1;
SetBodyFixed(-1, false);
WakeUp();
timer = 100;
var _local1:int = SoundPlayer.GetId("snd_a01");
_local1 = (_local1 + animal_index);
SoundPlayer.PlayById(_local1);
}
function SwitchFunction_Path(){
if (controlMode == 0){
controlMode = 1;
};
}
function TriggerPhysObj_Mincer(){
mincer_numtogenerate = (mincer_numtogenerate + 4);
SoundPlayer.Play("mincerwav");
}
function InitPhysObj_BadguyTimed(){
updateFunction = UpdatePhysObj_BadguyTimed;
timer = (Defs.fps * 3);
}
function UpdatePhysObj_Generator(){
var _local1:b2Vec2;
timer--;
if (timer <= 0){
timer = generator_time;
_local1 = GetBodyWorldPos(0);
Game.AddPhysObjAt(generator_object, (_local1.x * Game.p2w), (_local1.y * Game.p2w), 0, "", "");
SoundPlayer.Play("generatewav");
};
}
public function LimitLinearVelocity(_arg1:Number):void{
var _local2:b2Body;
var _local3:b2Vec2;
for each (_local2 in bodies) {
_local3 = _local2.GetLinearVelocity();
if (_local3.Length() > _arg1){
_local3.Normalize();
_local3.Multiply(_arg1);
_local2.SetLinearVelocity(_local3);
};
};
}
function InitPhysObj_Switch(){
GetParams(initParams);
var _local1:String = GetParam("type");
if (_local1 == ""){
_local1 = "once";
};
if (_local1 == "once"){
doSwitchFunction = SwitchedPhysObj_Switch;
updateFunction = null;
};
if (_local1 == "timed"){
switch_timer = (GetParamNumber("time") * Defs.fps);
doSwitchFunction = SwitchedPhysObj_TimedSwitch;
updateFunction = UpdatePhysObj_TimedSwitch;
};
if (_local1 == "2way"){
doSwitchFunction = SwitchedPhysObj_TwoWaySwitch;
updateFunction = UpdatePhysObj_TwoWaySwitch;
controlMode = 0;
};
}
public function GetGameObject(_arg1:int):GameObj{
var _local2:PhysObj_BodyUserData = (bodies[_arg1].GetUserData() as PhysObj_BodyUserData);
var _local3:GameObj = GameObjects.objs[_local2.gameObjectID];
return (_local3);
}
public function ApplyAngularVelocity(_arg1:int, _arg2:Number):void{
var _local3:b2Body;
if (_arg1 == -1){
for each (_local3 in bodies) {
_local3.ApplyTorque(_arg2);
};
} else {
bodies[_arg1].ApplyTorque(_arg2);
};
}
function InitPhysObj_Gate(){
GetParams(initParams);
switchName = GetParam("switch");
switchName1 = GetParam("switch1");
var _local1:String = GetParam("start");
gateMode = GetParam("mode", "once");
gateTime = (GetParamNumber("timer", 1) * Defs.fps);
updateFunction = UpdatePhysObj_Gate;
switchFunction = SwitchFunction_Gate;
controlMode = 0;
if (_local1 == "left"){
controlMode = 0;
};
if (_local1 == "right"){
controlMode = 1;
};
gateVel = GetParamNumber("strength", 100);
}
function UpdatePhysObj_Breakable(){
}
public function GetBodyAngle(_arg1:int):Number{
var _local2:b2Vec2 = new b2Vec2(0, 0);
var _local3:b2Body = bodies[_arg1];
return (_local3.GetAngle());
}
public function LimitAngularVelocity(_arg1:int, _arg2:Number):void{
var _local3:b2Body;
var _local4:Number;
if (_arg1 == -1){
for each (_local3 in bodies) {
_local4 = _local3.GetAngularVelocity();
if (_local4 >= _arg2){
_local4 = _arg2;
};
if (_local4 <= -(_arg2)){
_local4 = -(_arg2);
};
_local3.SetAngularVelocity(_local4);
};
} else {
_local3 = bodies[_arg1];
_local4 = _local3.GetAngularVelocity();
if (_local4 >= _arg2){
_local4 = _arg2;
};
if (_local4 <= -(_arg2)){
_local4 = -(_arg2);
};
_local3.SetAngularVelocity(_local4);
};
}
public function GetXForm(_arg1:int):b2XForm{
var _local2:b2Body = bodies[_arg1];
return (_local2.GetXForm());
}
function UpdatePhysObj_Magnet(){
if (magnet_mode == "static"){
} else {
if (magnet_mode == "timed"){
timer++;
if (timer >= magnet_time){
timer = 0;
magnet_polarity = (magnet_polarity == false);
SoundPlayer.Play("magnetwav");
};
};
};
var _local1:GameObj = GetGameObject(0);
if (magnet_polarity == false){
_local1.frameVel = -0.5;
};
if (magnet_polarity == true){
_local1.frameVel = 0.5;
};
_local1.CycleAnimation();
}
public function ApplyImpulse(_arg1:Number, _arg2:Number):void{
var _local3:b2Body;
for each (_local3 in bodies) {
_local3.ApplyImpulse(new b2Vec2(_arg1, _arg2), _local3.GetWorldCenter());
};
}
function InitPhysObj_Magnet(){
GetParams(initParams);
magnet_polarity = GetParamBool("polarity");
magnet_mode = GetParam("mode", "static");
magnet_time = (Defs.fps * GetParamNumber("time"));
switchName = "";
switchFunction = null;
if (magnet_mode == "switch"){
switchName = GetParam("switch");
switchFunction = SwitchFunction_Magnet;
};
updateFunction = UpdatePhysObj_Magnet;
timer = 0;
}
public function GetBodyAngularVelocity(_arg1:int):Number{
var _local2:b2Body = bodies[_arg1];
return (_local2.GetAngularVelocity());
}
public function AddToPos(_arg1:int, _arg2:b2Vec2):void{
var _local3:b2XForm;
var _local4:b2Body;
if (_arg1 == -1){
for each (_local4 in bodies) {
_local3 = _local4.GetXForm();
_local3.position.Add(_arg2);
_local4.SetXForm(_local3.position, 0);
};
} else {
_local3 = _local4.GetXForm();
_local3.position.Add(_arg2);
_local4.SetXForm(_local3.position, 0);
};
}
function SwitchFunction_Magnet(){
SoundPlayer.Play("magnetwav");
magnet_polarity = (magnet_polarity == false);
}
function InitPhysObj_Cannonball(){
timer = (Defs.fps * 3);
updateFunction = UpdatePhysObj_Cannonball;
}
function UpdatePhysObj_Gate(){
if (controlMode == 1){
ApplyAngularVelocity(1, -(gateVel));
};
if (controlMode == 2){
ApplyAngularVelocity(1, gateVel);
};
}
function SwitchFunction_Gate(){
if (controlMode == 0){
controlMode = 1;
} else {
if (controlMode == 1){
controlMode = 2;
} else {
if (controlMode == 2){
controlMode = 1;
};
};
};
}
}
}//package
Section 219
//PhysObj_Instances (PhysObj_Instances)
package {
public class PhysObj_Instances {
public var list:Array;
public function PhysObj_Instances(){
list = new Array();
}
public function Remove(_arg1:PhysObj_Instance):Boolean{
var _local3:PhysObj_Instance;
if (Exists(_arg1) == false){
return (false);
};
_arg1.Remove();
var _local2:Array = new Array();
for each (_local3 in list) {
if (_local3 == _arg1){
} else {
_local2.push(_local3);
};
};
list = _local2;
return (true);
}
public function GetAllByTypeNameContaining(_arg1:String):Array{
var _local3:PhysObj_Instance;
var _local2:Array = new Array();
for each (_local3 in list) {
if (_local3.typeName.match(_arg1)){
_local2.push(_local3);
};
};
return (_local2);
}
public function FindByTypeName(_arg1:String):PhysObj_Instance{
var _local2:PhysObj_Instance;
for each (_local2 in list) {
if (_local2.typeName == _arg1){
return (_local2);
};
};
return (null);
}
public function RemoveByName(_arg1:String):void{
var _local2:PhysObj_Instance = FindByName(_arg1);
if (_local2 == null){
return;
};
Remove(_local2);
}
public function GetAllByTypeName(_arg1:String):Array{
var _local3:PhysObj_Instance;
var _local2:Array = new Array();
for each (_local3 in list) {
if (_local3.typeName == _arg1){
_local2.push(_local3);
};
};
return (_local2);
}
public function Exists(_arg1:PhysObj_Instance):Boolean{
var _local2:PhysObj_Instance;
for each (_local2 in list) {
if (_local2 == _arg1){
return (true);
};
};
return (false);
}
public function FindByName(_arg1:String):PhysObj_Instance{
var _local2:PhysObj_Instance;
for each (_local2 in list) {
if (_local2.instanceName == _arg1){
return (_local2);
};
};
return (null);
}
public function GetByIndex(_arg1:int):PhysObj_Instance{
return (list[_arg1]);
}
}
}//package
Section 220
//PhysObj_Joint (PhysObj_Joint)
package {
import flash.geom.*;
public class PhysObj_Joint {
public var prism_enableLimit:Boolean;
public var prism_pos:Point;
public var obj0Name:String;
public var obj1Name:String;
public var dist_distance:Number;
public var name:String;
public var prism_lowerTranslation:Number;
public var prism_maxMotorForce:Number;
public var dist_pos0:Point;
public var dist_pos1:Point;
public var prism_enableMotor:Boolean;
public var prism_axisangle:Number;
public var prism_motorSpeed:Number;
public var rev_enableLimit:Boolean;
public var rev_enableMotor:Boolean;
public var rev_upperAngle:Number;
public var rev_lowerAngle:Number;
public var rev_maxMotorTorque:Number;
public var type:int;
public var prism_upperTranslation:Number;
public var rev_motorSpeed:Number;
public var rev_pos:Point;
public static const Type_Mouse:int = 3;
public static const Type_Prismatic:int = 2;
public static const Type_Distance:int = 1;
public static const Type_Rev:int = 0;
public function PhysObj_Joint(){
type = 0;
name = "";
obj0Name = "";
obj1Name = "";
rev_pos = new Point(0, 0);
rev_enableLimit = false;
rev_lowerAngle = 0;
rev_upperAngle = 0;
rev_enableMotor = false;
rev_motorSpeed = 0;
rev_maxMotorTorque = 0;
prism_pos = new Point(0, 0);
prism_lowerTranslation = 0;
prism_upperTranslation = 0;
prism_enableLimit = false;
prism_enableMotor = false;
prism_motorSpeed = 0;
prism_maxMotorForce = 0;
prism_axisangle = 0;
dist_pos0 = new Point(0, 0);
dist_pos1 = new Point(0, 0);
dist_distance = 1;
}
}
}//package
Section 221
//PhysObj_Shape (PhysObj_Shape)
package {
import flash.geom.*;
public class PhysObj_Shape {
public var type:int;
public var poly_rot:Number;
public var circle_pos:Point;
public var density:Number;
public var restitution:Number;
public var name:String;
public var collisionCategory:int;
public var circle_radius:Number;
public var friction:Number;
public var poly_points:Array;
public var collisionMask:int;
public static const Type_Poly:int = 0;
public static const Type_Circle:int = 1;
public function PhysObj_Shape(){
type = 0;
name = "";
poly_points = new Array();
circle_pos = new Point();
circle_radius = 0;
poly_rot = 0;
collisionCategory = 0;
collisionMask = 0;
}
public function Caclulate(){
var _local1:Matrix;
var _local2:Array;
var _local3:Point;
var _local4:Point;
if (type == Type_Poly){
_local1 = new Matrix();
_local1.rotate(poly_rot);
_local2 = new Array();
for each (_local3 in poly_points) {
_local4 = _local1.transformPoint(_local3);
_local2.push(_local4);
};
poly_points = _local2;
};
}
}
}//package
Section 222
//PhysObjs (PhysObjs)
package {
public class PhysObjs {
public var list:Array;
public function PhysObjs(){
list = new Array();
}
public function GetNum():int{
return (list.length);
}
public function FindIndexByName(_arg1:String):int{
var _local3:PhysObj;
var _local2:int;
for each (_local3 in list) {
if (_local3.name == _arg1){
return (_local2);
};
_local2++;
};
trace(("ERROR PhysObjs FindByName " + _arg1));
return (0);
}
public function GetByIndex(_arg1:int):PhysObj{
return (list[_arg1]);
}
public function FindByName(_arg1:String):PhysObj{
var _local2:PhysObj;
for each (_local2 in list) {
if (_local2.name == _arg1){
return (_local2);
};
};
trace(("ERROR PhysObjs FindByName " + _arg1));
return (null);
}
public function InitFromXml(_arg1:XML):void{
var _local2:int;
var _local3:XML;
var _local4:PhysObj;
list = new Array();
_local2 = 0;
while (_local2 < _arg1.physobj.length()) {
_local3 = _arg1.physobj[_local2];
_local4 = new PhysObj();
_local4.FromXml(_local3);
list.push(_local4);
_local2++;
};
}
}
}//package
Section 223
//Pickup (Pickup)
package {
import flash.display.*;
public dynamic class Pickup extends MovieClip {
}
}//package
Section 224
//pistol_flash (pistol_flash)
package {
import flash.display.*;
public dynamic class pistol_flash extends MovieClip {
}
}//package
Section 225
//player (player)
package {
import flash.display.*;
public dynamic class player extends MovieClip {
}
}//package
Section 226
//Player (Player)
package {
public class Player {
static const upg_total:int = 5;
static const upg_speed:int = 0;
static const upg_accel:int = 1;
static const upg_boost:int = 3;
static const upg_brake:int = 2;
static const upg_spin:int = 4;
static var levels:Array;
public static function GetCost(_arg1):int{
var _local2:int = levels[_arg1];
var _local3:int = (_local2 + 1);
return (_local3);
}
public static function Upgrade(_arg1):void{
var _local2:int = levels[_arg1];
_local2++;
if (_local2 > 10){
_local2 = 0;
};
levels[_arg1] = _local2;
}
public static function GetLevel(_arg1:int):int{
return (levels[_arg1]);
}
public static function InitOnce(){
levels = new Array();
levels.push(0, 0, 0, 0, 0);
}
public static function SetLevel(_arg1:int, _arg2:int):void{
levels[_arg1] = _arg2;
}
}
}//package
Section 227
//player_backwards (player_backwards)
package {
import flash.display.*;
public dynamic class player_backwards extends MovieClip {
}
}//package
Section 228
//player_head (player_head)
package {
import flash.display.*;
public dynamic class player_head extends MovieClip {
}
}//package
Section 229
//playerdeath (playerdeath)
package {
import flash.display.*;
public dynamic class playerdeath extends MovieClip {
}
}//package
Section 230
//Poly (Poly)
package {
import flash.display.*;
import flash.geom.*;
public class Poly {
var param0:String;
var param1:String;
var subTypeName:String;
var active:Boolean;
var name:String;
var pointList:Array;
var typeName:String;
var boundingRectangle:Rectangle;
var closed:Boolean;
var lineList:Array;
var iparam0:int;
var hitCallback:Object;
var type:int;
var catmullRomLength:Number;
public static const polytype_WALL = 1;
public static const polytype_CEILING = 6;
public static const polytype_ZONE = 3;
public static const polytype_PATH = 0;
public static const polytype_FLOOR = 5;
public static const polytype_OVERLAY = 4;
public static const polytype_TRIGGER = 2;
public function Poly(_arg1:String, _arg2:int, _arg3:Number, _arg4:Number):void{
lineList = new Array();
active = true;
type = _arg2;
name = _arg1;
boundingRectangle = null;
hitCallback = null;
closed = false;
pointList = new Array();
pointList.push(new Point(_arg3, _arg4));
}
function PointOnCurve(_arg1:Number, _arg2:Point, _arg3:Point, _arg4:Point, _arg5:Point):Point{
var _local6:Point = new Point();
var _local7:Number = (_arg1 * _arg1);
var _local8:Number = (_local7 * _arg1);
_local6.x = (0.5 * ((((2 * _arg3.x) + ((-(_arg2.x) + _arg4.x) * _arg1)) + (((((2 * _arg2.x) - (5 * _arg3.x)) + (4 * _arg4.x)) - _arg5.x) * _local7)) + ((((-(_arg2.x) + (3 * _arg3.x)) - (3 * _arg4.x)) + _arg5.x) * _local8)));
_local6.y = (0.5 * ((((2 * _arg3.y) + ((-(_arg2.y) + _arg4.y) * _arg1)) + (((((2 * _arg2.y) - (5 * _arg3.y)) + (4 * _arg4.y)) - _arg5.y) * _local7)) + ((((-(_arg2.y) + (3 * _arg3.y)) - (3 * _arg4.y)) + _arg5.y) * _local8)));
return (_local6);
}
public function GetPoint(_arg1:int):Point{
return (new Point(pointList[_arg1].x, pointList[_arg1].y));
}
public function GetPointNormal(_arg1:int):Point{
return (new Point(lineList[_arg1].nx, lineList[_arg1].ny));
}
public function GetPointOnCatmullRom(_arg1:Number):Point{
var _local4:Point;
var _local5:Point;
var _local6:Point;
var _local7:Point;
var _local2:int = GetNumPoints();
if (_local2 < 4){
return (new Point(0, 0));
};
var _local3:int = (_local2 - 1);
var _local8:Number = (Number(_local3) * _arg1);
var _local9:int = _local8;
var _local10:int = (_local9 - 1);
var _local11:int = _local9;
var _local12:int = (_local9 + 1);
var _local13:int = (_local9 + 2);
if (_local10 < 0){
_local10 = 0;
};
if (_local12 > (_local2 - 1)){
_local12 = (_local2 - 1);
};
if (_local13 > (_local2 - 1)){
_local13 = (_local2 - 1);
};
_local4 = pointList[_local10];
_local5 = pointList[_local11];
_local6 = pointList[_local12];
_local7 = pointList[_local13];
var _local14:int = (_local9 + 1);
var _local15:Number = ((1 / Number(_local3)) * _local9);
var _local16:Number = ((1 / Number(_local3)) * _local14);
var _local17:Number = ((1 / (_local16 - _local15)) * (_arg1 - _local15));
var _local18:Point = PointOnCurve(_local17, _local4, _local5, _local6, _local7);
return (_local18);
}
public function AddLine(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number):void{
var _local6:Rectangle;
var _local5:Line = new Line(_arg1, _arg2, _arg3, _arg4);
lineList.push(_local5);
pointList.push(new Point(_arg3, _arg4));
if (boundingRectangle == null){
boundingRectangle = _local5.boundingRect;
} else {
_local6 = boundingRectangle.clone();
boundingRectangle = _local6.union(_local5.boundingRect);
};
}
public function GetLine(_arg1:int):Line{
return (lineList[_arg1]);
}
public function CalculateCatmullRomLength(){
var _local2:int;
var _local4:Number;
var _local5:Point;
var _local6:Point;
var _local7:Point;
var _local1:Array = new Array();
var _local3:int = GetNumPoints();
if (_local3 < 4){
catmullRomLength = 0;
} else {
_local4 = 0;
while (_local4 < 1) {
_local5 = GetPointOnCatmullRom(_local4);
_local1.push(_local5);
_local4 = (_local4 + 0.025);
};
};
catmullRomLength = 0;
_local2 = 0;
while (_local2 < (_local1.length - 2)) {
_local6 = _local1[_local2];
_local7 = _local1[(_local2 + 1)];
catmullRomLength = (catmullRomLength + Utils.DistBetweenPoints(_local6.x, _local6.y, _local7.x, _local7.y));
_local2++;
};
_local1 = null;
}
public function Finish(_arg1:Boolean){
var _local2:Line;
var _local3:Line;
var _local4:Line;
var _local5:Rectangle;
if (_arg1){
_local2 = lineList[0];
_local3 = lineList[(lineList.length - 1)];
_local4 = new Line(_local3.x1, _local3.y1, _local2.x0, _local2.y0);
lineList.push(_local4);
_local5 = boundingRectangle.clone();
boundingRectangle = _local5.union(_local4.boundingRect);
};
closed = _arg1;
}
public function GetCatmullRomLength():Number{
return (catmullRomLength);
}
public function GetNumLines():int{
return (lineList.length);
}
public function OffsetFromStartPoint(){
var _local3:int;
var _local4:Line;
var _local1:* = -(pointList[0].x);
var _local2:* = -(pointList[0].y);
_local3 = 0;
while (_local3 < pointList.length) {
pointList[_local3].x = (pointList[_local3].x + _local1);
pointList[_local3].y = (pointList[_local3].y + _local2);
_local3++;
};
_local3 = 0;
while (_local3 < lineList.length) {
_local4 = lineList[_local3];
lineList[_local3].x0 = (_local4.x0 + _local1);
_local4.x1 = (_local4.x1 + _local1);
_local4.y0 = (_local4.y0 + _local2);
_local4.y1 = (_local4.y1 + _local2);
_local3++;
};
}
public function DrawCatmullRom(_arg1:BitmapData, _arg2:uint, _arg3:Number, _arg4:Number){
var _local6:Number;
var _local7:Point;
var _local5:int = GetNumPoints();
if (_local5 < 4){
return;
};
_local6 = 0;
while (_local6 < 1) {
_local7 = GetPointOnCatmullRom(_local6);
_arg1.setPixel32((_local7.x + _arg3), (_local7.y + _arg4), _arg2);
_local6 = (_local6 + 0.001);
};
}
public function GetNumPoints():int{
return (pointList.length);
}
public static function MakeSplineFromPointList(_arg1:Array):Poly{
var _local2:Point;
var _local3:Point;
var _local6:int;
_local2 = _arg1[0];
var _local4:Poly = new Poly("", 0, _local2.x, _local2.y);
var _local5:int = _arg1.length;
_local6 = 0;
while (_local6 < (_local5 - 1)) {
_local2 = _arg1[_local6];
_local3 = _arg1[(_local6 + 1)];
_local4.AddLine(_local2.x, _local2.y, _local3.x, _local3.y);
_local6++;
};
_local4.Finish(false);
_local4.CalculateCatmullRomLength();
return (_local4);
}
public static function FindAllByType(_arg1:int, _arg2:Array):Array{
var _local4:Poly;
var _local3:Array = new Array();
for each (_local4 in _arg2) {
if (_local4.type == _arg1){
_local3.push(_local4);
};
};
return (_local3);
}
public static function FindByName(_arg1:String, _arg2:Array):Poly{
var _local3:Poly;
for each (_local3 in _arg2) {
if (_local3.name == _arg1){
return (_local3);
};
};
return (null);
}
public static function FindIndexByName(_arg1:String, _arg2:Array):int{
var _local4:Poly;
var _local3:int;
for each (_local4 in _arg2) {
if (_local4.name == _arg1){
return (_local3);
};
_local3++;
};
return (-1);
}
}
}//package
Section 231
//PowerupMeter (PowerupMeter)
package {
import flash.display.*;
public dynamic class PowerupMeter extends MovieClip {
}
}//package
Section 232
//reloading_mc (reloading_mc)
package {
import flash.display.*;
public dynamic class reloading_mc extends MovieClip {
}
}//package
Section 233
//rifle_flash (rifle_flash)
package {
import flash.display.*;
public dynamic class rifle_flash extends MovieClip {
}
}//package
Section 234
//RoadBackgrounds (RoadBackgrounds)
package {
import flash.display.*;
public dynamic class RoadBackgrounds extends MovieClip {
}
}//package
Section 235
//RoadFairgroundBackgrounds (RoadFairgroundBackgrounds)
package {
import flash.display.*;
public dynamic class RoadFairgroundBackgrounds extends MovieClip {
}
}//package
Section 236
//rocketlauncher_explosion (rocketlauncher_explosion)
package {
import flash.display.*;
public dynamic class rocketlauncher_explosion extends MovieClip {
}
}//package
Section 237
//SaveData (SaveData)
package {
import flash.net.*;
public class SaveData {
static var id:String = "ZombieRun2";
public static function Clear():void{
var _local1:SharedObject = SharedObject.getLocal(id);
_local1.clear();
_local1.close();
_local1.flush();
trace("SaveData Data Cleared");
trace(("len: " + _local1.size));
}
public static function Save():void{
var _local1:int;
var _local4:Weapon;
var _local2:SharedObject = SharedObject.getLocal(id);
if (_local2 == null){
trace("SO null");
return;
};
if (_local2.size == 0){
trace("SO size 0");
};
_local2.clear();
_local2.data.currentLevel = Game.currentLevel;
_local2.data.currentWeapon = Game.currentWeapon;
_local2.data.secondaryWeapon = Game.secondaryWeapon;
var _local3:Array = new Array();
for each (_local4 in Game.weapons) {
_local3.push(_local4.available);
};
_local2.data.ws = _local3;
_local2.close();
trace("Saved Data OK");
}
public static function Load():void{
var _local3:Weapon;
var _local1:SharedObject = SharedObject.getLocal(id);
if (_local1 == null){
trace((("Shared Object: " + id) + " is null"));
return;
};
if (_local1.size == 0){
trace((("Shared Object: " + id) + " size=0"));
_local1.close();
return;
};
Game.currentLevel = _local1.data.currentLevel;
Game.currentWeapon = _local1.data.currentWeapon;
Game.secondaryWeapon = _local1.data.secondaryWeapon;
var _local2:int;
for each (_local3 in Game.weapons) {
_local3.available = _local1.data.ws[_local2];
_local2++;
};
_local1.close();
trace("Loaded data OK");
}
public static function DontLoad():void{
}
public static function Exists():Boolean{
var _local1:SharedObject = SharedObject.getLocal(id);
if (_local1 == null){
trace((("Shared Object: " + id) + " null"));
return (false);
};
if (_local1.size == 0){
trace((("Shared Object: " + id) + " size 0"));
_local1.close();
return (false);
};
_local1.close();
return (true);
}
public static function DontSave():void{
}
}
}//package
Section 238
//sfx_barrel_explode (sfx_barrel_explode)
package {
import flash.media.*;
public dynamic class sfx_barrel_explode extends Sound {
}
}//package
Section 239
//sfx_bullethit01 (sfx_bullethit01)
package {
import flash.media.*;
public dynamic class sfx_bullethit01 extends Sound {
}
}//package
Section 240
//sfx_bullethit02 (sfx_bullethit02)
package {
import flash.media.*;
public dynamic class sfx_bullethit02 extends Sound {
}
}//package
Section 241
//sfx_chainsaw (sfx_chainsaw)
package {
import flash.media.*;
public dynamic class sfx_chainsaw extends Sound {
}
}//package
Section 242
//sfx_crowbar (sfx_crowbar)
package {
import flash.media.*;
public dynamic class sfx_crowbar extends Sound {
}
}//package
Section 243
//sfx_crowd (sfx_crowd)
package {
import flash.media.*;
public dynamic class sfx_crowd extends Sound {
}
}//package
Section 244
//sfx_explode (sfx_explode)
package {
import flash.media.*;
public dynamic class sfx_explode extends Sound {
}
}//package
Section 245
//sfx_fireworksexplosion (sfx_fireworksexplosion)
package {
import flash.media.*;
public dynamic class sfx_fireworksexplosion extends Sound {
}
}//package
Section 246
//sfx_footstep (sfx_footstep)
package {
import flash.media.*;
public dynamic class sfx_footstep extends Sound {
}
}//package
Section 247
//sfx_headshot (sfx_headshot)
package {
import flash.media.*;
public dynamic class sfx_headshot extends Sound {
}
}//package
Section 248
//sfx_impact01 (sfx_impact01)
package {
import flash.media.*;
public dynamic class sfx_impact01 extends Sound {
}
}//package
Section 249
//sfx_impact02 (sfx_impact02)
package {
import flash.media.*;
public dynamic class sfx_impact02 extends Sound {
}
}//package
Section 250
//sfx_laser (sfx_laser)
package {
import flash.media.*;
public dynamic class sfx_laser extends Sound {
}
}//package
Section 251
//sfx_machinegun_shot (sfx_machinegun_shot)
package {
import flash.media.*;
public dynamic class sfx_machinegun_shot extends Sound {
}
}//package
Section 252
//sfx_machinegun_shot_02 (sfx_machinegun_shot_02)
package {
import flash.media.*;
public dynamic class sfx_machinegun_shot_02 extends Sound {
}
}//package
Section 253
//sfx_machinegun_shot_03 (sfx_machinegun_shot_03)
package {
import flash.media.*;
public dynamic class sfx_machinegun_shot_03 extends Sound {
}
}//package
Section 254
//sfx_pickup (sfx_pickup)
package {
import flash.media.*;
public dynamic class sfx_pickup extends Sound {
}
}//package
Section 255
//sfx_pistol_reload (sfx_pistol_reload)
package {
import flash.media.*;
public dynamic class sfx_pistol_reload extends Sound {
}
}//package
Section 256
//sfx_pistol_shot (sfx_pistol_shot)
package {
import flash.media.*;
public dynamic class sfx_pistol_shot extends Sound {
}
}//package
Section 257
//sfx_playerdie (sfx_playerdie)
package {
import flash.media.*;
public dynamic class sfx_playerdie extends Sound {
}
}//package
Section 258
//sfx_playerhit01 (sfx_playerhit01)
package {
import flash.media.*;
public dynamic class sfx_playerhit01 extends Sound {
}
}//package
Section 259
//sfx_playerhit02 (sfx_playerhit02)
package {
import flash.media.*;
public dynamic class sfx_playerhit02 extends Sound {
}
}//package
Section 260
//sfx_reload (sfx_reload)
package {
import flash.media.*;
public dynamic class sfx_reload extends Sound {
}
}//package
Section 261
//sfx_rifle_shot (sfx_rifle_shot)
package {
import flash.media.*;
public dynamic class sfx_rifle_shot extends Sound {
}
}//package
Section 262
//sfx_rocket (sfx_rocket)
package {
import flash.media.*;
public dynamic class sfx_rocket extends Sound {
}
}//package
Section 263
//sfx_shotgun (sfx_shotgun)
package {
import flash.media.*;
public dynamic class sfx_shotgun extends Sound {
}
}//package
Section 264
//sfx_whiz (sfx_whiz)
package {
import flash.media.*;
public dynamic class sfx_whiz extends Sound {
}
}//package
Section 265
//sfx_zombie (sfx_zombie)
package {
import flash.media.*;
public dynamic class sfx_zombie extends Sound {
}
}//package
Section 266
//sfx_zombie_02 (sfx_zombie_02)
package {
import flash.media.*;
public dynamic class sfx_zombie_02 extends Sound {
}
}//package
Section 267
//sfx_zombie_03 (sfx_zombie_03)
package {
import flash.media.*;
public dynamic class sfx_zombie_03 extends Sound {
}
}//package
Section 268
//ShockwaveLogo (ShockwaveLogo)
package {
import flash.display.*;
public dynamic class ShockwaveLogo extends MovieClip {
}
}//package
Section 269
//shoppingmall_background (shoppingmall_background)
package {
import flash.display.*;
public dynamic class shoppingmall_background extends MovieClip {
}
}//package
Section 270
//shotgun_flash (shotgun_flash)
package {
import flash.display.*;
public dynamic class shotgun_flash extends MovieClip {
}
}//package
Section 271
//SitelockedScreen (SitelockedScreen)
package {
import flash.display.*;
public dynamic class SitelockedScreen extends MovieClip {
public var buttonClickHere:SimpleButton;
}
}//package
Section 272
//sky (sky)
package {
import flash.display.*;
public dynamic class sky extends MovieClip {
}
}//package
Section 273
//SoundPlayer (SoundPlayer)
package {
import flash.media.*;
import flash.utils.*;
public class SoundPlayer {
public static const minPlayTime = 3;
static var channel:SoundChannel;
public static var startTimes:Array;
static var active = false;
public static var sound:Sound;
public static var volumes:Array;
public static var soundTransform:SoundTransform;
public static var playingChannels:Array;
static var main:Main;
public static var playingNames:Array;
public static var sounds:Array;
static var timer:Timer;
public static var times:Array;
public static var names:Array;
static var playingFlag:Boolean;
public static var lengths:Array;
static var Instances:Array;
public static var soundTransforms:Array;
static var doSFX:Boolean;
public static var soundChannels:Array;
public static function UpdateOncePerFrame():void{
var _local1:int;
var _local2:int = times.length;
_local1 = 0;
while (_local1 < _local2) {
if (times[_local1] > 0){
var _local3 = times;
var _local4 = _local1;
var _local5 = (_local3[_local4] - 1);
_local3[_local4] = _local5;
};
_local1++;
};
}
static function AddSound(_arg1:String){
var classRef:Class;
var s:Sound;
var _soundName = _arg1;
try {
classRef = (getDefinitionByName(_soundName) as Class);
} catch(e:Object) {
classRef = null;
};
if (classRef == null){
trace(("AddSound Error: Can't find sound " + _soundName));
sounds.push(null);
} else {
s = (new (classRef) as Sound);
sounds.push(s);
};
names.push(_soundName);
startTimes.push(0);
lengths.push(0);
volumes.push(1);
times.push(0);
}
public static function SetSoundChannelVolume(_arg1:SoundChannel, _arg2:Number){
if (_arg1 == null){
return;
};
var _local3:SoundTransform = _arg1.soundTransform;
_local3.volume = _arg2;
_arg1.soundTransform = _local3;
}
public static function ToggleMute(){
doSFX = (doSFX == false);
}
public static function Reset():void{
SoundMixer.stopAll();
playingChannels = new Array();
playingNames = new Array();
}
public static function InitOnce(_arg1:Main):void{
doSFX = Game.soundon;
main = _arg1;
startTimes = new Array();
lengths = new Array();
sounds = new Array();
names = new Array();
times = new Array();
volumes = new Array();
soundChannels = new Array();
soundTransforms = new Array();
AddSound("sfx_chainsaw");
AddSound("sfx_crowd");
AddSound("sfx_headshot");
AddSound("sfx_impact01");
AddSound("sfx_impact02");
AddSound("sfx_bullethit01");
AddSound("sfx_bullethit02");
AddSound("sfx_whiz");
AddSound("sfx_machinegun_shot");
AddSound("sfx_machinegun_shot_02");
AddSound("sfx_machinegun_shot_03");
AddSound("sfx_pistol_reload");
AddSound("sfx_pistol_shot");
AddSound("sfx_reload");
AddSound("sfx_rifle_shot");
AddSound("sfx_shotgun");
AddSound("sfx_zombie");
AddSound("sfx_zombie_02");
AddSound("sfx_zombie_03");
AddSound("sfx_barrel_explode");
AddSound("sfx_explode");
AddSound("sfx_footstep");
AddSound("sfx_rocket");
AddSound("sfx_crowbar");
AddSound("sfx_fireworksexplosion");
AddSound("sfx_pickup");
AddSound("sfx_laser");
AddSound("sfx_playerdie");
AddSound("sfx_playerhit01");
AddSound("sfx_playerhit02");
soundTransform = new SoundTransform(1, 0);
active = true;
playingFlag = false;
Reset();
}
public static function Play(_arg1:String, _arg2:Number=1, _arg3:int=0, _arg4:String=""):void{
if (doSFX == false){
return;
};
var _local5:int = names.indexOf(_arg1);
PlayById(_local5, _arg2, _arg3, _arg4);
}
public static function PlayById(_arg1:int, _arg2:Number=1, _arg3:int=0, _arg4:String=""):void{
var _local5:SoundTransform;
var _local6:Sound;
var _local7:SoundChannel;
if (doSFX == false){
return;
};
if (times[_arg1] > 0){
return;
};
if (sounds[_arg1] != null){
_local6 = sounds[_arg1];
_local5 = new SoundTransform();
_local5.volume = _arg2;
_local7 = _local6.play(0, _arg3, _local5);
times[_arg1] = 5;
if (_arg4 != ""){
trace(("adding " + _arg4));
playingNames.push(_arg4);
playingChannels.push(_local7);
};
} else {
trace(("SoundPlayer: Cant find sound " + _arg1));
};
}
public static function PlayRandomBetween(_arg1:String, _arg2:String, _arg3:Number=1, _arg4:int=0, _arg5:String=""):void{
if (doSFX == false){
return;
};
var _local6:int = names.indexOf(_arg1);
var _local7:int = names.indexOf(_arg2);
var _local8:int = Utils.RandBetweenInt(_local6, _local7);
PlayById(_local8, _arg3, _arg4, _arg5);
}
public static function GetId(_arg1:String):int{
var _local2:int = names.indexOf(_arg1);
return (_local2);
}
public static function GetSoundChannelByName(_arg1:String):SoundChannel{
var _local2:int;
var _local3:String;
_local2 = 0;
while (_local2 < playingChannels.length) {
_local3 = playingNames[_local2];
if (_local3 == _arg1){
return (playingChannels[_local2]);
};
_local2++;
};
return (null);
}
}
}//package
Section 274
//Stat (Stat)
package {
public class Stat {
var value:Number;
var name:String;
public function Stat(_arg1:String, _arg2:Number){
name = _arg1;
value = _arg2;
}
}
}//package
Section 275
//Stats (Stats)
package {
public class Stats {
static var list:Array;
public static function InitOnce(){
list = new Array();
}
public static function Add(_arg1:String, _arg2:Number){
var _local3:Stat = FindByName(_arg1);
_local3.value = (_local3.value + _arg2);
}
public static function FindByName(_arg1:String):Stat{
var _local2:Stat;
for each (_local2 in list) {
if (_local2.name == _arg1){
return (_local2);
};
};
return (null);
}
public static function Create(_arg1:String, _arg2:Number){
list.push(new Stat(_arg1, _arg2));
}
}
}//package
Section 276
//subwayBackgrounds (subwayBackgrounds)
package {
import flash.display.*;
public dynamic class subwayBackgrounds extends MovieClip {
}
}//package
Section 277
//TextBits (TextBits)
package {
import flash.display.*;
public dynamic class TextBits extends MovieClip {
}
}//package
Section 278
//TextBits_HeadShot (TextBits_HeadShot)
package {
import flash.display.*;
public dynamic class TextBits_HeadShot extends MovieClip {
}
}//package
Section 279
//titleScreen (titleScreen)
package {
import flash.display.*;
public dynamic class titleScreen extends MovieClip {
public var buttonContinue:SimpleButton;
public var buttonTwitter:SimpleButton;
public var sponsorLogo:MainLogo;
public var buttonLongAnimals:SimpleButton;
public var buttonStart:SimpleButton;
public var buttonMoreGames:SimpleButton;
public var buttonViewHighScores:SimpleButton;
public var buttonJimp:SimpleButton;
}
}//package
Section 280
//TitleScreenState (TitleScreenState)
package {
import flash.display.*;
import flash.events.*;
import flash.text.*;
import flash.net.*;
import com.newgrounds.components.*;
import flash.filters.*;
import flash.ui.*;
public class TitleScreenState {
static const numLevelsPerWorld:int = 5;
static var upgradeMCs:Array;
static var showingInstructions:Boolean;
static var greyFilter:ColorMatrixFilter = new ColorMatrixFilter([0.3086, 0.6094, 0.082, 0, 0, 0.3086, 0.6094, 0.082, 0, 0, 0.3086, 0.6094, 0.082, 0, 0, 0, 0, 0, 1, 0]);
static var levelSelect_selectedLevel:int;
static var numwselected:int;
static var wsels:Array;
static var nameEntered:String = "Your Name";
static var selectedAchievementIndex:int;
static var creditsMC:MovieClip;
static var upgradesMC:MovieClip;
static var main:Main;
static var helpOverlay:MovieClip;
static var instructionIndex:int;
static var overlayMC:MovieClip = null;
static var titleMC:MovieClip;
static var ws:Array;
static var instructionsMC:MovieClip;
public static function buttonViewHighScoresPressed(_arg1:MouseEvent){
titleMC.buttonStart.visible = false;
titleMC.buttonContinue.visible = false;
titleMC.buttonViewHighScores.visible = false;
if (Lic.GetLicensor() == Lic.LICENSOR_NEWGROUNDS){
Lic.ViewHighScores_Newgrounds(buttonViewHighScoresPressed_continue);
};
if (Lic.GetLicensor() == Lic.LICENSOR_ARMORGAMES){
Lic.ViewScore_ArmorGames(buttonViewHighScoresPressed_continue);
};
}
public static function LevelSelect_levelOut(_arg1:MouseEvent){
levelSelect_selectedLevel = -1;
Game.currentLevel = levelSelect_selectedLevel;
LevelSelect_Update();
}
public static function buttonViewScoresPressed(_arg1:MouseEvent){
navigateToURL(new URLRequest("http://www.longanimalsgames.com/ViewHighScore.php?game=blasterforce"), "_blank");
trace("view scores");
}
public static function buttonStartContinuePressed(_arg1:MouseEvent){
main.removeChild(titleMC);
titleMC = null;
Game.InitGame();
SaveData.Load();
Game.main.SetGameState(Main.gameState_LEVEL_PLAY);
}
public static function buttonJimpPressed(_arg1:MouseEvent){
navigateToURL(new URLRequest("http://jimp.grindheadstudios.com?referral=zomgies"), "_blank");
}
public static function buttonTwitterPressed(_arg1:MouseEvent){
navigateToURL(new URLRequest("http://twitter.com/ArmorGames"), "_blank");
}
public static function buttonSkipPressed(_arg1:MouseEvent){
titleMC.stop();
main.removeChild(titleMC);
titleMC = null;
Game.pause = false;
Game.RestartLevel();
}
public static function buttonCreditsBackPressed(_arg1:MouseEvent){
Game.main.removeChild(creditsMC);
creditsMC = null;
}
public static function buttonEnterCheatsPressed(_arg1:MouseEvent){
}
static function instructionsContinuePressed(_arg1:MouseEvent){
var _local2:Level = Game.GetCurrentLevel();
instructionIndex++;
if (instructionIndex > _local2.helpscreenFrames.length){
Game.main.removeChild(instructionsMC);
instructionsMC = null;
showingInstructions = false;
Game.InitLevelState(Game.levelState_Play);
Mouse.hide();
} else {
instructionsMC.gotoAndStop(_local2.helpscreenFrames[instructionIndex]);
instructionsMC.buttonContinue.visible = false;
if (_local2.helpscreenFrames.length > (instructionIndex + 1)){
instructionsMC.buttonContinue.visible = true;
};
instructionsMC.buttonDone.visible = (instructionsMC.buttonContinue.visible == false);
};
}
static function PlayOuttro(){
titleMC = main.AddMovieClip(0, 0, new end_animation());
titleMC.buttonContinue.addEventListener(MouseEvent.CLICK, buttonSkipPressed, false, 0, true);
titleMC.buttonQuit.addEventListener(MouseEvent.CLICK, buttonOuttroRestartPressed, false, 0, true);
titleMC.buttonSubmitHighscore.visible = false;
if (Lic.GetLicensor() == Lic.LICENSOR_ARMORGAMES){
titleMC.buttonSubmitHighscore.visible = true;
titleMC.buttonSubmitHighscore.addEventListener(MouseEvent.CLICK, buttonSubmitHighscorePressed, false, 0, true);
};
if (Lic.GetLicensor() == Lic.LICENSOR_NEWGROUNDS){
titleMC.buttonSubmitHighscore.visible = true;
titleMC.buttonSubmitHighscore.addEventListener(MouseEvent.CLICK, buttonSubmitHighscorePressed, false, 0, true);
};
titleMC.gotoAndPlay(1);
}
public static function LevelSelect_buttonNextPressed(_arg1:MouseEvent){
var _local5:int;
var _local6:String;
var _local7:MovieClip;
var _local2:Boolean;
var _local3:int = _arg1.currentTarget.levelID;
var _local4:Level = Game.GetLevel(_local3);
if (_local4.available){
_local2 = true;
};
if (Game.usedebug){
_local2 = true;
};
if (_local2 == false){
return;
};
_local5 = 0;
while (_local5 < Game.levels.length) {
_local6 = ("level" + _local5);
_local7 = (titleMC.getChildByName(_local6) as MovieClip);
_local7.removeEventListener(MouseEvent.CLICK, LevelSelect_buttonNextPressed);
_local7.removeEventListener(MouseEvent.MOUSE_OVER, LevelSelect_levelOver);
_local7.removeEventListener(MouseEvent.MOUSE_OUT, LevelSelect_levelOut);
_local5++;
};
Game.main.removeChild(titleMC);
titleMC = null;
SaveData.Save();
Mouse.hide();
Game.main.SetGameState(Main.gameState_LEVEL_PLAY);
}
static function MainLogo(_arg1:MovieClip):void{
Lic.MainLogo(_arg1);
}
public static function InitAchievementScreen(){
var _local2:Achievement;
var _local3:MovieClip;
Mouse.show();
overlayMC.buttonBack.addEventListener(MouseEvent.CLICK, AchievementScreen_buttonBackPressed, false, 0, true);
var _local1:int;
for each (_local2 in Game.achievements.list) {
_local3 = (overlayMC.getChildByName(("ach" + _local1.toString())) as MovieClip);
if (_local3 != null){
_local3.addEventListener(MouseEvent.CLICK, AchievementScreen_achievementPressed, false, 0, true);
_local3.achID = _local1;
_local3.textNumber.text = (_local1 + 1).toString();
_local3.tick.visible = false;
if (_local2.complete){
_local3.tick.visible = true;
};
_local3.selectedClip.visible = false;
};
_local1++;
};
selectedAchievementIndex = -1;
overlayMC.textName.text = "";
overlayMC.textDescription.text = "";
}
public static function Init(_arg1:Main){
Mouse.show();
main = _arg1;
MusicPlayer.StopMusic();
MusicPlayer.StartStream(0);
main.InitStage();
titleMC = main.AddMovieClip(0, 0, new titleScreen());
titleMC.buttonStart.addEventListener(MouseEvent.CLICK, buttonStartPressed, false, 0, true);
titleMC.buttonContinue.addEventListener(MouseEvent.CLICK, buttonStartContinuePressed, false, 0, true);
MainLogo(titleMC.sponsorLogo);
MoreGames(titleMC.buttonMoreGames);
titleMC.buttonTwitter.visible = false;
titleMC.buttonViewHighScores.visible = false;
if (Lic.GetLicensor() == Lic.LICENSOR_ARMORGAMES){
titleMC.buttonTwitter.visible = true;
titleMC.buttonViewHighScores.visible = true;
titleMC.buttonTwitter.addEventListener(MouseEvent.CLICK, buttonTwitterPressed, false, 0, true);
titleMC.buttonViewHighScores.addEventListener(MouseEvent.CLICK, buttonViewHighScoresPressed, false, 0, true);
};
if (Lic.GetLicensor() != Lic.LICENSOR_ADDICTINGGAMES){
titleMC.buttonLongAnimals.addEventListener(MouseEvent.CLICK, buttonLongAnimalsPressed, false, 0, true);
titleMC.buttonJimp.addEventListener(MouseEvent.CLICK, buttonJimpPressed, false, 0, true);
};
if (Lic.GetLicensor() == Lic.LICENSOR_NEWGROUNDS){
titleMC.buttonViewHighScores.visible = true;
titleMC.buttonViewHighScores.addEventListener(MouseEvent.CLICK, buttonViewHighScoresPressed, false, 0, true);
};
}
public static function buttonSubmitScorePressed(_arg1:MouseEvent){
var e = _arg1;
var s:int = Game.currentScore;
var key:int = s;
key = (key + 84563);
key = (key * 7);
key = (key - 276483);
nameEntered = titleMC.textName.text;
titleMC.buttonSubmit.visible = false;
trace(((("submit score " + s) + " key=") + key));
var path = "http://www.longanimalsgames.com/ViewHighScore.php";
var vars:URLVariables = new URLVariables();
vars.game = "blasterforce";
vars.submit = 1;
vars.score = s;
vars.key = key;
vars.name = nameEntered;
var request:URLRequest = new URLRequest(path);
request.method = URLRequestMethod.POST;
request.data = vars;
trace("Stats sent to server");
trace(request);
try {
sendToURL(request);
} catch(e:Error) {
trace(e.message);
};
buttonViewScoresPressed(e);
}
public static function buttonHelpOverlayStartPressed(_arg1:MouseEvent){
main.removeChild(helpOverlay);
helpOverlay = null;
main.removeChild(titleMC);
titleMC = null;
Game.InitGame();
Game.ResetGame();
SaveData.Save();
Game.main.SetGameState(Main.gameState_LEVEL_PLAY);
}
public static function buttonSubmitHighscorePressedCallback(){
titleMC.buttonContinue.visible = true;
titleMC.buttonQuit.visible = true;
}
public static function InitGameOverScreen(){
Mouse.show();
MusicPlayer.StopMusic();
MusicPlayer.StartStream(0);
main.InitStage();
titleMC.buttonDone.addEventListener(MouseEvent.CLICK, buttonDonePressed, false, 0, true);
titleMC.buttonRestart.addEventListener(MouseEvent.CLICK, buttonRestartPressed, false, 0, true);
titleMC.buttonSubmit.addEventListener(MouseEvent.CLICK, buttonSubmitScorePressed, false, 0, true);
titleMC.buttonMoreGames.addEventListener(MouseEvent.CLICK, buttonLongAnimalsPressed, false, 0, true);
titleMC.buttonLongAnimals.addEventListener(MouseEvent.CLICK, buttonLongAnimalsPressed, false, 0, true);
titleMC.buttonViewHighscores.addEventListener(MouseEvent.CLICK, buttonViewScoresPressed, false, 0, true);
var _local1:int = Game.currentScore;
titleMC.textScore.text = ("You Scored " + _local1);
titleMC.textName.text = nameEntered;
}
public static function WorldSelect_Update(){
var _local1:int;
var _local2:MovieClip;
_local1 = 0;
while (_local1 < 5) {
_local2 = titleMC[("level" + (_local1 + 1).toString())];
_local2.selectedMC.visible = false;
if (_local1 == Game.currentWorldID){
_local2.selectedMC.visible = true;
};
_local1++;
};
}
static function instructionsClosePressed(_arg1:MouseEvent){
Game.main.removeChild(instructionsMC);
instructionsMC = null;
Mouse.hide();
showingInstructions = false;
Game.InitLevelState(Game.levelState_Play);
}
public static function InitLevelEndScreen(){
Mouse.show();
var _local1:Level = Game.GetCurrentLevel();
titleMC.innerholder.inner.textStat0.text = (("You took " + Utils.CounterToSecondsString(Game.levelTimer)) + " seconds");
titleMC.innerholder.inner.textStat1.text = (((Game.numPigsSacrificed + " Guinea Pigs = ") + (Game.numPigsSacrificed * 5)) + " sec. penalty");
titleMC.innerholder.inner.textStat2.text = (("Final Time: " + Utils.CounterToSecondsString(_local1.lastTimeTotal)) + " seconds");
var _local2:int = Game.GetLastLevelAward(_local1);
var _local3 = "";
if (_local2 == 0){
_local3 = "Bronze Medal Awarded";
};
if (_local2 == 1){
_local3 = "Silver Medal Awarded";
};
if (_local2 == 2){
_local3 = "Gold Medal Awarded";
};
titleMC.innerholder.inner.textStat3.text = _local3;
titleMC.innerholder.inner.textStat4.text = ("Score: " + Game.currentScore);
titleMC.buttonNext.addEventListener(MouseEvent.CLICK, LevelEnd_buttonNextPressed, false, 0, true);
titleMC.buttonMainMenu.addEventListener(MouseEvent.CLICK, LevelEnd_buttonMenuPressed, false, 0, true);
SponsorBar(titleMC.sponsorBar);
}
public static function buttonStart1Over(_arg1:MouseEvent){
titleMC.textShipDetails.text = "Fast But Less Manoeverable";
}
public static function AchievementScreen_achievementPressed(_arg1:MouseEvent){
var _local2:Achievement;
var _local4:MovieClip;
selectedAchievementIndex = _arg1.currentTarget.achID;
_local2 = Game.achievements.list[selectedAchievementIndex];
overlayMC.textName.text = _local2.name;
overlayMC.textDescription.text = _local2.description;
var _local3:int;
for each (_local2 in Game.achievements.list) {
_local4 = (overlayMC.getChildByName(("ach" + _local3.toString())) as MovieClip);
if (_local4 != null){
_local4.selectedClip.visible = false;
if (_local3 == selectedAchievementIndex){
_local4.selectedClip.visible = true;
};
};
_local3++;
};
}
static function MoreGames(_arg1:SimpleButton):void{
Lic.MoreGames(_arg1);
}
public static function InitLevelSelect(){
var _local1:int;
var _local2:int;
var _local3:int;
var _local4:int;
var _local5:int;
var _local9:int;
var _local10:Level;
var _local11:MovieClip;
var _local12:int;
Mouse.show();
levelSelect_selectedLevel = -1;
SponsorBar(titleMC.sponsorBar);
var _local6 = 650;
_local2 = 30;
_local1 = _local2;
_local3 = 50;
_local4 = 70;
_local5 = 70;
var _local7:int;
var _local8:int;
while (_local8 < 1) {
_local9 = 0;
while (_local9 < Game.levels.length) {
_local10 = Game.GetLevel(_local9);
_local11.name = ("level" + _local9);
_local11.levelID = _local9;
_local11.gotoAndStop(1);
_local11.clipComplete.visible = false;
_local11.clipSelected.visible = false;
_local11.clipLocked.visible = false;
if (_local10.available == false){
_local11.clipLocked.visible = true;
};
if (_local10.complete == true){
_local11.clipComplete.visible = true;
_local12 = Game.GetLevelAward(_local10);
if (_local12 == 0){
_local11.clipComplete.gotoAndStop(1);
};
if (_local12 == 1){
_local11.clipComplete.gotoAndStop(2);
};
if (_local12 == 2){
_local11.clipComplete.gotoAndStop(3);
};
};
_local11.textLevelNumber.text = (_local9 + 1).toString();
_local11.x = _local1;
_local11.y = _local3;
_local11.addEventListener(MouseEvent.CLICK, LevelSelect_buttonNextPressed, false, 0, true);
_local11.addEventListener(MouseEvent.MOUSE_OVER, LevelSelect_levelOver, false, 0, true);
_local11.addEventListener(MouseEvent.MOUSE_OUT, LevelSelect_levelOut, false, 0, true);
_local11.useHandCursor = true;
_local11.buttonMode = true;
titleMC.addChild(_local11);
_local1 = (_local1 + _local4);
if (_local1 > _local6){
if (_local7 == 0){
_local7 = 25;
} else {
_local7 = 0;
};
_local1 = (_local2 + _local7);
_local3 = (_local3 + _local5);
};
_local9++;
};
_local3 = (_local3 + (_local5 + 20));
_local1 = _local2;
_local8++;
};
titleMC.textScore.text = ("Score: " + Game.currentScore);
titleMC.textTrackName.text = "";
titleMC.textStat0.text = "";
titleMC.textStat1.text = "";
LevelSelect_Update();
}
public static function buttonMaxAllUpgrades(_arg1:MouseEvent){
var _local2:Upgrade;
for each (_local2 in Game.upgrades) {
_local2.currentLevel = _local2.maxLevel;
};
UpdateUpgrades();
}
public static function buttonMoreGamesPressed(_arg1:MouseEvent){
navigateToURL(new URLRequest("http://armorgames.com/tag/zombie/"), "_blank");
}
public static function GameOverScreenComplete(){
main.removeChild(titleMC);
titleMC = null;
Game.main.SetGameState(Main.gameState_TITLE);
}
public static function WorldSelect_worldOut(_arg1:MouseEvent){
Game.currentWorldID = -1;
WorldSelect_Update();
titleMC.textInfo.text = "";
}
public static function LevelDone_buttonContinuePressed(_arg1:MouseEvent){
Game.NextLevel();
}
public static function InitUpgradesScreen(){
Game.cash = 1000000;
Mouse.show();
upgradesMC.buttonContinue.addEventListener(MouseEvent.CLICK, UpgradesScreen_buttonContinuePressed, false, 0, true);
upgradesMC.buttonLongAnimals.addEventListener(MouseEvent.CLICK, buttonLongAnimalsPressed, false, 0, true);
upgradesMC.buttonMoreGames.addEventListener(MouseEvent.CLICK, buttonMaxAllUpgrades, false, 0, true);
upgradesMC.buttonViewHighscores.addEventListener(MouseEvent.CLICK, buttonMinAllUpgrades, false, 0, true);
upgradeMCs = new Array();
InitUpgrade(upgradesMC.u0, 0);
InitUpgrade(upgradesMC.u1, 1);
InitUpgrade(upgradesMC.u2, 2);
InitUpgrade(upgradesMC.u3, 3);
InitUpgrade(upgradesMC.u4, 4);
InitUpgrade(upgradesMC.u5, 5);
InitUpgrade(upgradesMC.u6, 6);
InitUpgrade(upgradesMC.u7, 7);
UpdateUpgrades();
}
public static function BetweenLevelsScreen_buttonContinuePressed(_arg1:MouseEvent){
main.removeChild(titleMC);
titleMC = null;
Game.pause = false;
ReadyWeapons();
Game.NextLevel();
SaveData.Save();
}
static function PlayIntro(){
}
public static function LevelSelect_levelOver(_arg1:MouseEvent){
var _local2:int = _arg1.currentTarget.levelID;
levelSelect_selectedLevel = _local2;
Game.currentLevel = _local2;
LevelSelect_Update();
}
public static function LevelStart_buttonNextPressed(_arg1:MouseEvent){
Game.main.removeChild(titleMC);
titleMC = null;
Game.pause = false;
KeyReader.InitOnce(Game.main.stage);
}
public static function InitLevelFailScreen(){
Mouse.show();
PlayOuttro();
}
public static function InitHelpOverlay(){
helpOverlay = new HelpScreen();
helpOverlay.buttonContinue.addEventListener(MouseEvent.CLICK, buttonHelpOverlayStartPressed, false, 0, true);
main.addChild(helpOverlay);
}
static function LevelSelect_Update(){
var _local1:int;
var _local2:Level;
var _local3:int;
var _local4:String;
var _local5:MovieClip;
if (levelSelect_selectedLevel == -1){
titleMC.textTrackName.text = "";
titleMC.textStat0.text = "";
titleMC.textStat1.text = "";
} else {
_local2 = Game.GetLevel(levelSelect_selectedLevel);
titleMC.textTrackName.text = _local2.name;
titleMC.textStat0.text = "";
titleMC.textStat1.text = "";
if (_local2.complete){
titleMC.textStat0.text = (((((("Best Time: " + Utils.CounterToSecondsString(_local2.bestTimeTotal)) + " ( Gold = ") + Utils.CounterToSecondsString(_local2.goldTime)) + " Silver = ") + Utils.CounterToSecondsString(_local2.silverTime)) + " )");
_local3 = Game.GetLevelAward(_local2);
if (_local3 == 0){
titleMC.textStat1.text = "Bronze Medal";
};
if (_local3 == 1){
titleMC.textStat1.text = "Silver Medal";
};
if (_local3 == 2){
titleMC.textStat1.text = "Gold Medal";
};
} else {
titleMC.textStat0.text = (((("( Gold = " + Utils.CounterToSecondsString(_local2.goldTime)) + " Silver = ") + Utils.CounterToSecondsString(_local2.silverTime)) + " )");
};
};
_local1 = 0;
while (_local1 < Game.levels.length) {
_local4 = ("level" + _local1);
_local5 = (titleMC.getChildByName(_local4) as MovieClip);
if (_local1 == levelSelect_selectedLevel){
_local5.clipSelected.visible = true;
} else {
_local5.clipSelected.visible = false;
};
_local1++;
};
}
public static function InitBetweenLevelsScreen(){
var _local6:int;
var _local7:Weapon;
var _local8:MovieClip;
Mouse.show();
MusicPlayer.StopMusic();
MusicPlayer.StartStream(0);
Game.QuietAllSounds();
main.InitStage();
titleMC = main.AddMovieClip(0, 0, new BetweenLevelsScreen());
var _local1:MedalPopup = new MedalPopup();
titleMC.addChild(_local1);
titleMC.foundWeaponText.text = "";
if (Game.foundWeapon != -1){
titleMC.foundWeaponText.text = ("Found New Weapon: " + Game.weapons[Game.foundWeapon].name);
};
var _local2:* = ((100 / Game.numKills) * Game.numHeadshotKills);
var _local3:* = ((100 / Game.numLevelKills) * Game.numLevelHeadshotKills);
var _local4:* = ((100 / Game.numPickupsGenerated) * Game.numPickupsCollected);
var _local5:* = ((100 / Game.totalPickupsGenerated) * Game.totalPickupsCollected);
_local2 = Math.round(_local2);
_local3 = Math.round(_local3);
_local4 = Math.round(_local4);
_local5 = Math.round(_local5);
titleMC.textKills.text = (Game.numKills + " Kills");
titleMC.textHeadshots.text = (((Game.numHeadshotKills + " Headshots (") + _local2) + " percent)");
titleMC.textPickups.text = (((((Game.totalPickupsCollected + "/") + Game.totalPickupsGenerated) + " pickups (") + _local5) + " percent)");
titleMC.textLevelKills.text = (Game.numLevelKills + " Kills");
titleMC.textLevelHeadshots.text = (((Game.numLevelHeadshotKills + " Headshots (") + _local3) + " percent)");
titleMC.textLevelPickups.text = (((((Game.numPickupsCollected + "/") + Game.numPickupsGenerated) + " pickups (") + _local4) + " percent)");
titleMC.textScore.text = ("Score: " + Game.currentScore);
titleMC.buttonContinue.addEventListener(MouseEvent.CLICK, BetweenLevelsScreen_buttonContinuePressed, false, 0, true);
ws = new Array();
ws.push(titleMC.getChildByName("w0"));
ws.push(titleMC.getChildByName("w1"));
ws.push(titleMC.getChildByName("w2"));
ws.push(titleMC.getChildByName("w3"));
ws.push(titleMC.getChildByName("w4"));
ws.push(titleMC.getChildByName("w5"));
ws.push(titleMC.getChildByName("w6"));
ws.push(titleMC.getChildByName("w7"));
ws.push(titleMC.getChildByName("w8"));
ws.push(titleMC.getChildByName("w9"));
ws.push(titleMC.getChildByName("w10"));
wsels = new Array();
wsels.push(false);
wsels.push(false);
wsels.push(false);
wsels.push(false);
wsels.push(false);
wsels.push(false);
wsels.push(false);
wsels.push(false);
wsels.push(false);
wsels.push(false);
wsels.push(false);
numwselected = 0;
if (Game.currentWeapon != -1){
wsels[Game.currentWeapon] = true;
numwselected++;
};
if (Game.secondaryWeapon != -1){
wsels[Game.secondaryWeapon] = true;
numwselected++;
};
if (numwselected != 2){
titleMC.buttonContinue.visible = false;
};
_local6 = 0;
while (_local6 < Game.weapons.length) {
_local7 = Game.weapons[_local6];
_local8 = ws[_local6];
_local8.weapon.gotoAndStop((_local7.frame + 1));
_local8.weaponIndex = _local6;
if (_local7.available == false){
_local8.weapon.gotoAndStop(12);
_local8.selected.visible = false;
} else {
_local8.selected.visible = wsels[_local6];
_local8.addEventListener(MouseEvent.CLICK, BetweenLevelsScreen_weaponClicked, false, 0, true);
};
_local6++;
};
SaveData.Save();
}
public static function WorldSelect_worldOver(_arg1:MouseEvent){
var _local2:int = _arg1.currentTarget.worldID;
Game.currentWorldID = _local2;
WorldSelect_Update();
titleMC.textInfo.text = ("World " + (_local2 + 1));
}
public static function buttonLongAnimalsPressed(_arg1:MouseEvent){
navigateToURL(new URLRequest("http://www.longanimalsgames.com?referral=zomgies"), "_blank");
}
public static function InitLevelStartScreen(){
var _local3:Achievement;
var _local4:TextField;
Mouse.show();
Game.pause = true;
var _local1:Level = Game.GetCurrentLevel();
titleMC.textTitle.text = ("Starting Level " + (Game.currentLevel + 1));
titleMC.textAchievement0.text = "";
titleMC.textAchievement1.text = "";
titleMC.textAchievement2.text = "";
titleMC.complete0.gotoAndStop(1);
titleMC.complete1.gotoAndStop(1);
titleMC.complete2.gotoAndStop(1);
var _local2:int;
for each (_local3 in Game.achievements.list) {
if ((_local3.specificLevel - 1) == Game.currentLevel){
_local4 = titleMC[("textAchievement" + _local2)];
_local4.text = _local3.name;
_local4.text = (_local4.text + "\n");
_local4.text = (_local4.text + _local3.description);
_local2++;
};
};
titleMC.textBest.text = "Best Time: 1.23";
titleMC.buttonNext.addEventListener(MouseEvent.CLICK, LevelStart_buttonNextPressed, false, 0, true);
}
public static function MovieFinished(){
Game.InitGame();
main.SetGameState(Main.gameState_LEVEL_PLAY);
}
static function buttonRobotJamPressed(_arg1:MouseEvent){
navigateToURL(new URLRequest("http://www.robotjamgames.com?referral=bike"), "_blank");
}
public static function buttonClearSaveDataPressed(_arg1:MouseEvent){
SaveData.Clear();
}
public static function LevelSelect_buttonBackPressed(_arg1:MouseEvent){
Game.main.removeChild(titleMC);
titleMC = null;
SaveData.Save();
InitWorldSelect();
}
public static function WorldSelect_Next(){
var _local1:int;
var _local2:MovieClip;
_local1 = 0;
while (_local1 < 5) {
_local2 = titleMC[("level" + (_local1 + 1).toString())];
_local2.removeEventListener(MouseEvent.CLICK, WorldSelect_worldPressed);
_local2.removeEventListener(MouseEvent.MOUSE_OVER, WorldSelect_worldOver);
_local2.removeEventListener(MouseEvent.MOUSE_OUT, WorldSelect_worldOut);
_local1++;
};
Game.main.removeChild(titleMC);
titleMC = null;
InitLevelSelect();
}
static function buttonNickPressed(_arg1:MouseEvent){
navigateToURL(new URLRequest("http://www.nick.com/kids-choice-awards/kca.jhtml"), "_blank");
}
public static function buttonDonePressed(_arg1:MouseEvent){
main.removeChild(titleMC);
titleMC = null;
main.SetGameState(Main.gameState_TITLE);
}
public static function buttonStartPressed(_arg1:MouseEvent){
InitHelpOverlay();
}
public static function LevelEnd_buttonNextPressed(_arg1:MouseEvent){
Mouse.hide();
Game.main.removeChild(titleMC);
titleMC = null;
Game.NextLevel();
}
public static function UpgradesScreen_buttonUpgradePressed(_arg1:MouseEvent){
var _local2:MovieClip = (_arg1.currentTarget.parent as MovieClip);
var _local3:int = _local2.upgradeIndex;
var _local4:Upgrade = Game.upgrades[_local3];
_local4.DoUpgrade();
UpdateUpgrades();
}
public static function buttonMinAllUpgrades(_arg1:MouseEvent){
var _local2:Upgrade;
for each (_local2 in Game.upgrades) {
_local2.currentLevel = 0;
};
UpdateUpgrades();
}
public static function LevelFail_buttonNextPressed(_arg1:MouseEvent){
Mouse.hide();
Game.main.removeChild(titleMC);
titleMC = null;
Game.RestartLevel();
}
public static function WorldSelect_worldPressed(_arg1:MouseEvent){
WorldSelect_Next();
}
public static function AchievementScreen_buttonBackPressed(_arg1:MouseEvent){
Game.main.removeChild(overlayMC);
overlayMC = null;
}
public static function WorldSelect_buttonBackPressed(_arg1:MouseEvent){
}
public static function LevelEnd_buttonMenuPressed(_arg1:MouseEvent){
Game.main.removeChild(titleMC);
titleMC = null;
InitLevelSelect();
}
public static function buttonAchievementsPressed(_arg1:MouseEvent){
InitAchievementScreen();
}
static function SponsorBar(_arg1:MovieClip):void{
}
public static function LevelFail_buttonMenuPressed(_arg1:MouseEvent){
Game.main.removeChild(titleMC);
titleMC = null;
InitLevelSelect();
}
public static function buttonStart2Over(_arg1:MouseEvent){
titleMC.textShipDetails.text = "Fast Turn Rate / Less Acceleration";
}
public static function InitUpgrade(_arg1:MovieClip, _arg2:int){
var _local3:Upgrade = Game.upgrades[_arg2];
_arg1.upgradeIndex = _arg2;
_arg1.textName.text = _local3.name;
_arg1.buttonUpgrade.addEventListener(MouseEvent.CLICK, UpgradesScreen_buttonUpgradePressed, false, 0, true);
upgradeMCs.push(_arg1);
}
public static function buttonSubmitHighscorePressed(_arg1:MouseEvent){
titleMC.buttonContinue.visible = false;
titleMC.buttonQuit.visible = false;
titleMC.buttonSubmitHighscore.visible = false;
if (Lic.GetLicensor() == Lic.LICENSOR_ARMORGAMES){
Lic.SubmitHighscore_ArmorGames(Game.currentScore, buttonSubmitHighscorePressedCallback);
};
if (Lic.GetLicensor() == Lic.LICENSOR_NEWGROUNDS){
Lic.SubmitHighscore_Newgrounds(Game.currentScore, buttonSubmitHighscorePressedCallback);
};
}
public static function InitWorldSelect(){
var _local1:int;
var _local2:MovieClip;
Mouse.show();
titleMC.textInfo.text = "";
Game.currentWorldID = -1;
_local1 = 0;
while (_local1 < 5) {
_local2 = titleMC[("level" + (_local1 + 1).toString())];
_local2.addEventListener(MouseEvent.CLICK, WorldSelect_worldPressed, false, 0, true);
_local2.addEventListener(MouseEvent.MOUSE_OVER, WorldSelect_worldOver, false, 0, true);
_local2.addEventListener(MouseEvent.MOUSE_OUT, WorldSelect_worldOut, false, 0, true);
_local2.worldID = _local1;
_local2.gotoAndStop((_local1 + 1));
_local2.lock.visible = true;
_local2.selectedMC.visible = false;
_local1++;
};
WorldSelect_Update();
}
public static function UpdateUpgrades(){
var _local1:MovieClip;
var _local2:Upgrade;
var _local3:int;
var _local4:Number;
for each (_local1 in upgradeMCs) {
_local2 = Game.upgrades[_local1.upgradeIndex];
_local3 = _local1.totalFrames;
_local4 = Utils.ScaleTo(_local3, 1, 0, _local2.maxLevel, _local2.currentLevel);
_local1.gotoAndStop(int(_local4));
_local1.level.text = ((int((_local2.currentLevel + 1)) + " / ") + int(_local2.numLevels));
_local1.buttonUpgrade.visible = false;
_local1.cost.visible = false;
_local1.cost.text = _local2.GetCost();
if (_local2.CanAfford()){
_local1.buttonUpgrade.visible = true;
_local1.cost.visible = true;
};
};
upgradesMC.textCash.text = ("Cash " + Game.cash);
}
static function ReadyWeapons(){
var _local1:int;
Game.currentWeapon = -1;
Game.secondaryWeapon = -1;
_local1 = 0;
while (_local1 < 11) {
if (wsels[_local1] == true){
if (Game.currentWeapon == -1){
Game.currentWeapon = _local1;
} else {
Game.secondaryWeapon = _local1;
};
};
_local1++;
};
}
public static function buttonStartOut(_arg1:MouseEvent){
if (titleMC == null){
return;
};
if (titleMC.textShipDetails == null){
return;
};
titleMC.textShipDetails.text = "";
}
public static function buttonOuttroRestartPressed(_arg1:MouseEvent){
titleMC.stop();
main.removeChild(titleMC);
titleMC = null;
Game.main.SetGameState(Main.gameState_TITLE);
}
public static function Update(_arg1:Main){
Game.RenderTitleScreen();
}
public static function buttonStart0Over(_arg1:MouseEvent){
titleMC.textShipDetails.text = "Average Handling And Speed";
}
public static function UpgradesScreen_buttonContinuePressed(_arg1:MouseEvent){
main.removeChild(upgradesMC);
upgradesMC = null;
}
public static function BetweenLevelsScreen_weaponClicked(_arg1:MouseEvent){
var _local4:int;
var _local2:MovieClip = (_arg1.currentTarget as MovieClip);
var _local3:int = _local2.weaponIndex;
if (numwselected <= 1){
wsels[_local3] = (wsels[_local3] == false);
} else {
if (wsels[_local3] == true){
wsels[_local3] = false;
};
};
numwselected = 0;
_local4 = 0;
while (_local4 < 11) {
if (wsels[_local4] == false){
ws[_local4].selected.visible = false;
} else {
ws[_local4].selected.visible = true;
numwselected++;
};
_local4++;
};
titleMC.buttonContinue.visible = true;
if (numwselected != 2){
titleMC.buttonContinue.visible = false;
};
}
public static function InitEndGameScreen(){
}
static function InitLevelInstructions(){
showingInstructions = false;
var _local1:Level = Game.GetCurrentLevel();
if (_local1.helpscreenFrames.length == 0){
Game.InitLevelState(Game.levelState_Play);
return;
};
Mouse.show();
showingInstructions = true;
instructionIndex = 0;
instructionsMC.buttonContinue.addEventListener(MouseEvent.CLICK, instructionsContinuePressed, false, 0, true);
instructionsMC.buttonDone.addEventListener(MouseEvent.CLICK, instructionsClosePressed, false, 0, true);
Game.main.addChild(instructionsMC);
instructionsMC.buttonContinue.visible = false;
if (_local1.helpscreenFrames.length > (instructionIndex + 1)){
instructionsMC.buttonContinue.visible = true;
};
instructionsMC.buttonDone.visible = (instructionsMC.buttonContinue.visible == false);
instructionsMC.visible = true;
instructionsMC.gotoAndStop(_local1.helpscreenFrames[instructionIndex]);
}
public static function buttonCreditsPressed(_arg1:MouseEvent){
}
public static function SponsorBar_cheatsPressed(_arg1:MouseEvent){
}
public static function buttonRestartPressed(_arg1:MouseEvent){
main.removeChild(titleMC);
titleMC = null;
main.SetGameState(Main.gameState_LEVEL_PLAY);
}
public static function buttonViewHighScoresPressed_continue(){
titleMC.buttonStart.visible = true;
titleMC.buttonContinue.visible = true;
titleMC.buttonViewHighScores.visible = true;
}
}
}//package
Section 281
//Tune01 (Tune01)
package {
import flash.media.*;
public dynamic class Tune01 extends Sound {
}
}//package
Section 282
//Upgrade (Upgrade)
package {
public class Upgrade {
var maxLevel:int;
var currentLevel:int;
var max:Number;
var min:Number;
var numLevels:int;
var name:String;
var baseCost:int;
public function Upgrade(_arg1:String, _arg2:Number, _arg3:Number, _arg4:int, _arg5:int){
name = _arg1;
min = _arg2;
max = _arg3;
numLevels = _arg4;
maxLevel = (numLevels - 1);
currentLevel = 0;
baseCost = _arg5;
}
public function GetCost():int{
var _local1:int = (baseCost * (currentLevel + 1));
return (_local1);
}
public function GetLevel():int{
return (currentLevel);
}
public function CanAfford():Boolean{
var _local1:* = GetCost();
if (_local1 > Game.cash){
return (false);
};
return (true);
}
public function DoUpgrade(){
if (currentLevel >= maxLevel){
return;
};
Game.cash = (Game.cash - GetCost());
currentLevel++;
}
public function GetValue():Number{
return (Utils.ScaleTo(min, max, 0, maxLevel, currentLevel));
}
}
}//package
Section 283
//Utils (Utils)
package {
import flash.display.*;
import flash.geom.*;
public class Utils {
static function SideOfLine(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Number, _arg6:Number):Boolean{
var _local7:Number = CrossProduct((_arg3 - _arg1), (_arg4 - _arg2), (_arg5 - _arg1), (_arg6 - _arg2));
if (_local7 < 0){
return (false);
};
return (true);
}
public static function PointArrayFromString(_arg1:String):Array{
var _local4:int;
var _local6:Point;
var _local2:Array = new Array();
var _local3:Array = _arg1.split(",");
if ((((_local3.length < 2)) || (((_local3.length % 2) == 1)))){
trace(((("PointArrayFromString. Error, numpoints=" + _local3.length) + " , string= ") + _arg1));
return (_local2);
};
var _local5:int = (_local3.length / 2);
_local4 = 0;
while (_local4 < _local5) {
_local6 = new Point(0, 0);
_local6.x = Number(_local3[((_local4 * 2) + 0)]);
_local6.y = Number(_local3[((_local4 * 2) + 1)]);
_local2.push(_local6);
_local4++;
};
return (_local2);
}
public static function ScaleTo(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Number):Number{
var _local6:Number = (_arg4 - _arg3);
var _local7:Number = (_arg2 - _arg1);
var _local8:Number = ((1 / _local6) * (_arg5 - _arg3));
_local8 = ((_local7 * _local8) + _arg1);
return (_local8);
}
static function DotProduct(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number):Number{
var _local5:Number = ((_arg1 * _arg3) + (_arg2 * _arg4));
return (_local5);
}
static function RenderDotLine(_arg1:BitmapData, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Number, _arg6:int, _arg7:uint):void{
var _local8:int;
var _local9:int = _arg6;
var _local10:Number = ((_arg4 - _arg2) / Number(_local9));
var _local11:Number = ((_arg5 - _arg3) / Number(_local9));
_arg1.setPixel32(int(_arg2), int(_arg3), _arg7);
var _local12:Number = _arg2;
var _local13:Number = _arg3;
_local8 = 0;
while (_local8 < _local9) {
_arg2 = (_arg2 + _local10);
_arg3 = (_arg3 + _local11);
_arg1.setPixel32(int(_arg2), int(_arg3), _arg7);
_local8++;
};
}
public static function LimitNumber(_arg1:Number, _arg2:Number, _arg3:Number):Number{
if (_arg3 < _arg1){
_arg3 = _arg1;
};
if (_arg3 > _arg2){
_arg3 = _arg2;
};
return (_arg3);
}
public static function rgbToHex(_arg1:uint):String{
var _local2:String = _arg1.toString(16);
var _local3:String = ("00000" + _local2);
var _local4:int = _local3.length;
_local3 = _local3.substring((_local4 - 6), _local4);
return (_local3.toUpperCase());
}
public static function DegToRad(_arg1:Number):Number{
return ((((Math.PI * 2) / 360) * _arg1));
}
public static function RadToDeg(_arg1:Number):Number{
return (((360 / (Math.PI * 2)) * _arg1));
}
static function RandBetweenFloat(_arg1:Number, _arg2:Number):Number{
var _local3:Number = (Math.random() * (_arg2 - _arg1));
_local3 = (_local3 + _arg1);
return (_local3);
}
public static function LineLength(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number):Number{
var _local5:Number = (_arg3 - _arg1);
var _local6:Number = (_arg4 - _arg2);
return (Math.sqrt(((_local5 * _local5) + (_local6 * _local6))));
}
static function RenderRectangle(_arg1:BitmapData, _arg2:Rectangle, _arg3:uint):void{
RenderDotLine(_arg1, _arg2.left, _arg2.top, _arg2.right, _arg2.top, 100, _arg3);
RenderDotLine(_arg1, _arg2.left, _arg2.bottom, _arg2.right, _arg2.bottom, 100, _arg3);
RenderDotLine(_arg1, _arg2.left, _arg2.top, _arg2.left, _arg2.bottom, 100, _arg3);
RenderDotLine(_arg1, _arg2.right, _arg2.top, _arg2.right, _arg2.bottom, 100, _arg3);
}
public static function RemoveWhiteSpace(_arg1:String):String{
_arg1 = _arg1.replace(" ", "");
return (_arg1);
}
public static function DP1(_arg1:Number):Number{
var _local2:Number = (Math.ceil((_arg1 * 10)) / 10);
return (_local2);
}
public static function DP2(_arg1:Number):Number{
var _local2:Number = (Math.ceil((_arg1 * 100)) / 100);
return (_local2);
}
public static function NumberToString2DP(_arg1:Number):String{
var _local4:int;
var _local2:String = DP2(_arg1).toString();
var _local3:int = _local2.lastIndexOf(".");
if (_local3 == -1){
_local2.concat(".00");
} else {
_local4 = _local2.length;
if (_local3 == (_local4 - 1)){
_local2.concat("0");
};
};
return (_local2);
}
static function RandBetweenInt(_arg1:int, _arg2:int):int{
var _local3:int = (Math.random() * ((_arg2 - _arg1) + 1));
_local3 = (_local3 + _arg1);
return (_local3);
}
static function RenderCircle(_arg1:BitmapData, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:uint):void{
var _local8:int;
var _local10:Number;
var _local11:Number;
var _local6 = 50;
var _local7:Number = ((Math.PI * 2) / _local6);
var _local9:Number = 0;
_local8 = 0;
while (_local8 < _local6) {
_local10 = (_arg2 + (Math.cos(_local9) * _arg4));
_local11 = (_arg3 + (Math.sin(_local9) * _arg4));
_local9 = (_local9 + _local7);
_arg1.setPixel32(int(_local10), int(_local11), _arg5);
_local8++;
};
}
static function CrossProduct(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number):Number{
var _local5:Number = ((_arg1 * _arg4) - (_arg3 * _arg2));
return (_local5);
}
static function DotProductAng(_arg1:Number, _arg2:Number):Number{
var _local3:Number = Math.cos(_arg1);
var _local4:Number = Math.sin(_arg1);
var _local5:Number = Math.cos(_arg2);
var _local6:Number = Math.sin(_arg2);
var _local7:Number = ((_local3 * _local5) + (_local4 * _local6));
return (_local7);
}
public static function RandCircle():Number{
return ((Math.random() * (Math.PI * 2)));
}
public static function CounterToSecondsString(_arg1:int):String{
var _local2 = "";
var _local3:int = (_arg1 / int(Defs.fps));
var _local4:int = (_arg1 % int(Defs.fps));
_local2 = (_local2 + (_local3.toString() + ":"));
var _local5:Number = ((100 / Defs.fps) * Number(_local4));
_local2 = (_local2 + Math.floor(_local5).toString());
return (_local2);
}
static function DistBetweenPoints(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number):Number{
var _local5:Number = (_arg3 - _arg1);
var _local6:Number = (_arg4 - _arg2);
return (Math.sqrt(((_local5 * _local5) + (_local6 * _local6))));
}
public static function ScaleBetween(_arg1:Number, _arg2:Number, _arg3:Number):Number{
var _local4:Number = ((_arg2 - _arg1) * _arg3);
_local4 = (_arg1 + _local4);
return (_local4);
}
static function Dist2BetweenPoints(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number):Number{
var _local5:Number = (_arg3 - _arg1);
var _local6:Number = (_arg4 - _arg2);
return (((_local5 * _local5) + (_local6 * _local6)));
}
}
}//package
Section 284
//uzi_flash (uzi_flash)
package {
import flash.display.*;
public dynamic class uzi_flash extends MovieClip {
}
}//package
Section 285
//WaveDef (WaveDef)
package {
public class WaveDef {
public var pathID:int;
public var absoluteGenTime:int;
public var gapSeconds:Number;
public var pathType:int;
public var actionType:Number;
public var pos:Number;
public var side:int;
public var waveID:int;
public var pathSpeed:Number;
public var numInWave:int;
public var typeName:String;
public var xflip:Boolean;
public var type:int;
public var actionPos:Number;
public var actionLen:Number;
public function WaveDef(_arg1:int, _arg2:int, _arg3:Number, _arg4:String, _arg5:int, _arg6:int, _arg7:Number){
type = 0;
side = _arg2;
pos = _arg3;
typeName = _arg4;
pathID = _arg5;
pathType = _arg6;
absoluteGenTime = _arg1;
pathSpeed = _arg7;
numInWave = 0;
waveID = -1;
actionLen = 0;
actionPos = 0;
actionType = -1;
xflip = false;
}
public function SetID(_arg1:int, _arg2:int){
waveID = _arg1;
numInWave = _arg2;
}
}
}//package
Section 286
//Weapon (Weapon)
package {
import flash.geom.*;
public class Weapon {
var flashGraphicName:String;
var reloadSound:String;
var reloadTime:int;
var available:Boolean;
var loff:Point;
var name:String;
var graphicName:String;
var displayLine:Boolean;
var shootLineGraphicName:String;
var cartridgeRoff:Point;
var cartridgeFrame:int;
var showAmmo:Boolean;
var frame:int;
var shootFuncName:String;
var damage:Number;
var shootSound:String;
var clipSize:int;
var cartridgeLoff:Point;
var fireRate:int;
var constantSound:String;
var maxRange:Number;
var roff:Point;
public function Weapon(_arg1:String){
name = _arg1;
maxRange = 500;
shootFuncName = "FirePistol";
flashGraphicName = "";
fireRate = 10;
cartridgeLoff = new Point(0, 0);
cartridgeRoff = new Point(0, 0);
loff = new Point(0, 0);
roff = new Point(0, 0);
clipSize = 0;
reloadTime = 0;
damage = 0;
available = false;
displayLine = true;
cartridgeFrame = -1;
shootSound = "";
reloadSound = "";
constantSound = "";
showAmmo = true;
shootLineGraphicName = "";
frame = 0;
}
}
}//package
Section 287
//weapon_hmg_line (weapon_hmg_line)
package {
import flash.display.*;
public dynamic class weapon_hmg_line extends MovieClip {
}
}//package
Section 288
//weapon_laser_line (weapon_laser_line)
package {
import flash.display.*;
public dynamic class weapon_laser_line extends MovieClip {
}
}//package
Section 289
//weapon_machinegun_line (weapon_machinegun_line)
package {
import flash.display.*;
public dynamic class weapon_machinegun_line extends MovieClip {
}
}//package
Section 290
//weapon_pistol_line (weapon_pistol_line)
package {
import flash.display.*;
public dynamic class weapon_pistol_line extends MovieClip {
}
}//package
Section 291
//weapon_shotgun_line (weapon_shotgun_line)
package {
import flash.display.*;
public dynamic class weapon_shotgun_line extends MovieClip {
}
}//package
Section 292
//weapon_uzi_line (weapon_uzi_line)
package {
import flash.display.*;
public dynamic class weapon_uzi_line extends MovieClip {
}
}//package
Section 293
//WeaponSelector (WeaponSelector)
package {
import flash.display.*;
public dynamic class WeaponSelector extends MovieClip {
public var selected:MovieClip;
public var weapon:MovieClip;
}
}//package
Section 294
//Vec (Vec)
package {
import flash.geom.*;
public class Vec {
public var speed:Number;
public var rot:Number;
public function Vec(){
rot = 0;
speed = 0;
}
public function Add(_arg1:Vec){
var _local2:Number = (Math.cos(rot) * speed);
var _local3:Number = (Math.sin(rot) * speed);
var _local4:Number = (Math.cos(_arg1.rot) * _arg1.speed);
var _local5:Number = (Math.sin(_arg1.rot) * _arg1.speed);
var _local6:Number = (_local2 + _local4);
var _local7:Number = (_local3 + _local5);
rot = Math.atan2(_local7, _local6);
speed = Math.sqrt(((_local6 * _local6) + (_local7 * _local7)));
}
public function Set(_arg1:Number, _arg2:Number){
rot = _arg1;
speed = _arg2;
}
public function GetUnitXComponent():Number{
return (Math.cos(rot));
}
function NormalizeRot():void{
while (rot < 0) {
rot = (rot + (Math.PI * 2));
};
while (rot > (Math.PI * 2)) {
rot = (rot - (Math.PI * 2));
};
}
public function GetUnitTangent():Point{
var _local1:Number = (rot + (Math.PI * 0.5));
var _local2:Point = new Point(Math.cos(_local1), Math.sin(_local1));
return (_local2);
}
public function NearRot(_arg1:Number, _arg2:Number):Boolean{
var _local3:Number = (rot - _arg1);
var _local4:Number = Math.abs(_local3);
if (_local3 > Math.PI){
if (_arg1 < rot){
_arg1 = (_arg1 + (Math.PI * 2));
} else {
_arg1 = (_arg1 - (Math.PI * 2));
};
_local3 = (rot - _arg1);
};
if (Math.abs(_local3) <= _arg2){
return (true);
};
return (false);
}
public function SetDxDy(_arg1:Number, _arg2:Number, _arg3:Number){
rot = Math.atan2(_arg2, _arg1);
speed = _arg3;
}
public function AddRot(_arg1:Number):void{
rot = (rot + _arg1);
NormalizeRot();
}
public function SetAng(_arg1:Number){
rot = _arg1;
}
public function GetYComponent():Number{
return ((Math.sin(rot) * speed));
}
public function GetXComponent():Number{
return ((Math.cos(rot) * speed));
}
public function dotRot(_arg1:Number):Number{
var _local2:Number = Math.cos(rot);
var _local3:Number = Math.sin(rot);
var _local4:Number = Math.cos(_arg1);
var _local5:Number = Math.sin(_arg1);
var _local6:Number = ((_local2 * _local4) + (_local3 * _local5));
return (_local6);
}
public function GetUnitYComponent():Number{
return (Math.sin(rot));
}
public function CopyFrom(_arg1:Vec):void{
rot = _arg1.rot;
speed = _arg1.speed;
}
}
}//package
Section 295
//XmlHelper (XmlHelper)
package {
public class XmlHelper {
public static function GetAttrString(_arg1:Object, _arg2:String=""):String{
var _local3:String = _arg2;
if (_arg1 != undefined){
_local3 = String(_arg1);
};
return (_local3);
}
public static function GetAttrBoolean(_arg1:Object, _arg2:Boolean=false):Boolean{
var _local4:String;
var _local3:Boolean = _arg2;
if (_arg1 != null){
_local3 = false;
_local4 = String(_arg1);
_local4 = _local4.toLowerCase();
if (_arg1 == "true"){
_local3 = true;
};
};
return (_local3);
}
public static function GetAttrInt(_arg1:Object, _arg2:int=0):int{
var _local3:int = _arg2;
if (_arg1 != undefined){
_local3 = int(_arg1);
};
return (_local3);
}
public static function GetAttrNumber(_arg1:Object, _arg2:Number=0):Number{
var _local4:String;
var _local3:Number = _arg2;
if (_arg1 != undefined){
_local4 = String(_arg1);
if (_local4.charAt(0) == "%"){
_local4 = _local4.replace("%", "");
_local3 = Number(ExternalData.constants[_local4]);
} else {
_local3 = Number(_arg1);
};
};
return (_local3);
}
}
}//package