From 5b5cf8076c38e1eaf6b202c44f18d83f7c13f161 Mon Sep 17 00:00:00 2001
From: Paolo Brasolin <paolo.brasolin@eurac.edu>
Date: Mon, 4 Apr 2022 15:16:49 +0200
Subject: [PATCH] refactor: #fe improve player placement

---
 frontend/src/js/fight_scene.ts | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/frontend/src/js/fight_scene.ts b/frontend/src/js/fight_scene.ts
index 70a4243..36f936d 100644
--- a/frontend/src/js/fight_scene.ts
+++ b/frontend/src/js/fight_scene.ts
@@ -163,21 +163,22 @@ export default class FightScene extends Phaser.Scene {
 
   createPlayer() {
     this.player = this.physics.add
-      .sprite(
-        this.cameras.main.width + 300,
-        this.cameras.main.height - 100,
-        "oezi",
-      )
+      .sprite(0, 0, "oezi")
       .setScale(3)
       .setInteractive();
+    this.player.setPosition(
+      // NOTE: just outside the bound and above the ground
+      this.cameras.main.width + 0.5 * this.player.displayWidth,
+      this.cameras.main.height - 30 - 0.5 * this.player.displayHeight,
+    );
     this.player.flipX = true;
     this.player.play({ key: "player_run" });
     this.player.setCollideWorldBounds(true);
     this.tweens.add({
       targets: this.player,
-      x: this.cameras.main.width - 80,
+      x: this.cameras.main.width - this.player.displayWidth * 0.5,
       ease: "Power2",
-      duration: 2000,
+      duration: 1000,
       onComplete: () => {
         this.player.play({ key: "player_run", repeat: -1 });
       },
-- 
GitLab