Browse Source

fixed player bounding box

master
mortie 3 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

@@ -11,7 +11,7 @@ export default class Player extends Entity {
constructor(level) {
super(level, "player");

this.bounds.size.set(1, 2);
this.bounds.size.set(0.5, 2);
this.addTrait(new TCollider(this));
this.addTrait(new TKeyboardController(this));
this.addTrait(new TPhysics(this));
@@ -22,8 +22,11 @@ export default class Player extends Entity {
}

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