From d58b54d138022480703841fafea76761bc30ad3a Mon Sep 17 00:00:00 2001 From: Florian Date: Wed, 17 Sep 2025 14:05:11 +0200 Subject: [PATCH 1/3] Fixed Item Spawn crash --- items/item_spawn.gd | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/items/item_spawn.gd b/items/item_spawn.gd index af9d37a..a9d6e88 100644 --- a/items/item_spawn.gd +++ b/items/item_spawn.gd @@ -31,7 +31,8 @@ func _ready(): var pool = choose_pool() var index = randi_range(0, pool.size() - 1) var packed_scene : PackedScene = pool[index] - pool.remove_at(index) + if remove_after_spawn: + pool.remove_at(index) var object = packed_scene.instantiate() add_child.call_deferred(object) object.reparent.call_deferred(get_parent()) From fc55aa4c0977b88a3c6b4070825a4e513adc7610 Mon Sep 17 00:00:00 2001 From: Florian Date: Wed, 17 Sep 2025 14:08:57 +0200 Subject: [PATCH 2/3] Fixed dependencies --- buildings/Building 1x2 fixed.png.import | 6 ++++++ buildings/Building 2x1 downside.png.import | 6 ++++++ buildings/Building 2x1 fixed.png.import | 6 ++++++ item_ui/item_ui.tscn | 23 ++++++++++++++++++++++ main.tscn | 4 ++-- player/Player_Walk/Walk 1.png.import | 6 ++++++ player/Player_Walk/Walk 2.png.import | 6 ++++++ player/Player_Walk/Walk 3.png.import | 6 ++++++ player/Player_Walk/Walk 4.png.import | 6 ++++++ player/Player_Walk/Walk 5.png.import | 6 ++++++ player/Player_Walk/Walk 6.png.import | 6 ++++++ project.godot | 2 +- 12 files changed, 80 insertions(+), 3 deletions(-) create mode 100644 item_ui/item_ui.tscn diff --git a/buildings/Building 1x2 fixed.png.import b/buildings/Building 1x2 fixed.png.import index 0ac93ca..39a81c9 100644 --- a/buildings/Building 1x2 fixed.png.import +++ b/buildings/Building 1x2 fixed.png.import @@ -18,6 +18,8 @@ dest_files=["res://.godot/imported/Building 1x2 fixed.png-e90afc0d25a8919ada5700 compress/mode=0 compress/high_quality=false compress/lossy_quality=0.7 +compress/uastc_level=0 +compress/rdo_quality_loss=0.0 compress/hdr_compression=1 compress/normal_map=0 compress/channel_pack=0 @@ -25,6 +27,10 @@ mipmaps/generate=false mipmaps/limit=-1 roughness/mode=0 roughness/src_normal="" +process/channel_remap/red=0 +process/channel_remap/green=1 +process/channel_remap/blue=2 +process/channel_remap/alpha=3 process/fix_alpha_border=true process/premult_alpha=false process/normal_map_invert_y=false diff --git a/buildings/Building 2x1 downside.png.import b/buildings/Building 2x1 downside.png.import index 52d9ce5..0e57d53 100644 --- a/buildings/Building 2x1 downside.png.import +++ b/buildings/Building 2x1 downside.png.import @@ -18,6 +18,8 @@ dest_files=["res://.godot/imported/Building 2x1 downside.png-4b432eb4152bab7dd59 compress/mode=0 compress/high_quality=false compress/lossy_quality=0.7 +compress/uastc_level=0 +compress/rdo_quality_loss=0.0 compress/hdr_compression=1 compress/normal_map=0 compress/channel_pack=0 @@ -25,6 +27,10 @@ mipmaps/generate=false mipmaps/limit=-1 roughness/mode=0 roughness/src_normal="" +process/channel_remap/red=0 +process/channel_remap/green=1 +process/channel_remap/blue=2 +process/channel_remap/alpha=3 process/fix_alpha_border=true process/premult_alpha=false process/normal_map_invert_y=false diff --git a/buildings/Building 2x1 fixed.png.import b/buildings/Building 2x1 fixed.png.import index a78eae3..e7fdbe6 100644 --- a/buildings/Building 2x1 fixed.png.import +++ b/buildings/Building 2x1 fixed.png.import @@ -18,6 +18,8 @@ dest_files=["res://.godot/imported/Building 2x1 fixed.png-b02748fa52aebae62f987c compress/mode=0 compress/high_quality=false compress/lossy_quality=0.7 +compress/uastc_level=0 +compress/rdo_quality_loss=0.0 compress/hdr_compression=1 compress/normal_map=0 compress/channel_pack=0 @@ -25,6 +27,10 @@ mipmaps/generate=false mipmaps/limit=-1 roughness/mode=0 roughness/src_normal="" +process/channel_remap/red=0 +process/channel_remap/green=1 +process/channel_remap/blue=2 +process/channel_remap/alpha=3 process/fix_alpha_border=true process/premult_alpha=false process/normal_map_invert_y=false diff --git a/item_ui/item_ui.tscn b/item_ui/item_ui.tscn new file mode 100644 index 0000000..e690fdf --- /dev/null +++ b/item_ui/item_ui.tscn @@ -0,0 +1,23 @@ +[gd_scene load_steps=2 format=3 uid="uid://73g8y37skebh"] + +[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_8oq0s"] +draw_center = false +border_width_left = 5 +border_width_top = 5 +border_width_right = 5 +border_width_bottom = 5 +border_color = Color(0, 0, 0, 0.69411767) +border_blend = true +corner_radius_top_left = 50 +corner_radius_top_right = 50 +corner_radius_bottom_right = 50 +corner_radius_bottom_left = 50 + +[node name="ItemUI" type="PanelContainer"] +anchors_preset = 1 +anchor_left = 1.0 +anchor_right = 1.0 +offset_left = -100.0 +offset_bottom = 100.0 +grow_horizontal = 0 +theme_override_styles/panel = SubResource("StyleBoxFlat_8oq0s") diff --git a/main.tscn b/main.tscn index a0394c8..6791336 100644 --- a/main.tscn +++ b/main.tscn @@ -6,8 +6,8 @@ [ext_resource type="Script" uid="uid://colvx6wq0e8n7" path="res://world/building_generator.gd" id="4_1bvp3"] [ext_resource type="PackedScene" uid="uid://cjsrtswk4vgf2" path="res://healthbar/healthbar.tscn" id="6_7mycd"] [ext_resource type="PackedScene" uid="uid://dpdn2php3ydsv" path="res://death_screen/death_screen.tscn" id="7_5vw27"] -[ext_resource type="PackedScene" uid="uid://4l3elvxpghw8" path="res://utils/platform.tscn" id="7_272bh"] -[ext_resource type="PackedScene" uid="uid://gwctb2xqsbj" path="res://items/healthup.tscn" id="9_4c57u"] +[ext_resource type="PackedScene" path="res://utils/platform.tscn" id="7_272bh"] +[ext_resource type="PackedScene" path="res://items/healthup.tscn" id="9_4c57u"] [ext_resource type="PackedScene" uid="uid://chu67ci7sl488" path="res://enemies/ghost.tscn" id="9_kek77"] [node name="main" type="Node2D"] diff --git a/player/Player_Walk/Walk 1.png.import b/player/Player_Walk/Walk 1.png.import index 97cf918..7803358 100644 --- a/player/Player_Walk/Walk 1.png.import +++ b/player/Player_Walk/Walk 1.png.import @@ -18,6 +18,8 @@ dest_files=["res://.godot/imported/Walk 1.png-47c623e9d3540b4a00d2bddf52ae0b2a.c compress/mode=0 compress/high_quality=false compress/lossy_quality=0.7 +compress/uastc_level=0 +compress/rdo_quality_loss=0.0 compress/hdr_compression=1 compress/normal_map=0 compress/channel_pack=0 @@ -25,6 +27,10 @@ mipmaps/generate=false mipmaps/limit=-1 roughness/mode=0 roughness/src_normal="" +process/channel_remap/red=0 +process/channel_remap/green=1 +process/channel_remap/blue=2 +process/channel_remap/alpha=3 process/fix_alpha_border=true process/premult_alpha=false process/normal_map_invert_y=false diff --git a/player/Player_Walk/Walk 2.png.import b/player/Player_Walk/Walk 2.png.import index 48f18ef..3fac54f 100644 --- a/player/Player_Walk/Walk 2.png.import +++ b/player/Player_Walk/Walk 2.png.import @@ -18,6 +18,8 @@ dest_files=["res://.godot/imported/Walk 2.png-5dea4fdec55fa43e26680e08090fd654.c compress/mode=0 compress/high_quality=false compress/lossy_quality=0.7 +compress/uastc_level=0 +compress/rdo_quality_loss=0.0 compress/hdr_compression=1 compress/normal_map=0 compress/channel_pack=0 @@ -25,6 +27,10 @@ mipmaps/generate=false mipmaps/limit=-1 roughness/mode=0 roughness/src_normal="" +process/channel_remap/red=0 +process/channel_remap/green=1 +process/channel_remap/blue=2 +process/channel_remap/alpha=3 process/fix_alpha_border=true process/premult_alpha=false process/normal_map_invert_y=false diff --git a/player/Player_Walk/Walk 3.png.import b/player/Player_Walk/Walk 3.png.import index 285ace3..c65053d 100644 --- a/player/Player_Walk/Walk 3.png.import +++ b/player/Player_Walk/Walk 3.png.import @@ -18,6 +18,8 @@ dest_files=["res://.godot/imported/Walk 3.png-27890c0cb512383b8ecbd848c73efee1.c compress/mode=0 compress/high_quality=false compress/lossy_quality=0.7 +compress/uastc_level=0 +compress/rdo_quality_loss=0.0 compress/hdr_compression=1 compress/normal_map=0 compress/channel_pack=0 @@ -25,6 +27,10 @@ mipmaps/generate=false mipmaps/limit=-1 roughness/mode=0 roughness/src_normal="" +process/channel_remap/red=0 +process/channel_remap/green=1 +process/channel_remap/blue=2 +process/channel_remap/alpha=3 process/fix_alpha_border=true process/premult_alpha=false process/normal_map_invert_y=false diff --git a/player/Player_Walk/Walk 4.png.import b/player/Player_Walk/Walk 4.png.import index 03aa90d..c12f6b8 100644 --- a/player/Player_Walk/Walk 4.png.import +++ b/player/Player_Walk/Walk 4.png.import @@ -18,6 +18,8 @@ dest_files=["res://.godot/imported/Walk 4.png-232b1eae2acf3ad82130431014262cde.c compress/mode=0 compress/high_quality=false compress/lossy_quality=0.7 +compress/uastc_level=0 +compress/rdo_quality_loss=0.0 compress/hdr_compression=1 compress/normal_map=0 compress/channel_pack=0 @@ -25,6 +27,10 @@ mipmaps/generate=false mipmaps/limit=-1 roughness/mode=0 roughness/src_normal="" +process/channel_remap/red=0 +process/channel_remap/green=1 +process/channel_remap/blue=2 +process/channel_remap/alpha=3 process/fix_alpha_border=true process/premult_alpha=false process/normal_map_invert_y=false diff --git a/player/Player_Walk/Walk 5.png.import b/player/Player_Walk/Walk 5.png.import index fe3ebef..47122be 100644 --- a/player/Player_Walk/Walk 5.png.import +++ b/player/Player_Walk/Walk 5.png.import @@ -18,6 +18,8 @@ dest_files=["res://.godot/imported/Walk 5.png-cfb8eb15ace876127c083283fe74cdc0.c compress/mode=0 compress/high_quality=false compress/lossy_quality=0.7 +compress/uastc_level=0 +compress/rdo_quality_loss=0.0 compress/hdr_compression=1 compress/normal_map=0 compress/channel_pack=0 @@ -25,6 +27,10 @@ mipmaps/generate=false mipmaps/limit=-1 roughness/mode=0 roughness/src_normal="" +process/channel_remap/red=0 +process/channel_remap/green=1 +process/channel_remap/blue=2 +process/channel_remap/alpha=3 process/fix_alpha_border=true process/premult_alpha=false process/normal_map_invert_y=false diff --git a/player/Player_Walk/Walk 6.png.import b/player/Player_Walk/Walk 6.png.import index 22d7868..5b2bdef 100644 --- a/player/Player_Walk/Walk 6.png.import +++ b/player/Player_Walk/Walk 6.png.import @@ -18,6 +18,8 @@ dest_files=["res://.godot/imported/Walk 6.png-f243f98e182be67eb8681a11d34ee554.c compress/mode=0 compress/high_quality=false compress/lossy_quality=0.7 +compress/uastc_level=0 +compress/rdo_quality_loss=0.0 compress/hdr_compression=1 compress/normal_map=0 compress/channel_pack=0 @@ -25,6 +27,10 @@ mipmaps/generate=false mipmaps/limit=-1 roughness/mode=0 roughness/src_normal="" +process/channel_remap/red=0 +process/channel_remap/green=1 +process/channel_remap/blue=2 +process/channel_remap/alpha=3 process/fix_alpha_border=true process/premult_alpha=false process/normal_map_invert_y=false diff --git a/project.godot b/project.godot index 6f8803f..5b573d4 100644 --- a/project.godot +++ b/project.godot @@ -12,7 +12,7 @@ config_version=5 config/name="The Dark Side of Earth" run/main_scene="uid://cxo6bq26huau7" -config/features=PackedStringArray("4.4", "Forward Plus") +config/features=PackedStringArray("4.5", "Forward Plus") config/icon="res://icon.svg" [display] From 5658b577490929367117e975e5b347a656bc1d4a Mon Sep 17 00:00:00 2001 From: Florian Date: Wed, 17 Sep 2025 14:39:22 +0200 Subject: [PATCH 3/3] Made hp bar aware of max hp --- healthbar/healthbar.gd | 28 +++++++++++++++++++++++++--- item_ui/item_ui.tscn | 22 ++++++++++++++++++---- main.tscn | 10 +++++++--- player/player.gd | 10 +++++++++- 4 files changed, 59 insertions(+), 11 deletions(-) diff --git a/healthbar/healthbar.gd b/healthbar/healthbar.gd index 5566861..8a9f530 100644 --- a/healthbar/healthbar.gd +++ b/healthbar/healthbar.gd @@ -1,11 +1,13 @@ extends HBoxContainer -@export var initial_health : int = 5 @export var packedHeart : PackedScene; +var current_max_hp = 0 +var current_health = 0 func _ready() -> void: - for i in range(initial_health): - add_child(packedHeart.instantiate()) + #for i in range(initial_health): + #add_child(packedHeart.instantiate()) + pass func set_health(health : int): var i = 0 @@ -15,7 +17,27 @@ func set_health(health : int): heart.restore() else: heart.fade() + current_health = health +func set_maxhealth(new_max_hp : int): + if new_max_hp > current_max_hp: + for i in range(new_max_hp - current_max_hp): + add_child(packedHeart.instantiate()) + elif new_max_hp < current_max_hp: + var children = get_children() + for i in range(children.size()): + if new_max_hp < i+1: + children[i].queue_free() + current_health = min(current_health, current_max_hp) + else: pass + + current_max_hp = new_max_hp + set_health(current_max_hp) + func _on_player_health_changed(new_health: int) -> void: set_health(new_health) + + +func _on_player_max_hp_changed(new_max_hp: int) -> void: + set_maxhealth(new_max_hp) diff --git a/item_ui/item_ui.tscn b/item_ui/item_ui.tscn index e690fdf..1f2de90 100644 --- a/item_ui/item_ui.tscn +++ b/item_ui/item_ui.tscn @@ -1,4 +1,6 @@ -[gd_scene load_steps=2 format=3 uid="uid://73g8y37skebh"] +[gd_scene load_steps=3 format=3 uid="uid://73g8y37skebh"] + +[ext_resource type="Texture2D" uid="uid://cy70quh6k3s1j" path="res://icon.svg" id="1_lfuq2"] [sub_resource type="StyleBoxFlat" id="StyleBoxFlat_8oq0s"] draw_center = false @@ -13,11 +15,23 @@ corner_radius_top_right = 50 corner_radius_bottom_right = 50 corner_radius_bottom_left = 50 -[node name="ItemUI" type="PanelContainer"] +[node name="ItemUI" type="MarginContainer"] anchors_preset = 1 anchor_left = 1.0 anchor_right = 1.0 -offset_left = -100.0 -offset_bottom = 100.0 +offset_left = -150.0 +offset_bottom = 150.0 grow_horizontal = 0 +theme_override_constants/margin_left = 25 +theme_override_constants/margin_top = 25 +theme_override_constants/margin_right = 25 +theme_override_constants/margin_bottom = 25 + +[node name="PanelContainer" type="PanelContainer" parent="."] +layout_mode = 2 theme_override_styles/panel = SubResource("StyleBoxFlat_8oq0s") + +[node name="TextureRect" type="TextureRect" parent="PanelContainer"] +layout_mode = 2 +texture = ExtResource("1_lfuq2") +expand_mode = 1 diff --git a/main.tscn b/main.tscn index 6791336..a818ccf 100644 --- a/main.tscn +++ b/main.tscn @@ -1,13 +1,14 @@ -[gd_scene load_steps=10 format=3 uid="uid://cxo6bq26huau7"] +[gd_scene load_steps=11 format=3 uid="uid://cxo6bq26huau7"] [ext_resource type="PackedScene" uid="uid://cmaovvr15b3qk" path="res://player/player.tscn" id="2_1bvp3"] [ext_resource type="Script" uid="uid://vgxh2xdevat7" path="res://world/earth.gd" id="2_lquwl"] [ext_resource type="PackedScene" uid="uid://jjoyj1ldafkf" path="res://world/earth.tscn" id="3_lquwl"] [ext_resource type="Script" uid="uid://colvx6wq0e8n7" path="res://world/building_generator.gd" id="4_1bvp3"] +[ext_resource type="PackedScene" uid="uid://73g8y37skebh" path="res://item_ui/item_ui.tscn" id="6_4c57u"] [ext_resource type="PackedScene" uid="uid://cjsrtswk4vgf2" path="res://healthbar/healthbar.tscn" id="6_7mycd"] [ext_resource type="PackedScene" uid="uid://dpdn2php3ydsv" path="res://death_screen/death_screen.tscn" id="7_5vw27"] -[ext_resource type="PackedScene" path="res://utils/platform.tscn" id="7_272bh"] -[ext_resource type="PackedScene" path="res://items/healthup.tscn" id="9_4c57u"] +[ext_resource type="PackedScene" uid="uid://4l3elvxpghw8" path="res://utils/platform.tscn" id="7_272bh"] +[ext_resource type="PackedScene" uid="uid://gwctb2xqsbj" path="res://items/healthup.tscn" id="9_4c57u"] [ext_resource type="PackedScene" uid="uid://chu67ci7sl488" path="res://enemies/ghost.tscn" id="9_kek77"] [node name="main" type="Node2D"] @@ -42,6 +43,8 @@ autostart = true offset_right = 128.0 offset_bottom = 128.0 +[node name="ItemUI" parent="CanvasLayer" instance=ExtResource("6_4c57u")] + [node name="DeathScreen" parent="CanvasLayer" instance=ExtResource("7_5vw27")] visible = false @@ -56,6 +59,7 @@ position = Vector2(0, -3000) position = Vector2(0, -3100) [connection signal="health_changed" from="Player" to="CanvasLayer/Healthbar" method="_on_player_health_changed"] +[connection signal="max_hp_changed" from="Player" to="CanvasLayer/Healthbar" method="_on_player_max_hp_changed"] [connection signal="player_died" from="Player" to="CanvasLayer/DeathScreen" method="_on_player_player_died"] [connection signal="timeout" from="Building Generator/Timer" to="Building Generator" method="_on_timer_timeout"] [connection signal="visibility_changed" from="CanvasLayer/DeathScreen" to="Player" method="_on_death_screen_visibility_changed"] diff --git a/player/player.gd b/player/player.gd index 0193ec2..ca76900 100644 --- a/player/player.gd +++ b/player/player.gd @@ -22,13 +22,17 @@ var air_jumps_current = 1; # HP and Iframes signal health_changed(new_health : int) +signal max_hp_changed(new_max_hp : int) signal player_died var current_hp = 5: set(new_hp): current_hp = new_hp health_changed.emit(current_hp) -var max_hp = 5; +var max_hp = 5: + set(new_max_hp): + max_hp = new_max_hp + max_hp_changed.emit(max_hp) var hit_invulnerability = 0.5 var inv_time = 0; var dead = false; @@ -46,6 +50,10 @@ var atk_timer = 0 var active_item = null var item_cooldown = 0 +func _ready() -> void: + max_hp_changed.emit(max_hp) + health_changed.emit(current_hp) + func _physics_process(delta: float) -> void: manage_iframes(delta) manage_movement_options()