diff --git a/scenes/attaques/Bombes.tscn b/scenes/attaques/Bombes.tscn new file mode 100644 index 0000000..c9f6d55 --- /dev/null +++ b/scenes/attaques/Bombes.tscn @@ -0,0 +1,22 @@ +[gd_scene load_steps=4 format=3 uid="uid://bfso5wd843777"] + +[ext_resource type="Script" path="res://scripts/Instrument/onde.gd" id="1_mly3m"] +[ext_resource type="Texture2D" uid="uid://cb5xpbtagu6jv" path="res://ressources/images/ronde tambour.png.png" id="2_2cju6"] + +[sub_resource type="CircleShape2D" id="CircleShape2D_q35ff"] +radius = 109.018 + +[node name="Onde" type="Area2D"] +collision_layer = 3 +collision_mask = 3 +script = ExtResource("1_mly3m") + +[node name="Sprite2D" type="Sprite2D" parent="."] +rotation = 3.14159 +scale = Vector2(2.5, 2.5) +texture = ExtResource("2_2cju6") + +[node name="CollisionShape2D" type="CollisionShape2D" parent="."] +shape = SubResource("CircleShape2D_q35ff") + +[connection signal="body_entered" from="." to="." method="Collision"] diff --git a/scenes/attaques/FusilPompe.tscn b/scenes/attaques/FusilPompe.tscn new file mode 100644 index 0000000..56f229f --- /dev/null +++ b/scenes/attaques/FusilPompe.tscn @@ -0,0 +1,19 @@ +[gd_scene load_steps=3 format=3 uid="uid://ctuw2lsq5wn1x"] + +[ext_resource type="Script" path="res://scripts/Instrument/fusil_pompe.gd" id="1_bq6st"] +[ext_resource type="Texture2D" uid="uid://bv3bmi78swof6" path="res://ressources/images/griffes.svg" id="2_1lh44"] + +[node name="FusilPompe" type="Area2D"] +collision_layer = 3 +collision_mask = 3 +script = ExtResource("1_bq6st") + +[node name="Sprite2D" type="Sprite2D" parent="."] +scale = Vector2(0.75, 0.75) +texture = ExtResource("2_1lh44") + +[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="."] +scale = Vector2(0.75, 0.75) +polygon = PackedVector2Array(-130, -148, -130, -146.3, -132, -145.2, -132, -135.2, -128.8, -132, -137.4, -130, -140, -130, -140, -119.2, -136.8, -116, -136, -116, -148, -113.6, -148, -103.2, -144.8, -100, -139.5, -100, -137.6, -92, -124, -92, -124, -87.2, -120.8, -84, -115.5, -84, -113.6, -76, -99.5, -76, -97.6, -68, -84, -68, -84, -63.2, -80.8, -60, -75.5, -60, -73.6, -52, -60, -52, -60, -47.2, -56.8, -44, -51.5, -44, -49.6, -36, -36, -36, -36, -31.2, -32.8, -28, -28, -28, -28, -23.2, -24.8, -20, -20, -20, -20, -15.2, -16.8, -12, -12, -12, -12, -7.2, -8.8, -4, -4, -4, -4, 0.799988, -0.800003, 4, 4, 4, 4, 8.79999, 7.20001, 12, 12, 12, 12, 16.8, 15.2, 20, 20.5, 20, 22.4, 28, 28.2, 28, 30.2, 44, 44, 44, 44, 56.8, 47.2, 60, 52, 60, 52, 64.8, 55.2, 68, 60.5, 68, 62.4, 76, 68, 76, 68, 88.8, 71.2, 92, 76, 92, 76, 105.6, 84, 107.5, 84, 120.8, 87.2, 124, 92.5, 124, 94.4, 132, 100, 132, 100, 144.8, 103.2, 148, 108, 148, 108, 160.8, 111.2, 164, 116, 164, 116, 177.6, 124, 179.5, 124, 192.8, 127.2, 196, 132.5, 196, 134.4, 204, 144.8, 204, 148, 200.8, 148, 190.4, 140, 188.4, 140, 180, 142.4, 188, 152.8, 188, 156, 184.8, 156, 174.4, 148, 172.4, 148, 164, 150, 169, 150, 172.5, 161.4, 170, 164, 170, 164, 158.4, 156, 156.4, 156, 142.4, 148, 140.4, 148, 126.4, 140, 124.4, 140, 110.4, 132, 108.4, 132, 95.2, 128.8, 92, 123.5, 92, 121.6, 84, 116, 84, 116, 71.2, 112.8, 68, 108, 68, 108, 54.4, 100, 52.4, 100, 39.2, 96.8, 36, 92, 36, 92, 31.2, 88.8, 28, 83.5, 28, 82, 23, 82, 20, 76, 20, 76, 7.20001, 72.8, 4, 68, 4, 68, -0.800003, 64.8, -4, 60, -4, 60, -8.8, 56.8, -12, 52, -12, 52, -16.8, 48.8, -20, 44, -20, 44, -24.8, 40.8, -28, 36, -28, 36, -32.8, 32.8, -36, 28, -36, 28, -40.8, 24.8, -44, 20, -44, 20, -48.8, 16.8, -52, 12, -52, 12, -56.8, 8.79999, -60, 4, -60, 4, -64.8, 0.799988, -68, -4, -68, -4, -72.8, -7.2, -76, -12.5, -76, -14.4, -84, -28, -84, -28, -88.8, -31.2, -92, -36.5, -92, -38.4, -100, -52.5, -100, -54.4, -108, -60.2, -108, -62, -129.2, -62, -132.5, -73.4, -130, -76, -130, -76, -116, -78, -121, -78, -124, -92, -124, -92, -128.8, -95.2, -132, -100.5, -132, -102, -137, -102, -140, -116.5, -140, -118, -145, -118, -148) + +[connection signal="body_entered" from="." to="." method="Collision"] diff --git a/scenes/attaques/Onde.tscn b/scenes/attaques/Onde.tscn deleted file mode 100644 index fe2c8be..0000000 --- a/scenes/attaques/Onde.tscn +++ /dev/null @@ -1,19 +0,0 @@ -[gd_scene load_steps=4 format=3 uid="uid://y2j5qtyg4vt3"] - -[ext_resource type="Script" path="res://scripts/Instrument/onde.gd" id="1_6377h"] -[ext_resource type="Texture2D" uid="uid://bq2gg8sxvwth2" path="res://ressources/images/ronde tambour.png.png" id="1_oawub"] - -[sub_resource type="CircleShape2D" id="CircleShape2D_r81ru"] -radius = 125.575 - -[node name="Onde" type="CharacterBody2D"] -collision_layer = 2 -collision_mask = 2 -script = ExtResource("1_6377h") - -[node name="Sprite2D" type="Sprite2D" parent="."] -scale = Vector2(2.5, 2.5) -texture = ExtResource("1_oawub") - -[node name="CollisionShape2D" type="CollisionShape2D" parent="."] -shape = SubResource("CircleShape2D_r81ru") diff --git a/scenes/enemies/slime.tscn b/scenes/enemies/slime.tscn index 1ace833..e50663a 100644 --- a/scenes/enemies/slime.tscn +++ b/scenes/enemies/slime.tscn @@ -1,9 +1,10 @@ -[gd_scene load_steps=7 format=3 uid="uid://cyvqa6g64cw37"] +[gd_scene load_steps=8 format=3 uid="uid://cyvqa6g64cw37"] [ext_resource type="Script" path="res://scenes/enemies/slime.gd" id="1_hnufy"] -[ext_resource type="Texture2D" uid="uid://ba14nw87lxef4" path="res://ressources/images/blob-1.png.png" id="1_n4mgf"] -[ext_resource type="Texture2D" uid="uid://cpge55gmdllmi" path="res://ressources/images/blob-2-4.png.png" id="2_w8gqg"] -[ext_resource type="Texture2D" uid="uid://bst1iwqgqmcvl" path="res://ressources/images/blob-3.png.png" id="3_pwpfc"] +[ext_resource type="Texture2D" uid="uid://c85d5krtd4nks" path="res://ressources/images/blob-1.png" id="1_n4mgf"] +[ext_resource type="Texture2D" uid="uid://c0b6d7551nbcm" path="res://ressources/images/blob-2-4.png" id="2_w8gqg"] +[ext_resource type="Texture2D" uid="uid://c1rqfml1fi47x" path="res://ressources/images/blob-3-side.png" id="3_pwpfc"] +[ext_resource type="Texture2D" uid="uid://2gqy3xv26df1" path="res://ressources/images/blob-3.png" id="5_bhc5m"] [sub_resource type="SpriteFrames" id="SpriteFrames_qfla8"] animations = [{ @@ -13,6 +14,12 @@ animations = [{ }, { "duration": 1.0, "texture": ExtResource("2_w8gqg") +}, { +"duration": 1.0, +"texture": ExtResource("3_pwpfc") +}, { +"duration": 1.0, +"texture": ExtResource("5_bhc5m") }], "loop": false, "name": &"idle", diff --git a/scripts/Instrument/Flute.gd b/scripts/Instrument/Flute.gd index e8dce6a..5458a44 100644 --- a/scripts/Instrument/Flute.gd +++ b/scripts/Instrument/Flute.gd @@ -15,14 +15,7 @@ var is_on_cooldown = false # Indique si le cooldown est en cours func set_scene_parent(node: Node) -> void: scene_node = node - # Si scene_node est défini pour la première fois, on ajoute un Timer - if not scene_node.has_node("TirCooldownTimer"): - var cooldown_timer = Timer.new() - cooldown_timer.name = "TirCooldownTimer" - cooldown_timer.one_shot = true - cooldown_timer.wait_time = cooldown - cooldown_timer.connect("timeout", Callable(self, "_on_cooldown_timeout")) - scene_node.add_child(cooldown_timer) + func _process(delta) -> void: @@ -45,16 +38,3 @@ func spawn_balle(player_position: Vector2, direction_balle: Vector2, angle: floa color_index = (1 +color_index)% len(color_list) balle.get_node("Sprite2D").texture = color_list[color_index] scene_node.add_child(balle) - # Démarrez le cooldown après ce tir - start_cooldown() - - -# Démarrer le timer pour le cooldown -func start_cooldown() -> void: - is_on_cooldown = true - var cooldown_timer = scene_node.get_node("TirCooldownTimer") - cooldown_timer.start() - - -func _on_cooldown_timeout() -> void: - is_on_cooldown = false # Réinitialisez l'état de cooldown après expiration du Timer diff --git a/scripts/Instrument/Lyre.gd b/scripts/Instrument/Lyre.gd new file mode 100644 index 0000000..79cb3f8 --- /dev/null +++ b/scripts/Instrument/Lyre.gd @@ -0,0 +1,28 @@ +class_name Lyre + +var scene_node = null + +func set_scene_parent(node: Node) -> void: + scene_node = node + + +func jouer_melodie(player_position: Vector2, direction_balles: Vector2, angle: float) -> void: + spawn_onde(player_position, direction_balles, angle) + + + +func spawn_onde(player_position: Vector2, direction_balles: Vector2, angle: float) -> void: + if scene_node == null: + print("Erreur : Aucun nœud parent défini pour ajouter fusil.") + return + + var fusil_scene = preload("res://scenes/attaques/FusilPompe.tscn") + var fusil = fusil_scene.instantiate() + + if fusil: + fusil.position = player_position + direction_balles * 50 + fusil.rotation = angle + scene_node.add_child(fusil) + + else: + print("Erreur : Impossible de créer fusil.") diff --git a/scripts/Instrument/Tambour.gd b/scripts/Instrument/Tambour.gd index 4f2961e..c54d7ec 100644 --- a/scripts/Instrument/Tambour.gd +++ b/scripts/Instrument/Tambour.gd @@ -1,19 +1,12 @@ class_name Tambour var scene_node = null -@export var cooldown = 0.9 # Durée du cooldown en secondes +@export var cooldown = 3 # Durée du cooldown en secondes var is_on_cooldown = false # Indique si le cooldown est actif func set_scene_parent(node: Node) -> void: scene_node = node - # Si scene_node est défini pour la première fois, on ajoute un Timer - if not scene_node.has_node("TambourCooldownTimer2"): # Changement du nom du Timer unique pour le Tambour - var cooldown_timer = Timer.new() - cooldown_timer.name = "TambourCooldownTimer2" # Nom unique pour éviter les conflits - cooldown_timer.one_shot = true - cooldown_timer.wait_time = cooldown - cooldown_timer.connect("timeout", Callable(self, "_on_cooldown_timeout")) - scene_node.add_child(cooldown_timer) + func jouer_melodie(player_position: Vector2) -> void: @@ -27,29 +20,12 @@ func spawn_onde(player_position: Vector2) -> void: print("Erreur : Aucun nœud parent défini pour ajouter l'onde.") return - var onde_scene = preload("res://scenes/attaques/Onde.tscn") # Chargez la scène de l'onde + var onde_scene = preload("res://scenes/attaques/Bombes.tscn") # Chargez la scène de l'onde var onde = onde_scene.instantiate() if onde: onde.position = player_position scene_node.add_child(onde) - # Démarrez le cooldown après avoir ajouté l'onde - start_cooldown() else: print("Erreur : Impossible de créer l'onde.") - - -# Démarrer le Timer pour le cooldown -func start_cooldown() -> void: - is_on_cooldown = true - var cooldown_timer = scene_node.get_node("TambourCooldownTimer2") # Assurez-vous que le Timer est bien trouvé - if cooldown_timer: - cooldown_timer.start() - else: - print("Erreur : Timer introuvable.") - - -func _on_cooldown_timeout() -> void: - is_on_cooldown = false # Réinitialiser le cooldown lorsque le Timer se termine - print("Cooldown terminé.") diff --git a/scripts/Instrument/balle.gd b/scripts/Instrument/balle.gd index 0bbc40c..f01c97b 100644 --- a/scripts/Instrument/balle.gd +++ b/scripts/Instrument/balle.gd @@ -1,7 +1,6 @@ extends Area2D @export var speed: float = 300 # Définir la vitesse de la balle -@export var raycast: RayCast2D # Direction initiale du mouvement var initial_direction: Vector2 = Vector2(1, 0) # Exemple par défaut : vers la droite diff --git a/scripts/Instrument/fusil_pompe.gd b/scripts/Instrument/fusil_pompe.gd new file mode 100644 index 0000000..4e5abfc --- /dev/null +++ b/scripts/Instrument/fusil_pompe.gd @@ -0,0 +1,14 @@ +extends Area2D + +var timer = 0.0 +var cooldown = 0.35 + +func _process(delta: float) -> void: + timer += delta + if timer >= cooldown: + queue_free() + +func Collision(body: Node2D) -> void: + + if body.is_in_group("Enemies") : + queue_free() diff --git a/scripts/Instrument/onde.gd b/scripts/Instrument/onde.gd index 01ba3de..460800b 100644 --- a/scripts/Instrument/onde.gd +++ b/scripts/Instrument/onde.gd @@ -1,20 +1,14 @@ -extends CharacterBody2D +extends Area2D -var cooldown_timer = null +var timer = 0.0 +var cooldown = 1.5 func _process(delta: float) -> void: - if cooldown_timer == null: - cooldown_timer = Timer.new() - cooldown_timer.name = "OndeCooldownTimer" - cooldown_timer.one_shot = true - cooldown_timer.connect("timeout", Callable(self, "_on_cooldown_timeout")) - get_tree().root.add_child(cooldown_timer) + timer += delta + if timer >= cooldown: + queue_free() -# Démarrer le timer pour le cooldown -func start_cooldown() -> void: - cooldown_timer.start() -func _on_cooldown_timeout() -> void: - cooldown_timer.queue_free() - cooldown_timer = null - queue_free() +func Collision(body: Node2D) -> void: + if body.is_in_group("Enemies") : + queue_free() diff --git a/scripts/player_control.gd b/scripts/player_control.gd index c774c96..584c819 100644 --- a/scripts/player_control.gd +++ b/scripts/player_control.gd @@ -9,20 +9,30 @@ var boost_speed = 0 var flute = null var tambour = null +var lyre = null -# Slot actif (0 = Flûte, 1 = Tambour) -var active_slot = 0 +var flute_timer = 0.0 +var tambour_timer = 0.0 +var lyre_timer = 0.0 -var flute_timer = 0 +var flute_cooldown = 0.5 +var tambour_cooldown = 3.0 +var lyre_cooldown = 1 + +var slot = [null, null] func _ready() -> void: flute = load("res://scripts/Instrument/Flute.gd").new() flute.set_scene_parent(get_tree().get_root()) + slot.append(flute) tambour = load("res://scripts/Instrument/Tambour.gd").new() tambour.set_scene_parent(get_tree().get_root()) - - + + lyre = load("res://scripts/Instrument/Lyre.gd").new() + lyre.set_scene_parent(get_tree().get_root()) + slot.append(lyre) + func _physics_process(delta: float) -> void: move_and_slide() @@ -32,7 +42,6 @@ func _process(delta: float) -> void: direction.x = Input.get_action_raw_strength("BOUGER_DROITE") - Input.get_action_raw_strength("BOUGER_GAUCHE") direction.y = Input.get_action_raw_strength("BOUGER_BAS") - Input.get_action_raw_strength("BOUGER_HAUT") - if direction != Vector2.ZERO: if direction == previous_direction: if direction.x != 0 and direction.y != 0: @@ -42,31 +51,51 @@ func _process(delta: float) -> void: else: boost_speed = 0 - previous_direction = direction - velocity = direction * (move_speed + boost_speed) - - if Input.is_action_just_pressed("CHANGER_SLOT"): - active_slot = (active_slot + 1) % 2 - + previous_direction = direction + velocity = direction * (move_speed + boost_speed) + else: + velocity = Vector2.ZERO var direction_balle = Vector2.ZERO var angle = 0 + var angle_lyre = 0 if Input.is_action_pressed("JOUER_MUSIQUE_HAUT"): direction_balle = Vector2(0, -1) angle = 180 + angle_lyre = 270 + elif Input.is_action_pressed("JOUER_MUSIQUE_BAS"): direction_balle = Vector2(0, 1) - angle = 0 + angle_lyre = 90 + elif Input.is_action_pressed("JOUER_MUSIQUE_DROITE"): direction_balle = Vector2(1, 0) angle = 270 + elif Input.is_action_pressed("JOUER_MUSIQUE_GAUCHE"): direction_balle = Vector2(-1, 0) angle = 90 - if direction_balle != Vector2.ZERO : - if active_slot == 0: # Slot Flûte - flute.jouer_melodie(position, direction_balle, angle) - elif active_slot == 1: # Slot Tambour - tambour.jouer_melodie(position) + angle_lyre = 180 + + if flute_timer > 0: + flute_timer -= delta - pass + if tambour_timer > 0: + tambour_timer -= delta + + if lyre_timer > 0: + lyre_timer -= delta + + if flute and flute_timer <= 0.0 and direction_balle != Vector2.ZERO: + flute.jouer_melodie(position, direction_balle, angle) + flute_timer = flute_cooldown + + if tambour and tambour_timer <= 0.0 and direction_balle != Vector2.ZERO: + tambour.jouer_melodie(position) + tambour_timer = tambour_cooldown + + if lyre and lyre_timer <= 0.0 and direction_balle != Vector2.ZERO: + lyre.jouer_melodie(position, direction_balle, angle_lyre) + lyre_timer = lyre_cooldown + +