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, "player"); this.bounds.size.set(0.5, 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) { 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); } }