Bladeren bron

Previent le joueur quand il a perdu

DricomDragon 11 maanden geleden
bovenliggende
commit
fa33b83137

+ 25 - 0
godot/composants/interface/gagne/gagne.tscn

@@ -0,0 +1,25 @@
+[gd_scene format=3 uid="uid://byxtc8f6n5o3"]
+
+[node name="Gagne" type="Control"]
+layout_mode = 3
+anchors_preset = 15
+anchor_right = 1.0
+anchor_bottom = 1.0
+grow_horizontal = 2
+grow_vertical = 2
+
+[node name="Bravo" type="Label" parent="."]
+layout_mode = 1
+anchors_preset = 8
+anchor_left = 0.5
+anchor_top = 0.5
+anchor_right = 0.5
+anchor_bottom = 0.5
+offset_left = -31.5
+offset_top = -11.5
+offset_right = 31.5
+offset_bottom = 11.5
+grow_horizontal = 2
+grow_vertical = 2
+theme_override_font_sizes/font_size = 80
+text = "Bravo !"

+ 25 - 0
godot/composants/interface/perdu/perdu.tscn

@@ -0,0 +1,25 @@
+[gd_scene format=3 uid="uid://mj0r0qodppdk"]
+
+[node name="Perdu" type="Control"]
+layout_mode = 3
+anchors_preset = 15
+anchor_right = 1.0
+anchor_bottom = 1.0
+grow_horizontal = 2
+grow_vertical = 2
+
+[node name="OhNon" type="Label" parent="."]
+layout_mode = 1
+anchors_preset = 8
+anchor_left = 0.5
+anchor_top = 0.5
+anchor_right = 0.5
+anchor_bottom = 0.5
+offset_left = -31.5
+offset_top = -11.5
+offset_right = 31.5
+offset_bottom = 11.5
+grow_horizontal = 2
+grow_vertical = 2
+theme_override_font_sizes/font_size = 40
+text = "Partie perdue ..."

+ 10 - 0
godot/composants/objets/lanceur/lanceur.gd

@@ -1,14 +1,24 @@
 extends Node2D
 
 
+signal partie_perdue
+
 const SceneBalle = preload("res://composants/objets/balle/balle.tscn")
 
+## Quand il ne reste plus de balle, la partie est perdue !
+@export_range(1, 10) var nombre_de_balles: int = 1
+
 
 func _ready() -> void:
 	lancer_balle()
 
 
 func lancer_balle() -> void:
+	if nombre_de_balles <= 0:
+		partie_perdue.emit()
+		return # on ne lance pas la balle
+
+	nombre_de_balles -= 1
 	var nouvelle_balle: Balle = SceneBalle.instantiate()
 	add_child.call_deferred(nouvelle_balle) # Appeler plus tard sinon Godot pas content
 

+ 16 - 1
godot/exec/niveaux/carre_simple.tscn

@@ -1,9 +1,10 @@
-[gd_scene load_steps=5 format=3 uid="uid://cyyb8weydthjc"]
+[gd_scene load_steps=6 format=3 uid="uid://cyyb8weydthjc"]
 
 [ext_resource type="PackedScene" uid="uid://cpo1b44exbbyf" path="res://composants/objets/raquette/raquette.tscn" id="1_dbta1"]
 [ext_resource type="PackedScene" uid="uid://brd8yid3l7wgm" path="res://composants/objets/brique/brique.tscn" id="2_j0emn"]
 [ext_resource type="PackedScene" uid="uid://cux4pm68s7pr8" path="res://composants/objets/lanceur/lanceur.tscn" id="2_s5baa"]
 [ext_resource type="PackedScene" uid="uid://b28d5a4be36qa" path="res://composants/objets/arene/arene.tscn" id="4_imfht"]
+[ext_resource type="PackedScene" uid="uid://mj0r0qodppdk" path="res://composants/interface/perdu/perdu.tscn" id="5_4gti5"]
 
 [node name="CarreSimple" type="Node2D"]
 
@@ -12,6 +13,7 @@ position = Vector2(210, 400)
 
 [node name="Lanceur" parent="." instance=ExtResource("2_s5baa")]
 position = Vector2(195, 144)
+nombre_de_balles = 2
 
 [node name="Briques" type="Node2D" parent="."]
 
@@ -141,4 +143,17 @@ pouvoir_type = 0
 [node name="Arene" parent="." instance=ExtResource("4_imfht")]
 metadata/_edit_lock_ = true
 
+[node name="Message" type="PanelContainer" parent="."]
+visible = false
+offset_left = 20.0
+offset_top = 20.0
+offset_right = 400.0
+offset_bottom = 400.0
+
+[node name="Perdu" parent="Message" instance=ExtResource("5_4gti5")]
+visible = false
+layout_mode = 2
+
+[connection signal="partie_perdue" from="Lanceur" to="Message/Perdu" method="show"]
+[connection signal="partie_perdue" from="Lanceur" to="Message" method="show"]
 [connection signal="balle_detruite" from="Arene" to="Lanceur" method="_quand_balle_detruite"]