Repository: thetawavegame/thetawave-legacy (language: rust)

Issue:
Add item to item pool that increases the total health of the spaceship
Add item to item pool that increases the total health of the player by a reasonable amount.


Discussion / hints:

Fix patch:
diff --git a/assets/data/items.ron b/assets/data/items.ron
index c615b13..c91a87a 100644
--- a/assets/data/items.ron
+++ b/assets/data/items.ron
@@ -80,4 +80,12 @@
         sprite_index: 9,
         name: "enhanced_plating"
     ),
+    "structure_reinforcement": (
+        stat_effects: {
+            "max_health": 100.0,
+        },
+        price: 3,
+        sprite_index: 10,
+        name: "structure_reinforcement",
+    ),
 }
\ No newline at end of file
diff --git a/assets/texture/items_spritesheet.png b/assets/texture/items_spritesheet.png
index 9efd4cf..c43982e 100644
Binary files a/assets/texture/items_spritesheet.png and b/assets/texture/items_spritesheet.png differ
diff --git a/assets/texture/items_spritesheet.ron b/assets/texture/items_spritesheet.ron
index b35a616..08ebca6 100644
--- a/assets/texture/items_spritesheet.ron
+++ b/assets/texture/items_spritesheet.ron
@@ -1,5 +1,5 @@
 (
-    texture_width: 154,
+    texture_width: 168,
     texture_height: 14,
     sprites: [
         (
@@ -62,5 +62,11 @@
             width: 14,
             height: 14,
         ),
+        (
+            x: 140,
+            y: 0,
+            width: 14,
+            height: 14,
+        ),
     ],
 )
\ No newline at end of file
diff --git a/src/systems/item.rs b/src/systems/item.rs
index a8141b8..8e4196e 100644
--- a/src/systems/item.rs
+++ b/src/systems/item.rs
@@ -69,6 +69,11 @@ impl<'s> System<'s> for ItemSystem {
                         spaceship.max_speed += item.stat_effects["max_speed"];
                     }
 
+                    if item.stat_effects.contains_key("max_health") {
+                        spaceship.set_max_health(spaceship.max_health() + item.stat_effects["max_health"]);
+                        spaceship.set_health(spaceship.health() + item.stat_effects["max_health"]);
+                    }
+
                     if item.stat_effects.contains_key("crit_chance") {
                         spaceship.crit_chance += item.stat_effects["crit_chance"];
                     }
@@ -112,4 +117,3 @@ impl<'s> System<'s> for ItemSystem {
         }
     }
 }
-


Test patch: