code-game-jam-drop-plafond-.../scripts/Instrument/fusil_pompe.gd

25 lines
516 B
GDScript

extends Area2D
var timer = 0.0
var cooldown = 0.3
@onready var audio = $effet
var sound_list = [
preload("res://ressources/sons/lyre-1.mp3"),
preload("res://ressources/sons/lyre-2.mp3"),
preload("res://ressources/sons/lyre-3.mp3"),
]
func _ready() :
var index = randi() % 3
audio.stream = sound_list[index]
audio.play()
func _process(delta: float) -> void:
timer += delta
if timer >= cooldown:
queue_free()
func Collision(body: Node2D) -> void:
if body.is_in_group("Enemies") :
body.take_damage(3)