diff --git a/menu_principal/menu_principal_affichage.gd b/menu_principal/menu_principal_affichage.gd index a53b924..627ed76 100644 --- a/menu_principal/menu_principal_affichage.gd +++ b/menu_principal/menu_principal_affichage.gd @@ -32,6 +32,7 @@ func _on_param_button_pressed(): func on_exit_parametres() -> void : menu_principal.visible = true menu_parametres.visible = false + menu_parametres.set_process(false) @@ -39,9 +40,7 @@ func _on_play_button_pressed(): get_tree().root.add_child(first_room) musique_fond.playing = false menu_principal.visible = false - -func _on_load_button_pressed(): - print("Charger une sauvegarde") + func _on_musique_fond_finished() -> void: diff --git a/menu_principal/menu_principal_affichage.tscn b/menu_principal/menu_principal_affichage.tscn index 0d86a7b..6e13944 100644 --- a/menu_principal/menu_principal_affichage.tscn +++ b/menu_principal/menu_principal_affichage.tscn @@ -148,29 +148,6 @@ horizontal_alignment = 1 vertical_alignment = 1 language = "fr_FR" -[node name="credit_button" type="TextureButton" parent="Menu_principal/HBoxContainer/VBoxSideButton"] -custom_minimum_size = Vector2(0, 128) -layout_mode = 2 -texture_normal = ExtResource("3_o6osq") -texture_pressed = ExtResource("4_egxbj") -texture_hover = ExtResource("4_egxbj") -texture_focused = ExtResource("4_egxbj") -stretch_mode = 0 - -[node name="credit_label" type="Label" parent="Menu_principal/HBoxContainer/VBoxSideButton/credit_button"] -modulate = Color(0, 0, 0, 1) -layout_mode = 0 -offset_left = 25.0 -offset_top = 28.0 -offset_right = 175.0 -offset_bottom = 92.0 -theme_override_fonts/font = ExtResource("5_1lmm7") -theme_override_font_sizes/font_size = 25 -text = "Crédits" -horizontal_alignment = 1 -vertical_alignment = 1 -language = "fr_FR" - [node name="HSeparator2" type="HSeparator" parent="Menu_principal/HBoxContainer/VBoxSideButton"] modulate = Color(1, 1, 1, 0) self_modulate = Color(1, 1, 1, 0) diff --git a/parametres/assign_menu/assigner_bouton.gd b/parametres/assign_menu/assigner_bouton.gd index 99befae..dac3c20 100644 --- a/parametres/assign_menu/assigner_bouton.gd +++ b/parametres/assign_menu/assigner_bouton.gd @@ -5,7 +5,7 @@ extends Control @onready var button = $HBoxContainer/Button as Button @export var nom_action : String = "BOUGER_HAUT" -var nom_touche : String = OS.get_keycode_string(InputMap.action_get_events(nom_action)[0].physical_keycode) +@onready var nom_touche : String = OS.get_keycode_string(InputMap.action_get_events(nom_action)[0].physical_keycode) # Called when the node enters the scene tree for the first time. @@ -28,9 +28,9 @@ func set_texte_label() -> void : "BOUGER_BAS": label.text = "descendre" "BOUGER_DROITE": - label.text = "droite" + label.text = "aller à droite" "BOUGER_GAUCHE": - label.text = "gauche" + label.text = "aller à gauche" "PAUSE": label.text = "Pause" @@ -39,6 +39,7 @@ func set_texte_bouton() -> void: button.text = "%s" % nom_touche func definir_touche(touche)-> void: + var old = InputMap.action_get_events(nom_action)[0] var action_keycode=touche.physical_keycode @@ -46,11 +47,14 @@ func definir_touche(touche)-> void: InputMap.action_add_event(nom_action, touche) set_texte_bouton() + print(nom_action, "deviens ", nom_touche) for i in get_tree().get_nodes_in_group("changer_touches"): - if i.nom_action != self.nom_action : - if i.nom_touche==self.nom_touche : - i.definir_touche(old) + if i.nom_action != self.nom_action and i.nom_touche==self.nom_touche : + InputMap.action_erase_events(i.nom_action) + InputMap.action_add_event(i.nom_action, old) + i.set_texte_bouton() + print(i.nom_action, "deviens ", i.nom_touche, "car échange") func _on_button_pressed(): button.text = "Appuyez sur une touche..." @@ -63,5 +67,5 @@ func _unhandled_key_input(event): func _on_hidden(): - set_process_unhandled_key_input(true) + set_process_unhandled_key_input(false) set_texte_bouton() diff --git a/parametres/tab_parametres.tscn b/parametres/tab_parametres.tscn index e53df86..c8bf8c8 100644 --- a/parametres/tab_parametres.tscn +++ b/parametres/tab_parametres.tscn @@ -22,9 +22,11 @@ func _process(delta): func _on_commandes_tab_changed(tab): - if tab != 2 : - commandes.MarginContainer.ScrollContainer.VBoxContainer.assigner_bouton.set_process_unhandled_key_input(false) + commandes.MarginContainer.ScrollContainer.VBoxContainer.assigner_bouton6.set_process_unhandled_key_input(false) commandes.MarginContainer.ScrollContainer.VBoxContainer.assigner_bouton2.set_process_unhandled_key_input(false) + commandes.MarginContainer.ScrollContainer.VBoxContainer.assigner_bouton3.set_process_unhandled_key_input(false) + commandes.MarginContainer.ScrollContainer.VBoxContainer.assigner_bouton4.set_process_unhandled_key_input(false) + commandes.MarginContainer.ScrollContainer.VBoxContainer.assigner_bouton5.set_process_unhandled_key_input(false) " [node name="Tab_Parametres" type="Control"] diff --git a/ressources/sons/idle_theme.wav.import b/ressources/sons/idle_theme.wav.import index 496bf8c..d134209 100644 --- a/ressources/sons/idle_theme.wav.import +++ b/ressources/sons/idle_theme.wav.import @@ -2,7 +2,7 @@ importer="wav" type="AudioStreamWAV" -uid="uid://drtyf4pv1cswd" +uid="uid://qyacm71epyhi" path="res://.godot/imported/idle_theme.wav-7d853091879d7fbaec43f980f4ba9daf.sample" [deps] diff --git a/scenes/Room.tscn b/scenes/Room.tscn index 6d4c96d..b9011dc 100644 --- a/scenes/Room.tscn +++ b/scenes/Room.tscn @@ -1,36 +1,41 @@ -[gd_scene load_steps=8 format=3 uid="uid://durhes43gex7a"] +[gd_scene load_steps=12 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="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"] [sub_resource type="WorldBoundaryShape2D" id="WorldBoundaryShape2D_1c4te"] normal = Vector2(0, 1) -distance = -360.0 +distance = -328.0 [sub_resource type="WorldBoundaryShape2D" id="WorldBoundaryShape2D_qq3vn"] -distance = -360.0 +distance = -314.0 [sub_resource type="WorldBoundaryShape2D" id="WorldBoundaryShape2D_e1nqi"] normal = Vector2(-1, 0) -distance = -640.0 +distance = -592.0 [sub_resource type="WorldBoundaryShape2D" id="WorldBoundaryShape2D_ia1hi"] normal = Vector2(1, 0) -distance = -640.0 +distance = -596.0 [node name="Room" type="Node2D"] +script = ExtResource("1_jh83c") [node name="TextureRect" type="TextureRect" parent="."] -offset_left = -640.0 +offset_left = -638.0 offset_top = -360.0 -offset_right = 640.0 +offset_right = 642.0 offset_bottom = 360.0 texture = ExtResource("2_torsx") stretch_mode = 1 [node name="Player_Melodie" parent="." instance=ExtResource("1_cl1wt")] -scale = Vector2(4, 4) +scale = Vector2(3, 3) [node name="StaticBody2D" type="StaticBody2D" parent="." groups=["World_Border"]] collision_layer = 3 @@ -39,18 +44,92 @@ collision_mask = 3 [node name="World Border Up" type="CollisionShape2D" parent="StaticBody2D"] shape = SubResource("WorldBoundaryShape2D_1c4te") +[node name="TextureRect" type="TextureRect" parent="StaticBody2D/World Border Up"] +offset_left = -640.0 +offset_top = -392.0 +offset_right = 640.0 +offset_bottom = -328.0 +texture = ExtResource("3_oi2tl") +stretch_mode = 1 + [node name="World Border Down" type="CollisionShape2D" parent="StaticBody2D"] shape = SubResource("WorldBoundaryShape2D_qq3vn") +[node name="TextureRect" type="TextureRect" parent="StaticBody2D/World Border Down"] +offset_left = 622.0 +offset_top = 379.0 +offset_right = 1902.0 +offset_bottom = 443.0 +rotation = 3.14159 +texture = ExtResource("3_oi2tl") +stretch_mode = 1 + [node name="World Border Right" type="CollisionShape2D" parent="StaticBody2D"] shape = SubResource("WorldBoundaryShape2D_e1nqi") +[node name="TextureRect" type="TextureRect" parent="StaticBody2D/World Border Right"] +offset_left = -659.0 +offset_top = 374.0 +offset_right = 61.0 +offset_bottom = 438.0 +rotation = -1.5708 +texture = ExtResource("3_oi2tl") +stretch_mode = 1 + [node name="World Border Left" type="CollisionShape2D" parent="StaticBody2D"] shape = SubResource("WorldBoundaryShape2D_ia1hi") +[node name="TextureRect" type="TextureRect" parent="StaticBody2D/World Border Left"] +offset_left = 658.0 +offset_top = -355.0 +offset_right = 1378.0 +offset_bottom = -291.0 +rotation = 1.5708 +texture = ExtResource("3_oi2tl") +stretch_mode = 1 + +[node name="TextureRect" type="TextureRect" parent="StaticBody2D"] +offset_left = -659.0 +offset_top = -392.0 +offset_right = -595.0 +offset_bottom = -328.0 +texture = ExtResource("4_6a3f6") + +[node name="TextureRect2" type="TextureRect" parent="StaticBody2D"] +offset_left = -659.0 +offset_top = 379.0 +offset_right = -595.0 +offset_bottom = 443.0 +rotation = -1.5708 +texture = ExtResource("4_6a3f6") + +[node name="TextureRect3" type="TextureRect" parent="StaticBody2D"] +offset_left = 658.0 +offset_top = 379.0 +offset_right = 722.0 +offset_bottom = 443.0 +rotation = 3.14159 +texture = ExtResource("4_6a3f6") + +[node name="TextureRect4" type="TextureRect" parent="StaticBody2D"] +offset_left = 658.0 +offset_top = -392.0 +offset_right = 722.0 +offset_bottom = -328.0 +rotation = 1.5708 +texture = ExtResource("4_6a3f6") + [node name="CanvasLayer" type="CanvasLayer" parent="."] [node name="Camera2D" type="Camera2D" parent="CanvasLayer"] [node name="Slime" parent="." groups=["Enemies"] instance=ExtResource("3_04ip2")] position = Vector2(-448, 205) + +[node name="Menu_parametres" parent="." instance=ExtResource("6_6ubhx")] +process_mode = 3 +visible = false +offset_left = -640.0 +offset_top = -360.0 +offset_right = 640.0 +offset_bottom = 360.0 diff --git a/scenes/enemies/slime.gd b/scenes/enemies/slime.gd index adfd4ff..df33253 100644 --- a/scenes/enemies/slime.gd +++ b/scenes/enemies/slime.gd @@ -2,7 +2,6 @@ extends CharacterBody2D const SPEED = 100.0 -var old_pos = Vector2.ZERO @onready var player = get_parent().get_node("Player_Melodie") var player_position = Vector2.ZERO var target_position = Vector2.ZERO @@ -25,9 +24,6 @@ func _process(delta: float) -> void: else : direction = target_position - if old_pos == position : - $AnimatedSprite2D.play("idle") - else : - $AnimatedSprite2D.play("walk_down") + $AnimatedSprite2D.play("Generic") velocity = direction * SPEED diff --git a/scenes/enemies/slime.tscn b/scenes/enemies/slime.tscn index e50663a..a33edd0 100644 --- a/scenes/enemies/slime.tscn +++ b/scenes/enemies/slime.tscn @@ -1,45 +1,20 @@ -[gd_scene load_steps=8 format=3 uid="uid://cyvqa6g64cw37"] +[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="1_n4mgf"] -[ext_resource type="Texture2D" uid="uid://c0b6d7551nbcm" path="res://ressources/images/blob-2-4.png" id="2_w8gqg"] -[ext_resource type="Texture2D" uid="uid://c1rqfml1fi47x" path="res://ressources/images/blob-3-side.png" id="3_pwpfc"] -[ext_resource type="Texture2D" uid="uid://2gqy3xv26df1" path="res://ressources/images/blob-3.png" id="5_bhc5m"] +[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("1_n4mgf") +"texture": ExtResource("2_f4wf2") }, { "duration": 1.0, -"texture": ExtResource("2_w8gqg") -}, { -"duration": 1.0, -"texture": ExtResource("3_pwpfc") -}, { -"duration": 1.0, -"texture": ExtResource("5_bhc5m") +"texture": ExtResource("3_dyq42") }], "loop": false, -"name": &"idle", -"speed": 3.0 -}, { -"frames": [{ -"duration": 1.0, -"texture": ExtResource("1_n4mgf") -}, { -"duration": 1.0, -"texture": ExtResource("2_w8gqg") -}, { -"duration": 1.0, -"texture": ExtResource("3_pwpfc") -}, { -"duration": 1.0, -"texture": ExtResource("2_w8gqg") -}], -"loop": true, -"name": &"walk_down", +"name": &"Generic", "speed": 3.0 }] @@ -52,11 +27,9 @@ collision_mask = 3 script = ExtResource("1_hnufy") [node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."] -position = Vector2(-3, 12) +scale = Vector2(0.2, 0.2) sprite_frames = SubResource("SpriteFrames_qfla8") -animation = &"idle" -frame = 1 -frame_progress = 1.0 +animation = &"Generic" [node name="CollisionShape2D" type="CollisionShape2D" parent="."] shape = SubResource("CircleShape2D_bokrm") diff --git a/scenes/room.gd b/scenes/room.gd new file mode 100644 index 0000000..5fbafdf --- /dev/null +++ b/scenes/room.gd @@ -0,0 +1,24 @@ +extends Node2D + +@onready var menu_parametres = $Menu_parametres + +# Called when the node enters the scene tree for the first time. +func _ready() -> void: + menu_parametres.exit_parametres.connect(on_exit_parametres) + + +# Called every frame. 'delta' is the elapsed time since the previous frame. +func _process(delta: float) -> void: + if Input.is_action_just_pressed("PAUSE") : + on_param_button_pressed() + + +func on_param_button_pressed(): + get_tree().paused = true + menu_parametres.set_process(true) + menu_parametres.visible = true + +func on_exit_parametres() -> void : + get_tree().paused = false + menu_parametres.visible = false + menu_parametres.set_process(false)