Browse Source

fixed player bounding box

master
mortie 6 years ago
parent
commit
dfe7adb0d3
1 changed files with 7 additions and 4 deletions
  1. 7
    4
      js/entities/Player.js

+ 7
- 4
js/entities/Player.js View File

constructor(level) { constructor(level) {
super(level, "player"); super(level, "player");


this.bounds.size.set(1, 2);
this.bounds.size.set(0.5, 2);
this.addTrait(new TCollider(this)); this.addTrait(new TCollider(this));
this.addTrait(new TKeyboardController(this)); this.addTrait(new TKeyboardController(this));
this.addTrait(new TPhysics(this)); this.addTrait(new TPhysics(this));
} }


draw(ctx) { draw(ctx) {
this.texture.draw(ctx,
this.bounds.pos.pixelX - assets.entities.scale * 1.5,
this.bounds.pos.pixelY);
let x =
this.bounds.pos.pixelX -
assets.entities.scale * 1.5 -
this.bounds.size.pixelX / 2

this.texture.draw(ctx, x, this.bounds.pos.pixelY);
} }
} }

Loading…
Cancel
Save