41 lines
1.3 KiB
GDScript
41 lines
1.3 KiB
GDScript
extends Node
|
|
|
|
var cooldown:int = 0
|
|
|
|
func _determine_seconds_left() -> float:
|
|
var difficulty_calc:float = 20/float(GLOBALVARS.difficulty)
|
|
return difficulty_calc if difficulty_calc >= 3.0 else 3.0
|
|
|
|
func _unhandled_key_input(event: InputEvent) -> void:
|
|
if event.is_action_pressed("enter"):
|
|
if GLOBALVARS.selected_player == 0:
|
|
pass # SUBMIT ANSWER
|
|
|
|
func _physics_process(_delta: float) -> void:
|
|
if not GLOBALVARS.rotation_paused:
|
|
GLOBALVARS.seconds_left -= 0.01666666667
|
|
|
|
if GLOBALVARS.seconds_left <= 0:
|
|
%RULE_ENFORCEMENT.explode()
|
|
cooldown = 60
|
|
GLOBALVARS.seconds_left = _determine_seconds_left()
|
|
GLOBALVARS.rotation_paused = true
|
|
if GLOBALVARS.selected_player in GLOBALVARS.players_remaining:
|
|
GLOBALVARS.players_remaining.erase(GLOBALVARS.selected_player)
|
|
get_node("players/player_%s" % GLOBALVARS.selected_player).queue_free()
|
|
|
|
if cooldown <= 0 and GLOBALVARS.rotation_paused:
|
|
if len(GLOBALVARS.players_remaining) > 1 and 0 in GLOBALVARS.players_remaining:
|
|
while GLOBALVARS.selected_player not in GLOBALVARS.players_remaining:
|
|
GLOBALVARS.selected_player = (GLOBALVARS.selected_player+1)%4
|
|
elif 0 in GLOBALVARS.players_remaining:
|
|
pass # WIN CONDITION
|
|
else:
|
|
pass # LOSE CONDITION
|
|
|
|
GLOBALVARS.rotation_paused = false
|
|
%RULE_ENFORCEMENT.reset_rule_enforcement_device()
|
|
|
|
elif GLOBALVARS.rotation_paused:
|
|
cooldown -= 1
|