brackeys-12/meter.gd

33 lines
818 B
GDScript3
Raw Permalink Normal View History

2024-09-15 08:43:56 +00:00
extends TextureRect
@onready var globals = Data.data.globals
@onready var flood_levels = globals.flood_levels
var start_pos = Vector2(9, 5)
const FLOOD_ICON = preload("res://FloodIcon.tscn")
@onready var texture_rect_2: TextureRect = $TextureRect2
var flood_icons = []
func _ready() -> void:
var i = 0
for level in flood_levels:
var new_flood_icon = FLOOD_ICON.instantiate()
new_flood_icon.position = start_pos + Vector2(i * 30, 0)
new_flood_icon.text = level
flood_icons.push_back(new_flood_icon)
texture_rect_2.add_child(new_flood_icon)
i += 1
func _process(delta: float) -> void:
var i = 0
for flood_icon in flood_icons:
flood_icon.position = start_pos + Vector2(i * 30 - (Persister.get_value("game_time", PersisterEnums.Scope.UNKNOWN, 0) / 1000.0 * 30.0 / 25.0), 0)
i += 1