2025-05-12 17:10:37 +10:00
|
|
|
extends Node
|
|
|
|
|
|
2025-05-16 22:13:34 +10:00
|
|
|
signal game_win
|
|
|
|
|
signal game_lose
|
|
|
|
|
|
2025-05-17 17:26:28 +10:00
|
|
|
@export var grace : float = 3
|
|
|
|
|
@export var reaction_window : float = 1.5
|
2025-05-12 17:10:37 +10:00
|
|
|
@export_group("Node References")
|
|
|
|
|
@export var prepare_node : Control
|
|
|
|
|
@export var press_node : Control
|
|
|
|
|
var time_remaining : float
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Called when the node enters the scene tree for the first time.
|
|
|
|
|
func _ready() -> void:
|
|
|
|
|
time_remaining = randf_range(5,15)
|
|
|
|
|
pass # Replace with function body.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
|
|
|
|
func _process(delta: float) -> void:
|
|
|
|
|
time_remaining -= delta
|
2025-05-17 17:26:28 +10:00
|
|
|
grace -= delta
|
2025-05-12 17:10:37 +10:00
|
|
|
prepare_node.visible = time_remaining > 0
|
|
|
|
|
press_node.visible = time_remaining <= 0
|
|
|
|
|
if(time_remaining <= 0):
|
|
|
|
|
reaction_window -= delta
|
|
|
|
|
if(Input.is_action_just_pressed("reaction_press")):
|
|
|
|
|
if(time_remaining<=0 and reaction_window > 0):
|
2025-05-17 17:20:23 +10:00
|
|
|
print("reaction win")
|
|
|
|
|
game_win.emit()
|
2025-05-12 17:10:37 +10:00
|
|
|
#winner
|
|
|
|
|
else:
|
2025-05-17 17:26:28 +10:00
|
|
|
if(grace <= 0):
|
|
|
|
|
print("reaction lose")
|
|
|
|
|
game_lose.emit()
|
|
|
|
|
#loser
|
2025-05-17 17:20:23 +10:00
|
|
|
if(reaction_window <= 0):
|
|
|
|
|
print("reaction lose")
|
|
|
|
|
game_lose.emit()
|