From 4166263c8694a713abd74f7f76ab579d84aac03e Mon Sep 17 00:00:00 2001
From: Paolo Brasolin <paolo.brasolin@eurac.edu>
Date: Mon, 4 Apr 2022 15:27:22 +0200
Subject: [PATCH] feat: #fe parameterize foe duration

---
 frontend/src/js/foe.ts | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/frontend/src/js/foe.ts b/frontend/src/js/foe.ts
index 411b3d9..cc0624e 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(
-- 
GitLab