mirror of
https://github.com/photonstorm/phaser
synced 2025-02-16 14:08:28 +00:00
Masses of debugging fun and joy.
This commit is contained in:
parent
cc515082e5
commit
86fc07b5e3
5 changed files with 66 additions and 4 deletions
|
@ -1,4 +1,4 @@
|
|||
var CHECKSUM = {
|
||||
build: '9f8b8c60-575c-11e7-9988-39da119e4a13'
|
||||
build: 'db055440-5835-11e7-821c-f3e448a2ca69'
|
||||
};
|
||||
module.exports = CHECKSUM;
|
|
@ -65,12 +65,23 @@ var Body = new Class({
|
|||
this.vel.x = GetVelocity(delta, this.vel.x, this.accel.x, this.friction.x, this.maxVel.x);
|
||||
this.vel.y = GetVelocity(delta, this.vel.y, this.accel.y, this.friction.y, this.maxVel.y);
|
||||
|
||||
if (window.dumpit)
|
||||
{
|
||||
console.log('');
|
||||
console.log('UPDATE: pos', this.pos.x, this.pos.y, 'vel', this.vel.x, this.vel.y);
|
||||
}
|
||||
|
||||
var mx = this.vel.x * delta;
|
||||
var my = this.vel.y * delta;
|
||||
|
||||
var res = this.world.collisionMap.trace(this.pos.x, this.pos.y, mx, my, this.size.x, this.size.y);
|
||||
|
||||
UpdateMotion(this, res);
|
||||
|
||||
if (window.dumpit)
|
||||
{
|
||||
console.log('END res', res.pos.x, res.pos.y);
|
||||
}
|
||||
},
|
||||
|
||||
skipHash: function ()
|
||||
|
|
|
@ -82,6 +82,11 @@ var CollisionMap = new Class({
|
|||
{
|
||||
res.pos.x += vx;
|
||||
res.pos.y += vy;
|
||||
|
||||
if (window.dumpit)
|
||||
{
|
||||
console.log('STEP', res.pos.x, res.pos.y, 'VX', vx, 'VY', vy, 'step', step);
|
||||
}
|
||||
|
||||
var t = 0;
|
||||
var tilesize = this.tilesize;
|
||||
|
@ -104,27 +109,45 @@ var CollisionMap = new Class({
|
|||
{
|
||||
prevTileX = -1;
|
||||
}
|
||||
|
||||
console.group('VX');
|
||||
console.log('pxOffsetX', pxOffsetX);
|
||||
console.log('tileOffsetX', tileOffsetX);
|
||||
console.log('firstTileY', firstTileY);
|
||||
console.log('lastTileY', lastTileY);
|
||||
console.log('tileX', tileX);
|
||||
console.log('prevTileX', prevTileX);
|
||||
|
||||
if (tileX >= 0 && tileX < mapWidth)
|
||||
{
|
||||
// console.log('X:', tileX);
|
||||
|
||||
for (var tileY = firstTileY; tileY < lastTileY; tileY++)
|
||||
{
|
||||
// console.log('Y:', tileY);
|
||||
|
||||
if (prevTileX !== -1)
|
||||
{
|
||||
t = this.data[tileY][prevTileX];
|
||||
|
||||
// console.log('t1', t);
|
||||
|
||||
if (t > 1 && t <= this.lastSlope && this.checkDef(res, t, x, y, rvx, rvy, width, height, prevTileX, tileY))
|
||||
{
|
||||
// console.log('t1 break');
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
t = this.data[tileY][tileX];
|
||||
|
||||
console.log('Tile at', tileX, 'x', tileY, '=', t);
|
||||
|
||||
if (t === 1 || t > this.lastSlope || (t > 1 && this.checkDef(res, t, x, y, rvx, rvy, width, height, tileX, tileY)))
|
||||
{
|
||||
if (t > 1 && t <= this.lastSlope && res.collision.slope)
|
||||
{
|
||||
// console.log('t2 break');
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -134,10 +157,24 @@ var CollisionMap = new Class({
|
|||
x = res.pos.x;
|
||||
rvx = 0;
|
||||
|
||||
// 10, 32, 40, 0
|
||||
// (10 * 32) = 320
|
||||
// 320 - 40 + 0 = 280
|
||||
|
||||
console.log('>>> Hit solid tile <<<');
|
||||
|
||||
console.log('tileX', tileX);
|
||||
console.log('tilesize', tilesize);
|
||||
console.log('pxOffsetX', pxOffsetX);
|
||||
console.log('tileOffsetX', tileOffsetX);
|
||||
console.log('=', res.pos.x);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
console.groupEnd();
|
||||
}
|
||||
|
||||
// Vertical
|
||||
|
|
|
@ -44,7 +44,7 @@ var UpdateMotion = function (body, res)
|
|||
if (res.collision.slope)
|
||||
{
|
||||
var s = res.collision.slope;
|
||||
|
||||
|
||||
if (body.bounciness > 0)
|
||||
{
|
||||
var proj = body.vel.x * s.nx + body.vel.y * s.ny;
|
||||
|
@ -67,8 +67,19 @@ var UpdateMotion = function (body, res)
|
|||
body.standing = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (window.dumpit)
|
||||
{
|
||||
console.group('slope');
|
||||
console.log(s);
|
||||
console.log('pos', res.pos.x, res.pos.y);
|
||||
console.log('vel', body.vel.x, body.vel.y);
|
||||
console.groupEnd();
|
||||
}
|
||||
}
|
||||
|
||||
// body.pos = res.pos;
|
||||
|
||||
body.pos.x = res.pos.x;
|
||||
body.pos.y = res.pos.y;
|
||||
};
|
||||
|
|
|
@ -86,6 +86,8 @@ var World = new Class({
|
|||
// Check the body against the spatial hash
|
||||
checkHash: function (body, hash, size)
|
||||
{
|
||||
console.log('checkHash');
|
||||
|
||||
var checked = {};
|
||||
var xmin = Math.floor(body.pos.x / size);
|
||||
var ymin = Math.floor(body.pos.y / size);
|
||||
|
@ -99,11 +101,11 @@ var World = new Class({
|
|||
if (!hash[x])
|
||||
{
|
||||
hash[x] = {};
|
||||
hash[x][y] = [body];
|
||||
hash[x][y] = [ body ];
|
||||
}
|
||||
else if (!hash[x][y])
|
||||
{
|
||||
hash[x][y] = [body];
|
||||
hash[x][y] = [ body ];
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -140,6 +142,7 @@ var World = new Class({
|
|||
|
||||
if (bodyA.collides && bodyB.collides && bodyA.collides + bodyB.collides > COLLIDES.ACTIVE)
|
||||
{
|
||||
console.log('solve');
|
||||
Solver(this, bodyA, bodyB);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue