Plus de feux rouges et des portes qui vont vivre

Et oui du nouveau encore!
This commit is contained in:
Thomas
2025-02-24 21:44:52 +01:00
parent 725584c477
commit 65a74f0845
14 changed files with 4212 additions and 97 deletions

View File

@@ -0,0 +1,29 @@
extends Node2D
class_name LightSemaphore
@export var dependantSemaphore : LightSemaphore = null
@export var hasOwnTimerEnabled = true
@onready var lights := [$Sempahore/green, $Sempahore/yellow, $Sempahore/red ];
var light = 0;
func _ready() -> void:
$brakeZone.get_child(1).disabled = !light;
func change_light():
light += 1;
if light > 2:
light = 0;
$brakeZone.get_child(1).disabled = !light;
for i in range (lights.size()):
lights[i].visible = i == light
func _on_timer_timeout() -> void:
if hasOwnTimerEnabled:
if light == 0:
$Timer.wait_time = 1;
else:
$Timer.wait_time = 5;
$Timer.start()
change_light();
if dependantSemaphore:
dependantSemaphore.change_light();