diff --git a/frontend/src/js/foe.ts b/frontend/src/js/foe.ts index 411b3d9a7401ac586d335ada4b1586d4468eb5cb..cc0624efb7bc1da2ee962b68a7d9337b01a96134 100644 --- a/frontend/src/js/foe.ts +++ b/frontend/src/js/foe.ts @@ -14,8 +14,11 @@ class Foe { critter: Critter; clue: Clue; - constructor(scene: FightScene) { + duration: number; + + constructor(scene: FightScene, duration = 15) { this.scene = scene; + this.duration = duration; } async initialize() { @@ -29,7 +32,9 @@ class Foe { ).data; this.clue = new Clue(this.scene, this.beWord); - this.critter = new Critter(this.scene); + // TODO: this is the time to reach a collision w/player, but maybe we should just use the transversal of the full screen. + const critterSpeed = this.scene.player.getBounds().left / this.duration; + this.critter = new Critter(this.scene, critterSpeed); this.scene.foes.push(this); const overlap = this.scene.physics.add.overlap(