Fix colors
This commit is contained in:
parent
790385b67a
commit
ee2ff1112e
11 changed files with 88 additions and 108 deletions
|
@ -1,14 +1,16 @@
|
|||
class_name Flute
|
||||
|
||||
var scene_node = null
|
||||
var balle_scenes = [
|
||||
preload("res://scenes/attaques/Balle1.tscn"),
|
||||
preload("res://scenes/attaques/Balle2.tscn"),
|
||||
preload("res://scenes/attaques/Balle3.tscn")
|
||||
var balle_template = preload("res://scenes/attaques/Balle.tscn")
|
||||
var color_index = 0
|
||||
var color_list = [
|
||||
preload("res://ressources/images/note1.png"),
|
||||
preload("res://ressources/images/note2.png"),
|
||||
preload("res://ressources/images/note3.png"),
|
||||
preload("res://ressources/images/note2.png")
|
||||
]
|
||||
var current_balle_index = 0
|
||||
|
||||
@export var cooldown = 0.15 # Durée du cooldown en secondes
|
||||
@export var cooldown = 0.5 # Durée du cooldown en secondes
|
||||
var is_on_cooldown = false # Indique si le cooldown est en cours
|
||||
|
||||
func set_scene_parent(node: Node) -> void:
|
||||
|
@ -36,23 +38,15 @@ func spawn_balle(player_position: Vector2, direction_balle: Vector2, angle: floa
|
|||
if scene_node == null:
|
||||
print("Erreur : Aucun nœud parent défini pour ajouter la balle.")
|
||||
return
|
||||
|
||||
var current_balle_scene = balle_scenes[current_balle_index]
|
||||
var balle = current_balle_scene.instantiate()
|
||||
|
||||
if balle:
|
||||
balle.position = player_position
|
||||
balle.initial_direction = direction_balle
|
||||
balle.rotation = deg_to_rad(angle)
|
||||
scene_node.add_child(balle)
|
||||
|
||||
# Basculer vers la prochaine balle pour le prochain tir
|
||||
current_balle_index = (current_balle_index + 1) % len(balle_scenes)
|
||||
|
||||
# Démarrez le cooldown après ce tir
|
||||
start_cooldown()
|
||||
else:
|
||||
print("Erreur : la création de la balle a échoué.")
|
||||
var balle = balle_template.instantiate()
|
||||
balle.position = player_position
|
||||
balle.initial_direction = direction_balle
|
||||
balle.rotation = deg_to_rad(angle)
|
||||
color_index = (1 +color_index)% len(color_list)
|
||||
balle.get_node("Sprite2D").texture = color_list[color_index]
|
||||
scene_node.add_child(balle)
|
||||
# Démarrez le cooldown après ce tir
|
||||
start_cooldown()
|
||||
|
||||
|
||||
# Démarrer le timer pour le cooldown
|
||||
|
|
|
@ -1,20 +1,17 @@
|
|||
extends CharacterBody2D
|
||||
extends Area2D
|
||||
|
||||
@export var speed: float = 400 # Définir la vitesse de la balle
|
||||
@export var speed: float = 300 # Définir la vitesse de la balle
|
||||
@export var raycast: RayCast2D
|
||||
|
||||
|
||||
|
||||
# Direction initiale du mouvement
|
||||
var initial_direction: Vector2 = Vector2(1, 0) # Exemple par défaut : vers la droite
|
||||
|
||||
func _ready() -> void:
|
||||
# Configurer la vitesse sur l'axe désiré
|
||||
velocity = initial_direction * speed # Multiplie la direction initiale par la vitesse
|
||||
|
||||
func _physics_process(delta: float) -> void:
|
||||
move_and_collide(velocity * delta)
|
||||
if raycast.is_colliding():
|
||||
queue_free()
|
||||
position += initial_direction * speed * delta
|
||||
|
||||
|
||||
|
||||
func Collision(body: Node2D) -> void:
|
||||
if body.is_in_group("World_Border") :
|
||||
queue_free()
|
||||
if body.is_in_group("Enemies") :
|
||||
queue_free()
|
||||
|
|
|
@ -13,6 +13,7 @@ var tambour = null
|
|||
# Slot actif (0 = Flûte, 1 = Tambour)
|
||||
var active_slot = 0
|
||||
|
||||
var flute_timer = 0
|
||||
|
||||
func _ready() -> void:
|
||||
flute = load("res://scripts/Instrument/Flute.gd").new()
|
||||
|
@ -47,22 +48,22 @@ func _process(delta: float) -> void:
|
|||
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_pressed("JOUER_MUSIQUE_HAUT"):
|
||||
direction_balle = Vector2(0, -1)
|
||||
angle = 180
|
||||
elif Input.is_action_pressed("JOUER_MUSIQUE_BAS"):
|
||||
direction_balle = Vector2(0, 1)
|
||||
angle = 0
|
||||
elif Input.is_action_pressed("JOUER_MUSIQUE_DROITE"):
|
||||
direction_balle = Vector2(1, 0)
|
||||
angle = 270
|
||||
elif Input.is_action_pressed("JOUER_MUSIQUE_GAUCHE"):
|
||||
direction_balle = Vector2(-1, 0)
|
||||
angle = 90
|
||||
|
||||
|
||||
var direction_balle = Vector2.ZERO
|
||||
var angle = 0
|
||||
if Input.is_action_pressed("JOUER_MUSIQUE_HAUT"):
|
||||
direction_balle = Vector2(0, -1)
|
||||
angle = 180
|
||||
elif Input.is_action_pressed("JOUER_MUSIQUE_BAS"):
|
||||
direction_balle = Vector2(0, 1)
|
||||
angle = 0
|
||||
elif Input.is_action_pressed("JOUER_MUSIQUE_DROITE"):
|
||||
direction_balle = Vector2(1, 0)
|
||||
angle = 270
|
||||
elif Input.is_action_pressed("JOUER_MUSIQUE_GAUCHE"):
|
||||
direction_balle = Vector2(-1, 0)
|
||||
angle = 90
|
||||
if direction_balle != Vector2.ZERO :
|
||||
if active_slot == 0: # Slot Flûte
|
||||
flute.jouer_melodie(position, direction_balle, angle)
|
||||
elif active_slot == 1: # Slot Tambour
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue