vague de monstre
This commit is contained in:
parent
9d772a419b
commit
78917d152b
8 changed files with 175 additions and 17 deletions
|
@ -1,16 +1,15 @@
|
|||
[gd_scene load_steps=16 format=3 uid="uid://durhes43gex7a"]
|
||||
[gd_scene load_steps=15 format=3 uid="uid://durhes43gex7a"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://c7bfiw54rvaq2" path="res://scenes/player_melodie.tscn" id="1_cl1wt"]
|
||||
[ext_resource type="Script" path="res://scenes/room.gd" id="1_jh83c"]
|
||||
[ext_resource type="AudioStream" uid="uid://qyacm71epyhi" path="res://ressources/sons/idle_theme.wav" id="2_8nbnd"]
|
||||
[ext_resource type="Texture2D" uid="uid://ky4e7158gqf6" path="res://ressources/images/cgj_default_tile.svg" id="2_torsx"]
|
||||
[ext_resource type="PackedScene" uid="uid://cyvqa6g64cw37" path="res://scenes/enemies/slime.tscn" id="3_04ip2"]
|
||||
[ext_resource type="Texture2D" uid="uid://bge3nllk1bq5r" path="res://ressources/images/mur.svg" id="3_oi2tl"]
|
||||
[ext_resource type="Texture2D" uid="uid://dhva3tivsvknl" path="res://ressources/images/mur_coin.svg" id="4_6a3f6"]
|
||||
[ext_resource type="PackedScene" uid="uid://di4chlep1t1or" path="res://parametres/menu_parametres.tscn" id="6_6ubhx"]
|
||||
[ext_resource type="PackedScene" uid="uid://bndtclt51nsih" path="res://scenes/interface.tscn" id="8_5s7tf"]
|
||||
[ext_resource type="PackedScene" uid="uid://ctgxrbcg2vu1p" path="res://scenes/ecran_mort.tscn" id="10_3ou8w"]
|
||||
[ext_resource type="PackedScene" uid="uid://cm5spgl8o4fam" path="res://scenes/enemies/robot.tscn" id="10_5qrsc"]
|
||||
[ext_resource type="Script" path="res://scenes/vague.gd" id="12_n6lb5"]
|
||||
|
||||
[sub_resource type="WorldBoundaryShape2D" id="WorldBoundaryShape2D_1c4te"]
|
||||
normal = Vector2(0, 1)
|
||||
|
@ -44,10 +43,6 @@ offset_bottom = 360.0
|
|||
texture = ExtResource("2_torsx")
|
||||
stretch_mode = 1
|
||||
|
||||
[node name="Player_Melodie" parent="." node_paths=PackedStringArray("interface") groups=["Player"] instance=ExtResource("1_cl1wt")]
|
||||
scale = Vector2(3, 3)
|
||||
interface = NodePath("../Interface")
|
||||
|
||||
[node name="StaticBody2D" type="StaticBody2D" parent="." groups=["World_Border"]]
|
||||
collision_layer = 3
|
||||
collision_mask = 3
|
||||
|
@ -134,9 +129,6 @@ texture = ExtResource("4_6a3f6")
|
|||
|
||||
[node name="Camera2D" type="Camera2D" parent="CanvasLayer"]
|
||||
|
||||
[node name="Slime" parent="." groups=["Enemies"] instance=ExtResource("3_04ip2")]
|
||||
position = Vector2(-448, 205)
|
||||
|
||||
[node name="Interface" parent="." instance=ExtResource("8_5s7tf")]
|
||||
offset_left = -640.0
|
||||
offset_top = -360.0
|
||||
|
@ -159,8 +151,31 @@ offset_top = -383.0
|
|||
offset_right = -258.0
|
||||
offset_bottom = -383.0
|
||||
|
||||
[node name="Robot" parent="." groups=["Enemies"] instance=ExtResource("10_5qrsc")]
|
||||
position = Vector2(-428, 11)
|
||||
[node name="vague" type="Node2D" parent="." node_paths=PackedStringArray("spawner1", "spawner2", "spawner3", "spawner4")]
|
||||
script = ExtResource("12_n6lb5")
|
||||
spawner1 = NodePath("Spawner1")
|
||||
spawner2 = NodePath("Spawner2")
|
||||
spawner3 = NodePath("Spawner3")
|
||||
spawner4 = NodePath("Spawner4")
|
||||
|
||||
[node name="Spawner1" type="Node2D" parent="vague"]
|
||||
position = Vector2(482, -232)
|
||||
|
||||
[node name="Spawner2" type="Node2D" parent="vague"]
|
||||
position = Vector2(-538, 238)
|
||||
|
||||
[node name="Spawner3" type="Node2D" parent="vague"]
|
||||
position = Vector2(-502, -240)
|
||||
|
||||
[node name="Spawner4" type="Node2D" parent="vague"]
|
||||
position = Vector2(484, 220)
|
||||
|
||||
[node name="Timer" type="Timer" parent="vague"]
|
||||
|
||||
[node name="Player_Melodie" parent="vague" node_paths=PackedStringArray("interface") instance=ExtResource("1_cl1wt")]
|
||||
scale = Vector2(3, 3)
|
||||
interface = NodePath("../../Interface")
|
||||
|
||||
[connection signal="finished" from="Musique" to="." method="_on_audio_stream_player_finished"]
|
||||
[connection signal="retour_menu" from="Ecran mort" to="." method="_on_ecran_mort_retour_menu"]
|
||||
[connection signal="timeout" from="vague/Timer" to="vague" method="_on_timer_timeout"]
|
||||
|
|
|
@ -30,7 +30,7 @@ animations = [{
|
|||
[sub_resource type="CircleShape2D" id="CircleShape2D_s7foh"]
|
||||
radius = 38.2753
|
||||
|
||||
[node name="Poulpe" type="CharacterBody2D"]
|
||||
[node name="Poulpe" type="CharacterBody2D" groups=["Enemies"]]
|
||||
script = ExtResource("1_hu6wh")
|
||||
|
||||
[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."]
|
||||
|
|
|
@ -41,13 +41,13 @@ animations = [{
|
|||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_utjf8"]
|
||||
size = Vector2(126, 185)
|
||||
|
||||
[node name="Robot" type="CharacterBody2D"]
|
||||
[node name="Robot" type="CharacterBody2D" groups=["Enemies"]]
|
||||
script = ExtResource("1_tikkk")
|
||||
|
||||
[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."]
|
||||
sprite_frames = SubResource("SpriteFrames_vaeha")
|
||||
animation = &"Generic"
|
||||
frame_progress = 0.0803078
|
||||
frame_progress = 0.260687
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||
position = Vector2(-2, 6.5)
|
||||
|
|
|
@ -21,7 +21,7 @@ animations = [{
|
|||
[sub_resource type="CircleShape2D" id="CircleShape2D_bokrm"]
|
||||
radius = 20.0
|
||||
|
||||
[node name="Slime" type="CharacterBody2D"]
|
||||
[node name="Slime" type="CharacterBody2D" groups=["Enemies"]]
|
||||
collision_layer = 6
|
||||
collision_mask = 6
|
||||
script = ExtResource("1_hnufy")
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
radius = 6.0
|
||||
height = 32.0
|
||||
|
||||
[node name="Player_Melodie" type="CharacterBody2D"]
|
||||
[node name="Player_Melodie" type="CharacterBody2D" groups=["Player"]]
|
||||
collision_layer = 5
|
||||
script = ExtResource("1_7sg4g")
|
||||
|
||||
|
|
91
scenes/vague.gd
Normal file
91
scenes/vague.gd
Normal file
|
@ -0,0 +1,91 @@
|
|||
extends Node2D
|
||||
|
||||
@export var spawner1: Node2D
|
||||
@export var spawner2: Node2D
|
||||
@export var spawner3: Node2D
|
||||
@export var spawner4: Node2D
|
||||
|
||||
class Vague:
|
||||
var poulpes: int
|
||||
var slimes: int
|
||||
var robots: int
|
||||
|
||||
func _init(poulpes: int, slimes: int, robots: int):
|
||||
self.poulpes = poulpes
|
||||
self.slimes = slimes
|
||||
self.robots = robots
|
||||
|
||||
# Waves and spawners
|
||||
var vagues = [
|
||||
Vague.new(0, 1, 0),
|
||||
Vague.new(1, 1, 0),
|
||||
Vague.new(1, 2, 0),
|
||||
Vague.new(2, 2, 1),
|
||||
Vague.new(2, 3, 1),
|
||||
Vague.new(3, 3, 2),
|
||||
Vague.new(3, 4, 2),
|
||||
Vague.new(4, 4, 3),
|
||||
Vague.new(4, 5, 3),
|
||||
Vague.new(5, 5, 4),
|
||||
Vague.new(2, 3, 2),
|
||||
Vague.new(3, 2, 1),
|
||||
Vague.new(1, 4, 3),
|
||||
Vague.new(4, 1, 2),
|
||||
Vague.new(2, 2, 3),
|
||||
Vague.new(1, 5, 1),
|
||||
Vague.new(3, 1, 4),
|
||||
Vague.new(4, 3, 1),
|
||||
Vague.new(3, 4, 2),
|
||||
Vague.new(1, 2, 4),
|
||||
Vague.new(3, 5, 2)
|
||||
]
|
||||
|
||||
var spawners = []
|
||||
|
||||
var vague_actuelle = 0
|
||||
var poulpe_scene: PackedScene
|
||||
var slime_scene: PackedScene
|
||||
var robot_scene: PackedScene
|
||||
|
||||
func _ready():
|
||||
poulpe_scene = load("res://scenes/enemies/poulpe.tscn")
|
||||
slime_scene = load("res://scenes/enemies/slime.tscn")
|
||||
robot_scene = load("res://scenes/enemies/robot.tscn")
|
||||
|
||||
spawners = [spawner1, spawner2, spawner3, spawner4]
|
||||
|
||||
# Ensure spawners are set
|
||||
for spawner in spawners:
|
||||
if spawner == null:
|
||||
push_error("Spawner is not assigned.")
|
||||
|
||||
$Timer.start(2)
|
||||
|
||||
func instancier_ennemis(vague: Vague):
|
||||
for i in range(vague.poulpes):
|
||||
var spawner = spawners[randi() % len(spawners)]
|
||||
var poulpe_instance = poulpe_scene.instantiate()
|
||||
poulpe_instance.position = spawner.global_position
|
||||
add_child(poulpe_instance)
|
||||
|
||||
for i in range(vague.slimes):
|
||||
var spawner = spawners[randi() % len(spawners)]
|
||||
var slime_instance = slime_scene.instantiate()
|
||||
slime_instance.position = spawner.global_position
|
||||
add_child(slime_instance)
|
||||
|
||||
for i in range(vague.robots):
|
||||
var spawner = spawners[randi() % len(spawners)]
|
||||
var robot_instance = robot_scene.instantiate()
|
||||
robot_instance.position = spawner.global_position
|
||||
add_child(robot_instance)
|
||||
|
||||
func _on_timer_timeout():
|
||||
if vague_actuelle < len(vagues):
|
||||
print("t")
|
||||
instancier_ennemis(vagues[vague_actuelle])
|
||||
vague_actuelle = (vague_actuelle + 1) % len(vagues)
|
||||
$Timer.set_wait_time(10)
|
||||
$Timer.start()
|
||||
else:
|
||||
print("All waves cleared!")
|
22
scenes/vague/vague.yaml
Normal file
22
scenes/vague/vague.yaml
Normal file
|
@ -0,0 +1,22 @@
|
|||
vagues:
|
||||
- {slime: 1, poulpe: 0, robot: 0}
|
||||
- {slime: 1, poulpe: 1, robot: 0}
|
||||
- {slime: 2, poulpe: 1, robot: 0}
|
||||
- {slime: 2, poulpe: 2, robot: 1}
|
||||
- {slime: 3, poulpe: 2, robot: 1}
|
||||
- {slime: 3, poulpe: 3, robot: 2}
|
||||
- {slime: 4, poulpe: 3, robot: 2}
|
||||
- {slime: 4, poulpe: 4, robot: 3}
|
||||
- {slime: 5, poulpe: 4, robot: 3}
|
||||
- {slime: 5, poulpe: 5, robot: 4}
|
||||
- {slime: 3, poulpe: 2, robot: 2}
|
||||
- {slime: 2, poulpe: 3, robot: 1}
|
||||
- {slime: 4, poulpe: 1, robot: 3}
|
||||
- {slime: 1, poulpe: 4, robot: 2}
|
||||
- {slime: 2, poulpe: 2, robot: 3}
|
||||
- {slime: 5, poulpe: 1, robot: 1}
|
||||
- {slime: 1, poulpe: 3, robot: 4}
|
||||
- {slime: 3, poulpe: 4, robot: 1}
|
||||
- {slime: 4, poulpe: 3, robot: 2}
|
||||
- {slime: 2, poulpe: 1, robot: 4}
|
||||
- {slime: 5, poulpe: 3, robot: 2}
|
30
scenes/vague/yaml.gd
Normal file
30
scenes/vague/yaml.gd
Normal file
|
@ -0,0 +1,30 @@
|
|||
extends Node
|
||||
|
||||
func lire_yaml():
|
||||
var fichier = FileAccess.open("res://scenes/vague/vague.yaml", FileAccess.READ)
|
||||
if fichier != null:
|
||||
var contenu = fichier.get_as_text()
|
||||
fichier = null
|
||||
var yaml_contenu = parse_yaml(contenu)
|
||||
return yaml_contenu
|
||||
else:
|
||||
print("Erreur lors de la lecture du fichier YAML")
|
||||
return null
|
||||
|
||||
func parse_yaml(yaml_text):
|
||||
# Godot ne prend pas en charge nativement les fichiers YAML.
|
||||
# Vous devrez utiliser une bibliothèque externe pour parser les fichiers YAML.
|
||||
print("Erreur : Godot ne prend pas en charge nativement les fichiers YAML")
|
||||
return null
|
||||
|
||||
func _ready():
|
||||
var contenu = lire_yaml()
|
||||
if contenu:
|
||||
print(contenu)
|
||||
var vagues = contenu["vagues"]
|
||||
for i in range(len(vagues)):
|
||||
var vague = vagues[i]
|
||||
print("Vague ", i+1)
|
||||
print(" Slime : ", vague["slime"])
|
||||
print(" Poulpe : ", vague["poulpe"])
|
||||
print(" Robot : ", vague["robot"])
|
Loading…
Add table
Reference in a new issue