before fog of war
This commit is contained in:
@@ -24,6 +24,7 @@ var level_start_time: float = 0.0
|
||||
var player_search_attempts: int = 0
|
||||
var max_player_search_attempts: int = 100 # Limit retries to prevent infinite recursion
|
||||
var timer_running: bool = true # Flag to stop/start timer
|
||||
const HUD_BASE_SIZE: Vector2 = Vector2(1280, 720)
|
||||
|
||||
func _ready():
|
||||
print("IngameHUD: _ready() called")
|
||||
@@ -80,6 +81,10 @@ func _ready():
|
||||
# Start level timer
|
||||
level_start_time = Time.get_ticks_msec() / 1000.0
|
||||
|
||||
# Keep HUD text crisp with integer scaling
|
||||
_update_hud_scale()
|
||||
get_viewport().size_changed.connect(_update_hud_scale)
|
||||
|
||||
# Find local player (with retry limit)
|
||||
player_search_attempts = 0
|
||||
_find_local_player()
|
||||
@@ -184,6 +189,14 @@ func _process(_delta):
|
||||
# Update boss health (if boss exists)
|
||||
_update_boss_health()
|
||||
|
||||
func _update_hud_scale():
|
||||
# Scale HUD to an integer factor to keep pixel text crisp
|
||||
var viewport_size = get_viewport().get_visible_rect().size
|
||||
var scale_factor = int(floor(min(viewport_size.x / HUD_BASE_SIZE.x, viewport_size.y / HUD_BASE_SIZE.y)))
|
||||
if scale_factor < 1:
|
||||
scale_factor = 1
|
||||
scale = Vector2.ONE * scale_factor
|
||||
|
||||
func _update_player_health():
|
||||
if not local_player or not texture_progress_bar_hp:
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user