Просмотр исходного кода

:tada: Termine le niveau sismique

DricomDragon 9 месяцев назад
Родитель
Сommit
d2486b49b0
2 измененных файлов с 135 добавлено и 4 удалено
  1. 15 3
      godot/composants/mouvements/ping_pong.gd
  2. 120 1
      godot/exec/niveaux/ping_pong.tscn

+ 15 - 3
godot/composants/mouvements/ping_pong.gd

@@ -3,16 +3,28 @@ class_name PingPong
 ## Pour descendre doucement un objet a vitesse constante
 
 
-const vitesse: float = 10.0 # px / sec
-const depart: float = 50.0 # px du bord gauche
-const longueur: float = 300.0 # px de long
+const vitesse: float = 20.0 # px / sec
 
+var depart: float # px du bord gauche
+var longueur: float # px de long
 var temps: float = 0.0 # sec
+var calibrage_fait := false
 
 
 ## Descente tranquille
 func bouger(noeud: Node2D, delta: float) -> void:
+	calibrer(noeud.position.x)
 	temps += delta
 	noeud.position.x = depart + pingpong(temps * vitesse, longueur)
 
 
+func calibrer(position_x: float):
+	if calibrage_fait:
+		return
+
+	depart = position_x
+	var largeur_niveau = ProjectSettings.get_setting("display/window/size/viewport_width")
+	assert(largeur_niveau > 0)
+	longueur = largeur_niveau - 2 * depart
+	print("Calcul ping pong ", self, " depuis ", depart, " sur ", longueur, " px.")
+	calibrage_fait = true

+ 120 - 1
godot/exec/niveaux/ping_pong.tscn

@@ -18,6 +18,7 @@
 offset_right = 40.0
 offset_bottom = 40.0
 texture = ExtResource("1_a1ws5")
+metadata/_edit_lock_ = true
 
 [node name="Raquette" parent="." instance=ExtResource("2_sleah")]
 position = Vector2(210, 400)
@@ -29,11 +30,129 @@ position = Vector2(180, 144)
 script = ExtResource("4_78ofy")
 
 [node name="Ligne1" type="Node2D" parent="Briques"]
+position = Vector2(30, 224)
 script = ExtResource("4_78ofy")
 mouvement_script = ExtResource("5_rhvch")
 
 [node name="Brique1" parent="Briques/Ligne1" instance=ExtResource("5_2efjj")]
