|
1234567891011121314151617181920212223242526272829 |
- import Entity from "../Entity.js";
- import Texture from "../Texture.js";
- import Tile from "../Tile.js";
- import assets from "../assets.js";
-
- import TKeyboardController from "../traits/TKeyboardController.js";
- import TPhysics from "../traits/TPhysics.js";
- import TCollider from "../traits/TCollider.js";
-
- export default class Player extends Entity {
- constructor(level) {
- super(level);
-
- this.bounds.size.set(1, 2);
- this.addTrait(new TCollider(this));
- this.addTrait(new TKeyboardController(this));
- this.addTrait(new TPhysics(this));
-
- this.texture = new Texture(assets.entities, [
- new Tile(0, 0, "player-head"),
- ]);
- }
-
- draw(ctx) {
- this.texture.draw(ctx,
- this.bounds.pos.pixelX - assets.entities.scale * 1.5,
- this.bounds.pos.pixelY);
- }
- }
|