Merged N+ physics in and tidied up the Docs folder and logos.

This commit is contained in:
Richard Davey
2013-08-11 12:15:53 +01:00
parent aff7d99a8a
commit c2d7fb7fab
108 changed files with 17900 additions and 2017 deletions
+56
View File
@@ -0,0 +1,56 @@
var Phaser;
(function (Phaser) {
(function (Physics) {
/// <reference path="../../_definitions.ts" />
/**
* Phaser - Physics - Projection
*/
(function (Projection) {
var AABBConcave = (function () {
function AABBConcave() {
}
AABBConcave.Collide = function (x, y, obj, t) {
//if distance from "innermost" corner of AABB is further than tile radius,
//collision is occuring and we need to project
var signx = t.signx;
var signy = t.signy;
var ox = (t.pos.x + (signx * t.xw)) - (obj.pos.x - (signx * obj.xw));
var oy = (t.pos.y + (signy * t.yw)) - (obj.pos.y - (signy * obj.yw));
var twid = t.xw * 2;
var rad = Math.sqrt(twid * twid + 0);
//note that this should be precomputed at compile-time since it's constant
var len = Math.sqrt(ox * ox + oy * oy);
var pen = len - rad;
if (0 < pen) {
//collision; we need to either project along the axes, or project along corner->circlecenter vector
var lenP = Math.sqrt(x * x + y * y);
if (lenP < pen) {
//it's shorter to move along axis directions
obj.ReportCollisionVsWorld(x, y, x / lenP, y / lenP, t);
return Phaser.Physics.AABB.COL_AXIS;
} else {
//project along corner->circle vector
ox /= len;
oy /= len;
obj.ReportCollisionVsWorld(ox * pen, oy * pen, ox, oy, t);
return Phaser.Physics.AABB.COL_OTHER;
}
}
return Phaser.Physics.AABB.COL_NONE;
};
return AABBConcave;
})();
Projection.AABBConcave = AABBConcave;
})(Physics.Projection || (Physics.Projection = {}));
var Projection = Physics.Projection;
})(Phaser.Physics || (Phaser.Physics = {}));
var Physics = Phaser.Physics;
})(Phaser || (Phaser = {}));
+60
View File
@@ -0,0 +1,60 @@
/// <reference path="../../_definitions.ts" />
/**
* Phaser - Physics - Projection
*/
module Phaser.Physics.Projection {
export class AABBConcave {
public static Collide(x: number, y: number, obj: Phaser.Physics.AABB, t: Phaser.Physics.TileMapCell) {
//if distance from "innermost" corner of AABB is further than tile radius,
//collision is occuring and we need to project
var signx = t.signx;
var signy = t.signy;
var ox = (t.pos.x + (signx * t.xw)) - (obj.pos.x - (signx * obj.xw));//(ox,oy) is the vector form the innermost AABB corner to the
var oy = (t.pos.y + (signy * t.yw)) - (obj.pos.y - (signy * obj.yw));//circle's center
var twid = t.xw * 2;
var rad = Math.sqrt(twid * twid + 0);//this gives us the radius of a circle centered on the tile's corner and extending to the opposite edge of the tile;
//note that this should be precomputed at compile-time since it's constant
var len = Math.sqrt(ox * ox + oy * oy);
var pen = len - rad;
if (0 < pen)
{
//collision; we need to either project along the axes, or project along corner->circlecenter vector
var lenP = Math.sqrt(x * x + y * y);
if (lenP < pen)
{
//it's shorter to move along axis directions
obj.ReportCollisionVsWorld(x, y, x / lenP, y / lenP, t);
return Phaser.Physics.AABB.COL_AXIS;
}
else
{
//project along corner->circle vector
ox /= len;//len should never be 0, since if it IS 0, rad should be > than len
oy /= len;//and we should never reach here
obj.ReportCollisionVsWorld(ox * pen, oy * pen, ox, oy, t);
return Phaser.Physics.AABB.COL_OTHER;
}
}
return Phaser.Physics.AABB.COL_NONE;
}
}
}
+51
View File
@@ -0,0 +1,51 @@
var Phaser;
(function (Phaser) {
(function (Physics) {
/// <reference path="../../_definitions.ts" />
/**
* Phaser - Physics - Projection
*/
(function (Projection) {
var AABBConvex = (function () {
function AABBConvex() {
}
AABBConvex.Collide = function (x, y, obj, t) {
//if distance from "innermost" corner of AABB is less than than tile radius,
//collision is occuring and we need to project
var signx = t.signx;
var signy = t.signy;
var ox = (obj.pos.x - (signx * obj.xw)) - (t.pos.x - (signx * t.xw));
var oy = (obj.pos.y - (signy * obj.yw)) - (t.pos.y - (signy * t.yw));
var len = Math.sqrt(ox * ox + oy * oy);
var twid = t.xw * 2;
var rad = Math.sqrt(twid * twid + 0);
//note that this should be precomputed at compile-time since it's constant
var pen = rad - len;
if (((signx * ox) < 0) || ((signy * oy) < 0)) {
//the test corner is "outside" the 1/4 of the circle we're interested in
var lenP = Math.sqrt(x * x + y * y);
obj.ReportCollisionVsWorld(x, y, x / lenP, y / lenP, t);
return Phaser.Physics.AABB.COL_AXIS;
} else if (0 < pen) {
//project along corner->circle vector
ox /= len;
oy /= len;
obj.ReportCollisionVsWorld(ox * pen, oy * pen, ox, oy, t);
return Phaser.Physics.AABB.COL_OTHER;
}
return Phaser.Physics.AABB.COL_NONE;
};
return AABBConvex;
})();
Projection.AABBConvex = AABBConvex;
})(Physics.Projection || (Physics.Projection = {}));
var Projection = Physics.Projection;
})(Phaser.Physics || (Phaser.Physics = {}));
var Physics = Phaser.Physics;
})(Phaser || (Phaser = {}));
+50
View File
@@ -0,0 +1,50 @@
/// <reference path="../../_definitions.ts" />
/**
* Phaser - Physics - Projection
*/
module Phaser.Physics.Projection {
export class AABBConvex {
public static Collide(x: number, y: number, obj: Phaser.Physics.AABB, t: Phaser.Physics.TileMapCell) {
//if distance from "innermost" corner of AABB is less than than tile radius,
//collision is occuring and we need to project
var signx = t.signx;
var signy = t.signy;
var ox = (obj.pos.x - (signx * obj.xw)) - (t.pos.x - (signx * t.xw));//(ox,oy) is the vector from the circle center to
var oy = (obj.pos.y - (signy * obj.yw)) - (t.pos.y - (signy * t.yw));//the AABB
var len = Math.sqrt(ox * ox + oy * oy);
var twid = t.xw * 2;
var rad = Math.sqrt(twid * twid + 0);//this gives us the radius of a circle centered on the tile's corner and extending to the opposite edge of the tile;
//note that this should be precomputed at compile-time since it's constant
var pen = rad - len;
if (((signx * ox) < 0) || ((signy * oy) < 0))
{
//the test corner is "outside" the 1/4 of the circle we're interested in
var lenP = Math.sqrt(x * x + y * y);
obj.ReportCollisionVsWorld(x, y, x / lenP, y / lenP, t);
return Phaser.Physics.AABB.COL_AXIS;//we need to report
}
else if (0 < pen)
{
//project along corner->circle vector
ox /= len;
oy /= len;
obj.ReportCollisionVsWorld(ox * pen, oy * pen, ox, oy, t);
return Phaser.Physics.AABB.COL_OTHER;
}
return Phaser.Physics.AABB.COL_NONE;
}
}
}
+26
View File
@@ -0,0 +1,26 @@
var Phaser;
(function (Phaser) {
(function (Physics) {
/// <reference path="../../_definitions.ts" />
/**
* Phaser - Physics - Projection
*/
(function (Projection) {
var AABBFull = (function () {
function AABBFull() {
}
AABBFull.Collide = function (x, y, obj, t) {
var l = Math.sqrt(x * x + y * y);
obj.ReportCollisionVsWorld(x, y, x / l, y / l, t);
return Phaser.Physics.AABB.COL_AXIS;
};
return AABBFull;
})();
Projection.AABBFull = AABBFull;
})(Physics.Projection || (Physics.Projection = {}));
var Projection = Physics.Projection;
})(Phaser.Physics || (Phaser.Physics = {}));
var Physics = Phaser.Physics;
})(Phaser || (Phaser = {}));
+23
View File
@@ -0,0 +1,23 @@
/// <reference path="../../_definitions.ts" />
/**
* Phaser - Physics - Projection
*/
module Phaser.Physics.Projection {
export class AABBFull {
public static Collide(x: number, y: number, obj: Phaser.Physics.AABB, t: Phaser.Physics.TileMapCell) {
var l = Math.sqrt(x * x + y * y);
obj.ReportCollisionVsWorld(x, y, x / l, y / l, t);
return Phaser.Physics.AABB.COL_AXIS;
}
}
}