Skip to content

Commit 86fc07b

Browse files
committed
Masses of debugging fun and joy.
1 parent cc51508 commit 86fc07b

5 files changed

Lines changed: 66 additions & 4 deletions

File tree

v3/src/checksum.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
var CHECKSUM = {
2-
build: '9f8b8c60-575c-11e7-9988-39da119e4a13'
2+
build: 'db055440-5835-11e7-821c-f3e448a2ca69'
33
};
44
module.exports = CHECKSUM;

v3/src/physics/impact/Body.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,23 @@ var Body = new Class({
6565
this.vel.x = GetVelocity(delta, this.vel.x, this.accel.x, this.friction.x, this.maxVel.x);
6666
this.vel.y = GetVelocity(delta, this.vel.y, this.accel.y, this.friction.y, this.maxVel.y);
6767

68+
if (window.dumpit)
69+
{
70+
console.log('');
71+
console.log('UPDATE: pos', this.pos.x, this.pos.y, 'vel', this.vel.x, this.vel.y);
72+
}
73+
6874
var mx = this.vel.x * delta;
6975
var my = this.vel.y * delta;
7076

7177
var res = this.world.collisionMap.trace(this.pos.x, this.pos.y, mx, my, this.size.x, this.size.y);
7278

7379
UpdateMotion(this, res);
80+
81+
if (window.dumpit)
82+
{
83+
console.log('END res', res.pos.x, res.pos.y);
84+
}
7485
},
7586

7687
skipHash: function ()

v3/src/physics/impact/CollisionMap.js

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,11 @@ var CollisionMap = new Class({
8282
{
8383
res.pos.x += vx;
8484
res.pos.y += vy;
85+
86+
if (window.dumpit)
87+
{
88+
console.log('STEP', res.pos.x, res.pos.y, 'VX', vx, 'VY', vy, 'step', step);
89+
}
8590

8691
var t = 0;
8792
var tilesize = this.tilesize;
@@ -104,27 +109,45 @@ var CollisionMap = new Class({
104109
{
105110
prevTileX = -1;
106111
}
112+
113+
console.group('VX');
114+
console.log('pxOffsetX', pxOffsetX);
115+
console.log('tileOffsetX', tileOffsetX);
116+
console.log('firstTileY', firstTileY);
117+
console.log('lastTileY', lastTileY);
118+
console.log('tileX', tileX);
119+
console.log('prevTileX', prevTileX);
107120

108121
if (tileX >= 0 && tileX < mapWidth)
109122
{
123+
// console.log('X:', tileX);
124+
110125
for (var tileY = firstTileY; tileY < lastTileY; tileY++)
111126
{
127+
// console.log('Y:', tileY);
128+
112129
if (prevTileX !== -1)
113130
{
114131
t = this.data[tileY][prevTileX];
115132

133+
// console.log('t1', t);
134+
116135
if (t > 1 && t <= this.lastSlope && this.checkDef(res, t, x, y, rvx, rvy, width, height, prevTileX, tileY))
117136
{
137+
// console.log('t1 break');
118138
break;
119139
}
120140
}
121141

122142
t = this.data[tileY][tileX];
123143

144+
console.log('Tile at', tileX, 'x', tileY, '=', t);
145+
124146
if (t === 1 || t > this.lastSlope || (t > 1 && this.checkDef(res, t, x, y, rvx, rvy, width, height, tileX, tileY)))
125147
{
126148
if (t > 1 && t <= this.lastSlope && res.collision.slope)
127149
{
150+
// console.log('t2 break');
128151
break;
129152
}
130153

@@ -134,10 +157,24 @@ var CollisionMap = new Class({
134157
x = res.pos.x;
135158
rvx = 0;
136159

160+
// 10, 32, 40, 0
161+
// (10 * 32) = 320
162+
// 320 - 40 + 0 = 280
163+
164+
console.log('>>> Hit solid tile <<<');
165+
166+
console.log('tileX', tileX);
167+
console.log('tilesize', tilesize);
168+
console.log('pxOffsetX', pxOffsetX);
169+
console.log('tileOffsetX', tileOffsetX);
170+
console.log('=', res.pos.x);
171+
137172
break;
138173
}
139174
}
140175
}
176+
177+
console.groupEnd();
141178
}
142179

143180
// Vertical

v3/src/physics/impact/UpdateMotion.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ var UpdateMotion = function (body, res)
4444
if (res.collision.slope)
4545
{
4646
var s = res.collision.slope;
47-
47+
4848
if (body.bounciness > 0)
4949
{
5050
var proj = body.vel.x * s.nx + body.vel.y * s.ny;
@@ -67,8 +67,19 @@ var UpdateMotion = function (body, res)
6767
body.standing = true;
6868
}
6969
}
70+
71+
if (window.dumpit)
72+
{
73+
console.group('slope');
74+
console.log(s);
75+
console.log('pos', res.pos.x, res.pos.y);
76+
console.log('vel', body.vel.x, body.vel.y);
77+
console.groupEnd();
78+
}
7079
}
7180

81+
// body.pos = res.pos;
82+
7283
body.pos.x = res.pos.x;
7384
body.pos.y = res.pos.y;
7485
};

v3/src/physics/impact/World.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,8 @@ var World = new Class({
8686
// Check the body against the spatial hash
8787
checkHash: function (body, hash, size)
8888
{
89+
console.log('checkHash');
90+
8991
var checked = {};
9092
var xmin = Math.floor(body.pos.x / size);
9193
var ymin = Math.floor(body.pos.y / size);
@@ -99,11 +101,11 @@ var World = new Class({
99101
if (!hash[x])
100102
{
101103
hash[x] = {};
102-
hash[x][y] = [body];
104+
hash[x][y] = [ body ];
103105
}
104106
else if (!hash[x][y])
105107
{
106-
hash[x][y] = [body];
108+
hash[x][y] = [ body ];
107109
}
108110
else
109111
{
@@ -140,6 +142,7 @@ var World = new Class({
140142

141143
if (bodyA.collides && bodyB.collides && bodyA.collides + bodyB.collides > COLLIDES.ACTIVE)
142144
{
145+
console.log('solve');
143146
Solver(this, bodyA, bodyB);
144147
}
145148
}

0 commit comments

Comments
 (0)