Skip to content

Commit 7aa82a1

Browse files
committed
All physics projections added.
1 parent c2d7fb7 commit 7aa82a1

36 files changed

Lines changed: 5791 additions & 854 deletions

Phaser/Phaser.csproj

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,18 @@
9494
<TypeScriptCompile Include="physics\aabb\ProjAABBFull.ts" />
9595
<TypeScriptCompile Include="physics\aabb\ProjAABBConvex.ts" />
9696
<TypeScriptCompile Include="physics\aabb\ProjAABBConcave.ts" />
97+
<TypeScriptCompile Include="physics\aabb\ProjAABB45Deg.ts" />
98+
<TypeScriptCompile Include="physics\aabb\ProjAABB22Deg.ts" />
99+
<Content Include="physics\aabb\ProjAABB22Deg.js">
100+
<DependentUpon>ProjAABB22Deg.ts</DependentUpon>
101+
</Content>
102+
<Content Include="physics\aabb\ProjAABB45Deg.js">
103+
<DependentUpon>ProjAABB45Deg.ts</DependentUpon>
104+
</Content>
105+
<TypeScriptCompile Include="physics\aabb\ProjAABB67Deg.ts" />
106+
<Content Include="physics\aabb\ProjAABB67Deg.js">
107+
<DependentUpon>ProjAABB67Deg.ts</DependentUpon>
108+
</Content>
97109
<Content Include="physics\aabb\ProjAABBConcave.js">
98110
<DependentUpon>ProjAABBConcave.ts</DependentUpon>
99111
</Content>
@@ -104,6 +116,10 @@
104116
<DependentUpon>ProjAABBFull.ts</DependentUpon>
105117
</Content>
106118
<TypeScriptCompile Include="physics\Body.ts" />
119+
<TypeScriptCompile Include="physics\aabb\ProjAABBHalf.ts" />
120+
<Content Include="physics\aabb\ProjAABBHalf.js">
121+
<DependentUpon>ProjAABBHalf.ts</DependentUpon>
122+
</Content>
107123
<Content Include="physics\Body.js">
108124
<DependentUpon>Body.ts</DependentUpon>
109125
</Content>
@@ -112,10 +128,18 @@
112128
</Content>
113129
<TypeScriptCompile Include="physics\circle\ProjCircleFull.ts" />
114130
<TypeScriptCompile Include="physics\circle\ProjCircle45Deg.ts" />
131+
<TypeScriptCompile Include="physics\circle\ProjCircle22Deg.ts" />
132+
<Content Include="physics\circle\ProjCircle22Deg.js">
133+
<DependentUpon>ProjCircle22Deg.ts</DependentUpon>
134+
</Content>
115135
<Content Include="physics\circle\ProjCircle45Deg.js">
116136
<DependentUpon>ProjCircle45Deg.ts</DependentUpon>
117137
</Content>
118138
<TypeScriptCompile Include="physics\circle\ProjCircleConcave.ts" />
139+
<TypeScriptCompile Include="physics\circle\ProjCircle67Deg.ts" />
140+
<Content Include="physics\circle\ProjCircle67Deg.js">
141+
<DependentUpon>ProjCircle67Deg.ts</DependentUpon>
142+
</Content>
119143
<Content Include="physics\circle\ProjCircleConcave.js">
120144
<DependentUpon>ProjCircleConcave.ts</DependentUpon>
121145
</Content>
@@ -126,6 +150,10 @@
126150
<Content Include="physics\circle\ProjCircleFull.js">
127151
<DependentUpon>ProjCircleFull.ts</DependentUpon>
128152
</Content>
153+
<TypeScriptCompile Include="physics\circle\ProjCircleHalf.ts" />
154+
<Content Include="physics\circle\ProjCircleHalf.js">
155+
<DependentUpon>ProjCircleHalf.ts</DependentUpon>
156+
</Content>
129157
<Content Include="physics\PhysicsManager.js">
130158
<DependentUpon>PhysicsManager.ts</DependentUpon>
131159
</Content>

