The speedrun timer, can now be paused (not fullgame marathons tho, cause uhhhhh yea)

This commit is contained in:
JHDev2006
2025-09-16 15:18:53 +01:00
parent e438354bf8
commit 2a26c6a7e7
4 changed files with 12 additions and 8 deletions

View File

@@ -507,7 +507,7 @@ func do_i_frames() -> void:
refresh_hitbox()
func die(pit := false) -> void:
if state_machine.state.name == "Dead" or state_machine.state.name == "Pipe":
if ["Dead", "Pipe", "LevelExit"].has(state_machine.state.name):
return
is_dead = true
visible = not pit

View File

@@ -12,6 +12,8 @@ var show_timer := false
signal level_finished
var paused_time := 0.0
var start_time := 0.0
const GHOST_RECORDING_TEMPLATE := {
@@ -147,12 +149,17 @@ const MEDAL_CONVERSIONS := [2, 1.5, 1]
func _ready() -> void:
process_mode = Node.PROCESS_MODE_ALWAYS
func _physics_process(_delta: float) -> void:
func _physics_process(delta: float) -> void:
if timer_active:
timer = abs(start_time - Time.get_ticks_msec()) / 1000
if Global.game_paused and Global.current_game_mode != Global.GameMode.MARATHON:
paused_time += delta
else:
timer = (abs(start_time - Time.get_ticks_msec()) / 1000) - paused_time
if enable_recording:
if get_tree().get_first_node_in_group("Players") != null:
record_frame(get_tree().get_first_node_in_group("Players"))
else:
paused_time = 0
Global.player_ghost.visible = ghost_visible
if ghost_active and ghost_enabled:
ghost_idx += 1
@@ -163,6 +170,7 @@ func _physics_process(_delta: float) -> void:
func start_timer() -> void:
timer = 0
paused_time = 0
timer_active = true
show_timer = true
start_time = Time.get_ticks_msec()

View File

@@ -28,8 +28,6 @@ func handle_inputs() -> void:
selected_index = clamp(selected_index, 0, options.size() - 1)
if Input.is_action_just_pressed("ui_accept"):
option_selected()
if Input.is_action_just_pressed("pause"):
close()
func option_selected() -> void:
emit_signal("option_" + str(selected_index + 1) + "_selected")