Init Tambour

This commit is contained in:
Elouan 2025-01-24 18:45:09 +01:00
parent 5cf819a4ba
commit b5a9a54f94
15 changed files with 370 additions and 21 deletions

View file

@ -6,11 +6,20 @@ const max_boost_speed = 800
var previous_direction = Vector2.ZERO
var boost_speed = 0
var flute = null
var tambour = null
# Slot actif (0 = Flûte, 1 = Tambour)
var active_slot = 0
func _ready() -> void:
flute = load("res://scripts/Instrument/Flute.gd").new()
flute.set_scene_parent(get_tree().get_root())
tambour = load("res://scripts/Instrument/Tambour.gd").new()
tambour.set_scene_parent(get_tree().get_root())
@ -35,21 +44,28 @@ func _process(delta: float) -> void:
previous_direction = direction
velocity = direction * (move_speed + boost_speed)
if Input.is_action_just_pressed("JOUER_MUSIQUE_HAUT") or Input.is_action_just_pressed("JOUER_MUSIQUE_BAS") or Input.is_action_just_pressed("JOUER_MUSIQUE_DROITE") or Input.is_action_just_pressed("JOUER_MUSIQUE_GAUCHE"):
if Input.is_action_just_pressed("CHANGER_SLOT"):
active_slot = (active_slot + 1) % 2
if Input.is_action_pressed("JOUER_MUSIQUE_HAUT") or Input.is_action_pressed("JOUER_MUSIQUE_BAS") or Input.is_action_pressed("JOUER_MUSIQUE_DROITE") or Input.is_action_pressed("JOUER_MUSIQUE_GAUCHE"):
var direction_balle = Vector2.ZERO
var angle = 0
if Input.is_action_just_pressed("JOUER_MUSIQUE_HAUT"):
if Input.is_action_pressed("JOUER_MUSIQUE_HAUT"):
direction_balle = Vector2(0, -1)
angle = 180
elif Input.is_action_just_pressed("JOUER_MUSIQUE_BAS"):
elif Input.is_action_pressed("JOUER_MUSIQUE_BAS"):
direction_balle = Vector2(0, 1)
angle = 0
elif Input.is_action_just_pressed("JOUER_MUSIQUE_DROITE"):
elif Input.is_action_pressed("JOUER_MUSIQUE_DROITE"):
direction_balle = Vector2(1, 0)
angle = 270
elif Input.is_action_just_pressed("JOUER_MUSIQUE_GAUCHE"):
elif Input.is_action_pressed("JOUER_MUSIQUE_GAUCHE"):
direction_balle = Vector2(-1, 0)
angle = 90
flute.jouer_melodie(position, direction_balle, angle)
if active_slot == 0: # Slot Flûte
flute.jouer_melodie(position, direction_balle, angle)
elif active_slot == 1: # Slot Tambour
tambour.jouer_melodie(position)
pass