Phaser/_definitions.ts

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -114,13 +114,22 @@
114114
/// <reference path="physics/AABB.ts" />
115115
/// <reference path="physics/Circle.ts" />
116116
/// <reference path="physics/TileMapCell.ts" />
117-
/// <reference path="physics/aabb/ProjAABBFull.ts" />
118-
/// <reference path="physics/aabb/ProjAABBConvex.ts" />
117+
118+
/// <reference path="physics/aabb/ProjAABB22Deg.ts" />
119+
/// <reference path="physics/aabb/ProjAABB45Deg.ts" />
120+
/// <reference path="physics/aabb/ProjAABB67Deg.ts" />
119121
/// <reference path="physics/aabb/ProjAABBConcave.ts" />
120-
/// <reference path="physics/circle/ProjCircleFull.ts" />
121-
/// <reference path="physics/circle/ProjCircleConvex.ts" />
122-
/// <reference path="physics/circle/ProjCircleConcave.ts" />
122+
/// <reference path="physics/aabb/ProjAABBConvex.ts" />
123+
/// <reference path="physics/aabb/ProjAABBFull.ts" />
124+
/// <reference path="physics/aabb/ProjAABBHalf.ts" />
125+
126+
/// <reference path="physics/circle/ProjCircle22Deg.ts" />
123127
/// <reference path="physics/circle/ProjCircle45Deg.ts" />
128+
/// <reference path="physics/circle/ProjCircle67Deg.ts" />
129+
/// <reference path="physics/circle/ProjCircleConcave.ts" />
130+
/// <reference path="physics/circle/ProjCircleConvex.ts" />
131+
/// <reference path="physics/circle/ProjCircleFull.ts" />
132+
/// <reference path="physics/circle/ProjCircleHalf.ts" />
124133

125134
/// <reference path="particles/ParticleManager.ts" />
126135
/// <reference path="particles/Particle.ts" />

Phaser/physics/AABB.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ var Phaser;
2121
this.aabbTileProjections[Phaser.Physics.TileMapCell.CTYPE_CONCAVE] = Phaser.Physics.Projection.AABBConcave.Collide;
2222
this.aabbTileProjections[Phaser.Physics.TileMapCell.CTYPE_CONVEX] = Phaser.Physics.Projection.AABBConvex.Collide;
2323
}
24-
AABB.prototype.IntegrateVerlet = function () {
24+
AABB.prototype.integrateVerlet = function () {
2525
var d = 1;
2626
var g = 0.2;
2727

@@ -41,7 +41,7 @@ var Phaser;
4141
p.y += (d * py) - (d * oy) + g;
4242
};
4343

44-
AABB.prototype.ReportCollisionVsWorld = function (px, py, dx, dy, obj) {
44+
AABB.prototype.reportCollisionVsWorld = function (px, py, dx, dy, obj) {
4545
var p = this.pos;
4646
var o = this.oldpos;
4747

@@ -84,7 +84,7 @@ var Phaser;
8484
o.y += py + by + fy;
8585
};
8686

87-
AABB.prototype.CollideAABBVsTile = function (tile) {
87+
AABB.prototype.collideAABBVsTile = function (tile) {
8888
var pos = this.pos;
8989
var c = tile;
9090

@@ -121,12 +121,12 @@ var Phaser;
121121
}
122122
}
123123

124-
this.ResolveBoxTile(px, py, this, c);
124+
this.resolveBoxTile(px, py, this, c);
125125
}
126126
}
127127
};
128128

