significant work on game logic

This commit is contained in:
2025-03-21 17:24:21 -04:00
parent d080ac5c3b
commit 0f4083a263
19 changed files with 360 additions and 9 deletions

View File

@@ -8,7 +8,7 @@ func _physics_process(_delta: float) -> void:
Controls where the camera is pointed based on which player is selected
'''
target_angle = abs(GLOBALVARS.selected_player) * 90
target_angle = (abs(GLOBALVARS.selected_player) * 90)
if current_angle != target_angle:
current_angle += 0.1*(target_angle-current_angle)

View File

@@ -0,0 +1,40 @@
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

View File

@@ -0,0 +1 @@
uid://clwubcfa7jndm

View File

@@ -1,3 +1,14 @@
extends Node
var selected_player:int = 0
var seconds_left:float = 0.0
var difficulty:int = 1
var rotation_paused:bool = false
var players_remaining:Array = [0,1,2,3]
func reset_variables() -> void:
selected_player = 0
seconds_left = 5.0
difficulty = 1
rotation_paused = false
players_remaining = [0,1,2,3]

View File

@@ -1 +1,6 @@
extends Node
func _on_start_button_pressed() -> void:
GLOBALVARS.reset_variables()
get_tree().change_scene_to_file("res://main_scenes/game.tscn")

View File

@@ -0,0 +1,40 @@
extends Node3D
static var FUSE_SOUND:AudioStream = preload("res://assets/sounds/fuse.ogg")
static var EXPLOSION_SOUND:AudioStream = preload("res://assets/sounds/explode.wav")
var grow_explosion:bool = false
func reset_rule_enforcement_device() -> void:
'''
Start the fuse sound
'''
%SOUNDS.stream = FUSE_SOUND
%SOUNDS.volume_db = -10
%SOUNDS.play()
visible = true
%EXPLOSION.visible = false
grow_explosion = false
%EXPLOSION.scale = Vector3(0.355,0.355,0.355)
func explode() -> void:
'''
Make the rule enforcement device go boom
'''
%SOUNDS.stream = EXPLOSION_SOUND
%SOUNDS.volume_db = 0
%SOUNDS.play()
grow_explosion = true
%EXPLOSION.visible = true
func _ready() -> void:
reset_rule_enforcement_device()
func _process(_delta: float) -> void:
%TIME_LEFT.text = ("%.02f" % GLOBALVARS.seconds_left).replace(".",":")
if grow_explosion and %EXPLOSION.scale < Vector3(3,3,3):
%EXPLOSION.scale += Vector3(0.2,0.2,0.2)
elif grow_explosion:
%EXPLOSION.visible = false
visible = false

View File

@@ -0,0 +1 @@
uid://cs6veeykw6tfv