Des feux rouges!

Pour arrêter les voiture vroom vroom
This commit is contained in:
Thomas
2025-02-24 18:09:33 +01:00
parent 3ba18fbddf
commit 725584c477
14 changed files with 427 additions and 15 deletions

View File

@@ -0,0 +1,73 @@
[gd_scene load_steps=8 format=4 uid="uid://bmunphhwcsl3a"]
[ext_resource type="Script" path="res://urban_furnitures/high_semaphore.gd" id="2_nih7h"]
[ext_resource type="TileSet" uid="uid://ckj00wy20rkfx" path="res://assest/tilesets/exterieur.tres" id="3_ulyk6"]
[ext_resource type="PackedScene" uid="uid://brh7cqaxc13ie" path="res://zindex/ZIndexControler.tscn" id="4_k52t8"]
[ext_resource type="PackedScene" uid="uid://dpyadhlqawviq" path="res://vehicules/brakeZone.tscn" id="5_o0gjx"]
[sub_resource type="CircleShape2D" id="CircleShape2D_4c8ro"]
radius = 15.0
[sub_resource type="RectangleShape2D" id="RectangleShape2D_36vt6"]
size = Vector2(20, 3)
[sub_resource type="RectangleShape2D" id="RectangleShape2D_y0214"]
size = Vector2(200, 95.5)
[node name="Node2D" type="Node2D"]
script = ExtResource("2_nih7h")
[node name="Sempahore" type="StaticBody2D" parent="."]
[node name="abovePart" type="TileMapLayer" parent="Sempahore"]
z_index = 2000
tile_map_data = PackedByteArray("AAAAAPv/BAAXAH0AAAAAAPz/BAAXAH4AAAABAPv/BAAYAH0AAAABAPz/BAAYAH4AAAACAPv/BAAZAH0AAAACAPz/BAAZAH4AAAA=")
tile_set = ExtResource("3_ulyk6")
[node name="red" type="TileMapLayer" parent="Sempahore/abovePart"]
z_index = 2000
tile_map_data = PackedByteArray("AAABAPv/BAAKAIgAAAABAPz/BAAKAIkAAAACAPv/BAALAIgAAAACAPz/BAALAIkAAAA=")
tile_set = ExtResource("3_ulyk6")
[node name="yellow" type="TileMapLayer" parent="Sempahore/abovePart"]
z_index = 2000
tile_map_data = PackedByteArray("AAABAPv/BAAKAIgAAAABAPz/BAAKAIkAAAACAPv/BAALAIgAAAACAPz/BAALAIkAAAA=")
tile_set = ExtResource("3_ulyk6")
[node name="green" type="TileMapLayer" parent="Sempahore/abovePart"]
z_index = 2000
tile_map_data = PackedByteArray("AAABAPv/BAAKAIgAAAABAPz/BAAKAIkAAAACAPv/BAALAIgAAAACAPz/BAALAIkAAAA=")
tile_set = ExtResource("3_ulyk6")
[node name="CollisionShape2D" type="CollisionShape2D" parent="Sempahore"]
position = Vector2(20, -15)
shape = SubResource("CircleShape2D_4c8ro")
[node name="pylon" type="TileMapLayer" parent="Sempahore"]
tile_map_data = PackedByteArray("AAAAAP3/BAATAH8AAAAAAP7/BAATAIAAAAAAAP//BAATAIEAAAA=")
tile_set = ExtResource("3_ulyk6")
[node name="ZIndexControler" parent="Sempahore" instance=ExtResource("4_k52t8")]
position = Vector2(-2, 6)
[node name="ShapeCast2D" type="ShapeCast2D" parent="Sempahore/ZIndexControler"]
position = Vector2(21, -15)
shape = SubResource("RectangleShape2D_36vt6")
target_position = Vector2(-2, -125)
[node name="Timer" type="Timer" parent="."]
wait_time = 5.0
one_shot = true
autostart = true
[node name="Label" type="Label" parent="."]
offset_right = 40.0
offset_bottom = 23.0
[node name="brakeZone" parent="." instance=ExtResource("5_o0gjx")]
[node name="CollisionShape2D2" type="CollisionShape2D" parent="brakeZone"]
position = Vector2(-75, -75.25)
shape = SubResource("RectangleShape2D_y0214")
[connection signal="timeout" from="Timer" to="." method="_on_timer_timeout"]

View File

