Frame 1
function Vector2(x, y) {
this.x = x;
this.y = y;
}
Vector2.prototype.ToString = function () {
return(((("(" + this.x) + ",") + this.y) + ")");
};
Vector2.prototype.clone = function () {
var _local1 = new Vector2(this.x, this.y);
return(_local1);
};
Vector2.prototype.plus = function (v2) {
var _local1 = new Vector2(this.x + v2.x, this.y + v2.y);
return(_local1);
};
Vector2.prototype.minus = function (v2) {
var _local1 = new Vector2(this.x - v2.x, this.y - v2.y);
return(_local1);
};
Vector2.prototype.normR = function () {
var _local1 = new Vector2(this.y * -1, this.x);
return(_local1);
};
Vector2.prototype.dir = function () {
var _local1 = this.clone();
_local1.normalize();
return(_local1);
};
Vector2.prototype.proj = function (v2) {
var _local3 = v2;
var _local2 = _local3.dot(_local3);
if (_local2 == 0) {
trace("WARNING! Vector2.proj() was given a zero-length projection vector!");
var _local1 = this.clone();
} else {
var _local1 = _local3.clone();
_local1.mult(this.dot(_local3) / _local2);
}
return(_local1);
};
Vector2.prototype.projLen = function (v2) {
var _local2 = v2;
var _local1 = _local2.dot(_local2);
if (_local1 == 0) {
trace("WARNING! Vector2.projLen() was given a zero-length projection vector!");
return(0);
}
return(Math.abs(this.dot(_local2) / _local1));
};
Vector2.prototype.dot = function (v2) {
return((this.x * v2.x) + (this.y * v2.y));
};
Vector2.prototype.cross = function (v2) {
return((this.x * v2.y) - (this.y * v2.x));
};
Vector2.prototype.len = function () {
var _local1 = this;
return(Math.sqrt((_local1.x * _local1.x) + (_local1.y * _local1.y)));
};
Vector2.prototype.copy = function (v2) {
this.x = v2.x;
this.y = v2.y;
};
Vector2.prototype.mult = function (s) {
this.x = this.x * s;
this.y = this.y * s;
};
Vector2.prototype.normalize = function () {
var _local2 = this;
var _local1 = _local2.len();
if (_local1 != 0) {
_local2.x = _local2.x / _local1;
_local2.y = _local2.y / _local1;
} else {
trace("WARNING! Vector2.normalize() was called on a zero-length vector!");
}
};
Vector2.prototype.pluseq = function (v2) {
this.x = this.x + v2.x;
this.y = this.y + v2.y;
};
Vector2.prototype.minuseq = function (v2) {
this.x = this.x - v2.x;
this.y = this.y - v2.y;
};
function InputManager() {
var _local1 = this;
_local1.vrend = new VectorRenderer();
_local1.mPos = new Vector2(_local1.vrend.buffer._xmouse, _local1.vrend.buffer._ymouse);
_local1.mOldpos = new Vector2(_local1.vrend.buffer._xmouse, _local1.vrend.buffer._ymouse);
_local1.mDelta = new Vector2(0, 0);
_local1.mDownPos = new Vector2(0, 0);
_local1.mUpPos = new Vector2(0, 0);
_local1.onMouseDown = _local1.CaptureMouseDown;
_local1.onMouseUp = _local1.CaptureMouseUp;
Mouse.addListener(_local1);
_local1.mState = false;
_local1.mOldState = false;
_local1.mPressed = false;
_local1.mReleased = false;
_local1.kCode = new Array();
_local1.kState = new Array();
_local1.kOldState = new Array();
_local1.tKey = new Array();
_local1.tState = new Array();
}
InputManager.prototype.RegisterKey = function (knum) {
var _local2 = this;
var _local1 = _local2.kCode.length;
_local2.kCode.push(knum);
_local2.kState[_local1] = false;
_local2.kOldState[_local1] = false;
return(_local1);
};
InputManager.prototype.RegisterToggle = function (knum) {
var _local1 = this;
var _local2 = _local1.tKey.length;
_local1.tKey.push(_local1.RegisterKey(knum));
_local1.tState[_local2] = false;
return(_local2);
};
InputManager.prototype.Update = function () {
var _local1 = this;
_local1.mOldpos.copy(_local1.mPos);
_local1.mPos.x = _local1.vrend.buffer._xmouse;
_local1.mPos.y = _local1.vrend.buffer._ymouse;
_local1.mDelta = _local1.mPos.minus(_local1.mOldpos);
if (_local1.mState && (!_local1.mOldState)) {
_local1.mPressed = true;
_local1.mOldState = true;
_local1.mDownPos.x = _local1.mPos.x;
_local1.mDownPos.y = _local1.mPos.y;
} else {
_local1.mPressed = false;
}
if ((!_local1.mState) && (_local1.mOldState)) {
_local1.mReleased = true;
_local1.mOldState = false;
_local1.mUpPos.x = _local1.mPos.x;
_local1.mUpPos.y = _local1.mPos.y;
} else {
_local1.mReleased = false;
}
if (_local1.mState) {
_local1.mUpPos.x = _local1.mPos.x;
_local1.mUpPos.y = _local1.mPos.y;
}
var _local2 = 0;
while (_local2 < _local1.kCode.length) {
_local1.kOldState[_local2] = Key.isDown(_local1.kCode[_local2]);
_local2++;
}
var _local3 = _local1.kOldState;
_local1.kOldState = _local1.kState;
_local1.kState = _local3;
_local2 = 0;
while (_local2 < _local1.tKey.length) {
if (_local1.Pressed(_local1.tKey[_local2])) {
_local1.tState[_local2] = !_local1.tState[_local2];
}
_local2++;
}
};
InputManager.prototype.CaptureMouseDown = function () {
this.mOldState = false;
this.mState = true;
};
InputManager.prototype.CaptureMouseUp = function () {
this.mOldState = true;
this.mState = false;
};
InputManager.prototype.getMousePos = function () {
return(this.mPos.clone());
};
InputManager.prototype.getMouseDelta = function () {
return(this.mDelta.clone());
};
InputManager.prototype.getMouseDragDelta = function () {
return(this.mUpPos.minus(this.mDownPos));
};
InputManager.prototype.getMouseDownPos = function () {
return(this.mDownPos.clone());
};
InputManager.prototype.getMouseUpPos = function () {
return(this.mUpPos.clone());
};
InputManager.prototype.MousePressed = function () {
return(this.mPressed);
};
InputManager.prototype.MouseReleased = function () {
return(this.mReleased);
};
InputManager.prototype.MouseDown = function () {
return(this.mState);
};
InputManager.prototype.Down = function (knum) {
return(this.kState[knum]);
};
InputManager.prototype.Pressed = function (knum) {
return(this.kState[knum] && (!this.kOldState[knum]));
};
InputManager.prototype.Released = function (knum) {
return((!this.kState[knum]) && (this.kOldState[knum]));
};
InputManager.prototype.Toggled = function (tnum) {
return(this.tState[tnum]);
};
function VectorRenderer() {
var _local1 = this;
_local1.buffer = CreateMC("EMPTY_MC", "rend");
_local1.buffer._x = 0;
_local1.buffer._y = 0;
_local1.thickness = 0;
_local1.rgb = 0;
_local1.alpha = 100;
}
VectorRenderer.prototype.Clear = function () {
var _local1 = this;
_local1.buffer.clear();
_local1.buffer.lineStyle(_local1.thickness, _local1.rgb, _local1.alpha);
};
VectorRenderer.prototype.SetStyle = function (thick, rgb, alpha) {
this.buffer.lineStyle(thick, rgb, alpha);
};
VectorRenderer.prototype.DrawLine = function (va, vb) {
this.buffer.moveTo(va.x, va.y);
this.buffer.lineTo(vb.x, vb.y);
};
VectorRenderer.prototype.DrawLine_S = function (x0, y0, x1, y1) {
this.buffer.moveTo(x0, y0);
this.buffer.lineTo(x1, y1);
};
VectorRenderer.prototype.DrawArrow_S = function (x0, y0, x1, y1) {
this.buffer.moveTo(x0, y0);
this.buffer.lineTo(x1, y1);
var _local3 = x1 - x0;
var _local2 = y1 - y0;
var len = Math.sqrt((_local3 * _local3) + (_local2 * _local2));
if (len == 0) {
} else {
_local3 = _local3 / len;
_local2 = _local2 / len;
var nx = (-_local2);
var ny = _local3;
var _local1 = 2;
this.buffer.moveTo(x1, y1);
this.buffer.lineTo((x1 - (_local1 * _local3)) - (_local1 * nx), (y1 - (_local1 * _local2)) - (_local1 * ny));
this.buffer.moveTo(x1, y1);
this.buffer.lineTo((x1 - (_local1 * _local3)) + (_local1 * nx), (y1 - (_local1 * _local2)) + (_local1 * ny));
}
};
VectorRenderer.prototype.DrawArrow = function (p0, p1) {
var x0 = p0.x;
var y0 = p0.y;
var _local3 = p1.x;
var _local2 = p1.y;
this.buffer.moveTo(x0, y0);
this.buffer.lineTo(_local3, _local2);
var dx = (_local3 - x0);
var dy = (_local2 - y0);
var len = Math.sqrt((dx * dx) + (dy * dy));
if (len == 0) {
} else {
dx = dx / len;
dy = dy / len;
var nx = (-dy);
var ny = dx;
var _local1 = 2;
this.buffer.moveTo(_local3, _local2);
this.buffer.lineTo((_local3 - (_local1 * dx)) - (_local1 * nx), (_local2 - (_local1 * dy)) - (_local1 * ny));
this.buffer.moveTo(_local3, _local2);
this.buffer.lineTo((_local3 - (_local1 * dx)) + (_local1 * nx), (_local2 - (_local1 * dy)) + (_local1 * ny));
}
};
VectorRenderer.prototype.DrawArrowR = function (p0, p1, r) {
var x0 = p0.x;
var y0 = p0.y;
var _local3 = p1.x;
var _local2 = p1.y;
this.buffer.moveTo(x0, y0);
this.buffer.lineTo(_local3, _local2);
var dx = (_local3 - x0);
var dy = (_local2 - y0);
var len = Math.sqrt((dx * dx) + (dy * dy));
if (len == 0) {
} else {
dx = dx / len;
dy = dy / len;
var nx = (-dy);
var ny = dx;
var _local1 = r;
this.buffer.moveTo(_local3, _local2);
this.buffer.lineTo((_local3 - (_local1 * dx)) - (_local1 * nx), (_local2 - (_local1 * dy)) - (_local1 * ny));
this.buffer.moveTo(_local3, _local2);
this.buffer.lineTo((_local3 - (_local1 * dx)) + (_local1 * nx), (_local2 - (_local1 * dy)) + (_local1 * ny));
}
};
VectorRenderer.prototype.DrawLinestrip = function (vList) {
var _local2 = vList;
var _local3 = this;
_local3.buffer.moveTo(_local2[0].x, _local2[0].y);
var _local1 = 0;
while (_local1 < _local2.length) {
_local3.buffer.lineTo(_local2[_local1].x, _local2[_local1].y);
_local1++;
}
};
VectorRenderer.prototype.DrawTri = function (va, vb, vc) {
var _local1 = va;
var _local2 = this;
_local2.buffer.moveTo(_local1.x, _local1.y);
_local2.buffer.lineTo(vb.x, vb.y);
_local2.buffer.lineTo(vc.x, vc.y);
_local2.buffer.lineTo(_local1.x, _local1.y);
};
VectorRenderer.prototype.DrawQuad = function (a, b, c, d) {
var _local1 = this;
var _local2 = a;
_local1.buffer.moveTo(_local2.x, _local2.y);
_local1.buffer.lineTo(b.x, b.y);
_local1.buffer.lineTo(c.x, c.y);
_local1.buffer.lineTo(d.x, d.y);
_local1.buffer.lineTo(_local2.x, _local2.y);
};
VectorRenderer.prototype.DrawPlus = function (v) {
var _local1 = v;
var _local2 = this;
_local2.buffer.moveTo(_local1.x - 1, _local1.y);
_local2.buffer.lineTo(_local1.x + 1, _local1.y);
_local2.buffer.moveTo(_local1.x, _local1.y - 1);
_local2.buffer.lineTo(_local1.x, _local1.y + 1);
};
VectorRenderer.prototype.DrawPlus_S = function (vx, vy) {
var _local1 = vy;
var _local2 = vx;
var _local3 = this;
_local3.buffer.moveTo(_local2 - 1, _local1);
_local3.buffer.lineTo(_local2 + 1, _local1);
_local3.buffer.moveTo(_local2, _local1 - 1);
_local3.buffer.lineTo(_local2, _local1 + 1);
};
VectorRenderer.prototype.DrawPlusR = function (v, r) {
var _local1 = v;
var _local2 = r;
var _local3 = this;
_local3.buffer.moveTo(_local1.x - _local2, _local1.y);
_local3.buffer.lineTo(_local1.x + _local2, _local1.y);
_local3.buffer.moveTo(_local1.x, _local1.y - _local2);
_local3.buffer.lineTo(_local1.x, _local1.y + _local2);
};
VectorRenderer.prototype.DrawCross = function (v) {
var _local1 = v;
var _local2 = this;
_local2.buffer.moveTo(_local1.x - 1, _local1.y - 1);
_local2.buffer.lineTo(_local1.x + 1, _local1.y + 1);
_local2.buffer.moveTo(_local1.x + 1, _local1.y - 1);
_local2.buffer.lineTo(_local1.x - 1, _local1.y + 1);
};
VectorRenderer.prototype.DrawCross_S = function (vx, vy) {
var _local1 = vy;
var _local2 = vx;
var _local3 = this;
_local3.buffer.moveTo(_local2 - 1, _local1 - 1);
_local3.buffer.lineTo(_local2 + 1, _local1 + 1);
_local3.buffer.moveTo(_local2 + 1, _local1 - 1);
_local3.buffer.lineTo(_local2 - 1, _local1 + 1);
};
VectorRenderer.prototype.DrawCrossR = function (v, r) {
var _local1 = v;
var _local2 = r;
var _local3 = this;
_local3.buffer.moveTo(_local1.x - _local2, _local1.y - _local2);
_local3.buffer.lineTo(_local1.x + _local2, _local1.y + _local2);
_local3.buffer.moveTo(_local1.x + _local2, _local1.y - _local2);
_local3.buffer.lineTo(_local1.x - _local2, _local1.y + _local2);
};
VectorRenderer.prototype.DrawCircle = function (v, r) {
var _local1 = r;
var _local3 = v.x;
var _local2 = v.y;
this.buffer.moveTo(_local3 + _local1, _local2);
this.buffer.curveTo(_local1 + _local3, (0.4142 * _local1) + _local2, (0.7071 * _local1) + _local3, (0.7071 * _local1) + _local2);
this.buffer.curveTo((0.4142 * _local1) + _local3, _local1 + _local2, _local3, _local1 + _local2);
this.buffer.curveTo((-0.4142 * _local1) + _local3, _local1 + _local2, (-0.7071 * _local1) + _local3, (0.7071 * _local1) + _local2);
this.buffer.curveTo((-_local1) + _local3, (0.4142 * _local1) + _local2, (-_local1) + _local3, _local2);
this.buffer.curveTo((-_local1) + _local3, (-0.4142 * _local1) + _local2, (-0.7071 * _local1) + _local3, (-0.7071 * _local1) + _local2);
this.buffer.curveTo((-0.4142 * _local1) + _local3, (-_local1) + _local2, _local3, (-_local1) + _local2);
this.buffer.curveTo((0.4142 * _local1) + _local3, (-_local1) + _local2, (0.7071 * _local1) + _local3, (-0.7071 * _local1) + _local2);
this.buffer.curveTo(_local1 + _local3, (-0.4142 * _local1) + _local2, _local1 + _local3, _local2);
};
VectorRenderer.prototype.DrawArc = function (p0, p1, c) {
this.buffer.moveTo(p0.x, p0.y);
this.buffer.curveTo(c.x, c.y, p1.x, p1.y);
};
VectorRenderer.prototype.DrawArc_S = function (x0, y0, x1, y1, xc, yc) {
this.buffer.moveTo(x0, y0);
this.buffer.curveTo(xc, yc, x1, y1);
};
VectorRenderer.prototype.DrawAABB = function (p, xw, yw) {
var _local1 = p;
var _local2 = xw;
var _local3 = yw;
var v0 = new Vector2(_local1.x + _local2, _local1.y + _local3);
var v1 = new Vector2(_local1.x - _local2, _local1.y + _local3);
var v2 = new Vector2(_local1.x - _local2, _local1.y - _local3);
var v3 = new Vector2(_local1.x + _local2, _local1.y - _local3);
this.DrawQuad(v0, v1, v2, v3);
};
VectorRenderer.prototype.DrawAABB_S = function (minx, maxx, miny, maxy) {
var v0 = new Vector2(maxx, maxy);
var _local3 = new Vector2(minx, maxy);
var _local2 = new Vector2(minx, miny);
var _local1 = new Vector2(maxx, miny);
this.DrawQuad(v0, _local3, _local2, _local1);
};
VectorRenderer.prototype.DrawConcaveCCWArc_S = function (cx, cy, px, py) {
var _local1 = cy;
var _local2 = cx;
var p0x = px;
var p0y = py;
var vx = (p0x - _local2);
var vy = (p0y - _local1);
var r = Math.sqrt((vx * vx) + (vy * vy));
var nx = vy;
var ny = (-vx);
var p1x = ((p0x + nx) - _local2);
var _local3 = (p0y + ny) - _local1;
var len = Math.sqrt((p1x * p1x) + (_local3 * _local3));
p1x = p1x / len;
_local3 = _local3 / len;
p1x = p1x * r;
_local3 = _local3 * r;
p1x = p1x + _local2;
_local3 = _local3 + _local1;
var c0x = (((p0x + p1x) * 0.5) - _local2);
var c0y = (((p0y + _local3) * 0.5) - _local1);
var clen = Math.sqrt((c0x * c0x) + (c0y * c0y));
var dlen = (r - clen);
c0x = c0x / clen;
c0y = c0y / clen;
c0x = c0x * (r + dlen);
c0y = c0y * (r + dlen);
c0x = c0x + _local2;
c0y = c0y + _local1;
this.buffer.moveTo(p0x, p0y);
this.buffer.curveTo(c0x, c0y, p1x, _local3);
var p0x = p1x;
var p0y = _local3;
var vx = (p0x - _local2);
var vy = (p0y - _local1);
var r = Math.sqrt((vx * vx) + (vy * vy));
var nx = vy;
var ny = (-vx);
var p1x = ((p0x + nx) - _local2);
_local3 = (p0y + ny) - _local1;
var len = Math.sqrt((p1x * p1x) + (_local3 * _local3));
p1x = p1x / len;
_local3 = _local3 / len;
p1x = p1x * r;
_local3 = _local3 * r;
p1x = p1x + _local2;
_local3 = _local3 + _local1;
var c0x = (((p0x + p1x) * 0.5) - _local2);
var c0y = (((p0y + _local3) * 0.5) - _local1);
var clen = Math.sqrt((c0x * c0x) + (c0y * c0y));
var dlen = (r - clen);
c0x = c0x / clen;
c0y = c0y / clen;
c0x = c0x * (r + dlen);
c0y = c0y * (r + dlen);
c0x = c0x + _local2;
c0y = c0y + _local1;
this.buffer.curveTo(c0x, c0y, p1x, _local3);
};
VectorRenderer.prototype.DrawLinestrip_nrope = function (vList) {
var _local2 = vList;
var _local3 = this;
_local3.buffer.moveTo(_local2[0].x, _local2[0].y);
var _local1 = 1;
while (_local1 < _local2.length) {
_local3.buffer.lineTo(_local2[_local1].x, _local2[_local1].y);
_local1++;
}
};
function GraphicsSystem() {
var _local1 = this;
_local1.front_depth = 1001;
_local1.back_depth = 1000;
_local1.stepsize = 10;
}
GraphicsSystem.prototype.GetNextDepth_Front = function () {
var _local1 = this;
_local1.front_depth = _local1.front_depth + _local1.stepsize;
return(_local1.front_depth);
};
GraphicsSystem.prototype.GetNextDepth_Back = function () {
var _local1 = this;
_local1.back_depth = _local1.back_depth - _local1.stepsize;
return(_local1.back_depth);
};
function CreateMC(linkName, instanceName) {
var _local2 = instanceName;
var _local3 = _root;
var _local1 = gfx.GetNextDepth_Front();
if (linkName == "EMPTY_MC") {
return(_local3.createEmptyMovieClip(_local2, _local1));
}
if (linkName == "TEXT_MC") {
return(_local3.createTextField(_local2, _local1, 0, 0, 100, 100));
}
return(_local3.attachMovie(linkName, _local2 + _local1, _local1));
}
DestroyMC = function (mc) {
mc.swapDepths(1048000);
mc.removeMovieClip();
};
function Point(x, y, title, col, isDraggable, dragFunc, xmin, ymin, xmax, ymax) {
var _local1 = this;
var _local3 = title;
_local1.pos = new Vector2(x, y);
_local1.title = _local3;
_local1.mc = CreateMC("pointMC", "point_" + _local3);
_local1.mc.title = _local1.mc.attachMovie("titleMC", "title_" + _local3, 1);
_local1.mc.title.txt = _local1.title;
_local1.mc.title._x = 4;
_local1.mc.title._y = -4;
var _local2 = new Color(_local1.mc.gfx);
_local2.setRGB(col);
_local1.mc._x = x;
_local1.mc._y = y;
if (isDraggable) {
_local1.mc.hitArea = _local1.mc.gfx;
_local1.mc.onPress = function () {
this.startDrag(false, xmin, ymin, xmax, ymax);
this.onEnterFrame = dragFunc;
};
_local1.mc.onMouseUp = function () {
var _local1 = this;
_local1.stopDrag();
_local1.onEnterFrame();
_local1.onEnterFrame = null;
};
}
}
function AABB(x, y, xw, yw, title, col, isDraggable, dragFunc, xmin, ymin, xmax, ymax) {
var _local1 = this;
var _local2 = title;
_local1.pos = new Vector2(x, y);
_local1.xw = xw;
_local1.yw = yw;
_local1.title = _local2;
_local1.mc = CreateMC("EMPTY_MC", "aabb_" + _local2);
_local1.mc.point = _local1.mc.AttachMovie("pointMC", "aabbcenter_" + _local2, 2);
_local1.mc.point._xscale = 100 / _local1.mc.point._width;
_local1.mc.point._yscale = 100 / _local1.mc.point._height;
var _local3 = new Color(_local1.mc.point);
_local3.setRGB(col);
_local1.mc.title = _local1.mc.attachMovie("titleMC", "title_" + _local2, 3);
_local1.mc.title.txt = _local1.title;
_local1.mc.title._x = xw;
_local1.mc.title._y = -yw;
_local1.mc.extents = _local1.mc.createEmptyMovieClip("aabbextents_" + _local2, 1);
_local1.mc.extents.lineStyle(0, col, 100);
_local1.mc.extents.beginFill(col, 25);
_local1.mc.extents.moveTo(xw, yw);
_local1.mc.extents.lineTo(xw, -yw);
_local1.mc.extents.lineTo(-xw, -yw);
_local1.mc.extents.lineTo(-xw, yw);
_local1.mc.extents.lineTo(xw, yw);
_local1.mc.extents.endFill();
_local1.mc._x = x;
_local1.mc._y = y;
if (isDraggable) {
_local1.mc.hitArea = _local1.mc.extents;
_local1.mc.onPress = function () {
this.startDrag(false, xmin + xw, ymin + yw, xmax - xw, ymax - yw);
this.onEnterFrame = dragFunc;
};
_local1.mc.onRelease = function () {
var _local1 = this;
_local1.stopDrag();
_local1.onEnterFrame();
_local1.onEnterFrame = null;
};
}
}
function Circle(x, y, r, title, col, isDraggable, dragFunc, xmin, ymin, xmax, ymax) {
var _local1 = this;
var _local2 = title;
_local1.pos = new Vector2(x, y);
_local1.r = r;
_local1.title = _local2;
_local1.mc = CreateMC("EMPTY_MC", "circle_" + _local2);
_local1.mc.point = _local1.mc.AttachMovie("pointMC", "circlecenter_" + _local2, 2);
_local1.mc.point._xscale = 100 / _local1.mc.point._width;
_local1.mc.point._yscale = 100 / _local1.mc.point._height;
var _local3 = new Color(_local1.mc.point);
_local3.setRGB(col);
_local1.mc.title = _local1.mc.attachMovie("titleMC", "title_" + _local2, 3);
_local1.mc.title.txt = _local1.title;
_local1.mc.title._x = r;
_local1.mc.title._y = -r;
_local1.mc.extents = _local1.mc.createEmptyMovieClip("circleextents_" + _local2, 1);
_local1.mc.extents.lineStyle(0, col, 100);
_local1.mc.extents.beginFill(col, 25);
_local1.mc.extents.moveTo(r, 0);
_local1.mc.extents.curveTo(r, 0.4142 * r, 0.7071 * r, 0.7071 * r);
_local1.mc.extents.curveTo(0.4142 * r, r, 0, r);
_local1.mc.extents.curveTo(-0.4142 * r, r, -0.7071 * r, 0.7071 * r);
_local1.mc.extents.curveTo(-r, 0.4142 * r, -r, 0);
_local1.mc.extents.curveTo(-r, -0.4142 * r, -0.7071 * r, -0.7071 * r);
_local1.mc.extents.curveTo(-0.4142 * r, -r, 0, -r);
_local1.mc.extents.curveTo(0.4142 * r, -r, 0.7071 * r, -0.7071 * r);
_local1.mc.extents.curveTo(r, -0.4142 * r, r, 0);
_local1.mc.extents.endFill();
_local1.mc._x = x;
_local1.mc._y = y;
if (isDraggable) {
_local1.mc.hitArea = _local1.mc.extents;
_local1.mc.onPress = function () {
this.startDrag(false, xmin + r, ymin + r, xmax - r, ymax - r);
this.onEnterFrame = dragFunc;
};
_local1.mc.onRelease = function () {
var _local1 = this;
_local1.stopDrag();
_local1.onEnterFrame();
_local1.onEnterFrame = null;
};
}
}
function DrawSepAxis(rend, dir, offset, c0, r0, c1, r1) {
var _local1 = dir;
var _local2 = _local1.normR();
var _local3 = new Vector2(c1.x + (_local2.x * offset), c1.y + (_local2.y * offset));
var delta = c1.minus(c0);
var temp = delta.proj(_local1);
var p0 = new Vector2(_local3.x - temp.x, _local3.y - temp.y);
rend.SetStyle(0, 2263074, 20);
rend.DrawLine_S((c1.x + (_local2.x * offset)) - (300 * _local1.x), (c1.y + (_local2.y * offset)) - (300 * _local1.y), (c1.x + (_local2.x * offset)) + (300 * _local1.x), (c1.y + (_local2.y * offset)) + (300 * _local1.y));
rend.SetStyle(2, 8921634, 100);
rend.DrawLine_S(p0.x - (r0 * _local1.x), p0.y - (r0 * _local1.y), p0.x + (r0 * _local1.x), p0.y + (r0 * _local1.y));
rend.SetStyle(4, 2237064, 30);
rend.DrawLine_S(_local3.x - (r1 * _local1.x), _local3.y - (r1 * _local1.y), _local3.x + (r1 * _local1.x), _local3.y + (r1 * _local1.y));
var pen = (0 < ((r0 + r1) - delta.len()));
return(pen);
}
gfx = new GraphicsSystem();
input = new InputManager();
rend = new VectorRenderer();
function DrawAABBSepAxis() {
rend.Clear();
var _local1 = box0.pos;
var _local2 = box1.pos;
var xw0 = box0.xw;
var yw0 = box0.yw;
var xw1 = box1.xw;
var yw1 = box1.yw;
var delta = _local2.minus(_local1);
var signX = 1;
var _local3 = 1;
if (delta.x < 0) {
signX = -1;
}
if (delta.y < 0) {
_local3 = -1;
}
var penAxis = 0;
var px = ((xw0 + xw1) - Math.abs(delta.x));
var py = ((yw0 + yw1) - Math.abs(delta.y));
if (0 < px) {
if (0 < py) {
if (px < py) {
penAxis = 1;
} else {
penAxis = -1;
}
}
}
rend.SetStyle(0, 2263074, 20);
rend.DrawLine(_local1, _local2);
rend.SetStyle(0, 2237064, 20);
rend.DrawLine_S(_local1.x, _local1.y, _local1.x, 244);
rend.SetStyle(0, 8921634, 20);
rend.DrawLine_S(_local2.x, _local2.y, _local2.x, 244);
rend.SetStyle(2, 2263074, 100);
rend.DrawLine_S(_local1.x, 244, _local2.x, 244);
rend.SetStyle(0, 2237064, 20);
rend.DrawLine_S(_local1.x + (signX * xw0), _local1.y, _local1.x + (signX * xw0), 233);
rend.SetStyle(2, 2237064, 100);
rend.DrawLine_S(_local1.x, 233, _local1.x + (signX * xw0), 233);
rend.SetStyle(0, 8921634, 20);
rend.DrawLine_S(_local2.x - (signX * xw1), _local2.y, _local2.x - (signX * xw1), 237);
rend.SetStyle(2, 8921634, 100);
rend.DrawLine_S(_local2.x, 237, _local2.x - (signX * xw1), 237);
if (penAxis == 1) {
rend.SetStyle(2, 8921736, 100);
} else {
rend.SetStyle(2, 11184810, 100);
}
if (0 < px) {
rend.DrawArrow_S(_local1.x + (signX * xw0), 250, (_local1.x + (signX * xw0)) - (signX * px), 250);
}
rend.SetStyle(0, 2237064, 20);
rend.DrawLine_S(_local1.x, _local1.y, 244, _local1.y);
rend.SetStyle(0, 8921634, 20);
rend.DrawLine_S(_local2.x, _local2.y, 244, _local2.y);
rend.SetStyle(2, 2263074, 100);
rend.DrawLine_S(244, _local1.y, 244, _local2.y);
rend.SetStyle(0, 2237064, 20);
rend.DrawLine_S(_local1.x, _local1.y + (_local3 * yw0), 233, _local1.y + (_local3 * yw0));
rend.SetStyle(2, 2237064, 100);
rend.DrawLine_S(233, _local1.y, 233, _local1.y + (_local3 * yw0));
rend.SetStyle(0, 8921634, 20);
rend.DrawLine_S(_local2.x, _local2.y - (_local3 * yw1), 237, _local2.y - (_local3 * yw1));
rend.SetStyle(2, 8921634, 100);
rend.DrawLine_S(237, _local2.y, 237, _local2.y - (_local3 * yw1));
if (penAxis == -1) {
rend.SetStyle(2, 8921736, 100);
} else {
rend.SetStyle(2, 11184810, 100);
}
if (0 < py) {
rend.DrawArrow_S(250, _local1.y + (_local3 * yw0), 250, (_local1.y + (_local3 * yw0)) - (_local3 * py));
}
}
function Box0Dragged() {
_root.box0.pos.x = this._x;
_root.box0.pos.y = this._y;
DrawAABBSepAxis();
}
function Box1Dragged() {
_root.box1.pos.x = this._x;
_root.box1.pos.y = this._y;
DrawAABBSepAxis();
}
box0 = new AABB(70, 30, 36, 16, "", 2237064, true, Box0Dragged, 26, 26, 230, 230);
box1 = new AABB(120, 90, 24, 48, "", 8921634, true, Box1Dragged, 26, 26, 230, 230);
DrawAABBSepAxis();