1
0
Fork 0

Fixed temperature bar

Yan Wittmann 2025-01-11 13:15:28 +01:00
parent 5c0fc2beed
commit 7d5f91adcb
1 changed files with 18 additions and 19 deletions

View File

@ -63,27 +63,26 @@ func _on_game_tick_timeout() -> void:
func update_bars() -> void:
if health_bar != null:
health_bar.max_value = player.max_health
health_bar.value = clamp(player.health, 0, player.max_health)
$Camera2D/CanvasLayer/HealthLabel.text = str(player.health) + "/" + str(player.max_health)
$Camera2D/CanvasLayer/HealthLabel.add_theme_color_override("font_color", Color(1, 1, 1))
if health_bar != null:
health_bar.max_value = player.max_health
health_bar.value = clamp(player.health, 0, player.max_health)
$Camera2D/CanvasLayer/HealthLabel.text = str(health_bar.value) + "/" + str(player.max_health)
$Camera2D/CanvasLayer/HealthLabel.add_theme_color_override("font_color", Color(1, 1, 1))
if food_bar != null:
food_bar.max_value = player.max_food
food_bar.value = clamp(player.food, 0, player.max_food)
$Camera2D/CanvasLayer/FoodLabel.text = str(player.food) + "/" + str(player.max_food)
if food_bar != null:
food_bar.max_value = player.max_food
food_bar.value = clamp(player.food, 0, player.max_food)
$Camera2D/CanvasLayer/FoodLabel.text = str(food_bar.value) + "/" + str(player.max_food)
if temperature_bar != null:
var temperature_value: int = player.temperature_endure - player.temperature_timer
temperature_bar.max_value = player.temperature_endure
temperature_bar.value = clamp(temperature_value, 0, player.temperature_endure)
$Camera2D/CanvasLayer/TemperatureLabel.text = str(player.temperature_endure) + "/" + str(player.max_temperature)
if temperature_bar != null:
temperature_bar.max_value = player.temperature_set_buff_value
temperature_bar.value = clamp(player.temperature_buff_timer, 0, player.temperature_set_buff_value)
$Camera2D/CanvasLayer/TemperatureLabel.text = str(temperature_bar.value) + "/" + str(player.temperature_set_buff_value)
func toggle_temperature_layer() -> void:
if temperature_layer != null:
temperature_layer.visible = not temperature_layer.visible
print("TemperatureLayer visibility:", temperature_layer.visible)
else:
print("TemperatureLayer is null!")
if temperature_layer != null:
temperature_layer.visible = not temperature_layer.visible
print("TemperatureLayer visibility:", temperature_layer.visible)
else:
print("TemperatureLayer is null!")