ajout mod poulpe

This commit is contained in:
Elouan 2025-01-25 01:44:33 +01:00
parent 4bab72b7d4
commit 2ae314b374
16 changed files with 296 additions and 7 deletions

View file

@ -29,6 +29,7 @@ project/assembly_name="code-game-jam-drop-plafond-2025"
World_Border=""
Enemies=""
Player=""
[input]

48
scenes/enemies/poulpe.gd Normal file
View file

@ -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)

View file

@ -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")

View file

@ -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"]

View file

@ -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()

35
scenes/enemies/sli2D1.tmp Normal file
View file

@ -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")

View file

@ -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")

View file

@ -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")

View file

@ -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")

View file

@ -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)

View file

@ -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="."]

View file

@ -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="."]

View file

@ -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()

View file

@ -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)

View file

@ -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)

View file

@ -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()