abbayedesmorts-godot/scripts/smallfire_2.gd

26 lines
620 B
GDScript

extends Area2D
var direction = 0 # 0 go left, 1 go right
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
$sprites.play()
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
if direction == 0:
if position.x > 50:
position.x -= 45 * delta
else:
queue_free()
if direction == 1:
if position.x < 255:
position.x += 45 * delta
else:
queue_free()
func _on_body_entered(body: Node2D) -> void:
if body.is_in_group("player") and Global.jeandeath == 0:
Global.jeandeath = 1
Global.jeanblocked = 1