33 lines
864 B
GDScript
33 lines
864 B
GDScript
extends Area2D
|
|
|
|
var limitx = [0,0]
|
|
var direction = 0 # 0 left to right, 1 right to left
|
|
var speed = 0
|
|
var is_on_ground: bool = false
|
|
var coyote_time: float = 0.1
|
|
var coyote_time_counter: float = 0.0
|
|
|
|
# Called when the node enters the scene tree for the first time.
|
|
func _ready() -> void:
|
|
$sprites.play("default")
|
|
|
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
|
func _process(delta: float) -> void:
|
|
if Global.stop == 0:
|
|
if direction == 0:
|
|
if limitx[1] > position.x:
|
|
position.x += speed * delta
|
|
else:
|
|
direction = 1
|
|
$sprites.flip_h = true
|
|
else:
|
|
if limitx[0] < position.x:
|
|
position.x -= speed * delta
|
|
else:
|
|
direction = 0
|
|
$sprites.flip_h = false
|
|
|
|
func _on_body_entered(body: Node2D) -> void:
|
|
if body.is_in_group("player") and Global.jeandeath == 0:
|
|
Global.jeandeath = 1
|
|
Global.jeanblocked = 1
|