129-
AABB.prototype.CollideAABBVsWorldBounds = function () {
129+
AABB.prototype.collideAABBVsWorldBounds = function () {
130130
var p = this.pos;
131131
var xw = this.xw;
132132
var yw = this.yw;
@@ -140,13 +140,13 @@ var Phaser;
140140
var dx = XMIN - (p.x - xw);
141141
if (0 < dx) {
142142
//object is colliding with XMIN
143-
this.ReportCollisionVsWorld(dx, 0, 1, 0, null);
143+
this.reportCollisionVsWorld(dx, 0, 1, 0, null);
144144
} else {
145145
//test XMAX
146146
dx = (p.x + xw) - XMAX;
147147
if (0 < dx) {
148148
//object is colliding with XMAX
149-
this.ReportCollisionVsWorld(-dx, 0, -1, 0, null);
149+
this.reportCollisionVsWorld(-dx, 0, -1, 0, null);
150150
}
151151
}
152152

@@ -155,13 +155,13 @@ var Phaser;
155155
var dy = YMIN - (p.y - yw);
156156
if (0 < dy) {
157157
//object is colliding with YMIN
158-
this.ReportCollisionVsWorld(0, dy, 0, 1, null);
158+
this.reportCollisionVsWorld(0, dy, 0, 1, null);
159159
} else {
160160
//test YMAX
161161
dy = (p.y + yw) - YMAX;
162162
if (0 < dy) {
163163
//object is colliding with YMAX
164-
this.ReportCollisionVsWorld(0, -dy, 0, -1, null);
164+
this.reportCollisionVsWorld(0, -dy, 0, -1, null);
165165
}
166166
}
167167
};
@@ -177,11 +177,11 @@ var Phaser;
177177
context.fillRect(this.pos.x, this.pos.y, 2, 2);
178178
};
179179

