mirror of
https://github.com/logsol/chuck.js.git
synced 2026-05-11 18:47:35 +00:00
first attempt of implmenting asm style box2d engine
This commit is contained in:
parent
ebf167107a
commit
cca3a258ba
12 changed files with 12255 additions and 10876 deletions
|
|
@ -22,8 +22,11 @@ function (Parent, Box2D, Settings, Exception, Nc) {
|
|||
|
||||
var bodyDef = new Box2D.Dynamics.b2BodyDef();
|
||||
bodyDef.type = Box2D.Dynamics.b2Body.b2_staticBody;
|
||||
bodyDef.position.x = (this.options.x * Settings.TILE_SIZE + Settings.TILE_SIZE / 2) / Settings.RATIO;
|
||||
bodyDef.position.y = (this.options.y * Settings.TILE_SIZE + Settings.TILE_SIZE / 2) / Settings.RATIO;
|
||||
|
||||
var x = (this.options.x * Settings.TILE_SIZE + Settings.TILE_SIZE / 2) / Settings.RATIO;
|
||||
var y = (this.options.y * Settings.TILE_SIZE + Settings.TILE_SIZE / 2) / Settings.RATIO;
|
||||
|
||||
bodyDef.position = new Box2D.Common.Math.b2Vec2(x, y);
|
||||
bodyDef.angle = (this.options.r || 0) * 90 * Math.PI / 180;
|
||||
|
||||
return bodyDef;
|
||||
|
|
@ -31,8 +34,14 @@ function (Parent, Box2D, Settings, Exception, Nc) {
|
|||
|
||||
Tile.prototype.createPhysicTile = function (tile) {
|
||||
var vertices = this.createVertices(tile);
|
||||
var tileShape = new Box2D.Collision.Shapes.b2PolygonShape();
|
||||
tileShape.SetAsArray(vertices, vertices.length);
|
||||
|
||||
var tileShape;
|
||||
if(Settings.USE_ASM) {
|
||||
tileShape = Box2D.createPolygonShape(vertices);
|
||||
} else {
|
||||
tileShape = new Box2D.Collision.Shapes.b2PolygonShape();
|
||||
tileShape.SetAsArray(vertices, vertices.length);
|
||||
}
|
||||
|
||||
var fixtureDef = new Box2D.Dynamics.b2FixtureDef();
|
||||
fixtureDef.shape = tileShape;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue