diff --git a/Instrument/Corde.gd b/Instrument/Corde.gd new file mode 100644 index 0000000..ebda478 --- /dev/null +++ b/Instrument/Corde.gd @@ -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) diff --git a/Instrument/Flute.gd b/Instrument/Flute.gd new file mode 100644 index 0000000..c211405 --- /dev/null +++ b/Instrument/Flute.gd @@ -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é.") diff --git a/Instrument/Instrument.gd b/Instrument/Instrument.gd new file mode 100644 index 0000000..484c935 --- /dev/null +++ b/Instrument/Instrument.gd @@ -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) diff --git a/Instrument/Percusson.gd b/Instrument/Percusson.gd new file mode 100644 index 0000000..168ef6b --- /dev/null +++ b/Instrument/Percusson.gd @@ -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) diff --git a/Instrument/Tambour.gd b/Instrument/Tambour.gd new file mode 100644 index 0000000..c17e019 --- /dev/null +++ b/Instrument/Tambour.gd @@ -0,0 +1,8 @@ +extends Percussion + +func _init() -> void: + super("Tambour") + +func faire_roulement() -> void: + print("Le tambour fait un roulement.") + jouer() diff --git a/Instrument/Vent.gd b/Instrument/Vent.gd new file mode 100644 index 0000000..d557412 --- /dev/null +++ b/Instrument/Vent.gd @@ -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) diff --git a/project.godot b/project.godot index 9da3292..db07fcc 100644 --- a/project.godot +++ b/project.godot @@ -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) ] } +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] diff --git a/ressources/images/note1.png b/ressources/images/note1.png new file mode 100644 index 0000000..e529fb1 Binary files /dev/null and b/ressources/images/note1.png differ diff --git a/ressources/images/note1.png.import b/ressources/images/note1.png.import new file mode 100644 index 0000000..6d56d4b --- /dev/null +++ b/ressources/images/note1.png.import @@ -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 diff --git a/ressources/images/note2.png b/ressources/images/note2.png new file mode 100644 index 0000000..08d8cd4 Binary files /dev/null and b/ressources/images/note2.png differ diff --git a/ressources/images/note2.png.import b/ressources/images/note2.png.import new file mode 100644 index 0000000..fbb7ba0 --- /dev/null +++ b/ressources/images/note2.png.import @@ -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 diff --git a/ressources/images/note3.png b/ressources/images/note3.png new file mode 100644 index 0000000..35cfa23 Binary files /dev/null and b/ressources/images/note3.png differ diff --git a/ressources/images/note3.png.import b/ressources/images/note3.png.import new file mode 100644 index 0000000..2b16d6e --- /dev/null +++ b/ressources/images/note3.png.import @@ -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 diff --git a/scenes/Attaque/Balle.tscn b/scenes/Attaque/Balle.tscn new file mode 100644 index 0000000..c6599bb --- /dev/null +++ b/scenes/Attaque/Balle.tscn @@ -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) diff --git a/scenes/Room.tscn b/scenes/Room.tscn index 989978b..4f7d197 100644 --- a/scenes/Room.tscn +++ b/scenes/Room.tscn @@ -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"] -[sub_resource type="WorldBoundaryShape2D" id="WorldBoundaryShape2D_1c4te"] -normal = Vector2(0, 1) -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 +[sub_resource type="RectangleShape2D" id="RectangleShape2D_18mp2"] +size = Vector2(1280, 720) [node name="Room" type="Node2D"] [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="World Border Up" type="CollisionShape2D" parent="StaticBody2D"] -shape = SubResource("WorldBoundaryShape2D_1c4te") +[node name="Bottom Wall" type="CollisionShape2D" parent="StaticBody2D"] +position = Vector2(3, 721) +shape = SubResource("RectangleShape2D_18mp2") -[node name="World Border Down" type="CollisionShape2D" parent="StaticBody2D"] -shape = SubResource("WorldBoundaryShape2D_qq3vn") +[node name="Top Wall" type="CollisionShape2D" parent="StaticBody2D"] +position = Vector2(0, -719) +shape = SubResource("RectangleShape2D_18mp2") -[node name="World Border Right" type="CollisionShape2D" parent="StaticBody2D"] -shape = SubResource("WorldBoundaryShape2D_e1nqi") +[node name="Left Wall" type="CollisionShape2D" parent="StaticBody2D"] +position = Vector2(-1278, -2) +shape = SubResource("RectangleShape2D_18mp2") -[node name="World Border Left" type="CollisionShape2D" parent="StaticBody2D"] -shape = SubResource("WorldBoundaryShape2D_ia1hi") - -[node name="CanvasLayer" type="CanvasLayer" parent="."] - -[node name="Camera2D" type="Camera2D" parent="CanvasLayer"] +[node name="Right Wall" type="CollisionShape2D" parent="StaticBody2D"] +position = Vector2(1280, -4) +shape = SubResource("RectangleShape2D_18mp2") diff --git a/scripts/player_control.gd b/scripts/player_control.gd index 92f2ac9..c883ae7 100644 --- a/scripts/player_control.gd +++ b/scripts/player_control.gd @@ -6,6 +6,11 @@ const max_boost_speed = 800 var previous_direction = Vector2.ZERO 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: @@ -28,5 +33,6 @@ func _process(delta: float) -> void: previous_direction = direction velocity = direction * (move_speed + boost_speed) - print(velocity) - pass + + if Input.is_action_just_pressed("JOUER_MUSIQUE"): + flute.jouer_melodie(position)