#13 inventaire fonctionnel

This commit is contained in:
Altaezio
2025-08-03 19:38:46 +02:00
parent 06519e9c7a
commit e76e51b4e2
20 changed files with 130 additions and 20 deletions

View File

@@ -60,3 +60,11 @@ text = "0"
label_settings = SubResource("LabelSettings_bye71")
horizontal_alignment = 1
vertical_alignment = 1
[node name="Inventory" type="HBoxContainer" parent="."]
layout_mode = 0
offset_left = 157.0
offset_top = 86.0
offset_right = 291.0
offset_bottom = 126.0
alignment = 1

View File

@@ -1,4 +1,12 @@
extends Control
func _on_root_gui_player_stats_updated(player:Player):
func _on_root_gui_player_updated(player: Player):
$EnergyInfo/Label.text = str(player.energy)
var children = $Inventory.get_children()
for child in children:
child.free()
for item in player.inventory.items:
var item_rect = TextureRect.new()
item_rect.texture = item.icon
$Inventory.add_child(item_rect)

View File

@@ -24,4 +24,4 @@ offset_bottom = 160.0
grow_horizontal = 1
grow_vertical = 1
[connection signal="player_stats_updated" from="." to="PlayerInfo" method="_on_root_gui_player_stats_updated"]
[connection signal="player_updated" from="." to="PlayerInfo" method="_on_root_gui_player_updated"]

View File

@@ -1,7 +1,7 @@
extends Control
class_name RootGui
signal player_stats_updated(player : Player)
signal player_updated(player: Player)
func _on_player_player_stats_updated(player:Player):
emit_signal("player_stats_updated", player)
func _on_player_player_updated(player: Player):
emit_signal("player_updated", player)