Lots of new World helpers

This commit is contained in:
Richard Davey 2017-08-16 01:20:35 +01:00
parent e64981c51d
commit 51670f5d26
3 changed files with 160 additions and 30 deletions

View file

@ -1,4 +1,4 @@
var CHECKSUM = {
build: 'c897f920-8210-11e7-91c0-5f772e8c4462'
build: '7d813d50-8217-11e7-b68c-d36461f65b44'
};
module.exports = CHECKSUM;

View file

@ -110,16 +110,16 @@ var CollisionMap = new Class({
prevTileX = -1;
}
if (window.debugslopes)
{
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 (window.debugslopes)
// {
// 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)
{
@ -163,32 +163,26 @@ var CollisionMap = new Class({
x = res.pos.x;
rvx = 0;
if (window.debugslopes)
{
console.log('>>> Hit solid tile <<<');
// if (window.debugslopes)
// {
// 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);
}
// 9 * 32 = 288
// - 16 = 272
// + 0 = 272
// Where does the 16 come from?
// console.log('tileX', tileX);
// console.log('tilesize', tilesize);
// console.log('pxOffsetX', pxOffsetX);
// console.log('tileOffsetX', tileOffsetX);
// console.log('=', res.pos.x);
// }
break;
}
}
}
if (window.debugslopes)
{
console.groupEnd();
}
// if (window.debugslopes)
// {
// console.groupEnd();
// }
}
// Vertical

View file

@ -150,6 +150,142 @@ var World = new Class({
// console.log('solve');
Solver(this, bodyA, bodyB);
}
},
//////////////
// Helpers //
//////////////
setCollidesNever: function (bodies)
{
for (var i = 0; i < bodies.length; i++)
{
bodies[i].collides = COLLIDES.NEVER;
}
return this;
},
setLite: function (bodies)
{
for (var i = 0; i < bodies.length; i++)
{
bodies[i].collides = COLLIDES.LITE;
}
return this;
},
setPassive: function (bodies)
{
for (var i = 0; i < bodies.length; i++)
{
bodies[i].collides = COLLIDES.PASSIVE;
}
return this;
},
setActive: function (bodies)
{
for (var i = 0; i < bodies.length; i++)
{
bodies[i].collides = COLLIDES.ACTIVE;
}
return this;
},
setFixed: function (bodies)
{
for (var i = 0; i < bodies.length; i++)
{
bodies[i].collides = COLLIDES.FIXED;
}
return this;
},
setTypeNone: function (bodies)
{
for (var i = 0; i < bodies.length; i++)
{
bodies[i].type = TYPE.NONE;
}
return this;
},
setTypeA: function (bodies)
{
for (var i = 0; i < bodies.length; i++)
{
bodies[i].type = TYPE.A;
}
return this;
},
setTypeB: function (bodies)
{
for (var i = 0; i < bodies.length; i++)
{
bodies[i].type = TYPE.B;
}
return this;
},
setAvsB: function (bodies)
{
for (var i = 0; i < bodies.length; i++)
{
bodies[i].type = TYPE.A;
bodies[i].checkAgainst = TYPE.B;
}
return this;
},
setBvsA: function (bodies)
{
for (var i = 0; i < bodies.length; i++)
{
bodies[i].type = TYPE.B;
bodies[i].checkAgainst = TYPE.A;
}
return this;
},
setCheckAgainstNone: function (bodies)
{
for (var i = 0; i < bodies.length; i++)
{
bodies[i].checkAgainst = TYPE.NONE;
}
return this;
},
setCheckAgainstA: function (bodies)
{
for (var i = 0; i < bodies.length; i++)
{
bodies[i].checkAgainst = TYPE.A;
}
return this;
},
setCheckAgainstB: function (bodies)
{
for (var i = 0; i < bodies.length; i++)
{
bodies[i].checkAgainst = TYPE.B;
}
return this;
}
});