diff --git a/project.godot b/project.godot index 1ec1a46..e6c3459 100644 --- a/project.godot +++ b/project.godot @@ -29,6 +29,7 @@ project/assembly_name="code-game-jam-drop-plafond-2025" World_Border="" Enemies="" +Player="" [input] diff --git a/scenes/enemies/poulpe.gd b/scenes/enemies/poulpe.gd new file mode 100644 index 0000000..c560819 --- /dev/null +++ b/scenes/enemies/poulpe.gd @@ -0,0 +1,48 @@ +extends CharacterBody2D + +const SPEED = 50.0 +@onready var player = get_parent().get_node("Player_Melodie") +var player_position = Vector2.ZERO +var target_position = Vector2.ZERO + +var move_timer = 1 + +var vie = 3 +var balle = null +var Balle = null + +func _ready() -> void: + Balle = load("res://scenes/enemies/poulpeBullet.tscn") + + +func take_damage(dmg : int) : + vie -= dmg + if vie <= 0: + queue_free() + + +func _physics_process(delta: float) -> void: + player_position = player.position + target_position = (player_position - position).normalized() + move_and_slide() + + +func _process(delta: float) -> void: + var direction : Vector2 + move_timer -= delta + + if move_timer < 0: + attaquer_joueur() + move_timer = 1 + + + $AnimatedSprite2D.play("Generic") + + velocity = target_position * SPEED * -1 + + +func attaquer_joueur() -> void: + balle = Balle.instantiate() + balle.set_direction(target_position) + balle.position = position + get_parent().add_child(balle) diff --git a/scenes/enemies/poulpe.tscn b/scenes/enemies/poulpe.tscn new file mode 100644 index 0000000..4c746c7 --- /dev/null +++ b/scenes/enemies/poulpe.tscn @@ -0,0 +1,33 @@ +[gd_scene load_steps=6 format=3 uid="uid://voiqrkjd02om"] + +[ext_resource type="Script" path="res://scenes/enemies/poulpe.gd" id="1_hu6wh"] +[ext_resource type="Texture2D" uid="uid://2spn60rmdyy5" path="res://ressources/images/poulpe-1.png" id="1_lgwa7"] +[ext_resource type="Texture2D" uid="uid://b4ukmsspx16f" path="res://ressources/images/poulpe-2.png" id="2_5x4i5"] + +[sub_resource type="SpriteFrames" id="SpriteFrames_2hq77"] +animations = [{ +"frames": [{ +"duration": 1.0, +"texture": ExtResource("1_lgwa7") +}, { +"duration": 1.0, +"texture": ExtResource("2_5x4i5") +}], +"loop": true, +"name": &"Generic", +"speed": 5.0 +}] + +[sub_resource type="CircleShape2D" id="CircleShape2D_s7foh"] +radius = 38.2753 + +[node name="Poulpe" type="CharacterBody2D"] +script = ExtResource("1_hu6wh") + +[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."] +scale = Vector2(0.4, 0.4) +sprite_frames = SubResource("SpriteFrames_2hq77") +animation = &"Generic" + +[node name="CollisionShape2D" type="CollisionShape2D" parent="."] +shape = SubResource("CircleShape2D_s7foh") diff --git a/scenes/enemies/poulpeBullet.tscn b/scenes/enemies/poulpeBullet.tscn new file mode 100644 index 0000000..c34e260 --- /dev/null +++ b/scenes/enemies/poulpeBullet.tscn @@ -0,0 +1,17 @@ +[gd_scene load_steps=3 format=3 uid="uid://gytt3e3u0pid"] + +[ext_resource type="Script" path="res://scenes/enemies/poulpe_bullet.gd" id="1_qycm8"] +[ext_resource type="Texture2D" uid="uid://bg7xknf5g2rfj" path="res://ressources/images/poulpe-bullet.png" id="2_o0wmh"] + +[node name="PoulpeBullet" type="Area2D"] +script = ExtResource("1_qycm8") + +[node name="Sprite2D" type="Sprite2D" parent="."] +scale = Vector2(0.35, 0.35) +texture = ExtResource("2_o0wmh") + +[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="."] +scale = Vector2(0.35, 0.35) +polygon = PackedVector2Array(-42, -44, -42, 43.2, -39.9, 44.3, -36.4, 42, -34.3, 42, -28, 6.2, -28, -1.4, -18, 7.89999, -18, 9.2, 23.5, 32, 28.8, 32, 32, 28.8, 32, 25.5, 18, 0.5, 18, -2.9, -6.8, -26.6, 19.4, -32, 32.4, -32, 41.4, -36, 43.2, -36, 44.3, -38.1, 42, -41.7, 42, -44) + +[connection signal="body_entered" from="." to="." method="Collision"] diff --git a/scenes/enemies/poulpe_bullet.gd b/scenes/enemies/poulpe_bullet.gd new file mode 100644 index 0000000..434c459 --- /dev/null +++ b/scenes/enemies/poulpe_bullet.gd @@ -0,0 +1,20 @@ +extends Area2D + +var speed = 200.0 +var direction = Vector2.ZERO + +func _process(delta: float) -> void: + position += direction * speed * delta + +func set_direction(direction: Vector2) -> void: + self.direction = direction + + +func Collision(body: Node2D) -> void: + if body.is_in_group("World_Border") : + queue_free() + if body.is_in_group("Player"): + body.take_damage(3) + queue_free() + + diff --git a/scenes/enemies/sli2D1.tmp b/scenes/enemies/sli2D1.tmp new file mode 100644 index 0000000..a33edd0 --- /dev/null +++ b/scenes/enemies/sli2D1.tmp @@ -0,0 +1,35 @@ +[gd_scene load_steps=6 format=3 uid="uid://cyvqa6g64cw37"] + +[ext_resource type="Script" path="res://scenes/enemies/slime.gd" id="1_hnufy"] +[ext_resource type="Texture2D" uid="uid://c85d5krtd4nks" path="res://ressources/images/blob-1.png" id="2_f4wf2"] +[ext_resource type="Texture2D" uid="uid://c0b6d7551nbcm" path="res://ressources/images/blob-2-4.png" id="3_dyq42"] + +[sub_resource type="SpriteFrames" id="SpriteFrames_qfla8"] +animations = [{ +"frames": [{ +"duration": 1.0, +"texture": ExtResource("2_f4wf2") +}, { +"duration": 1.0, +"texture": ExtResource("3_dyq42") +}], +"loop": false, +"name": &"Generic", +"speed": 3.0 +}] + +[sub_resource type="CircleShape2D" id="CircleShape2D_bokrm"] +radius = 20.0 + +[node name="Slime" type="CharacterBody2D"] +collision_layer = 3 +collision_mask = 3 +script = ExtResource("1_hnufy") + +[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."] +scale = Vector2(0.2, 0.2) +sprite_frames = SubResource("SpriteFrames_qfla8") +animation = &"Generic" + +[node name="CollisionShape2D" type="CollisionShape2D" parent="."] +shape = SubResource("CircleShape2D_bokrm") diff --git a/scenes/enemies/sli97B9.tmp b/scenes/enemies/sli97B9.tmp new file mode 100644 index 0000000..a33edd0 --- /dev/null +++ b/scenes/enemies/sli97B9.tmp @@ -0,0 +1,35 @@ +[gd_scene load_steps=6 format=3 uid="uid://cyvqa6g64cw37"] + +[ext_resource type="Script" path="res://scenes/enemies/slime.gd" id="1_hnufy"] +[ext_resource type="Texture2D" uid="uid://c85d5krtd4nks" path="res://ressources/images/blob-1.png" id="2_f4wf2"] +[ext_resource type="Texture2D" uid="uid://c0b6d7551nbcm" path="res://ressources/images/blob-2-4.png" id="3_dyq42"] + +[sub_resource type="SpriteFrames" id="SpriteFrames_qfla8"] +animations = [{ +"frames": [{ +"duration": 1.0, +"texture": ExtResource("2_f4wf2") +}, { +"duration": 1.0, +"texture": ExtResource("3_dyq42") +}], +"loop": false, +"name": &"Generic", +"speed": 3.0 +}] + +[sub_resource type="CircleShape2D" id="CircleShape2D_bokrm"] +radius = 20.0 + +[node name="Slime" type="CharacterBody2D"] +collision_layer = 3 +collision_mask = 3 +script = ExtResource("1_hnufy") + +[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."] +scale = Vector2(0.2, 0.2) +sprite_frames = SubResource("SpriteFrames_qfla8") +animation = &"Generic" + +[node name="CollisionShape2D" type="CollisionShape2D" parent="."] +shape = SubResource("CircleShape2D_bokrm") diff --git a/scenes/enemies/sliA92E.tmp b/scenes/enemies/sliA92E.tmp new file mode 100644 index 0000000..a33edd0 --- /dev/null +++ b/scenes/enemies/sliA92E.tmp @@ -0,0 +1,35 @@ +[gd_scene load_steps=6 format=3 uid="uid://cyvqa6g64cw37"] + +[ext_resource type="Script" path="res://scenes/enemies/slime.gd" id="1_hnufy"] +[ext_resource type="Texture2D" uid="uid://c85d5krtd4nks" path="res://ressources/images/blob-1.png" id="2_f4wf2"] +[ext_resource type="Texture2D" uid="uid://c0b6d7551nbcm" path="res://ressources/images/blob-2-4.png" id="3_dyq42"] + +[sub_resource type="SpriteFrames" id="SpriteFrames_qfla8"] +animations = [{ +"frames": [{ +"duration": 1.0, +"texture": ExtResource("2_f4wf2") +}, { +"duration": 1.0, +"texture": ExtResource("3_dyq42") +}], +"loop": false, +"name": &"Generic", +"speed": 3.0 +}] + +[sub_resource type="CircleShape2D" id="CircleShape2D_bokrm"] +radius = 20.0 + +[node name="Slime" type="CharacterBody2D"] +collision_layer = 3 +collision_mask = 3 +script = ExtResource("1_hnufy") + +[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."] +scale = Vector2(0.2, 0.2) +sprite_frames = SubResource("SpriteFrames_qfla8") +animation = &"Generic" + +[node name="CollisionShape2D" type="CollisionShape2D" parent="."] +shape = SubResource("CircleShape2D_bokrm") diff --git a/scenes/enemies/sliDD95.tmp b/scenes/enemies/sliDD95.tmp new file mode 100644 index 0000000..a33edd0 --- /dev/null +++ b/scenes/enemies/sliDD95.tmp @@ -0,0 +1,35 @@ +[gd_scene load_steps=6 format=3 uid="uid://cyvqa6g64cw37"] + +[ext_resource type="Script" path="res://scenes/enemies/slime.gd" id="1_hnufy"] +[ext_resource type="Texture2D" uid="uid://c85d5krtd4nks" path="res://ressources/images/blob-1.png" id="2_f4wf2"] +[ext_resource type="Texture2D" uid="uid://c0b6d7551nbcm" path="res://ressources/images/blob-2-4.png" id="3_dyq42"] + +[sub_resource type="SpriteFrames" id="SpriteFrames_qfla8"] +animations = [{ +"frames": [{ +"duration": 1.0, +"texture": ExtResource("2_f4wf2") +}, { +"duration": 1.0, +"texture": ExtResource("3_dyq42") +}], +"loop": false, +"name": &"Generic", +"speed": 3.0 +}] + +[sub_resource type="CircleShape2D" id="CircleShape2D_bokrm"] +radius = 20.0 + +[node name="Slime" type="CharacterBody2D"] +collision_layer = 3 +collision_mask = 3 +script = ExtResource("1_hnufy") + +[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."] +scale = Vector2(0.2, 0.2) +sprite_frames = SubResource("SpriteFrames_qfla8") +animation = &"Generic" + +[node name="CollisionShape2D" type="CollisionShape2D" parent="."] +shape = SubResource("CircleShape2D_bokrm") diff --git a/scenes/enemies/slime.gd b/scenes/enemies/slime.gd index df33253..b4c1679 100644 --- a/scenes/enemies/slime.gd +++ b/scenes/enemies/slime.gd @@ -7,14 +7,29 @@ var player_position = Vector2.ZERO var target_position = Vector2.ZERO var move_timer = 2 +var next_degat = 1 + +var vie = 4 +func take_damage(dmg : int) : + vie -= dmg + if vie <= 0: + queue_free() + func _physics_process(delta: float) -> void: player_position = player.position target_position = (player_position - position).normalized() move_and_slide() + next_degat -= delta + for i in get_slide_collision_count(): var collision = get_slide_collision(i) + if collision.get_collider_shape().get_instance_id() == player.get_child(1).get_instance_id(): + if next_degat <= 0: + player.take_damage(2) + next_degat = 1 + func _process(delta: float) -> void: var direction : Vector2 @@ -27,3 +42,9 @@ func _process(delta: float) -> void: $AnimatedSprite2D.play("Generic") velocity = direction * SPEED + + +func Collision(body: Node2D) -> void: + print(body) + if body.is_in_group("Player") : + body.take_damage(1) diff --git a/scenes/enemies/slime.tscn b/scenes/enemies/slime.tscn index a33edd0..d690b49 100644 --- a/scenes/enemies/slime.tscn +++ b/scenes/enemies/slime.tscn @@ -22,8 +22,8 @@ animations = [{ radius = 20.0 [node name="Slime" type="CharacterBody2D"] -collision_layer = 3 -collision_mask = 3 +collision_layer = 6 +collision_mask = 6 script = ExtResource("1_hnufy") [node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."] diff --git a/scenes/player_melodie.tscn b/scenes/player_melodie.tscn index 7cc90e9..39b5e2a 100644 --- a/scenes/player_melodie.tscn +++ b/scenes/player_melodie.tscn @@ -8,6 +8,7 @@ radius = 6.0 height = 32.0 [node name="Player_Melodie" type="CharacterBody2D"] +collision_layer = 5 script = ExtResource("1_7sg4g") [node name="Sprite2D" type="Sprite2D" parent="."] diff --git a/scripts/Instrument/balle.gd b/scripts/Instrument/balle.gd index f01c97b..6209e30 100644 --- a/scripts/Instrument/balle.gd +++ b/scripts/Instrument/balle.gd @@ -13,4 +13,6 @@ func Collision(body: Node2D) -> void: if body.is_in_group("World_Border") : queue_free() if body.is_in_group("Enemies") : + body.take_damage(1) + print(body.vie) queue_free() diff --git a/scripts/Instrument/fusil_pompe.gd b/scripts/Instrument/fusil_pompe.gd index 4e5abfc..c5d9f06 100644 --- a/scripts/Instrument/fusil_pompe.gd +++ b/scripts/Instrument/fusil_pompe.gd @@ -1,7 +1,7 @@ extends Area2D var timer = 0.0 -var cooldown = 0.35 +var cooldown = 0.3 func _process(delta: float) -> void: timer += delta @@ -9,6 +9,5 @@ func _process(delta: float) -> void: queue_free() func Collision(body: Node2D) -> void: - if body.is_in_group("Enemies") : - queue_free() + body.take_damage(3) diff --git a/scripts/Instrument/onde.gd b/scripts/Instrument/onde.gd index 460800b..78b8915 100644 --- a/scripts/Instrument/onde.gd +++ b/scripts/Instrument/onde.gd @@ -1,7 +1,7 @@ extends Area2D var timer = 0.0 -var cooldown = 1.5 +var cooldown = 0.33 func _process(delta: float) -> void: timer += delta @@ -11,4 +11,4 @@ func _process(delta: float) -> void: func Collision(body: Node2D) -> void: if body.is_in_group("Enemies") : - queue_free() + body.take_damage(2) diff --git a/scripts/player_control.gd b/scripts/player_control.gd index 584c819..788e03a 100644 --- a/scripts/player_control.gd +++ b/scripts/player_control.gd @@ -21,6 +21,8 @@ var lyre_cooldown = 1 var slot = [null, null] +var vie = 10 + func _ready() -> void: flute = load("res://scripts/Instrument/Flute.gd").new() flute.set_scene_parent(get_tree().get_root()) @@ -99,3 +101,8 @@ func _process(delta: float) -> void: lyre_timer = lyre_cooldown +func take_damage(dmg : int) : + vie -= dmg + print(vie) + if vie <= 0: + queue_free()