STORY   LOOP   FURRY   PORN   GAMES
• C •   SERVICES [?] [R] RND   POPULAR
Archived flashes:
229652
/disc/ · /res/     /show/ · /fap/ · /gg/ · /swf/P0001 · P2596 · P5191

<div style="position:absolute;top:-99px;left:-99px;"><img src="http://swfchan.com:57475/55964812?noj=FRM55964812-30DC" width="1" height="1"></div>

tutA_demo05.swf

This is the info page for
Flash #41741

(Click the ID number above for more basic data on this flash file.)


Text
p0

change obj shape

change tile shape

[arrow keys]: thrust
[spacebar] + [drag mouse]: grab/throw object
[click + hold] + [drag mouse]: shove object

[shift] + [drag mouse]: move tile

ActionScript [AS1/AS2]

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.x = _local1.mPos.x; _local1.mOldpos.y = _local1.mPos.y; _local1.mPos.x = _local1.vrend.buffer._xmouse; _local1.mPos.y = _local1.vrend.buffer._ymouse; _local1.mDelta.x = _local1.mPos.x - _local1.mOldpos.x; _local1.mDelta.y = _local1.mPos.y - _local1.mOldpos.y; 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 = gfx.CreateEmptySprite(); _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.StartFill = function (x, y, rgb, alpha) { this.buffer.moveTo(x, y); this.buffer.beginFill(rgb, alpha); }; VectorRenderer.prototype.StopFill = function () { this.buffer.endFill(); }; 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.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.DrawTri_S = function (vax, vay, vbx, vby, vcx, vcy) { var _local1 = this; _local1.buffer.moveTo(vax, vay); _local1.buffer.lineTo(vbx, vby); _local1.buffer.lineTo(vcx, vcy); _local1.buffer.lineTo(vax, vay); }; 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.DrawQuad_S = function (ax, ay, bx, by, cx, cy, dx, dy) { var _local1 = this; _local1.buffer.moveTo(ax, ay); _local1.buffer.lineTo(bx, by); _local1.buffer.lineTo(cx, cy); _local1.buffer.lineTo(dx, dy); _local1.buffer.lineTo(ax, ay); }; 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.DrawCircle_S = function (x, y, r) { var _local1 = r; var _local2 = y; var _local3 = x; 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); }; 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 = 1; 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 NinjaGraphicsSystem() { var _local1 = this; _local1.rootbuffer = _root.createEmptyMovieClip("rootbuffer", 1000); _local1.front_depth = 1000; _local1.back_depth = 1000; _local1.stepsize = 100; } NinjaGraphicsSystem.prototype.CreateSprite = function (linkage) { var _local1 = this.GetNextDepth_Front(); var _local2 = this.rootbuffer.attachMovie(linkage, linkage + _local1, _local1); return(_local2); }; NinjaGraphicsSystem.prototype.CreateEmptySprite = function () { var _local1 = this.GetNextDepth_Front(); var _local2 = this.rootbuffer.createEmptyMovieClip("emptyMC" + _local1, _local1); return(_local2); }; NinjaGraphicsSystem.prototype.DestroyMC = function (mc) { mc.swapDepths(1048000); mc.removeMovieClip(); }; NinjaGraphicsSystem.prototype.GetNextDepth_Front = function () { var _local1 = this; _local1.front_depth = _local1.front_depth + _local1.stepsize; return(_local1.front_depth); }; NinjaGraphicsSystem.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 TileMapCell(x, y, xw, yw) { var _local1 = this; _local1.ID = TID_EMPTY; _local1.CTYPE = CTYPE_EMPTY; _local1.pos = new Vector2(x, y); _local1.xw = xw; _local1.yw = yw; _local1.minx = _local1.pos.x - _local1.xw; _local1.maxx = _local1.pos.x + _local1.xw; _local1.miny = _local1.pos.y - _local1.yw; _local1.maxy = _local1.pos.y + _local1.yw; _local1.signx = 0; _local1.signy = 0; _local1.sx = 0; _local1.sy = 0; _local1.mc = gfx.CreateSprite("tileMC"); _local1.mc.gotoAndStop(1); _local1.mc._xscale = _local1.xw * 2; _local1.mc._yscale = _local1.yw * 2; _local1.mc._x = _local1.pos.x; _local1.mc._y = _local1.pos.y; var _local2 = new Color(_local1.mc); _local2.setRGB(7960968); } TID_EMPTY = 0; TID_FULL = 1; TID_45DEGpn = 2; TID_45DEGnn = 3; TID_45DEGnp = 4; TID_45DEGpp = 5; TID_CONCAVEpn = 6; TID_CONCAVEnn = 7; TID_CONCAVEnp = 8; TID_CONCAVEpp = 9; TID_CONVEXpn = 10; TID_CONVEXnn = 11; TID_CONVEXnp = 12; TID_CONVEXpp = 13; TID_22DEGpnS = 14; TID_22DEGnnS = 15; TID_22DEGnpS = 16; TID_22DEGppS = 17; TID_22DEGpnB = 18; TID_22DEGnnB = 19; TID_22DEGnpB = 20; TID_22DEGppB = 21; TID_67DEGpnS = 22; TID_67DEGnnS = 23; TID_67DEGnpS = 24; TID_67DEGppS = 25; TID_67DEGpnB = 26; TID_67DEGnnB = 27; TID_67DEGnpB = 28; TID_67DEGppB = 29; TID_HALFd = 30; TID_HALFr = 31; TID_HALFu = 32; TID_HALFl = 33; CTYPE_EMPTY = 0; CTYPE_FULL = 1; CTYPE_45DEG = 2; CTYPE_CONCAVE = 6; CTYPE_CONVEX = 10; CTYPE_22DEGs = 14; CTYPE_22DEGb = 18; CTYPE_67DEGs = 22; CTYPE_67DEGb = 26; CTYPE_HALF = 30; TileMapCell.prototype.Draw = function () { this.mc.gotoAndStop(this.ID + 1); }; TileMapCell.prototype.SetState = function (ID) { var _local1 = this; if (ID == TID_EMPTY) { _local1.Clear(); } else { _local1.ID = ID; _local1.UpdateType(); _local1.Draw(); } }; TileMapCell.prototype.Clear = function () { var _local1 = this; _local1.ID = TID_EMPTY; _local1.UpdateType(); _local1.Draw(); }; TileMapCell.prototype.UpdateType = function () { var _local1 = this; if (0 < _local1.ID) { if (_local1.ID < CTYPE_45DEG) { _local1.CTYPE = CTYPE_FULL; _local1.signx = 0; _local1.signy = 0; _local1.sx = 0; _local1.sy = 0; } else if (_local1.ID < CTYPE_CONCAVE) { _local1.CTYPE = CTYPE_45DEG; if (_local1.ID == TID_45DEGpn) { _local1.signx = 1; _local1.signy = -1; _local1.sx = _local1.signx / Math.SQRT2; _local1.sy = _local1.signy / Math.SQRT2; } else if (_local1.ID == TID_45DEGnn) { _local1.signx = -1; _local1.signy = -1; _local1.sx = _local1.signx / Math.SQRT2; _local1.sy = _local1.signy / Math.SQRT2; } else if (_local1.ID == TID_45DEGnp) { _local1.signx = -1; _local1.signy = 1; _local1.sx = _local1.signx / Math.SQRT2; _local1.sy = _local1.signy / Math.SQRT2; } else if (_local1.ID == TID_45DEGpp) { _local1.signx = 1; _local1.signy = 1; _local1.sx = _local1.signx / Math.SQRT2; _local1.sy = _local1.signy / Math.SQRT2; } else { trace(((((("BAAAD TILE!!!!!: ID=" + _local1.ID) + " (") + t.i) + ",") + t.j) + ")"); return(false); } } else if (_local1.ID < CTYPE_CONVEX) { _local1.CTYPE = CTYPE_CONCAVE; if (_local1.ID == TID_CONCAVEpn) { _local1.signx = 1; _local1.signy = -1; _local1.sx = 0; _local1.sy = 0; } else if (_local1.ID == TID_CONCAVEnn) { _local1.signx = -1; _local1.signy = -1; _local1.sx = 0; _local1.sy = 0; } else if (_local1.ID == TID_CONCAVEnp) { _local1.signx = -1; _local1.signy = 1; _local1.sx = 0; _local1.sy = 0; } else if (_local1.ID == TID_CONCAVEpp) { _local1.signx = 1; _local1.signy = 1; _local1.sx = 0; _local1.sy = 0; } else { trace(((((("BAAAD TILE!!!!!: ID=" + _local1.ID) + " (") + t.i) + ",") + t.j) + ")"); return(false); } } else if (_local1.ID < CTYPE_22DEGs) { _local1.CTYPE = CTYPE_CONVEX; if (_local1.ID == TID_CONVEXpn) { _local1.signx = 1; _local1.signy = -1; _local1.sx = 0; _local1.sy = 0; } else if (_local1.ID == TID_CONVEXnn) { _local1.signx = -1; _local1.signy = -1; _local1.sx = 0; _local1.sy = 0; } else if (_local1.ID == TID_CONVEXnp) { _local1.signx = -1; _local1.signy = 1; _local1.sx = 0; _local1.sy = 0; } else if (_local1.ID == TID_CONVEXpp) { _local1.signx = 1; _local1.signy = 1; _local1.sx = 0; _local1.sy = 0; } else { trace(((((("BAAAD TILE!!!!!: ID=" + _local1.ID) + " (") + t.i) + ",") + t.j) + ")"); return(false); } } else if (_local1.ID < CTYPE_22DEGb) { _local1.CTYPE = CTYPE_22DEGs; if (_local1.ID == TID_22DEGpnS) { _local1.signx = 1; _local1.signy = -1; var _local2 = 2.23606797749979; _local1.sx = (_local1.signx * 1) / _local2; _local1.sy = (_local1.signy * 2) / _local2; } else if (_local1.ID == TID_22DEGnnS) { _local1.signx = -1; _local1.signy = -1; var _local2 = 2.23606797749979; _local1.sx = (_local1.signx * 1) / _local2; _local1.sy = (_local1.signy * 2) / _local2; } else if (_local1.ID == TID_22DEGnpS) { _local1.signx = -1; _local1.signy = 1; var _local2 = 2.23606797749979; _local1.sx = (_local1.signx * 1) / _local2; _local1.sy = (_local1.signy * 2) / _local2; } else if (_local1.ID == TID_22DEGppS) { _local1.signx = 1; _local1.signy = 1; var _local2 = 2.23606797749979; _local1.sx = (_local1.signx * 1) / _local2; _local1.sy = (_local1.signy * 2) / _local2; } else { trace(((((("BAAAD TILE!!!!!: ID=" + _local1.ID) + " (") + t.i) + ",") + t.j) + ")"); return(false); } } else if (_local1.ID < CTYPE_67DEGs) { _local1.CTYPE = CTYPE_22DEGb; if (_local1.ID == TID_22DEGpnB) { _local1.signx = 1; _local1.signy = -1; var _local2 = 2.23606797749979; _local1.sx = (_local1.signx * 1) / _local2; _local1.sy = (_local1.signy * 2) / _local2; } else if (_local1.ID == TID_22DEGnnB) { _local1.signx = -1; _local1.signy = -1; var _local2 = 2.23606797749979; _local1.sx = (_local1.signx * 1) / _local2; _local1.sy = (_local1.signy * 2) / _local2; } else if (_local1.ID == TID_22DEGnpB) { _local1.signx = -1; _local1.signy = 1; var _local2 = 2.23606797749979; _local1.sx = (_local1.signx * 1) / _local2; _local1.sy = (_local1.signy * 2) / _local2; } else if (_local1.ID == TID_22DEGppB) { _local1.signx = 1; _local1.signy = 1; var _local2 = 2.23606797749979; _local1.sx = (_local1.signx * 1) / _local2; _local1.sy = (_local1.signy * 2) / _local2; } else { trace(((((("BAAAD TILE!!!!!: ID=" + _local1.ID) + " (") + t.i) + ",") + t.j) + ")"); return(false); } } else if (_local1.ID < CTYPE_67DEGb) { _local1.CTYPE = CTYPE_67DEGs; if (_local1.ID == TID_67DEGpnS) { _local1.signx = 1; _local1.signy = -1; var _local2 = 2.23606797749979; _local1.sx = (_local1.signx * 2) / _local2; _local1.sy = (_local1.signy * 1) / _local2; } else if (_local1.ID == TID_67DEGnnS) { _local1.signx = -1; _local1.signy = -1; var _local2 = 2.23606797749979; _local1.sx = (_local1.signx * 2) / _local2; _local1.sy = (_local1.signy * 1) / _local2; } else if (_local1.ID == TID_67DEGnpS) { _local1.signx = -1; _local1.signy = 1; var _local2 = 2.23606797749979; _local1.sx = (_local1.signx * 2) / _local2; _local1.sy = (_local1.signy * 1) / _local2; } else if (_local1.ID == TID_67DEGppS) { _local1.signx = 1; _local1.signy = 1; var _local2 = 2.23606797749979; _local1.sx = (_local1.signx * 2) / _local2; _local1.sy = (_local1.signy * 1) / _local2; } else { trace(((((("BAAAD TILE!!!!!: ID=" + _local1.ID) + " (") + t.i) + ",") + t.j) + ")"); return(false); } } else if (_local1.ID < CTYPE_HALF) { _local1.CTYPE = CTYPE_67DEGb; if (_local1.ID == TID_67DEGpnB) { _local1.signx = 1; _local1.signy = -1; var _local2 = 2.23606797749979; _local1.sx = (_local1.signx * 2) / _local2; _local1.sy = (_local1.signy * 1) / _local2; } else if (_local1.ID == TID_67DEGnnB) { _local1.signx = -1; _local1.signy = -1; var _local2 = 2.23606797749979; _local1.sx = (_local1.signx * 2) / _local2; _local1.sy = (_local1.signy * 1) / _local2; } else if (_local1.ID == TID_67DEGnpB) { _local1.signx = -1; _local1.signy = 1; var _local2 = 2.23606797749979; _local1.sx = (_local1.signx * 2) / _local2; _local1.sy = (_local1.signy * 1) / _local2; } else if (_local1.ID == TID_67DEGppB) { _local1.signx = 1; _local1.signy = 1; var _local2 = 2.23606797749979; _local1.sx = (_local1.signx * 2) / _local2; _local1.sy = (_local1.signy * 1) / _local2; } else { trace(((((("BAAAD TILE!!!!!: ID=" + _local1.ID) + " (") + t.i) + ",") + t.j) + ")"); return(false); } } else { _local1.CTYPE = CTYPE_HALF; if (_local1.ID == TID_HALFd) { _local1.signx = 0; _local1.signy = -1; _local1.sx = _local1.signx; _local1.sy = _local1.signy; } else if (_local1.ID == TID_HALFu) { _local1.signx = 0; _local1.signy = 1; _local1.sx = _local1.signx; _local1.sy = _local1.signy; } else if (_local1.ID == TID_HALFl) { _local1.signx = 1; _local1.signy = 0; _local1.sx = _local1.signx; _local1.sy = _local1.signy; } else if (_local1.ID == TID_HALFr) { _local1.signx = -1; _local1.signy = 0; _local1.sx = _local1.signx; _local1.sy = _local1.signy; } else { trace(((((("BAAD TILE!!!: ID=" + _local1.ID) + " (") + t.i) + ",") + t.j) + ")"); return(false); } } } else { _local1.CTYPE = CTYPE_EMPTY; _local1.signx = 0; _local1.signy = 0; _local1.sx = 0; _local1.sy = 0; } return(undefined); }; function CollideAABBVsTile(tile) { var pos = this.pos; var _local3 = tile; var tx = _local3.pos.x; var ty = _local3.pos.y; var txw = _local3.xw; var tyw = _local3.yw; var dx = (pos.x - tx); var _local2 = (txw + this.xw) - Math.abs(dx); if (0 < _local2) { var dy = (pos.y - ty); var _local1 = (tyw + this.yw) - Math.abs(dy); if (0 < _local1) { if (_local2 < _local1) { if (dx < 0) { _local2 = _local2 * -1; _local1 = 0; } else { _local1 = 0; } } else if (dy < 0) { _local2 = 0; _local1 = _local1 * -1; } else { _local2 = 0; } ResolveBoxTile(_local2, _local1, this, _local3); } } } function ProjAABB_Full(x, y, obj, t) { var _local2 = y; var _local3 = x; var _local1 = Math.sqrt((_local3 * _local3) + (_local2 * _local2)); obj.ReportCollisionVsWorld(_local3, _local2, _local3 / _local1, _local2 / _local1, t); return(COL_AXIS); } function ProjAABB_Half(x, y, obj, t) { var _local1 = t; var _local3 = _local1.signx; var _local2 = _local1.signy; var ox = ((obj.pos.x - (_local3 * obj.xw)) - _local1.pos.x); var oy = ((obj.pos.y - (_local2 * obj.yw)) - _local1.pos.y); var dp = ((ox * _local3) + (oy * _local2)); if (dp < 0) { _local3 = _local3 * (-dp); _local2 = _local2 * (-dp); var lenN = Math.sqrt((_local3 * _local3) + (_local2 * _local2)); var lenP = Math.sqrt((x * x) + (y * y)); if (lenP < lenN) { obj.ReportCollisionVsWorld(x, y, x / lenP, y / lenP, _local1); return(COL_AXIS); } obj.ReportCollisionVsWorld(_local3, _local2, _local1.signx, _local1.signy, _local1); return(COL_OTHER); } return(COL_NONE); } function ProjAABB_Concave(x, y, obj, t) { var _local1 = t; var signx = _local1.signx; var signy = _local1.signy; var _local3 = (_local1.pos.x + (signx * _local1.xw)) - (obj.pos.x - (signx * obj.xw)); var _local2 = (_local1.pos.y + (signy * _local1.yw)) - (obj.pos.y - (signy * obj.yw)); var twid = (_local1.xw * 2); var rad = Math.sqrt((twid * twid) + 0); var len = Math.sqrt((_local3 * _local3) + (_local2 * _local2)); var pen = (len - rad); if (0 < pen) { var lenP = Math.sqrt((x * x) + (y * y)); if (lenP < pen) { obj.ReportCollisionVsWorld(x, y, x / lenP, y / lenP, _local1); return(COL_AXIS); } _local3 = _local3 / len; _local2 = _local2 / len; obj.ReportCollisionVsWorld(_local3 * pen, _local2 * pen, _local3, _local2, _local1); return(COL_OTHER); } return(COL_NONE); } function ProjAABB_Convex(x, y, obj, t) { var _local1 = t; var signx = _local1.signx; var signy = _local1.signy; var _local3 = (obj.pos.x - (signx * obj.xw)) - (_local1.pos.x - (signx * _local1.xw)); var _local2 = (obj.pos.y - (signy * obj.yw)) - (_local1.pos.y - (signy * _local1.yw)); var len = Math.sqrt((_local3 * _local3) + (_local2 * _local2)); var twid = (_local1.xw * 2); var rad = Math.sqrt((twid * twid) + 0); var pen = (rad - len); if (((signx * _local3) < 0) || ((signy * _local2) < 0)) { var lenP = Math.sqrt((x * x) + (y * y)); obj.ReportCollisionVsWorld(x, y, x / lenP, y / lenP, _local1); return(COL_AXIS); } if (0 < pen) { _local3 = _local3 / len; _local2 = _local2 / len; obj.ReportCollisionVsWorld(_local3 * pen, _local2 * pen, _local3, _local2, _local1); return(COL_OTHER); } return(COL_NONE); } function ProjAABB_45Deg(x, y, obj, t) { var _local1 = t; var signx = _local1.signx; var signy = _local1.signy; var ox = ((obj.pos.x - (signx * obj.xw)) - _local1.pos.x); var oy = ((obj.pos.y - (signy * obj.yw)) - _local1.pos.y); var _local3 = _local1.sx; var _local2 = _local1.sy; var dp = ((ox * _local3) + (oy * _local2)); if (dp < 0) { _local3 = _local3 * (-dp); _local2 = _local2 * (-dp); var lenN = Math.sqrt((_local3 * _local3) + (_local2 * _local2)); var lenP = Math.sqrt((x * x) + (y * y)); if (lenP < lenN) { obj.ReportCollisionVsWorld(x, y, x / lenP, y / lenP, _local1); return(COL_AXIS); } obj.ReportCollisionVsWorld(_local3, _local2, _local1.sx, _local1.sy); return(COL_OTHER); } return(COL_NONE); } function ProjAABB_22DegS(x, y, obj, t) { var _local1 = t; var _local2 = obj; var signx = _local1.signx; var signy = _local1.signy; var py = (_local2.pos.y - (signy * _local2.yw)); var _local3 = _local1.pos.y - py; if (0 < (_local3 * signy)) { var ox = ((_local2.pos.x - (signx * _local2.xw)) - (_local1.pos.x + (signx * _local1.xw))); var oy = ((_local2.pos.y - (signy * _local2.yw)) - (_local1.pos.y - (signy * _local1.yw))); var sx = _local1.sx; var sy = _local1.sy; var dp = ((ox * sx) + (oy * sy)); if (dp < 0) { sx = sx * (-dp); sy = sy * (-dp); var lenN = Math.sqrt((sx * sx) + (sy * sy)); var lenP = Math.sqrt((x * x) + (y * y)); var aY = Math.abs(_local3); if (lenP < lenN) { if (aY < lenP) { _local2.ReportCollisionVsWorld(0, _local3, 0, _local3 / aY, _local1); return(COL_OTHER); } _local2.ReportCollisionVsWorld(x, y, x / lenP, y / lenP, _local1); return(COL_AXIS); } if (aY < lenN) { _local2.ReportCollisionVsWorld(0, _local3, 0, _local3 / aY, _local1); return(COL_OTHER); } _local2.ReportCollisionVsWorld(sx, sy, _local1.sx, _local1.sy, _local1); return(COL_OTHER); } } return(COL_NONE); } function ProjAABB_22DegB(x, y, obj, t) { var _local1 = t; var signx = _local1.signx; var signy = _local1.signy; var ox = ((obj.pos.x - (signx * obj.xw)) - (_local1.pos.x - (signx * _local1.xw))); var oy = ((obj.pos.y - (signy * obj.yw)) - (_local1.pos.y + (signy * _local1.yw))); var _local3 = _local1.sx; var _local2 = _local1.sy; var dp = ((ox * _local3) + (oy * _local2)); if (dp < 0) { _local3 = _local3 * (-dp); _local2 = _local2 * (-dp); var lenN = Math.sqrt((_local3 * _local3) + (_local2 * _local2)); var lenP = Math.sqrt((x * x) + (y * y)); if (lenP < lenN) { obj.ReportCollisionVsWorld(x, y, x / lenP, y / lenP, _local1); return(COL_AXIS); } obj.ReportCollisionVsWorld(_local3, _local2, _local1.sx, _local1.sy, _local1); return(COL_OTHER); } return(COL_NONE); } function ProjAABB_67DegS(x, y, obj, t) { var _local1 = t; var _local2 = obj; var signx = _local1.signx; var signy = _local1.signy; var px = (_local2.pos.x - (signx * _local2.xw)); var _local3 = _local1.pos.x - px; if (0 < (_local3 * signx)) { var ox = ((_local2.pos.x - (signx * _local2.xw)) - (_local1.pos.x - (signx * _local1.xw))); var oy = ((_local2.pos.y - (signy * _local2.yw)) - (_local1.pos.y + (signy * _local1.yw))); var sx = _local1.sx; var sy = _local1.sy; var dp = ((ox * sx) + (oy * sy)); if (dp < 0) { sx = sx * (-dp); sy = sy * (-dp); var lenN = Math.sqrt((sx * sx) + (sy * sy)); var lenP = Math.sqrt((x * x) + (y * y)); var aX = Math.abs(_local3); if (lenP < lenN) { if (aX < lenP) { _local2.ReportCollisionVsWorld(_local3, 0, _local3 / aX, 0, _local1); return(COL_OTHER); } _local2.ReportCollisionVsWorld(x, y, x / lenP, y / lenP, _local1); return(COL_AXIS); } if (aX < lenN) { _local2.ReportCollisionVsWorld(_local3, 0, _local3 / aX, 0, _local1); return(COL_OTHER); } _local2.ReportCollisionVsWorld(sx, sy, _local1.sx, _local1.sy, _local1); return(COL_OTHER); } } return(COL_NONE); } function ProjAABB_67DegB(x, y, obj, t) { var _local1 = t; var signx = _local1.signx; var signy = _local1.signy; var ox = ((obj.pos.x - (signx * obj.xw)) - (_local1.pos.x + (signx * _local1.xw))); var oy = ((obj.pos.y - (signy * obj.yw)) - (_local1.pos.y - (signy * _local1.yw))); var _local3 = _local1.sx; var _local2 = _local1.sy; var dp = ((ox * _local3) + (oy * _local2)); if (dp < 0) { _local3 = _local3 * (-dp); _local2 = _local2 * (-dp); var lenN = Math.sqrt((_local3 * _local3) + (_local2 * _local2)); var lenP = Math.sqrt((x * x) + (y * y)); if (lenP < lenN) { obj.ReportCollisionVsWorld(x, y, x / lenP, y / lenP, _local1); return(COL_AXIS); } obj.ReportCollisionVsWorld(_local3, _local2, _local1.sx, _local1.sy, _local1); return(COL_OTHER); } return(COL_NONE); } function ResolveBoxTile(x, y, box, t) { var _local1 = t; if (0 < _local1.ID) { return(Proj_AABBTile[_local1.CTYPE](x, y, box, _local1)); } trace(((((("ResolveBoxTile() was called with an empty (or unknown) tile!: ID=" + _local1.ID) + " (") + _local1.i) + ",") + _local1.j) + ")"); return(false); } Proj_AABBTile = new Object(); Proj_AABBTile[CTYPE_FULL] = ProjAABB_Full; Proj_AABBTile[CTYPE_45DEG] = ProjAABB_45Deg; Proj_AABBTile[CTYPE_CONCAVE] = ProjAABB_Concave; Proj_AABBTile[CTYPE_CONVEX] = ProjAABB_Convex; Proj_AABBTile[CTYPE_22DEGs] = ProjAABB_22DegS; Proj_AABBTile[CTYPE_22DEGb] = ProjAABB_22DegB; Proj_AABBTile[CTYPE_67DEGs] = ProjAABB_67DegS; Proj_AABBTile[CTYPE_67DEGb] = ProjAABB_67DegB; Proj_AABBTile[CTYPE_HALF] = ProjAABB_Half; function CollideCircleVsTile(tile) { var pos = this.pos; var r = this.r; var _local1 = tile; var tx = _local1.pos.x; var ty = _local1.pos.y; var txw = _local1.xw; var tyw = _local1.yw; var _local3 = pos.x - tx; var px = ((txw + r) - Math.abs(_local3)); if (0 < px) { var _local2 = pos.y - ty; var py = ((tyw + r) - Math.abs(_local2)); if (0 < py) { var oH = 0; var oV = 0; if (_local3 < (-txw)) { oH = -1; } else if (txw < _local3) { oH = 1; } if (_local2 < (-tyw)) { oV = -1; } else if (tyw < _local2) { oV = 1; } ResolveCircleTile(px, py, oH, oV, this, _local1); } } } function ProjCircle_Full(x, y, oH, oV, obj, t) { var _local1 = t; var _local2 = obj; if (oH == 0) { if (oV == 0) { if (x < y) { var dx = (_local2.pos.x - _local1.pos.x); if (dx < 0) { _local2.ReportCollisionVsWorld(-x, 0, -1, 0, _local1); return(COL_AXIS); } _local2.ReportCollisionVsWorld(x, 0, 1, 0, _local1); return(COL_AXIS); } var _local3 = _local2.pos.y - _local1.pos.y; if (_local3 < 0) { _local2.ReportCollisionVsWorld(0, -y, 0, -1, _local1); return(COL_AXIS); } _local2.ReportCollisionVsWorld(0, y, 0, 1, _local1); return(COL_AXIS); } _local2.ReportCollisionVsWorld(0, y * oV, 0, oV, _local1); return(COL_AXIS); } if (oV == 0) { _local2.ReportCollisionVsWorld(x * oH, 0, oH, 0, _local1); return(COL_AXIS); } var vx = (_local1.pos.x + (oH * _local1.xw)); var vy = (_local1.pos.y + (oV * _local1.yw)); var dx = (_local2.pos.x - vx); var _local3 = _local2.pos.y - vy; var len = Math.sqrt((dx * dx) + (_local3 * _local3)); var pen = (_local2.r - len); if (0 < pen) { if (len == 0) { dx = oH / Math.SQRT2; _local3 = oV / Math.SQRT2; } else { dx = dx / len; _local3 = _local3 / len; } _local2.ReportCollisionVsWorld(dx * pen, _local3 * pen, dx, _local3, _local1); return(COL_OTHER); } return(COL_NONE); } function ProjCircle_Half(x, y, oH, oV, obj, t) { var _local1 = t; var _local2 = obj; var _local3 = oV; var signx = _local1.signx; var signy = _local1.signy; var celldp = ((oH * signx) + (_local3 * signy)); if (0 < celldp) { return(COL_NONE); } if (oH == 0) { if (_local3 == 0) { var r = _local2.r; var ox = ((_local2.pos.x - (signx * r)) - _local1.pos.x); var oy = ((_local2.pos.y - (signy * r)) - _local1.pos.y); var sx = signx; var sy = signy; var dp = ((ox * sx) + (oy * sy)); if (dp < 0) { sx = sx * (-dp); sy = sy * (-dp); var lenN = Math.sqrt((sx * sx) + (sy * sy)); var lenP = Math.sqrt((x * x) + (y * y)); if (lenP < lenN) { _local2.ReportCollisionVsWorld(x, y, x / lenP, y / lenP, _local1); return(COL_AXIS); } _local2.ReportCollisionVsWorld(sx, sy, _local1.signx, _local1.signy); return(COL_OTHER); } } else if (celldp == 0) { var r = _local2.r; var dx = (_local2.pos.x - _local1.pos.x); if ((dx * signx) < 0) { _local2.ReportCollisionVsWorld(0, y * _local3, 0, _local3, _local1); return(COL_AXIS); } var dy = (_local2.pos.y - (_local1.pos.y + (_local3 * _local1.yw))); var len = Math.sqrt((dx * dx) + (dy * dy)); var pen = (_local2.r - len); if (0 < pen) { if (len == 0) { dx = signx / Math.SQRT2; dy = _local3 / Math.SQRT2; } else { dx = dx / len; dy = dy / len; } _local2.ReportCollisionVsWorld(dx * pen, dy * pen, dx, dy, _local1); return(COL_OTHER); } } else { _local2.ReportCollisionVsWorld(0, y * _local3, 0, _local3, _local1); return(COL_AXIS); } } else if (_local3 == 0) { if (celldp == 0) { var r = _local2.r; var dy = (_local2.pos.y - _local1.pos.y); if ((dy * signy) < 0) { _local2.ReportCollisionVsWorld(x * oH, 0, oH, 0, _local1); return(COL_AXIS); } var dx = (_local2.pos.x - (_local1.pos.x + (oH * _local1.xw))); var len = Math.sqrt((dx * dx) + (dy * dy)); var pen = (_local2.r - len); if (0 < pen) { if (len == 0) { dx = signx / Math.SQRT2; dy = _local3 / Math.SQRT2; } else { dx = dx / len; dy = dy / len; } _local2.ReportCollisionVsWorld(dx * pen, dy * pen, dx, dy, _local1); return(COL_OTHER); } } else { _local2.ReportCollisionVsWorld(x * oH, 0, oH, 0, _local1); return(COL_AXIS); } } else { var vx = (_local1.pos.x + (oH * _local1.xw)); var vy = (_local1.pos.y + (_local3 * _local1.yw)); var dx = (_local2.pos.x - vx); var dy = (_local2.pos.y - vy); var len = Math.sqrt((dx * dx) + (dy * dy)); var pen = (_local2.r - len); if (0 < pen) { if (len == 0) { dx = oH / Math.SQRT2; dy = _local3 / Math.SQRT2; } else { dx = dx / len; dy = dy / len; } _local2.ReportCollisionVsWorld(dx * pen, dy * pen, dx, dy, _local1); return(COL_OTHER); } } return(COL_NONE); } function ProjCircle_45Deg(x, y, oH, oV, obj, t) { var _local1 = t; var _local2 = obj; var signx = _local1.signx; var signy = _local1.signy; if (oH == 0) { if (oV == 0) { var sx = _local1.sx; var sy = _local1.sy; var ox = ((_local2.pos.x - (sx * _local2.r)) - _local1.pos.x); var _local3 = (_local2.pos.y - (sy * _local2.r)) - _local1.pos.y; var dp = ((ox * sx) + (_local3 * sy)); if (dp < 0) { sx = sx * (-dp); sy = sy * (-dp); if (x < y) { lenP = x; y = 0; if ((_local2.pos.x - _local1.pos.x) < 0) { x = x * -1; } } else { lenP = y; x = 0; if ((_local2.pos.y - _local1.pos.y) < 0) { y = y * -1; } } var lenN = Math.sqrt((sx * sx) + (sy * sy)); if (lenP < lenN) { _local2.ReportCollisionVsWorld(x, y, x / lenP, y / lenP, _local1); return(COL_AXIS); } _local2.ReportCollisionVsWorld(sx, sy, _local1.sx, _local1.sy, _local1); return(COL_OTHER); } } else { if ((signy * oV) < 0) { _local2.ReportCollisionVsWorld(0, y * oV, 0, oV, _local1); return(COL_AXIS); } var sx = _local1.sx; var sy = _local1.sy; var ox = (_local2.pos.x - (_local1.pos.x - (signx * _local1.xw))); var _local3 = _local2.pos.y - (_local1.pos.y + (oV * _local1.yw)); var perp = ((ox * (-sy)) + (_local3 * sx)); if (0 < ((perp * signx) * signy)) { var len = Math.sqrt((ox * ox) + (_local3 * _local3)); var pen = (_local2.r - len); if (0 < pen) { ox = ox / len; _local3 = _local3 / len; _local2.ReportCollisionVsWorld(ox * pen, _local3 * pen, ox, _local3, _local1); return(COL_OTHER); } } else { var dp = ((ox * sx) + (_local3 * sy)); var pen = (_local2.r - Math.abs(dp)); if (0 < pen) { _local2.ReportCollisionVsWorld(sx * pen, sy * pen, sx, sy, _local1); return(COL_OTHER); } } } } else if (oV == 0) { if ((signx * oH) < 0) { _local2.ReportCollisionVsWorld(x * oH, 0, oH, 0, _local1); return(COL_AXIS); } var sx = _local1.sx; var sy = _local1.sy; var ox = (_local2.pos.x - (_local1.pos.x + (oH * _local1.xw))); var _local3 = _local2.pos.y - (_local1.pos.y - (signy * _local1.yw)); var perp = ((ox * (-sy)) + (_local3 * sx)); if (((perp * signx) * signy) < 0) { var len = Math.sqrt((ox * ox) + (_local3 * _local3)); var pen = (_local2.r - len); if (0 < pen) { ox = ox / len; _local3 = _local3 / len; _local2.ReportCollisionVsWorld(ox * pen, _local3 * pen, ox, _local3, _local1); return(COL_OTHER); } } else { var dp = ((ox * sx) + (_local3 * sy)); var pen = (_local2.r - Math.abs(dp)); if (0 < pen) { _local2.ReportCollisionVsWorld(sx * pen, sy * pen, sx, sy, _local1); return(COL_OTHER); } } } else { if (0 < ((signx * oH) + (signy * oV))) { return(COL_NONE); } var vx = (_local1.pos.x + (oH * _local1.xw)); var vy = (_local1.pos.y + (oV * _local1.yw)); var dx = (_local2.pos.x - vx); var dy = (_local2.pos.y - vy); var len = Math.sqrt((dx * dx) + (dy * dy)); var pen = (_local2.r - len); if (0 < pen) { if (len == 0) { dx = oH / Math.SQRT2; dy = oV / Math.SQRT2; } else { dx = dx / len; dy = dy / len; } _local2.ReportCollisionVsWorld(dx * pen, dy * pen, dx, dy, _local1); return(COL_OTHER); } } return(COL_NONE); } function ProjCircle_Concave(x, y, oH, oV, obj, t) { var _local1 = t; var _local2 = obj; var _local3 = oV; var signx = _local1.signx; var signy = _local1.signy; if (oH == 0) { if (_local3 == 0) { var ox = ((_local1.pos.x + (signx * _local1.xw)) - _local2.pos.x); var oy = ((_local1.pos.y + (signy * _local1.yw)) - _local2.pos.y); var twid = (_local1.xw * 2); var trad = Math.sqrt((twid * twid) + 0); var len = Math.sqrt((ox * ox) + (oy * oy)); var pen = ((len + _local2.r) - trad); if (0 < pen) { if (x < y) { lenP = x; y = 0; if ((_local2.pos.x - _local1.pos.x) < 0) { x = x * -1; } } else { lenP = y; x = 0; if ((_local2.pos.y - _local1.pos.y) < 0) { y = y * -1; } } if (lenP < pen) { _local2.ReportCollisionVsWorld(x, y, x / lenP, y / lenP, _local1); return(COL_AXIS); } ox = ox / len; oy = oy / len; _local2.ReportCollisionVsWorld(ox * pen, oy * pen, ox, oy, _local1); return(COL_OTHER); } return(COL_NONE); } if ((signy * _local3) < 0) { _local2.ReportCollisionVsWorld(0, y * _local3, 0, _local3, _local1); return(COL_AXIS); } var vx = (_local1.pos.x - (signx * _local1.xw)); var vy = (_local1.pos.y + (_local3 * _local1.yw)); var dx = (_local2.pos.x - vx); var dy = (_local2.pos.y - vy); var len = Math.sqrt((dx * dx) + (dy * dy)); var pen = (_local2.r - len); if (0 < pen) { if (len == 0) { dx = 0; dy = _local3; } else { dx = dx / len; dy = dy / len; } _local2.ReportCollisionVsWorld(dx * pen, dy * pen, dx, dy, _local1); return(COL_OTHER); } } else if (_local3 == 0) { if ((signx * oH) < 0) { _local2.ReportCollisionVsWorld(x * oH, 0, oH, 0, _local1); return(COL_AXIS); } var vx = (_local1.pos.x + (oH * _local1.xw)); var vy = (_local1.pos.y - (signy * _local1.yw)); var dx = (_local2.pos.x - vx); var dy = (_local2.pos.y - vy); var len = Math.sqrt((dx * dx) + (dy * dy)); var pen = (_local2.r - len); if (0 < pen) { if (len == 0) { dx = oH; dy = 0; } else { dx = dx / len; dy = dy / len; } _local2.ReportCollisionVsWorld(dx * pen, dy * pen, dx, dy, _local1); return(COL_OTHER); } } else { if (0 < ((signx * oH) + (signy * _local3))) { return(COL_NONE); } var vx = (_local1.pos.x + (oH * _local1.xw)); var vy = (_local1.pos.y + (_local3 * _local1.yw)); var dx = (_local2.pos.x - vx); var dy = (_local2.pos.y - vy); var len = Math.sqrt((dx * dx) + (dy * dy)); var pen = (_local2.r - len); if (0 < pen) { if (len == 0) { dx = oH / Math.SQRT2; dy = _local3 / Math.SQRT2; } else { dx = dx / len; dy = dy / len; } _local2.ReportCollisionVsWorld(dx * pen, dy * pen, dx, dy, _local1); return(COL_OTHER); } } return(COL_NONE); } function ProjCircle_Convex(x, y, oH, oV, obj, t) { var _local1 = t; var _local2 = obj; var signx = _local1.signx; var signy = _local1.signy; if (oH == 0) { if (oV == 0) { var ox = (_local2.pos.x - (_local1.pos.x - (signx * _local1.xw))); var oy = (_local2.pos.y - (_local1.pos.y - (signy * _local1.yw))); var twid = (_local1.xw * 2); var trad = Math.sqrt((twid * twid) + 0); var len = Math.sqrt((ox * ox) + (oy * oy)); var pen = ((trad + _local2.r) - len); if (0 < pen) { if (x < y) { lenP = x; y = 0; if ((_local2.pos.x - _local1.pos.x) < 0) { x = x * -1; } } else { lenP = y; x = 0; if ((_local2.pos.y - _local1.pos.y) < 0) { y = y * -1; } } if (lenP < pen) { _local2.ReportCollisionVsWorld(x, y, x / lenP, y / lenP, _local1); return(COL_AXIS); } ox = ox / len; oy = oy / len; _local2.ReportCollisionVsWorld(ox * pen, oy * pen, ox, oy, _local1); return(COL_OTHER); } } else { if ((signy * oV) < 0) { _local2.ReportCollisionVsWorld(0, y * oV, 0, oV, _local1); return(COL_AXIS); } var ox = (_local2.pos.x - (_local1.pos.x - (signx * _local1.xw))); var oy = (_local2.pos.y - (_local1.pos.y - (signy * _local1.yw))); var twid = (_local1.xw * 2); var trad = Math.sqrt((twid * twid) + 0); var len = Math.sqrt((ox * ox) + (oy * oy)); var pen = ((trad + _local2.r) - len); if (0 < pen) { ox = ox / len; oy = oy / len; _local2.ReportCollisionVsWorld(ox * pen, oy * pen, ox, oy, _local1); return(COL_OTHER); } } } else if (oV == 0) { if ((signx * oH) < 0) { _local2.ReportCollisionVsWorld(x * oH, 0, oH, 0, _local1); return(COL_AXIS); } var ox = (_local2.pos.x - (_local1.pos.x - (signx * _local1.xw))); var oy = (_local2.pos.y - (_local1.pos.y - (signy * _local1.yw))); var twid = (_local1.xw * 2); var trad = Math.sqrt((twid * twid) + 0); var len = Math.sqrt((ox * ox) + (oy * oy)); var pen = ((trad + _local2.r) - len); if (0 < pen) { ox = ox / len; oy = oy / len; _local2.ReportCollisionVsWorld(ox * pen, oy * pen, ox, oy, _local1); return(COL_OTHER); } } else if (0 < ((signx * oH) + (signy * oV))) { var ox = (_local2.pos.x - (_local1.pos.x - (signx * _local1.xw))); var oy = (_local2.pos.y - (_local1.pos.y - (signy * _local1.yw))); var twid = (_local1.xw * 2); var trad = Math.sqrt((twid * twid) + 0); var len = Math.sqrt((ox * ox) + (oy * oy)); var pen = ((trad + _local2.r) - len); if (0 < pen) { ox = ox / len; oy = oy / len; _local2.ReportCollisionVsWorld(ox * pen, oy * pen, ox, oy, _local1); return(COL_OTHER); } } else { var vx = (_local1.pos.x + (oH * _local1.xw)); var vy = (_local1.pos.y + (oV * _local1.yw)); var dx = (_local2.pos.x - vx); var _local3 = _local2.pos.y - vy; var len = Math.sqrt((dx * dx) + (_local3 * _local3)); var pen = (_local2.r - len); if (0 < pen) { if (len == 0) { dx = oH / Math.SQRT2; _local3 = oV / Math.SQRT2; } else { dx = dx / len; _local3 = _local3 / len; } _local2.ReportCollisionVsWorld(dx * pen, _local3 * pen, dx, _local3, _local1); return(COL_OTHER); } } return(COL_NONE); } function ProjCircle_22DegS(x, y, oH, oV, obj, t) { var _local1 = t; var _local2 = obj; var signx = _local1.signx; var signy = _local1.signy; if (0 < (signy * oV)) { return(COL_NONE); } if (oH == 0) { if (oV == 0) { var sx = _local1.sx; var sy = _local1.sy; var r = _local2.r; var ox = (_local2.pos.x - (_local1.pos.x - (signx * _local1.xw))); var _local3 = _local2.pos.y - _local1.pos.y; var perp = ((ox * (-sy)) + (_local3 * sx)); if (0 < ((perp * signx) * signy)) { var len = Math.sqrt((ox * ox) + (_local3 * _local3)); var pen = (r - len); if (0 < pen) { ox = ox / len; _local3 = _local3 / len; _local2.ReportCollisionVsWorld(ox * pen, _local3 * pen, ox, _local3, _local1); return(COL_OTHER); } } else { ox = ox - (r * sx); _local3 = _local3 - (r * sy); var dp = ((ox * sx) + (_local3 * sy)); if (dp < 0) { sx = sx * (-dp); sy = sy * (-dp); var lenN = Math.sqrt((sx * sx) + (sy * sy)); if (x < y) { lenP = x; y = 0; if ((_local2.pos.x - _local1.pos.x) < 0) { x = x * -1; } } else { lenP = y; x = 0; if ((_local2.pos.y - _local1.pos.y) < 0) { y = y * -1; } } if (lenP < lenN) { _local2.ReportCollisionVsWorld(x, y, x / lenP, y / lenP, _local1); return(COL_AXIS); } _local2.ReportCollisionVsWorld(sx, sy, _local1.sx, _local1.sy, _local1); return(COL_OTHER); } } } else { _local2.ReportCollisionVsWorld(0, y * oV, 0, oV, _local1); return(COL_AXIS); } } else if (oV == 0) { if ((signx * oH) < 0) { var vx = (_local1.pos.x - (signx * _local1.xw)); var vy = _local1.pos.y; var dx = (_local2.pos.x - vx); var dy = (_local2.pos.y - vy); if ((dy * signy) < 0) { _local2.ReportCollisionVsWorld(x * oH, 0, oH, 0, _local1); return(COL_AXIS); } var len = Math.sqrt((dx * dx) + (dy * dy)); var pen = (_local2.r - len); if (0 < pen) { if (len == 0) { dx = oH / Math.SQRT2; dy = oV / Math.SQRT2; } else { dx = dx / len; dy = dy / len; } _local2.ReportCollisionVsWorld(dx * pen, dy * pen, dx, dy, _local1); return(COL_OTHER); } } else { var sx = _local1.sx; var sy = _local1.sy; var ox = (_local2.pos.x - (_local1.pos.x + (oH * _local1.xw))); var _local3 = _local2.pos.y - (_local1.pos.y - (signy * _local1.yw)); var perp = ((ox * (-sy)) + (_local3 * sx)); if (((perp * signx) * signy) < 0) { var len = Math.sqrt((ox * ox) + (_local3 * _local3)); var pen = (_local2.r - len); if (0 < pen) { ox = ox / len; _local3 = _local3 / len; _local2.ReportCollisionVsWorld(ox * pen, _local3 * pen, ox, _local3, _local1); return(COL_OTHER); } } else { var dp = ((ox * sx) + (_local3 * sy)); var pen = (_local2.r - Math.abs(dp)); if (0 < pen) { _local2.ReportCollisionVsWorld(sx * pen, sy * pen, sx, sy, _local1); return(COL_OTHER); } } } } else { var vx = (_local1.pos.x + (oH * _local1.xw)); var vy = (_local1.pos.y + (oV * _local1.yw)); var dx = (_local2.pos.x - vx); var dy = (_local2.pos.y - vy); var len = Math.sqrt((dx * dx) + (dy * dy)); var pen = (_local2.r - len); if (0 < pen) { if (len == 0) { dx = oH / Math.SQRT2; dy = oV / Math.SQRT2; } else { dx = dx / len; dy = dy / len; } _local2.ReportCollisionVsWorld(dx * pen, dy * pen, dx, dy, _local1); return(COL_OTHER); } } return(COL_NONE); } function ProjCircle_22DegB(x, y, oH, oV, obj, t) { var _local1 = t; var _local2 = obj; var signx = _local1.signx; var _local3 = _local1.signy; if (oH == 0) { if (oV == 0) { var sx = _local1.sx; var sy = _local1.sy; var r = _local2.r; var ox = ((_local2.pos.x - (sx * r)) - (_local1.pos.x - (signx * _local1.xw))); var oy = ((_local2.pos.y - (sy * r)) - (_local1.pos.y + (_local3 * _local1.yw))); var dp = ((ox * sx) + (oy * sy)); if (dp < 0) { sx = sx * (-dp); sy = sy * (-dp); var lenN = Math.sqrt((sx * sx) + (sy * sy)); if (x < y) { lenP = x; y = 0; if ((_local2.pos.x - _local1.pos.x) < 0) { x = x * -1; } } else { lenP = y; x = 0; if ((_local2.pos.y - _local1.pos.y) < 0) { y = y * -1; } } if (lenP < lenN) { _local2.ReportCollisionVsWorld(x, y, x / lenP, y / lenP, _local1); return(COL_AXIS); } _local2.ReportCollisionVsWorld(sx, sy, _local1.sx, _local1.sy, _local1); return(COL_OTHER); } } else { if ((_local3 * oV) < 0) { _local2.ReportCollisionVsWorld(0, y * oV, 0, oV, _local1); return(COL_AXIS); } var sx = _local1.sx; var sy = _local1.sy; var ox = (_local2.pos.x - (_local1.pos.x - (signx * _local1.xw))); var oy = (_local2.pos.y - (_local1.pos.y + (_local3 * _local1.yw))); var perp = ((ox * (-sy)) + (oy * sx)); if (0 < ((perp * signx) * _local3)) { var len = Math.sqrt((ox * ox) + (oy * oy)); var pen = (_local2.r - len); if (0 < pen) { ox = ox / len; oy = oy / len; _local2.ReportCollisionVsWorld(ox * pen, oy * pen, ox, oy, _local1); return(COL_OTHER); } } else { var dp = ((ox * sx) + (oy * sy)); var pen = (_local2.r - Math.abs(dp)); if (0 < pen) { _local2.ReportCollisionVsWorld(sx * pen, sy * pen, sx, sy, _local1); return(COL_OTHER); } } } } else if (oV == 0) { if ((signx * oH) < 0) { _local2.ReportCollisionVsWorld(x * oH, 0, oH, 0, _local1); return(COL_AXIS); } var ox = (_local2.pos.x - (_local1.pos.x + (signx * _local1.xw))); var oy = (_local2.pos.y - _local1.pos.y); if ((oy * _local3) < 0) { _local2.ReportCollisionVsWorld(x * oH, 0, oH, 0, _local1); return(COL_AXIS); } var sx = _local1.sx; var sy = _local1.sy; var perp = ((ox * (-sy)) + (oy * sx)); if (((perp * signx) * _local3) < 0) { var len = Math.sqrt((ox * ox) + (oy * oy)); var pen = (_local2.r - len); if (0 < pen) { ox = ox / len; oy = oy / len; _local2.ReportCollisionVsWorld(ox * pen, oy * pen, ox, oy, _local1); return(COL_OTHER); } } else { var dp = ((ox * sx) + (oy * sy)); var pen = (_local2.r - Math.abs(dp)); if (0 < pen) { _local2.ReportCollisionVsWorld(sx * pen, sy * pen, _local1.sx, _local1.sy, _local1); return(COL_OTHER); } } } else { if (0 < ((signx * oH) + (_local3 * oV))) { var slen = 2.23606797749979; var sx = ((signx * 1) / slen); var sy = ((_local3 * 2) / slen); var r = _local2.r; var ox = ((_local2.pos.x - (sx * r)) - (_local1.pos.x - (signx * _local1.xw))); var oy = ((_local2.pos.y - (sy * r)) - (_local1.pos.y + (_local3 * _local1.yw))); var dp = ((ox * sx) + (oy * sy)); if (dp < 0) { _local2.ReportCollisionVsWorld((-sx) * dp, (-sy) * dp, _local1.sx, _local1.sy, _local1); return(COL_OTHER); } return(COL_NONE); } var vx = (_local1.pos.x + (oH * _local1.xw)); var vy = (_local1.pos.y + (oV * _local1.yw)); var dx = (_local2.pos.x - vx); var dy = (_local2.pos.y - vy); var len = Math.sqrt((dx * dx) + (dy * dy)); var pen = (_local2.r - len); if (0 < pen) { if (len == 0) { dx = oH / Math.SQRT2; dy = oV / Math.SQRT2; } else { dx = dx / len; dy = dy / len; } _local2.ReportCollisionVsWorld(dx * pen, dy * pen, dx, dy, _local1); return(COL_OTHER); } } return(COL_NONE); } function ProjCircle_67DegS(x, y, oH, oV, obj, t) { var _local1 = t; var _local2 = obj; var signx = _local1.signx; var signy = _local1.signy; if (0 < (signx * oH)) { return(COL_NONE); } if (oH == 0) { if (oV == 0) { var sx = _local1.sx; var sy = _local1.sy; var r = _local2.r; var ox = (_local2.pos.x - _local1.pos.x); var _local3 = _local2.pos.y - (_local1.pos.y - (signy * _local1.yw)); var perp = ((ox * (-sy)) + (_local3 * sx)); if (((perp * signx) * signy) < 0) { var len = Math.sqrt((ox * ox) + (_local3 * _local3)); var pen = (r - len); if (0 < pen) { ox = ox / len; _local3 = _local3 / len; _local2.ReportCollisionVsWorld(ox * pen, _local3 * pen, ox, _local3, _local1); return(COL_OTHER); } } else { ox = ox - (r * sx); _local3 = _local3 - (r * sy); var dp = ((ox * sx) + (_local3 * sy)); if (dp < 0) { sx = sx * (-dp); sy = sy * (-dp); var lenN = Math.sqrt((sx * sx) + (sy * sy)); if (x < y) { lenP = x; y = 0; if ((_local2.pos.x - _local1.pos.x) < 0) { x = x * -1; } } else { lenP = y; x = 0; if ((_local2.pos.y - _local1.pos.y) < 0) { y = y * -1; } } if (lenP < lenN) { _local2.ReportCollisionVsWorld(x, y, x / lenP, y / lenP, _local1); return(COL_AXIS); } _local2.ReportCollisionVsWorld(sx, sy, _local1.sx, _local1.sy, _local1); return(COL_OTHER); } } } else if ((signy * oV) < 0) { var vx = _local1.pos.x; var vy = (_local1.pos.y - (signy * _local1.yw)); var dx = (_local2.pos.x - vx); var dy = (_local2.pos.y - vy); if ((dx * signx) < 0) { _local2.ReportCollisionVsWorld(0, y * oV, 0, oV, _local1); return(COL_AXIS); } var len = Math.sqrt((dx * dx) + (dy * dy)); var pen = (_local2.r - len); if (0 < pen) { if (len == 0) { dx = oH / Math.SQRT2; dy = oV / Math.SQRT2; } else { dx = dx / len; dy = dy / len; } _local2.ReportCollisionVsWorld(dx * pen, dy * pen, dx, dy, _local1); return(COL_OTHER); } } else { var sx = _local1.sx; var sy = _local1.sy; var ox = (_local2.pos.x - (_local1.pos.x - (signx * _local1.xw))); var _local3 = _local2.pos.y - (_local1.pos.y + (oV * _local1.yw)); var perp = ((ox * (-sy)) + (_local3 * sx)); if (0 < ((perp * signx) * signy)) { var len = Math.sqrt((ox * ox) + (_local3 * _local3)); var pen = (_local2.r - len); if (0 < pen) { ox = ox / len; _local3 = _local3 / len; _local2.ReportCollisionVsWorld(ox * pen, _local3 * pen, ox, _local3, _local1); return(COL_OTHER); } } else { var dp = ((ox * sx) + (_local3 * sy)); var pen = (_local2.r - Math.abs(dp)); if (0 < pen) { _local2.ReportCollisionVsWorld(sx * pen, sy * pen, _local1.sx, _local1.sy, _local1); return(COL_OTHER); } } } } else { if (oV == 0) { _local2.ReportCollisionVsWorld(x * oH, 0, oH, 0, _local1); return(COL_AXIS); } var vx = (_local1.pos.x + (oH * _local1.xw)); var vy = (_local1.pos.y + (oV * _local1.yw)); var dx = (_local2.pos.x - vx); var dy = (_local2.pos.y - vy); var len = Math.sqrt((dx * dx) + (dy * dy)); var pen = (_local2.r - len); if (0 < pen) { if (len == 0) { dx = oH / Math.SQRT2; dy = oV / Math.SQRT2; } else { dx = dx / len; dy = dy / len; } _local2.ReportCollisionVsWorld(dx * pen, dy * pen, dx, dy, _local1); return(COL_OTHER); } } return(COL_NONE); } function ProjCircle_67DegB(x, y, oH, oV, obj, t) { var _local1 = t; var _local2 = obj; var signx = _local1.signx; var _local3 = _local1.signy; if (oH == 0) { if (oV == 0) { var sx = _local1.sx; var sy = _local1.sy; var r = _local2.r; var ox = ((_local2.pos.x - (sx * r)) - (_local1.pos.x + (signx * _local1.xw))); var oy = ((_local2.pos.y - (sy * r)) - (_local1.pos.y - (_local3 * _local1.yw))); var dp = ((ox * sx) + (oy * sy)); if (dp < 0) { sx = sx * (-dp); sy = sy * (-dp); var lenN = Math.sqrt((sx * sx) + (sy * sy)); if (x < y) { lenP = x; y = 0; if ((_local2.pos.x - _local1.pos.x) < 0) { x = x * -1; } } else { lenP = y; x = 0; if ((_local2.pos.y - _local1.pos.y) < 0) { y = y * -1; } } if (lenP < lenN) { _local2.ReportCollisionVsWorld(x, y, x / lenP, y / lenP, _local1); return(COL_AXIS); } _local2.ReportCollisionVsWorld(sx, sy, _local1.sx, _local1.sy, _local1); return(COL_OTHER); } } else { if ((_local3 * oV) < 0) { _local2.ReportCollisionVsWorld(0, y * oV, 0, oV, _local1); return(COL_AXIS); } var ox = (_local2.pos.x - _local1.pos.x); var oy = (_local2.pos.y - (_local1.pos.y + (_local3 * _local1.yw))); if ((ox * signx) < 0) { _local2.ReportCollisionVsWorld(0, y * oV, 0, oV, _local1); return(COL_AXIS); } var sx = _local1.sx; var sy = _local1.sy; var perp = ((ox * (-sy)) + (oy * sx)); if (0 < ((perp * signx) * _local3)) { var len = Math.sqrt((ox * ox) + (oy * oy)); var pen = (_local2.r - len); if (0 < pen) { ox = ox / len; oy = oy / len; _local2.ReportCollisionVsWorld(ox * pen, oy * pen, ox, oy, _local1); return(COL_OTHER); } } else { var dp = ((ox * sx) + (oy * sy)); var pen = (_local2.r - Math.abs(dp)); if (0 < pen) { _local2.ReportCollisionVsWorld(sx * pen, sy * pen, sx, sy, _local1); return(COL_OTHER); } } } } else if (oV == 0) { if ((signx * oH) < 0) { _local2.ReportCollisionVsWorld(x * oH, 0, oH, 0, _local1); return(COL_AXIS); } var slen = 2.23606797749979; var sx = ((signx * 2) / slen); var sy = ((_local3 * 1) / slen); var ox = (_local2.pos.x - (_local1.pos.x + (signx * _local1.xw))); var oy = (_local2.pos.y - (_local1.pos.y - (_local3 * _local1.yw))); var perp = ((ox * (-sy)) + (oy * sx)); if (((perp * signx) * _local3) < 0) { var len = Math.sqrt((ox * ox) + (oy * oy)); var pen = (_local2.r - len); if (0 < pen) { ox = ox / len; oy = oy / len; _local2.ReportCollisionVsWorld(ox * pen, oy * pen, ox, oy, _local1); return(COL_OTHER); } } else { var dp = ((ox * sx) + (oy * sy)); var pen = (_local2.r - Math.abs(dp)); if (0 < pen) { _local2.ReportCollisionVsWorld(sx * pen, sy * pen, _local1.sx, _local1.sy, _local1); return(COL_OTHER); } } } else { if (0 < ((signx * oH) + (_local3 * oV))) { var sx = _local1.sx; var sy = _local1.sy; var r = _local2.r; var ox = ((_local2.pos.x - (sx * r)) - (_local1.pos.x + (signx * _local1.xw))); var oy = ((_local2.pos.y - (sy * r)) - (_local1.pos.y - (_local3 * _local1.yw))); var dp = ((ox * sx) + (oy * sy)); if (dp < 0) { _local2.ReportCollisionVsWorld((-sx) * dp, (-sy) * dp, _local1.sx, _local1.sy, _local1); return(COL_OTHER); } return(COL_NONE); } var vx = (_local1.pos.x + (oH * _local1.xw)); var vy = (_local1.pos.y + (oV * _local1.yw)); var dx = (_local2.pos.x - vx); var dy = (_local2.pos.y - vy); var len = Math.sqrt((dx * dx) + (dy * dy)); var pen = (_local2.r - len); if (0 < pen) { if (len == 0) { dx = oH / Math.SQRT2; dy = oV / Math.SQRT2; } else { dx = dx / len; dy = dy / len; } _local2.ReportCollisionVsWorld(dx * pen, dy * pen, dx, dy, _local1); return(COL_OTHER); } } return(COL_NONE); } function ResolveCircleTile(x, y, oH, oV, obj, t) { var _local1 = t; if (0 < _local1.ID) { return(Proj_CircleTile[_local1.CTYPE](x, y, oH, oV, obj, _local1)); } trace(((((("ResolveCircleTile() was called with an empty (or unknown) tile!: ID=" + _local1.ID) + " (") + _local1.i) + ",") + _local1.j) + ")"); return(false); } Proj_CircleTile = new Object(); Proj_CircleTile[CTYPE_FULL] = ProjCircle_Full; Proj_CircleTile[CTYPE_45DEG] = ProjCircle_45Deg; Proj_CircleTile[CTYPE_CONCAVE] = ProjCircle_Concave; Proj_CircleTile[CTYPE_CONVEX] = ProjCircle_Convex; Proj_CircleTile[CTYPE_22DEGs] = ProjCircle_22DegS; Proj_CircleTile[CTYPE_22DEGb] = ProjCircle_22DegB; Proj_CircleTile[CTYPE_67DEGs] = ProjCircle_67DegS; Proj_CircleTile[CTYPE_67DEGb] = ProjCircle_67DegB; Proj_CircleTile[CTYPE_HALF] = ProjCircle_Half; function ReportCollisionVsWorld(px, py, dx, dy, obj) { var _local1 = this.pos; var _local2 = this.oldpos; var vx = (_local1.x - _local2.x); var vy = (_local1.y - _local2.y); var _local3 = (vx * dx) + (vy * dy); var nx = (_local3 * dx); var ny = (_local3 * dy); var tx = (vx - nx); var ty = (vy - ny); var b; var bx; var by; var f; var fx; var fy; if (_local3 < 0) { f = FRICTION; fx = tx * f; fy = ty * f; b = 1 + BOUNCE; bx = nx * b; by = ny * b; } else { bx = (by = (fx = (fy = 0))); } _local1.x = _local1.x + px; _local1.y = _local1.y + py; _local2.x = _local2.x + ((px + bx) + fx); _local2.y = _local2.y + ((py + by) + fy); } function IntegrateVerlet() { var _local1 = DRAG; var _local2 = GRAV; p = this.pos; o = this.oldpos; ox = o.x; oy = o.y; o.x = (px = p.x); o.y = (py = p.y); p.x = p.x + ((_local1 * px) - (_local1 * ox)); p.y = p.y + (((_local1 * py) - (_local1 * oy)) + _local2); } function CollideCircleVsWorldBounds() { var p = this.pos; var _local3 = this.r; var _local2 = XMIN - (p.x - _local3); if (0 < _local2) { this.ReportCollisionVsWorld(_local2, 0, 1, 0, null); } else { _local2 = (p.x + _local3) - XMAX; if (0 < _local2) { this.ReportCollisionVsWorld(-_local2, 0, -1, 0, null); } } var _local1 = YMIN - (p.y - _local3); if (0 < _local1) { this.ReportCollisionVsWorld(0, _local1, 0, 1, null); } else { _local1 = (p.y + _local3) - YMAX; if (0 < _local1) { this.ReportCollisionVsWorld(0, -_local1, 0, -1, null); } } } function CollideAABBVsWorldBounds() { var _local3 = this; var p = _local3.pos; var xw = _local3.xw; var yw = _local3.yw; var _local2 = XMIN - (p.x - xw); if (0 < _local2) { _local3.ReportCollisionVsWorld(_local2, 0, 1, 0, null); } else { _local2 = (p.x + xw) - XMAX; if (0 < _local2) { _local3.ReportCollisionVsWorld(-_local2, 0, -1, 0, null); } } var _local1 = YMIN - (p.y - yw); if (0 < _local1) { _local3.ReportCollisionVsWorld(0, _local1, 0, 1, null); } else { _local1 = (p.y + yw) - YMAX; if (0 < _local1) { _local3.ReportCollisionVsWorld(0, -_local1, 0, -1, null); } } } function AABB(pos, xw, yw) { var _local1 = this; _local1.OTYPE = OTYPE_AABB; _local1.pos = pos.clone(); _local1.oldpos = _local1.pos.clone(); _local1.xw = Math.abs(xw); _local1.yw = Math.abs(yw); } function Circle(pos, r) { var _local1 = this; _local1.OTYPE = OTYPE_CIRCLE; _local1.pos = pos.clone(); _local1.oldpos = _local1.pos.clone(); _local1.r = Math.abs(r); } OTYPE_AABB = 0; OTYPE_CIRCLE = 1; AABB.prototype.Draw = function (rend) { var _local1 = this; rend.DrawAABB(_local1.pos, _local1.xw, _local1.yw); }; AABB.prototype.Verlet = IntegrateVerlet; AABB.prototype.ReportCollisionVsWorld = ReportCollisionVsWorld; AABB.prototype.CollideVsWorldBounds = CollideAABBVsWorldBounds; AABB.prototype.CollideVsTile = CollideAABBVsTile; Circle.prototype.Draw = function (rend) { rend.DrawCircle(this.pos, this.r); }; Circle.prototype.Verlet = IntegrateVerlet; Circle.prototype.ReportCollisionVsWorld = ReportCollisionVsWorld; Circle.prototype.CollideVsWorldBounds = CollideCircleVsWorldBounds; Circle.prototype.CollideVsTile = CollideCircleVsTile; function GDragged() { _root.pointG.pos.x = this._x; _root.pointG.pos.y = this._y; GRefresh(pointG.pos); } function GRefresh(pos) { var _local1 = (pos.x - slider_min) / (slider_max - slider_min); GRAV = _local1 * MAX_G; } function BDragged() { _root.pointB.pos.x = this._x; _root.pointB.pos.y = this._y; BRefresh(pointB.pos); } function BRefresh(pos) { var _local1 = (pos.x - slider_min) / (slider_max - slider_min); BOUNCE = _local1 * MAX_B; } function FDragged() { _root.pointF.pos.x = this._x; _root.pointF.pos.y = this._y; FRefresh(pointF.pos); } function FRefresh(pos) { var _local1 = (pos.x - slider_min) / (slider_max - slider_min); _local1 = _local1 * _local1; _local1 = _local1 * _local1; _local1 = _local1 * _local1; FRICTION = _local1 * MAX_F; } function ToggleObjShape() { var _local1 = demoObj.pos; var _local2 = demoObj.oldpos; if (demoObj.OTYPE == OTYPE_CIRCLE) { demoObj = new AABB(new Vector2(_local1.x, _local1.y), OBJRAD * 0.75, OBJRAD * 1.25); } else { demoObj = new Circle(new Vector2(_local1.x, _local1.y), OBJRAD); } demoObj.oldpos.x = _local2.x; demoObj.oldpos.y = _local2.y; } function ToggleTileShape() { curTileShape = (curTileShape + 1) % tileShapeList.length; demoTile.SetState(tileShapeList[curTileShape]); } gfx = new NinjaGraphicsSystem(); debug_rend = new VectorRenderer(); input = new InputManager(); static_rend = new VectorRenderer(); GRAV = 0.2; DRAG = 0.999999; BOUNCE = 0.3; FRICTION = 0.05; MIN_F = 0; MAX_F = 1; MIN_B = 0; MAX_B = 0.99; MIN_G = 0; MAX_G = 1; XMIN = 0; XMAX = 400; YMIN = 0; YMAX = 400; OBJRAD = 24; TILERAD = OBJRAD * 2; OBJSPEED = 0.2; MAXSPEED = 20; static_rend.SetStyle(0, 0, 100); static_rend.DrawAABB_S(XMIN, XMAX - 1, YMIN, YMAX); demoTile = new TileMapCell(0.5 * (XMAX + XMIN), 0.5 * (YMAX + YMIN), TILERAD, TILERAD); demoTile.SetState(TID_FULL); demoObj = new Circle(new Vector2(0.5 * (XMIN + XMAX), YMAX - (3 * OBJRAD)), OBJRAD); slider_min = 200; slider_max = 350; pointG = new Point((GRAV * 150) + 200, 420, "gravity", 2263074, true, GDragged, slider_min, 420, slider_max, 420); pointB = new Point((BOUNCE * 150) + 200, 440, "bounce", 2237064, true, BDragged, slider_min, 440, slider_max, 440); pointF = new Point(290, 460, "friction", 8921634, true, FDragged, slider_min, 460, slider_max, 460); BRefresh(pointB.pos); GRefresh(pointG.pos); FRefresh(pointF.pos); static_rend.SetStyle(0, 2263074, 100); static_rend.DrawLine_S(slider_min, 420, slider_max, 420); static_rend.SetStyle(0, 2237064, 100); static_rend.DrawLine_S(slider_min, 440, slider_max, 440); static_rend.SetStyle(0, 8921634, 100); static_rend.DrawLine_S(slider_min, 460, slider_max, 460); curTileShape = 0; tileShapeList = new Array(); tileShapeList.push(TID_FULL); tileShapeList.push(TID_45DEGpn); tileShapeList.push(TID_CONCAVEnn); tileShapeList.push(TID_CONVEXpn); tileShapeList.push(TID_22DEGnnS); tileShapeList.push(TID_22DEGpnB); tileShapeList.push(TID_67DEGnnS); tileShapeList.push(TID_67DEGpnB); tileShapeList.push(TID_HALFl); function TickDemo() { input.Update(); debug_rend.Clear(); var _local1 = input.getMousePos(); var d = input.getMouseDelta(); if (Key.isDown(16)) { demoTile.pos.x = Math.min(XMAX - TILERAD, Math.max(XMIN + TILERAD, _local1.x)); demoTile.pos.y = Math.min(YMAX - TILERAD, Math.max(YMIN + TILERAD, _local1.y)); demoTile.mc._x = demoTile.pos.x; demoTile.mc._y = demoTile.pos.y; } else { demoObj.Verlet(); if (input.MouseDown()) { if (_local1.y < YMAX) { var dragScale = 0.1; demoObj.pos.x = demoObj.pos.x + (d.x * dragScale); demoObj.pos.y = demoObj.pos.y + (d.y * dragScale); } } else if (Key.isDown(32)) { demoObj.pos.x = _local1.x; demoObj.pos.y = _local1.y; } else { var fx = 0; var fy = 0; if (Key.isDown(37)) { fx = fx - OBJSPEED; } if (Key.isDown(39)) { fx = fx + OBJSPEED; } if (Key.isDown(38)) { fy = fy - (OBJSPEED + GRAV); } if (Key.isDown(40)) { fy = fy + OBJSPEED; } var _local2 = demoObj.pos; var _local3 = demoObj.oldpos; var vx = (_local2.x - _local3.x); var vy = (_local2.y - _local3.y); var newx = Math.min(MAXSPEED, Math.max(-MAXSPEED, vx + fx)); var newy = Math.min(MAXSPEED, Math.max(-MAXSPEED, vy + fy)); _local2.x = _local3.x + newx; _local2.y = _local3.y + newy; } demoObj.CollideVsTile(demoTile); demoObj.CollideVsWorldBounds(); } debug_rend.SetStyle(0, 7960968, 100); debug_rend.buffer.beginFill(13290192, 100); demoObj.Draw(debug_rend); debug_rend.buffer.endFill(); } _root.onEnterFrame = TickDemo;
Instance of Symbol 40 MovieClip in Frame 1
on (rollOver) { this.gotoAndStop(2); } on (rollOut) { this.gotoAndStop(1); } on (release) { _root.ToggleObjShape(); }
Instance of Symbol 40 MovieClip in Frame 1
on (rollOver) { this.gotoAndStop(2); } on (rollOut) { this.gotoAndStop(1); } on (release) { _root.ToggleTileShape(); }
Symbol 40 MovieClip Frame 1
this.stop();
Symbol 40 MovieClip Frame 2
this.stop();