@@ -13,12 +13,18 @@ size = Vector2(20, 3)
[node name="toit" type="TileMapLayer" parent="."]
z_index = 2000
tile_map_data = PackedByteArray("AAD9//3/BAAQAH8AAAD+//z/BAARAH4AAAD+//3/BAARAH8AAAD///v/BAASAH0AAAD///z/BAASAH4AAAD///3/BAASAH8AAAAAAPv/BAATAH0AAAAAAPz/BAATAH4AAAA=")
tile_map_data = PackedByteArray("AAD9//3/BAAQAH8AAAD+//z/BAARAH4AAAD///v/BAASAH0AAAD///z/BAASAH4AAAD///3/BAASAH8AAAAAAPv/BAATAH0AAAAAAPz/BAATAH4AAAD+//3/BAARAH8AAAA=")
tile_set = ExtResource("1_7l72r")
[node name="TileMapLayer2" type="TileMapLayer" parent="toit"]
z_index = 2000
tile_map_data = PackedByteArray("AAD+//3/BAAUAH0AAAD+//7/BAAUAH4AAAA=")
tile_map_data = PackedByteArray("AAD+//3/BAALAH0AAAD+//7/BAALAH4AAAA=")
tile_set = ExtResource("1_7l72r")
[node name="TileMapLayer3" type="TileMapLayer" parent="toit"]
z_index = 2000
position = Vector2(48, -27)
tile_map_data = PackedByteArray("AAD+//3/BAAVAH0AAAD+//7/BAAVAH4AAAA=")
tile_set = ExtResource("1_7l72r")
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]

View File

@@ -0,0 +1,69 @@
[gd_scene load_steps=8 format=4 uid="uid://c6nlrmhu8362v"]
[ext_resource type="Script" path="res://urban_furnitures/high_semaphore.gd" id="1_1ufoq"]
[ext_resource type="TileSet" uid="uid://ckj00wy20rkfx" path="res://assest/tilesets/exterieur.tres" id="1_03yma"]
[ext_resource type="PackedScene" uid="uid://brh7cqaxc13ie" path="res://zindex/ZIndexControler.tscn" id="2_hhwk3"]
[ext_resource type="PackedScene" uid="uid://dpyadhlqawviq" path="res://vehicules/brakeZone.tscn" id="4_j5rhp"]
[sub_resource type="CircleShape2D" id="CircleShape2D_4c8ro"]
radius = 15.0
[sub_resource type="RectangleShape2D" id="RectangleShape2D_36vt6"]
size = Vector2(20, 3)
[sub_resource type="RectangleShape2D" id="RectangleShape2D_4glgt"]
size = Vector2(200, 102)
[node name="Node2D" type="Node2D"]
script = ExtResource("1_1ufoq")
[node name="Sempahore" type="StaticBody2D" parent="."]
[node name="abovePart" type="TileMapLayer" parent="Sempahore"]
z_index = 2000
tile_map_data = PackedByteArray("AAD9//3/BAAQAH8AAAD+//z/BAARAH4AAAD+//3/BAARAH8AAAD///v/BAASAH0AAAD///z/BAASAH4AAAD///3/BAASAH8AAAAAAPv/BAATAH0AAAAAAPz/BAATAH4AAAA=")
tile_set = ExtResource("1_03yma")
[node name="red" type="TileMapLayer" parent="Sempahore/abovePart"]
z_index = 2000
tile_map_data = PackedByteArray("AAD+//3/BAAOAH0AAAD+//7/BAAOAH4AAAD///3/BAAPAH0AAAA=")
tile_set = ExtResource("1_03yma")
[node name="yellow" type="TileMapLayer" parent="Sempahore/abovePart"]
z_index = 2000
tile_map_data = PackedByteArray("AAD+//3/BAAOAH8AAAD+//7/BAAOAIAAAAD///3/BAAPAH8AAAA=")
tile_set = ExtResource("1_03yma")
[node name="green" type="TileMapLayer" parent="Sempahore/abovePart"]
z_index = 2000
tile_map_data = PackedByteArray("AAD+//3/BAAOAIEAAAD+//7/BAAOAIIAAAD///3/BAAPAIEAAAA=")
tile_set = ExtResource("1_03yma")
[node name="CollisionShape2D" type="CollisionShape2D" parent="Sempahore"]
position = Vector2(20, -15)
shape = SubResource("CircleShape2D_4c8ro")
[node name="pylon" type="TileMapLayer" parent="Sempahore"]
tile_map_data = PackedByteArray("AAAAAP3/BAATAH8AAAAAAP7/BAATAIAAAAAAAP//BAATAIEAAAA=")
tile_set = ExtResource("1_03yma")
[node name="ZIndexControler" parent="Sempahore" instance=ExtResource("2_hhwk3")]
position = Vector2(-2, 6)
[node name="ShapeCast2D" type="ShapeCast2D" parent="Sempahore/ZIndexControler"]
position = Vector2(21, -15)
shape = SubResource("RectangleShape2D_36vt6")
target_position = Vector2(-2, -125)
[node name="brakeZone" parent="." instance=ExtResource("4_j5rhp")]
[node name="CollisionShape2D3" type="CollisionShape2D" parent="brakeZone"]
position = Vector2(110, 66)
shape = SubResource("RectangleShape2D_4glgt")
[node name="Timer" type="Timer" parent="."]
wait_time = 5.0
one_shot = true
autostart = true
[connection signal="timeout" from="Timer" to="." method="_on_timer_timeout"]

View File

@@ -0,0 +1,29 @@
extends Node2D
class_name LightSemaphore
@export var dependantSemaphore : LightSemaphore = null
@export var hasOwnTimerEnabled = true
@onready var lights := [$Sempahore/abovePart/green, $Sempahore/abovePart/yellow, $Sempahore/abovePart/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();