Pickup flute
This commit is contained in:
parent
204848fcf1
commit
142500fdd8
9 changed files with 181 additions and 39 deletions
19
ressources/sons/melodie-bobo-1.mp3.import
Normal file
19
ressources/sons/melodie-bobo-1.mp3.import
Normal file
|
@ -0,0 +1,19 @@
|
|||
[remap]
|
||||
|
||||
importer="mp3"
|
||||
type="AudioStreamMP3"
|
||||
uid="uid://kqdamgqyyxw2"
|
||||
path="res://.godot/imported/melodie-bobo-1.mp3-7aa3030b2c790daa8c4313aa01ae98f9.mp3str"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://ressources/sons/melodie-bobo-1.mp3"
|
||||
dest_files=["res://.godot/imported/melodie-bobo-1.mp3-7aa3030b2c790daa8c4313aa01ae98f9.mp3str"]
|
||||
|
||||
[params]
|
||||
|
||||
loop=false
|
||||
loop_offset=0
|
||||
bpm=0
|
||||
beat_count=0
|
||||
bar_beats=4
|
19
ressources/sons/melodie-bobo-2.mp3.import
Normal file
19
ressources/sons/melodie-bobo-2.mp3.import
Normal file
|
@ -0,0 +1,19 @@
|
|||
[remap]
|
||||
|
||||
importer="mp3"
|
||||
type="AudioStreamMP3"
|
||||
uid="uid://08ck1o5bu3ik"
|
||||
path="res://.godot/imported/melodie-bobo-2.mp3-bb198435e05ddb0da77a07ac4cfc56ba.mp3str"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://ressources/sons/melodie-bobo-2.mp3"
|
||||
dest_files=["res://.godot/imported/melodie-bobo-2.mp3-bb198435e05ddb0da77a07ac4cfc56ba.mp3str"]
|
||||
|
||||
[params]
|
||||
|
||||
loop=false
|
||||
loop_offset=0
|
||||
bpm=0
|
||||
beat_count=0
|
||||
bar_beats=4
|
19
ressources/sons/melodie-bobo-3.mp3.import
Normal file
19
ressources/sons/melodie-bobo-3.mp3.import
Normal file
|
@ -0,0 +1,19 @@
|
|||
[remap]
|
||||
|
||||
importer="mp3"
|
||||
type="AudioStreamMP3"
|
||||
uid="uid://br06mx63u85ws"
|
||||
path="res://.godot/imported/melodie-bobo-3.mp3-12ce345635646780a00ff0064dda381b.mp3str"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://ressources/sons/melodie-bobo-3.mp3"
|
||||
dest_files=["res://.godot/imported/melodie-bobo-3.mp3-12ce345635646780a00ff0064dda381b.mp3str"]
|
||||
|
||||
[params]
|
||||
|
||||
loop=false
|
||||
loop_offset=0
|
||||
bpm=0
|
||||
beat_count=0
|
||||
bar_beats=4
|
19
ressources/sons/melodie-bobo-4.mp3.import
Normal file
19
ressources/sons/melodie-bobo-4.mp3.import
Normal file
|
@ -0,0 +1,19 @@
|
|||
[remap]
|
||||
|
||||
importer="mp3"
|
||||
type="AudioStreamMP3"
|
||||
uid="uid://dj7u75k6nesm8"
|
||||
path="res://.godot/imported/melodie-bobo-4.mp3-85d81fc35615c5448418bb695518b42e.mp3str"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://ressources/sons/melodie-bobo-4.mp3"
|
||||
dest_files=["res://.godot/imported/melodie-bobo-4.mp3-85d81fc35615c5448418bb695518b42e.mp3str"]
|
||||
|
||||
[params]
|
||||
|
||||
loop=false
|
||||
loop_offset=0
|
||||
bpm=0
|
||||
beat_count=0
|
||||
bar_beats=4
|
19
ressources/sons/melodie-bobo-5.mp3.import
Normal file
19
ressources/sons/melodie-bobo-5.mp3.import
Normal file
|
@ -0,0 +1,19 @@
|
|||
[remap]
|
||||
|
||||
importer="mp3"
|
||||
type="AudioStreamMP3"
|
||||
uid="uid://62041of2bg8o"
|
||||
path="res://.godot/imported/melodie-bobo-5.mp3-3f367a2a630c34a5f2323ebc8535769d.mp3str"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://ressources/sons/melodie-bobo-5.mp3"
|
||||
dest_files=["res://.godot/imported/melodie-bobo-5.mp3-3f367a2a630c34a5f2323ebc8535769d.mp3str"]
|
||||
|
||||
[params]
|
||||
|
||||
loop=false
|
||||
loop_offset=0
|
||||
bpm=0
|
||||
beat_count=0
|
||||
bar_beats=4
|
|
@ -1,16 +1,15 @@
|
|||
[gd_scene load_steps=16 format=3 uid="uid://durhes43gex7a"]
|
||||
[gd_scene load_steps=15 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="AudioStream" uid="uid://qyacm71epyhi" path="res://ressources/sons/idle_theme.wav" id="2_8nbnd"]
|
||||
[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"]
|
||||
[ext_resource type="PackedScene" uid="uid://bndtclt51nsih" path="res://scenes/interface.tscn" id="8_5s7tf"]
|
||||
[ext_resource type="PackedScene" uid="uid://bdpm5s1tpslhc" path="res://scenes/pickups/flute_pickup.tscn" id="10_0do8n"]
|
||||
[ext_resource type="PackedScene" uid="uid://ctgxrbcg2vu1p" path="res://scenes/ecran_mort.tscn" id="10_3ou8w"]
|
||||
[ext_resource type="PackedScene" uid="uid://cm5spgl8o4fam" path="res://scenes/enemies/robot.tscn" id="10_5qrsc"]
|
||||
|
||||
[sub_resource type="WorldBoundaryShape2D" id="WorldBoundaryShape2D_1c4te"]
|
||||
normal = Vector2(0, 1)
|
||||
|
@ -45,6 +44,7 @@ texture = ExtResource("2_torsx")
|
|||
stretch_mode = 1
|
||||
|
||||
[node name="Player_Melodie" parent="." node_paths=PackedStringArray("interface") groups=["Player"] instance=ExtResource("1_cl1wt")]
|
||||
position = Vector2(0, 200)
|
||||
scale = Vector2(3, 3)
|
||||
interface = NodePath("../Interface")
|
||||
|
||||
|
@ -134,9 +134,6 @@ texture = ExtResource("4_6a3f6")
|
|||
|
||||
[node name="Camera2D" type="Camera2D" parent="CanvasLayer"]
|
||||
|
||||
[node name="Slime" parent="." groups=["Enemies"] instance=ExtResource("3_04ip2")]
|
||||
position = Vector2(-448, 205)
|
||||
|
||||
[node name="Interface" parent="." instance=ExtResource("8_5s7tf")]
|
||||
offset_left = -640.0
|
||||
offset_top = -360.0
|
||||
|
@ -159,8 +156,9 @@ offset_top = -383.0
|
|||
offset_right = -258.0
|
||||
offset_bottom = -383.0
|
||||
|
||||
[node name="Robot" parent="." groups=["Enemies"] instance=ExtResource("10_5qrsc")]
|
||||
position = Vector2(-428, 11)
|
||||
[node name="InstrumentPickup" parent="." instance=ExtResource("10_0do8n")]
|
||||
position = Vector2(2, -64)
|
||||
scale = Vector2(0.15, 0.15)
|
||||
|
||||
[connection signal="finished" from="Musique" to="." method="_on_audio_stream_player_finished"]
|
||||
[connection signal="retour_menu" from="Ecran mort" to="." method="_on_ecran_mort_retour_menu"]
|
||||
|
|
21
scenes/pickups/flute_pickup.tscn
Normal file
21
scenes/pickups/flute_pickup.tscn
Normal file
|
@ -0,0 +1,21 @@
|
|||
[gd_scene load_steps=4 format=3 uid="uid://bdpm5s1tpslhc"]
|
||||
|
||||
[ext_resource type="Texture2D" uid="uid://bncbi6cd1m5y7" path="res://ressources/images/flute.svg" id="1_7m80x"]
|
||||
[ext_resource type="Script" path="res://scripts/Instrument/flute_pickup.gd" id="1_42t6n"]
|
||||
|
||||
[sub_resource type="CapsuleShape2D" id="CapsuleShape2D_rt2x3"]
|
||||
radius = 50.0
|
||||
height = 613.39
|
||||
|
||||
[node name="FlutePickup" type="Area2D"]
|
||||
collision_layer = 0
|
||||
script = ExtResource("1_42t6n")
|
||||
|
||||
[node name="Sprite2D" type="Sprite2D" parent="."]
|
||||
texture = ExtResource("1_7m80x")
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||
rotation = -0.785398
|
||||
shape = SubResource("CapsuleShape2D_rt2x3")
|
||||
|
||||
[connection signal="body_entered" from="." to="." method="_on_body_entered"]
|
18
scripts/Instrument/flute_pickup.gd
Normal file
18
scripts/Instrument/flute_pickup.gd
Normal file
|
@ -0,0 +1,18 @@
|
|||
extends Area2D
|
||||
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
pass # Replace with function body.
|
||||
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta: float) -> void:
|
||||
pass
|
||||
|
||||
|
||||
|
||||
func _on_body_entered(body: Node2D) -> void:
|
||||
if body.is_in_group("Player") :
|
||||
body.pick_up("flute")
|
||||
queue_free()
|
|
@ -21,11 +21,15 @@ var flute_cooldown = 0.5
|
|||
var tambour_cooldown = 3.0
|
||||
var lyre_cooldown = 1
|
||||
|
||||
var slot = []
|
||||
var slotstr = []
|
||||
var instrument_list = [
|
||||
"",
|
||||
""
|
||||
]
|
||||
|
||||
var vie = 10
|
||||
|
||||
signal instrument_switch
|
||||
|
||||
func _ready() -> void:
|
||||
flute = load("res://scripts/Instrument/Flute.gd").new()
|
||||
flute.set_scene_parent(get_tree().get_root())
|
||||
|
@ -36,31 +40,10 @@ func _ready() -> void:
|
|||
lyre = load("res://scripts/Instrument/Lyre.gd").new()
|
||||
lyre.set_scene_parent(get_tree().get_root())
|
||||
|
||||
|
||||
|
||||
|
||||
func _physics_process(delta: float) -> void:
|
||||
move_and_slide()
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
var direction : Vector2 = Vector2.ZERO
|
||||
direction.x = Input.get_action_raw_strength("BOUGER_DROITE") - Input.get_action_raw_strength("BOUGER_GAUCHE")
|
||||
direction.y = Input.get_action_raw_strength("BOUGER_BAS") - Input.get_action_raw_strength("BOUGER_HAUT")
|
||||
|
||||
if direction != Vector2.ZERO:
|
||||
if direction == previous_direction:
|
||||
if direction.x != 0 and direction.y != 0:
|
||||
boost_speed = min(boost_speed + acceleration / 16, (max_boost_speed - move_speed) / 8)
|
||||
else:
|
||||
boost_speed = min(boost_speed + acceleration, max_boost_speed - move_speed)
|
||||
else:
|
||||
boost_speed = 0
|
||||
|
||||
previous_direction = direction
|
||||
velocity = direction * (move_speed + boost_speed)
|
||||
else:
|
||||
velocity = Vector2.ZERO
|
||||
|
||||
func play_music(delta : float):
|
||||
var direction_balle = Vector2.ZERO
|
||||
var angle = 0
|
||||
var angle_lyre = 0
|
||||
|
@ -81,7 +64,7 @@ func _process(delta: float) -> void:
|
|||
direction_balle = Vector2(-1, 0)
|
||||
angle = 90
|
||||
angle_lyre = 180
|
||||
|
||||
|
||||
if flute_timer > 0:
|
||||
flute_timer -= delta
|
||||
|
||||
|
@ -90,19 +73,46 @@ func _process(delta: float) -> void:
|
|||
|
||||
if lyre_timer > 0:
|
||||
lyre_timer -= delta
|
||||
|
||||
if flute and flute_timer <= 0.0 and direction_balle != Vector2.ZERO:
|
||||
|
||||
if instrument_list.has("flute") and flute_timer <= 0.0 and direction_balle != Vector2.ZERO:
|
||||
flute.jouer_melodie(position, direction_balle, angle)
|
||||
flute_timer = flute_cooldown
|
||||
|
||||
if tambour and tambour_timer <= 0.0 and direction_balle != Vector2.ZERO:
|
||||
if instrument_list.has("tambour") and tambour_timer <= 0.0 and direction_balle != Vector2.ZERO:
|
||||
tambour.jouer_melodie(position)
|
||||
tambour_timer = tambour_cooldown
|
||||
|
||||
if lyre and lyre_timer <= 0.0 and direction_balle != Vector2.ZERO:
|
||||
if instrument_list.has("lyre") and lyre_timer <= 0.0 and direction_balle != Vector2.ZERO :
|
||||
lyre.jouer_melodie(position, direction_balle, angle_lyre)
|
||||
lyre_timer = lyre_cooldown
|
||||
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
var direction : Vector2 = Vector2.ZERO
|
||||
direction.x = Input.get_action_raw_strength("BOUGER_DROITE") - Input.get_action_raw_strength("BOUGER_GAUCHE")
|
||||
direction.y = Input.get_action_raw_strength("BOUGER_BAS") - Input.get_action_raw_strength("BOUGER_HAUT")
|
||||
|
||||
if direction != Vector2.ZERO:
|
||||
if direction == previous_direction:
|
||||
if direction.x != 0 and direction.y != 0:
|
||||
boost_speed = min(boost_speed + acceleration / 16, (max_boost_speed - move_speed) / 8)
|
||||
else:
|
||||
boost_speed = min(boost_speed + acceleration, max_boost_speed - move_speed)
|
||||
else:
|
||||
boost_speed = 0
|
||||
|
||||
previous_direction = direction
|
||||
velocity = direction * (move_speed + boost_speed)
|
||||
else:
|
||||
velocity = Vector2.ZERO
|
||||
|
||||
play_music(delta)
|
||||
|
||||
func pick_up(instrument : String) :
|
||||
if len(instrument_list) < 2 :
|
||||
instrument_list.append(instrument)
|
||||
else :
|
||||
instrument_list[0] = instrument_list[1]
|
||||
instrument_list[1] = instrument
|
||||
instrument_switch.emit()
|
||||
|
||||
func take_damage(dmg : int) :
|
||||
vie -= dmg
|
||||
|
|
Loading…
Add table
Reference in a new issue