51 lines
1 KiB
GDScript
51 lines
1 KiB
GDScript
extends Area2D
|
|
|
|
var diraxeset = 0
|
|
var aleat = 0
|
|
var isonfloor = 0
|
|
|
|
# Called when the node enters the scene tree for the first time.
|
|
func _ready() -> void:
|
|
$sprites.play()
|
|
|
|
func _process(delta: float) -> void:
|
|
# Add the gravity.
|
|
if isonfloor == 0:
|
|
position.y += 35 * delta
|
|
diraxeset = 0
|
|
else:
|
|
if diraxeset == 0:
|
|
if position.y < 137:
|
|
if position.x < 70:
|
|
aleat = 1
|
|
elif position.x > 230:
|
|
aleat = 0
|
|
else:
|
|
aleat = randi() % 2
|
|
else:
|
|
if position.x < 103:
|
|
aleat = 1
|
|
if position.x > 197:
|
|
aleat = 0
|
|
diraxeset = 1
|
|
if aleat == 0:
|
|
position.x -= 35 * delta
|
|
else:
|
|
position.x += 35 * delta
|
|
|
|
# Touching ground, deleting axe
|
|
if position.y > 169:
|
|
Global.axes -= 1
|
|
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
|
|
|
|
if body.is_in_group("suelo"):
|
|
isonfloor = 1
|
|
|
|
func _on_body_exited(body: Node2D) -> void:
|
|
if body.is_in_group("suelo"):
|
|
isonfloor = 0
|