Kaynağa Gözat

Permet a une brique d'avoir plusieurs vies

DricomDragon 11 ay önce
ebeveyn
işleme
fdbc9ccc57

+ 9 - 1
godot/composants/objets/brique/brique.gd

@@ -4,8 +4,16 @@ extends StaticBody2D
 
 const EclatementScene: PackedScene = preload("res://effets/eclatement_brique/eclatement_brique.tscn")
 
+@export var nombre_de_vies: int = 1
 
-func frapper(nb: int) -> void:
+
+func frapper(nb_degats: int) -> void:
+	nombre_de_vies -= nb_degats
+	if nombre_de_vies <= 0:
+		_mourir()
+
+
+func _mourir() -> void:
 	queue_free()
 	var effet_eclatement: Node2D = EclatementScene.instantiate()
 	effet_eclatement.position = self.position

+ 6 - 42
godot/exec/niveaux/carre_simple.tscn

@@ -74,65 +74,29 @@ position = Vector2(240, 96)
 [node name="Brique20" parent="Briques" instance=ExtResource("2_j0emn")]
 position = Vector2(270, 96)
 
-[node name="Brique21" parent="Briques" instance=ExtResource("2_j0emn")]
-position = Vector2(0, 16)
-
-[node name="Brique22" parent="Briques" instance=ExtResource("2_j0emn")]
-position = Vector2(30, 16)
-
-[node name="Brique23" parent="Briques" instance=ExtResource("2_j0emn")]
-position = Vector2(60, 16)
-
-[node name="Brique24" parent="Briques" instance=ExtResource("2_j0emn")]
-position = Vector2(90, 16)
-
-[node name="Brique25" parent="Briques" instance=ExtResource("2_j0emn")]
-position = Vector2(120, 16)
-
-[node name="Brique26" parent="Briques" instance=ExtResource("2_j0emn")]
-position = Vector2(150, 16)
-
-[node name="Brique27" parent="Briques" instance=ExtResource("2_j0emn")]
-position = Vector2(180, 16)
-
-[node name="Brique28" parent="Briques" instance=ExtResource("2_j0emn")]
-position = Vector2(210, 16)
-
-[node name="Brique29" parent="Briques" instance=ExtResource("2_j0emn")]
-position = Vector2(240, 16)
-
-[node name="Brique30" parent="Briques" instance=ExtResource("2_j0emn")]
-position = Vector2(270, 16)
-
-[node name="Brique31" parent="Briques" instance=ExtResource("2_j0emn")]
-position = Vector2(300, 16)
-
-[node name="Brique32" parent="Briques" instance=ExtResource("2_j0emn")]
-position = Vector2(330, 16)
-
-[node name="Brique33" parent="Briques" instance=ExtResource("2_j0emn")]
-position = Vector2(360, 16)
-
-[node name="Brique34" parent="Briques" instance=ExtResource("2_j0emn")]
-position = Vector2(390, 16)
-
 [node name="Brique35" parent="Briques" instance=ExtResource("2_j0emn")]
 position = Vector2(120, 112)
+nombre_de_vies = 2
 
 [node name="Brique36" parent="Briques" instance=ExtResource("2_j0emn")]
 position = Vector2(150, 112)
+nombre_de_vies = 2
 
 [node name="Brique37" parent="Briques" instance=ExtResource("2_j0emn")]
 position = Vector2(180, 112)
+nombre_de_vies = 2
 
 [node name="Brique38" parent="Briques" instance=ExtResource("2_j0emn")]
 position = Vector2(210, 112)
+nombre_de_vies = 2
 
 [node name="Brique39" parent="Briques" instance=ExtResource("2_j0emn")]
 position = Vector2(240, 112)
+nombre_de_vies = 2
 
 [node name="Brique40" parent="Briques" instance=ExtResource("2_j0emn")]
 position = Vector2(270, 112)
+nombre_de_vies = 2
 
 [node name="Arene" parent="." instance=ExtResource("4_imfht")]
 metadata/_edit_lock_ = true