-position = Vector2(0, 256)
+
+[node name="Brique4" parent="Briques/Ligne1" instance=ExtResource("5_2efjj")]
+position = Vector2(-30, 16)
+pouvoir_type = 2
+
+[node name="Brique5" parent="Briques/Ligne1" instance=ExtResource("5_2efjj")]
+position = Vector2(0, 16)
+
+[node name="Brique8" parent="Briques/Ligne1" instance=ExtResource("5_2efjj")]
+position = Vector2(0, 32)
+
+[node name="Brique11" parent="Briques/Ligne1" instance=ExtResource("5_2efjj")]
+position = Vector2(-30, 0)
+
+[node name="Brique12" parent="Briques/Ligne1" instance=ExtResource("5_2efjj")]
+position = Vector2(-30, 32)
+
+[node name="Ligne2" type="Node2D" parent="Briques"]
+position = Vector2(60, 112)
+script = ExtResource("4_78ofy")
+mouvement_script = ExtResource("5_rhvch")
+
+[node name="Brique1" parent="Briques/Ligne2" instance=ExtResource("5_2efjj")]
+position = Vector2(-30, 0)
+
+[node name="Brique2" parent="Briques/Ligne2" instance=ExtResource("5_2efjj")]
+
+[node name="Brique3" parent="Briques/Ligne2" instance=ExtResource("5_2efjj")]
+position = Vector2(30, 0)
+
+[node name="Brique4" parent="Briques/Ligne2" instance=ExtResource("5_2efjj")]
+position = Vector2(-60, 16)
+
+[node name="Brique5" parent="Briques/Ligne2" instance=ExtResource("5_2efjj")]
+position = Vector2(-30, 16)
+pouvoir_type = 2
+
+[node name="Brique6" parent="Briques/Ligne2" instance=ExtResource("5_2efjj")]
+position = Vector2(0, 16)
+pouvoir_type = 3
+
+[node name="Brique7" parent="Briques/Ligne2" instance=ExtResource("5_2efjj")]
+position = Vector2(30, 16)
+
+[node name="Brique8" parent="Briques/Ligne2" instance=ExtResource("5_2efjj")]
+position = Vector2(-30, 32)
+
+[node name="Brique9" parent="Briques/Ligne2" instance=ExtResource("5_2efjj")]
+position = Vector2(0, 32)
+
+[node name="Brique10" parent="Briques/Ligne2" instance=ExtResource("5_2efjj")]
+position = Vector2(30, 32)
+
+[node name="Brique11" parent="Briques/Ligne2" instance=ExtResource("5_2efjj")]
+position = Vector2(-60, 0)
+
+[node name="Brique12" parent="Briques/Ligne2" instance=ExtResource("5_2efjj")]
+position = Vector2(-60, 32)
+
+[node name="Ligne3" type="Node2D" parent="Briques"]
+position = Vector2(90, 0)
+script = ExtResource("4_78ofy")
+mouvement_script = ExtResource("5_rhvch")
+
+[node name="Brique1" parent="Briques/Ligne3" instance=ExtResource("5_2efjj")]
+position = Vector2(-60, 0)
+
+[node name="Brique2" parent="Briques/Ligne3" instance=ExtResource("5_2efjj")]
+position = Vector2(-30, 0)
+
+[node name="Brique3" parent="Briques/Ligne3" instance=ExtResource("5_2efjj")]
+
+[node name="Brique4" parent="Briques/Ligne3" instance=ExtResource("5_2efjj")]
+position = Vector2(-90, 16)
+
+[node name="Brique5" parent="Briques/Ligne3" instance=ExtResource("5_2efjj")]
+position = Vector2(-60, 16)
+pouvoir_type = 4
+
+[node name="Brique6" parent="Briques/Ligne3" instance=ExtResource("5_2efjj")]
+position = Vector2(-30, 16)
+
+[node name="Brique7" parent="Briques/Ligne3" instance=ExtResource("5_2efjj")]
+position = Vector2(0, 16)
+
+[node name="Brique8" parent="Briques/Ligne3" instance=ExtResource("5_2efjj")]
+position = Vector2(-60, 32)
+
+[node name="Brique9" parent="Briques/Ligne3" instance=ExtResource("5_2efjj")]
+position = Vector2(-30, 32)
+
+[node name="Brique10" parent="Briques/Ligne3" instance=ExtResource("5_2efjj")]
+position = Vector2(0, 32)
+
+[node name="Brique11" parent="Briques/Ligne3" instance=ExtResource("5_2efjj")]
+position = Vector2(-90, 0)
+
+[node name="Brique12" parent="Briques/Ligne3" instance=ExtResource("5_2efjj")]
+position = Vector2(-90, 32)
+
+[node name="Brique13" parent="Briques/Ligne3" instance=ExtResource("5_2efjj")]
+position = Vector2(30, 16)
+pouvoir_type = 4
+
+[node name="Brique14" parent="Briques/Ligne3" instance=ExtResource("5_2efjj")]
+position = Vector2(30, 0)
+
+[node name="Brique15" parent="Briques/Ligne3" instance=ExtResource("5_2efjj")]
+position = Vector2(30, 32)
+
+[node name="Brique16" parent="Briques/Ligne3" instance=ExtResource("5_2efjj")]
+position = Vector2(60, 16)
+
+[node name="Brique17" parent="Briques/Ligne3" instance=ExtResource("5_2efjj")]
+position = Vector2(60, 0)
+
+[node name="Brique18" parent="Briques/Ligne3" instance=ExtResource("5_2efjj")]
+position = Vector2(60, 32)
 
 [node name="Arene" parent="." instance=ExtResource("6_e2f67")]
 metadata/_edit_lock_ = true