inventaire de 3 items #52

This commit is contained in:
Altaezio
2025-09-19 13:30:05 +02:00
parent 42edc97401
commit 88bfa71bd8
12 changed files with 216 additions and 28 deletions

View File

@@ -10,6 +10,24 @@ func _on_player_updated(player:Player):
%EnergyCount.text = str(player.energy) + "/" + str(player.max_energy)
%EnergyInfo.modulate = Color.WHITE if player.energy > 0 else Color.RED
for i in player.inventory.max_items:
var item : Item = player.inventory.get_item(i)
if item:
if %Inventory.get_child_count() <= i:
var texture_rect = TextureRect.new()
texture_rect.expand_mode = TextureRect.EXPAND_FIT_WIDTH_PROPORTIONAL
%Inventory.add_child(texture_rect)
%Inventory.get_child(i).texture = item.icon
%Inventory.get_child(i).visible = true
if i == player.inventory.current_item_ind:
%Inventory.get_child(i).modulate = Color.WHITE
else:
%Inventory.get_child(i).modulate = Color.DARK_GRAY
else:
if %Inventory.get_child_count() > i:
%Inventory.get_child(i).visible = false
update_no_energy_left_info(player.energy)
func _on_planet_updated(planet:Planet):