This repository has been archived on 2022-03-31. You can view files and clone it, but cannot push or open issues or pull requests.
Tyra/scripts/Balle.gd

22 lines
698 B
GDScript3
Raw Normal View History

2021-04-07 18:15:41 +02:00
extends Area2D
var vitesseBalle = 700
2021-04-08 13:55:24 +02:00
var sonMortEnnemi = preload("res://scenes/SonMortEnnemi.tscn") # récupération Son
2021-04-07 18:15:41 +02:00
func _ready():
pass
2021-04-08 03:02:23 +02:00
func _physics_process(delta): # déplacement de la balle
2021-04-07 18:15:41 +02:00
position += transform.x * vitesseBalle * delta
func _on_Area2D_body_entered(body):
2021-04-08 03:02:23 +02:00
if "Murs" in body.name: # supprime la balle quand elle percute un mur
2021-04-07 18:15:41 +02:00
queue_free()
2021-04-08 03:02:23 +02:00
if "Ennemi" in body.name: # supprime l'ennemi et la balle quand le joueur touche qq1
2021-04-07 18:15:41 +02:00
queue_free()
2021-04-08 13:55:24 +02:00
var son = sonMortEnnemi.instance() # création object son
son.position = get_global_position() # récupération de la position
get_tree().get_root().call_deferred("add_child", son) # ajout du son
2021-04-07 18:15:41 +02:00
body.queue_free()