180-
AABB.prototype.ResolveBoxTile = function (x, y, box, t) {
180+
AABB.prototype.resolveBoxTile = function (x, y, box, t) {
181181
if (0 < t.ID) {
182182
return this.aabbTileProjections[t.CTYPE](x, y, box, t);
183183
} else {
184-
//trace("ResolveBoxTile() was called with an empty (or unknown) tile!: ID=" + t.ID + " ("+ t.i + "," + t.j + ")");
184+
//trace("resolveBoxTile() was called with an empty (or unknown) tile!: ID=" + t.ID + " ("+ t.i + "," + t.j + ")");
185185
return false;
186186
}
187187
};

Phaser/physics/AABB.ts

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,15 @@ module Phaser.Physics {
1919
this.yw = Math.abs(yw);
2020

2121
this.aabbTileProjections = {};
22-
this.aabbTileProjections[Phaser.Physics.TileMapCell.CTYPE_FULL] = Phaser.Physics.Projection.AABBFull.Collide;
22+
this.aabbTileProjections[Phaser.Physics.TileMapCell.CTYPE_22DEGs] = Phaser.Physics.Projection.AABB22Deg.CollideS;
23+
this.aabbTileProjections[Phaser.Physics.TileMapCell.CTYPE_22DEGb] = Phaser.Physics.Projection.AABB22Deg.CollideB;
24+
this.aabbTileProjections[Phaser.Physics.TileMapCell.CTYPE_45DEG] = Phaser.Physics.Projection.AABB45Deg.Collide;
25+
this.aabbTileProjections[Phaser.Physics.TileMapCell.CTYPE_67DEGs] = Phaser.Physics.Projection.AABB67Deg.CollideS;
26+
this.aabbTileProjections[Phaser.Physics.TileMapCell.CTYPE_67DEGb] = Phaser.Physics.Projection.AABB67Deg.CollideB;
2327
this.aabbTileProjections[Phaser.Physics.TileMapCell.CTYPE_CONCAVE] = Phaser.Physics.Projection.AABBConcave.Collide;
2428
this.aabbTileProjections[Phaser.Physics.TileMapCell.CTYPE_CONVEX] = Phaser.Physics.Projection.AABBConvex.Collide;
29+
this.aabbTileProjections[Phaser.Physics.TileMapCell.CTYPE_FULL] = Phaser.Physics.Projection.AABBFull.Collide;
30+
this.aabbTileProjections[Phaser.Physics.TileMapCell.CTYPE_HALF] = Phaser.Physics.Projection.AABBHalf.Collide;
2531

2632
}
2733

@@ -41,7 +47,7 @@ module Phaser.Physics {
4147

4248
private aabbTileProjections;
4349

44-
public IntegrateVerlet() {
50+
public integrateVerlet() {
4551

4652
var d = 1; // global drag
4753
var g = 0.2; // global gravity
@@ -63,7 +69,7 @@ module Phaser.Physics {
6369

6470
}
6571

66-
public ReportCollisionVsWorld(px: number, py: number, dx: number, dy: number, obj: TileMapCell) {
72+
public reportCollisionVsWorld(px: number, py: number, dx: number, dy: number, obj: TileMapCell = null) {
6773

6874
var p = this.pos;
6975
var o = this.oldpos;
@@ -113,7 +119,7 @@ module Phaser.Physics {
113119
}
114120

115121

116-
public CollideAABBVsTile(tile:Phaser.Physics.TileMapCell) {
122+
public collideAABBVsTile(tile:Phaser.Physics.TileMapCell) {
117123

118124
var pos = this.pos;
119125
var c = tile;
@@ -167,13 +173,13 @@ module Phaser.Physics {
167173
}
168174
}
169175

170-
this.ResolveBoxTile(px, py, this, c);
176+
this.resolveBoxTile(px, py, this, c);
171177

172178
}
173179
}
174180
}
175181

176-
public CollideAABBVsWorldBounds() {
182+
public collideAABBVsWorldBounds() {
177183

178184
var p = this.pos;
179185
var xw = this.xw;
@@ -189,7 +195,7 @@ module Phaser.Physics {
189195
if (0 < dx)
190196
{
191197
//object is colliding with XMIN
192-
this.ReportCollisionVsWorld(dx, 0, 1, 0, null);
198+
this.reportCollisionVsWorld(dx, 0, 1, 0, null);
193199
}
194200
else
195201
{
@@ -198,7 +204,7 @@ module Phaser.Physics {
198204
if (0 < dx)
199205
{
200206
//object is colliding with XMAX
201-
this.ReportCollisionVsWorld(-dx, 0, -1, 0, null);
207+
this.reportCollisionVsWorld(-dx, 0, -1, 0, null);
202208
}
203209
}
204210

@@ -208,7 +214,7 @@ module Phaser.Physics {
208214
if (0 < dy)
209215
{
210216
//object is colliding with YMIN
211-
this.ReportCollisionVsWorld(0, dy, 0, 1, null);
217+
this.reportCollisionVsWorld(0, dy, 0, 1, null);
212218
}
213219
else
214220
{
@@ -217,7 +223,7 @@ module Phaser.Physics {
217223
if (0 < dy)
218224
{
219225
//object is colliding with YMAX
220-
this.ReportCollisionVsWorld(0, -dy, 0, -1, null);
226+
this.reportCollisionVsWorld(0, -dy, 0, -1, null);
221227
}
222228
}
223229
}
@@ -235,15 +241,15 @@ module Phaser.Physics {
235241

236242
}
237243

238-
public ResolveBoxTile(x, y, box, t) {
244+
public resolveBoxTile(x, y, box, t) {
239245

240246
if (0 < t.ID)
241247
{
242248
return this.aabbTileProjections[t.CTYPE](x, y, box, t);
243249
}
244250
else
245251
{
246-
//trace("ResolveBoxTile() was called with an empty (or unknown) tile!: ID=" + t.ID + " ("+ t.i + "," + t.j + ")");
252+
//trace("resolveBoxTile() was called with an empty (or unknown) tile!: ID=" + t.ID + " ("+ t.i + "," + t.j + ")");
247253
return false;
248254
}
249255
}

Phaser/physics/Circle.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ var Phaser;
2020
this.circleTileProjections[Phaser.Physics.TileMapCell.CTYPE_CONCAVE] = Phaser.Physics.Projection.CircleConcave.Collide;
2121
this.circleTileProjections[Phaser.Physics.TileMapCell.CTYPE_CONVEX] = Phaser.Physics.Projection.CircleConvex.Collide;
2222
}
23-
Circle.prototype.IntegrateVerlet = function () {
23+
Circle.prototype.integrateVerlet = function () {
2424
var d = 1;
2525
var g = 0.2;
2626

@@ -41,7 +41,7 @@ var Phaser;
4141
p.y += (d * py) - (d * oy) + g;
4242
};
4343

44-
Circle.prototype.ReportCollisionVsWorld = function (px, py, dx, dy, obj) {
44+
Circle.prototype.reportCollisionVsWorld = function (px, py, dx, dy, obj) {
4545
var p = this.pos;
4646
var o = this.oldpos;
4747

@@ -84,7 +84,7 @@ var Phaser;
8484
o.y += py + by + fy;
8585
};
8686

87-
Circle.prototype.CollideCircleVsWorldBounds = function () {
87+
Circle.prototype.collideCircleVsWorldBounds = function () {
8888
var p = this.pos;
8989
var r = this.radius;
9090
var XMIN = 0;
@@ -98,13 +98,13 @@ var Phaser;
9898

9999
if (0 < dx) {
100100
//object is colliding with XMIN
101-
this.ReportCollisionVsWorld(dx, 0, 1, 0, null);
101+
this.reportCollisionVsWorld(dx, 0, 1, 0, null);
102102
} else {
103103
//test XMAX
104104
dx = (p.x + r) - XMAX;
105105
if (0 < dx) {
106106
//object is colliding with XMAX
107-
this.ReportCollisionVsWorld(-dx, 0, -1, 0, null);
107+
this.reportCollisionVsWorld(-dx, 0, -1, 0, null);
108108
}
109109
}
110110

@@ -114,13 +114,13 @@ var Phaser;
114114

115115
if (0 < dy) {
116116
//object is colliding with YMIN
117-
this.ReportCollisionVsWorld(0, dy, 0, 1, null);
117+
this.reportCollisionVsWorld(0, dy, 0, 1, null);
118118
} else {
119119
//test YMAX
120120
dy = (p.y + r) - YMAX;
121121
if (0 < dy) {
122122
//object is colliding with YMAX
123-
this.ReportCollisionVsWorld(0, -dy, 0, -1, null);
123+
this.reportCollisionVsWorld(0, -dy, 0, -1, null);
124124
}
125125
}
126126
};
@@ -165,7 +165,7 @@ var Phaser;
165165
}
166166
};
167167

168-
Circle.prototype.CollideCircleVsTile = function (tile) {
168+
Circle.prototype.collideCircleVsTile = function (tile) {
169169
var pos = this.pos;
170170
var r = this.radius;
171171
var c = tile;
@@ -203,16 +203,16 @@ var Phaser;
203203
this.oV = 1;
204204
}
205205

206-
this.ResolveCircleTile(px, py, this.oH, this.oV, this, c);
206+
this.resolveCircleTile(px, py, this.oH, this.oV, this, c);
207207
}
208208
}
209209
};
210210

211-
Circle.prototype.ResolveCircleTile = function (x, y, oH, oV, obj, t) {
211+
Circle.prototype.resolveCircleTile = function (x, y, oH, oV, obj, t) {
212212
if (0 < t.ID) {
213213
return this.circleTileProjections[t.CTYPE](x, y, oH, oV, obj, t);
214214
} else {
215-
console.log("ResolveCircleTile() was called with an empty (or unknown) tile!: ID=" + t.ID + " (" + t.i + "," + t.j + ")");
215+
console.log("resolveCircleTile() was called with an empty (or unknown) tile!: ID=" + t.ID + " (" + t.i + "," + t.j + ")");
216216
return false;
217217
}
218218
};

0 commit comments

Comments
 (0)