30 lines
666 B
GDScript
30 lines
666 B
GDScript
extends Area2D
|
|
|
|
var audio : AudioStreamPlayer
|
|
var sound_list = [
|
|
preload("res://ressources/sons/tambour-1.mp3"),
|
|
preload("res://ressources/sons/tambour-2.mp3"),
|
|
preload("res://ressources/sons/tambour-3.mp3"),
|
|
]
|
|
|
|
|
|
func _ready() :
|
|
var index = randi_range(0, 2)
|
|
print(sound_list[index])
|
|
var audiostream = AudioStreamPlayer.new()
|
|
audiostream.stream = sound_list[index]
|
|
get_tree().current_scene.add_child(audiostream)
|
|
audiostream.play()
|
|
|
|
var timer = 0.0
|
|
var cooldown = 0.33
|
|
|
|
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)
|