From e837a7575e3b95db7a66e01bb4cdf779998237a5 Mon Sep 17 00:00:00 2001
From: Paolo Brasolin <paolo.brasolin@eurac.edu>
Date: Wed, 6 Apr 2022 14:34:36 +0200
Subject: [PATCH] feat: #fe simplify hud stats padding

---
 frontend/src/js/hud.ts | 26 +++++++++-----------------
 1 file changed, 9 insertions(+), 17 deletions(-)

diff --git a/frontend/src/js/hud.ts b/frontend/src/js/hud.ts
index 3a73d0e..b0da2f0 100644
--- a/frontend/src/js/hud.ts
+++ b/frontend/src/js/hud.ts
@@ -63,32 +63,24 @@ export default class HUD {
       .setOrigin(0.5, 0.5);
   }
 
-  statsTextStyle() {
+  statsTextStyle(): Phaser.Types.GameObjects.Text.TextStyle {
     return {
       ...STATS_BASE_TEXT_STYLE,
       fontSize: this.options.statsFontSize,
+      padding: {
+        x: this.options.statsPadding,
+        y: this.options.statsPadding,
+      },
     };
   }
 
   initScore(scene: Phaser.Scene) {
-    return scene.add
-      .text(
-        this.options.statsPadding,
-        this.options.statsPadding,
-        "",
-        this.statsTextStyle(),
-      )
-      .setOrigin(0, 0);
+    return scene.add.text(0, 0, "", this.statsTextStyle()).setOrigin(0, 0);
   }
 
   initHealth(scene: Phaser.Scene) {
     return scene.add
-      .text(
-        scene.cameras.main.width - this.options.statsPadding,
-        this.options.statsPadding,
-        "",
-        this.statsTextStyle(),
-      )
+      .text(scene.cameras.main.width, 0, "", this.statsTextStyle())
       .setOrigin(1, 0);
   }
 
@@ -96,7 +88,7 @@ export default class HUD {
     return scene.add
       .text(
         scene.cameras.main.width * 0.5,
-        this.options.statsPadding,
+        0,
         `${ICONS.CLOCK}1:23.32`,
         this.statsTextStyle(),
       )
@@ -132,7 +124,7 @@ export default class HUD {
     const text = this.scene.add
       .text(
         this.scene.cameras.main.width / 2,
-        this.scene.cameras.main.height / 2,
+        this.scene.cameras.main.height * this.options.inputPosition,
         input,
         {
           ...INPUT_BASE_TEXT_STYLE,
-- 
GitLab