Library Items

Symbol 1 FontUsed by:2 41 42 43 44
Symbol 2 EditableTextUses:1Used by:3
Symbol 3 MovieClip [titleMC]Uses:2
Symbol 4 GraphicUsed by:5
Symbol 5 MovieClipUses:4Used by:6
Symbol 6 MovieClip [pointMC]Uses:5
Symbol 7 GraphicUsed by:37
Symbol 8 GraphicUsed by:37
Symbol 9 GraphicUsed by:37
Symbol 10 GraphicUsed by:37
Symbol 11 GraphicUsed by:37
Symbol 12 GraphicUsed by:37
Symbol 13 GraphicUsed by:37
Symbol 14 GraphicUsed by:37
Symbol 15 GraphicUsed by:37
Symbol 16 GraphicUsed by:37
Symbol 17 GraphicUsed by:37
Symbol 18 GraphicUsed by:37
Symbol 19 GraphicUsed by:37
Symbol 20 GraphicUsed by:37
Symbol 21 GraphicUsed by:37
Symbol 22 GraphicUsed by:37
Symbol 23 GraphicUsed by:37
Symbol 24 GraphicUsed by:37
Symbol 25 GraphicUsed by:37
Symbol 26 GraphicUsed by:37
Symbol 27 GraphicUsed by:37
Symbol 28 GraphicUsed by:37
Symbol 29 GraphicUsed by:37
Symbol 30 GraphicUsed by:37
Symbol 31 GraphicUsed by:37
Symbol 32 GraphicUsed by:37
Symbol 33 GraphicUsed by:37
Symbol 34 GraphicUsed by:37
Symbol 35 GraphicUsed by:37
Symbol 36 GraphicUsed by:37
Symbol 37 MovieClip [tileMC]Uses:7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
Symbol 38 GraphicUsed by:40
Symbol 39 GraphicUsed by:40
Symbol 40 MovieClipUses:38 39Used by:Timeline
Symbol 41 TextUses:1Used by:Timeline
Symbol 42 TextUses:1Used by:Timeline
Symbol 43 TextUses:1Used by:Timeline
Symbol 44 TextUses:1Used by:Timeline

Instance Names

"gfx"Symbol 6 MovieClip [pointMC] Frame 1Symbol 5 MovieClip

Special Tags

ExportAssets (56)Timeline Frame 1Symbol 3 as "titleMC"
ExportAssets (56)Timeline Frame 1Symbol 6 as "pointMC"
ExportAssets (56)Timeline Frame 1Symbol 37 as "tileMC"

Dynamic Text Variables

txtSymbol 2 EditableText"p0"




http://swfchan.com/9/41741/info.shtml
Created: 10/5 -2019 05:52:12 Last modified: 10/5 -2019 05:52:12 Server time: 30/12 -2024 16:05:52