Ajoute Instrument + jouer melodie
This commit is contained in:
parent
5b26e074e4
commit
4ba84426d6
16 changed files with 207 additions and 29 deletions
8
Instrument/Corde.gd
Normal file
8
Instrument/Corde.gd
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
extends Instrument
|
||||||
|
class_name Corde
|
||||||
|
|
||||||
|
func _init(nom : String) -> void:
|
||||||
|
super(nom)
|
||||||
|
|
||||||
|
func pincer() -> void:
|
||||||
|
print("On pince l'instrument %s." % nom)
|
19
Instrument/Flute.gd
Normal file
19
Instrument/Flute.gd
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
extends Vent
|
||||||
|
|
||||||
|
var Balle = preload("res://scenes/Attaque/Balle.tscn").instantiate() # Charger le nœud Balle
|
||||||
|
|
||||||
|
func _init() -> void:
|
||||||
|
super("Flûte")
|
||||||
|
|
||||||
|
func jouer_melodie(player_position) -> void:
|
||||||
|
print("La flûte joue une mélodie.")
|
||||||
|
jouer()
|
||||||
|
spawn_balle(player_position)
|
||||||
|
|
||||||
|
|
||||||
|
func spawn_balle(player_position) -> void:
|
||||||
|
# Assurez-vous que vous ajoutez la balle comme enfant dans une scène appropriée
|
||||||
|
if Balle:
|
||||||
|
Balle.position = player_position # Place la balle à la position actuelle du joueur
|
||||||
|
else:
|
||||||
|
print("Erreur : la création de la balle a échoué.")
|
9
Instrument/Instrument.gd
Normal file
9
Instrument/Instrument.gd
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
class_name Instrument
|
||||||
|
|
||||||
|
var nom : String
|
||||||
|
|
||||||
|
func _init(nom : String) -> void:
|
||||||
|
self.nom = nom
|
||||||
|
|
||||||
|
func jouer() -> void:
|
||||||
|
print("L'instrument %s est joué." % nom)
|
9
Instrument/Percusson.gd
Normal file
9
Instrument/Percusson.gd
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
extends Instrument
|
||||||
|
class_name Percussion
|
||||||
|
|
||||||
|
|
||||||
|
func _init(nom : String) -> void:
|
||||||
|
super(nom)
|
||||||
|
|
||||||
|
func frapper() -> void:
|
||||||
|
print("On frappe l'instrument %s." % nom)
|
8
Instrument/Tambour.gd
Normal file
8
Instrument/Tambour.gd
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
extends Percussion
|
||||||
|
|
||||||
|
func _init() -> void:
|
||||||
|
super("Tambour")
|
||||||
|
|
||||||
|
func faire_roulement() -> void:
|
||||||
|
print("Le tambour fait un roulement.")
|
||||||
|
jouer()
|
8
Instrument/Vent.gd
Normal file
8
Instrument/Vent.gd
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
extends Instrument
|
||||||
|
class_name Vent
|
||||||
|
|
||||||
|
func _init(nom : String) -> void:
|
||||||
|
super(nom)
|
||||||
|
|
||||||
|
func souffler() -> void:
|
||||||
|
print("On souffle dans l'instrument %s." % nom)
|
|
@ -52,6 +52,11 @@ PAUSE={
|
||||||
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194305,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null)
|
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194305,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null)
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
JOUER_MUSIQUE={
|
||||||
|
"deadzone": 0.5,
|
||||||
|
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":32,"key_label":0,"unicode":32,"location":0,"echo":false,"script":null)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
[rendering]
|
[rendering]
|
||||||
|
|
||||||
|
|
BIN
ressources/images/note1.png
Normal file
BIN
ressources/images/note1.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 203 B |
34
ressources/images/note1.png.import
Normal file
34
ressources/images/note1.png.import
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="texture"
|
||||||
|
type="CompressedTexture2D"
|
||||||
|
uid="uid://ge7xtkpw6hgb"
|
||||||
|
path="res://.godot/imported/note1.png-96f27d997f75f6c14a701aa9df88a950.ctex"
|
||||||
|
metadata={
|
||||||
|
"vram_texture": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://ressources/images/note1.png"
|
||||||
|
dest_files=["res://.godot/imported/note1.png-96f27d997f75f6c14a701aa9df88a950.ctex"]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
compress/mode=0
|
||||||
|
compress/high_quality=false
|
||||||
|
compress/lossy_quality=0.7
|
||||||
|
compress/hdr_compression=1
|
||||||
|
compress/normal_map=0
|
||||||
|
compress/channel_pack=0
|
||||||
|
mipmaps/generate=false
|
||||||
|
mipmaps/limit=-1
|
||||||
|
roughness/mode=0
|
||||||
|
roughness/src_normal=""
|
||||||
|
process/fix_alpha_border=true
|
||||||
|
process/premult_alpha=false
|
||||||
|
process/normal_map_invert_y=false
|
||||||
|
process/hdr_as_srgb=false
|
||||||
|
process/hdr_clamp_exposure=false
|
||||||
|
process/size_limit=0
|
||||||
|
detect_3d/compress_to=1
|
BIN
ressources/images/note2.png
Normal file
BIN
ressources/images/note2.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 203 B |
34
ressources/images/note2.png.import
Normal file
34
ressources/images/note2.png.import
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="texture"
|
||||||
|
type="CompressedTexture2D"
|
||||||
|
uid="uid://nb4g0mje6w08"
|
||||||
|
path="res://.godot/imported/note2.png-7ddebed95ea93b6f57090ac58466a01e.ctex"
|
||||||
|
metadata={
|
||||||
|
"vram_texture": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://ressources/images/note2.png"
|
||||||
|
dest_files=["res://.godot/imported/note2.png-7ddebed95ea93b6f57090ac58466a01e.ctex"]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
compress/mode=0
|
||||||
|
compress/high_quality=false
|
||||||
|
compress/lossy_quality=0.7
|
||||||
|
compress/hdr_compression=1
|
||||||
|
compress/normal_map=0
|
||||||
|
compress/channel_pack=0
|
||||||
|
mipmaps/generate=false
|
||||||
|
mipmaps/limit=-1
|
||||||
|
roughness/mode=0
|
||||||
|
roughness/src_normal=""
|
||||||
|
process/fix_alpha_border=true
|
||||||
|
process/premult_alpha=false
|
||||||
|
process/normal_map_invert_y=false
|
||||||
|
process/hdr_as_srgb=false
|
||||||
|
process/hdr_clamp_exposure=false
|
||||||
|
process/size_limit=0
|
||||||
|
detect_3d/compress_to=1
|
BIN
ressources/images/note3.png
Normal file
BIN
ressources/images/note3.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 203 B |
34
ressources/images/note3.png.import
Normal file
34
ressources/images/note3.png.import
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="texture"
|
||||||
|
type="CompressedTexture2D"
|
||||||
|
uid="uid://ejn64hq1j8cb"
|
||||||
|
path="res://.godot/imported/note3.png-3a2fd90f8e888d278f8e7c03cb67db73.ctex"
|
||||||
|
metadata={
|
||||||
|
"vram_texture": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://ressources/images/note3.png"
|
||||||
|
dest_files=["res://.godot/imported/note3.png-3a2fd90f8e888d278f8e7c03cb67db73.ctex"]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
compress/mode=0
|
||||||
|
compress/high_quality=false
|
||||||
|
compress/lossy_quality=0.7
|
||||||
|
compress/hdr_compression=1
|
||||||
|
compress/normal_map=0
|
||||||
|
compress/channel_pack=0
|
||||||
|
mipmaps/generate=false
|
||||||
|
mipmaps/limit=-1
|
||||||
|
roughness/mode=0
|
||||||
|
roughness/src_normal=""
|
||||||
|
process/fix_alpha_border=true
|
||||||
|
process/premult_alpha=false
|
||||||
|
process/normal_map_invert_y=false
|
||||||
|
process/hdr_as_srgb=false
|
||||||
|
process/hdr_clamp_exposure=false
|
||||||
|
process/size_limit=0
|
||||||
|
detect_3d/compress_to=1
|
13
scenes/Attaque/Balle.tscn
Normal file
13
scenes/Attaque/Balle.tscn
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
[gd_scene load_steps=2 format=3 uid="uid://btpp8l4efhrmj"]
|
||||||
|
|
||||||
|
[ext_resource type="Texture2D" uid="uid://ge7xtkpw6hgb" path="res://ressources/images/note1.png" id="1_qx664"]
|
||||||
|
|
||||||
|
[node name="Balle1" type="CharacterBody2D"]
|
||||||
|
|
||||||
|
[node name="Sprite2D" type="Sprite2D" parent="."]
|
||||||
|
rotation = 3.14159
|
||||||
|
texture = ExtResource("1_qx664")
|
||||||
|
|
||||||
|
[node name="RayCast2D" type="RayCast2D" parent="."]
|
||||||
|
position = Vector2(0, -7)
|
||||||
|
target_position = Vector2(0, 15)
|
|
@ -1,40 +1,31 @@
|
||||||
[gd_scene load_steps=6 format=3 uid="uid://durhes43gex7a"]
|
[gd_scene load_steps=3 format=3 uid="uid://durhes43gex7a"]
|
||||||
|
|
||||||
[ext_resource type="PackedScene" uid="uid://c7bfiw54rvaq2" path="res://scenes/player_melodie.tscn" id="1_cl1wt"]
|
[ext_resource type="PackedScene" uid="uid://c7bfiw54rvaq2" path="res://scenes/player_melodie.tscn" id="1_cl1wt"]
|
||||||
|
|
||||||
[sub_resource type="WorldBoundaryShape2D" id="WorldBoundaryShape2D_1c4te"]
|
[sub_resource type="RectangleShape2D" id="RectangleShape2D_18mp2"]
|
||||||
normal = Vector2(0, 1)
|
size = Vector2(1280, 720)
|
||||||
distance = -360.0
|
|
||||||
|
|
||||||
[sub_resource type="WorldBoundaryShape2D" id="WorldBoundaryShape2D_qq3vn"]
|
|
||||||
distance = -360.0
|
|
||||||
|
|
||||||
[sub_resource type="WorldBoundaryShape2D" id="WorldBoundaryShape2D_e1nqi"]
|
|
||||||
normal = Vector2(-1, 0)
|
|
||||||
distance = -640.0
|
|
||||||
|
|
||||||
[sub_resource type="WorldBoundaryShape2D" id="WorldBoundaryShape2D_ia1hi"]
|
|
||||||
normal = Vector2(1, 0)
|
|
||||||
distance = -640.0
|
|
||||||
|
|
||||||
[node name="Room" type="Node2D"]
|
[node name="Room" type="Node2D"]
|
||||||
|
|
||||||
[node name="Player_Melodie" parent="." instance=ExtResource("1_cl1wt")]
|
[node name="Player_Melodie" parent="." instance=ExtResource("1_cl1wt")]
|
||||||
|
position = Vector2(0, -9)
|
||||||
|
|
||||||
|
[node name="Camera2D" type="Camera2D" parent="."]
|
||||||
|
|
||||||
[node name="StaticBody2D" type="StaticBody2D" parent="."]
|
[node name="StaticBody2D" type="StaticBody2D" parent="."]
|
||||||
|
|
||||||
[node name="World Border Up" type="CollisionShape2D" parent="StaticBody2D"]
|
[node name="Bottom Wall" type="CollisionShape2D" parent="StaticBody2D"]
|
||||||
shape = SubResource("WorldBoundaryShape2D_1c4te")
|
position = Vector2(3, 721)
|
||||||
|
shape = SubResource("RectangleShape2D_18mp2")
|
||||||
|
|
||||||
[node name="World Border Down" type="CollisionShape2D" parent="StaticBody2D"]
|
[node name="Top Wall" type="CollisionShape2D" parent="StaticBody2D"]
|
||||||
shape = SubResource("WorldBoundaryShape2D_qq3vn")
|
position = Vector2(0, -719)
|
||||||
|
shape = SubResource("RectangleShape2D_18mp2")
|
||||||
|
|
||||||
[node name="World Border Right" type="CollisionShape2D" parent="StaticBody2D"]
|
[node name="Left Wall" type="CollisionShape2D" parent="StaticBody2D"]
|
||||||
shape = SubResource("WorldBoundaryShape2D_e1nqi")
|
position = Vector2(-1278, -2)
|
||||||
|
shape = SubResource("RectangleShape2D_18mp2")
|
||||||
|
|
||||||
[node name="World Border Left" type="CollisionShape2D" parent="StaticBody2D"]
|
[node name="Right Wall" type="CollisionShape2D" parent="StaticBody2D"]
|
||||||
shape = SubResource("WorldBoundaryShape2D_ia1hi")
|
position = Vector2(1280, -4)
|
||||||
|
shape = SubResource("RectangleShape2D_18mp2")
|
||||||
[node name="CanvasLayer" type="CanvasLayer" parent="."]
|
|
||||||
|
|
||||||
[node name="Camera2D" type="Camera2D" parent="CanvasLayer"]
|
|
||||||
|
|
|
@ -6,6 +6,11 @@ const max_boost_speed = 800
|
||||||
|
|
||||||
var previous_direction = Vector2.ZERO
|
var previous_direction = Vector2.ZERO
|
||||||
var boost_speed = 0
|
var boost_speed = 0
|
||||||
|
var flute = null
|
||||||
|
|
||||||
|
func _ready() -> void:
|
||||||
|
flute = load("res://Instrument/Flute.gd").new()
|
||||||
|
flute._init()
|
||||||
|
|
||||||
|
|
||||||
func _physics_process(delta: float) -> void:
|
func _physics_process(delta: float) -> void:
|
||||||
|
@ -28,5 +33,6 @@ func _process(delta: float) -> void:
|
||||||
|
|
||||||
previous_direction = direction
|
previous_direction = direction
|
||||||
velocity = direction * (move_speed + boost_speed)
|
velocity = direction * (move_speed + boost_speed)
|
||||||
print(velocity)
|
|
||||||
pass
|
if Input.is_action_just_pressed("JOUER_MUSIQUE"):
|
||||||
|
flute.jouer_melodie(position)
|
||||||
|
|
Loading…
Add table
Reference in a new issue