godot-puzzle/level/player_barrier_01.gd

26 lines
624 B
GDScript

extends Board
var ball: Piece
var goal: Piece
func _ready() -> void:
for piece in pieces():
if piece.type == Piece.Type.Ball:
ball = piece
if piece.type == Piece.Type.Goal:
goal = piece
super()
func won() -> bool:
return ball.lpos + ball.lvel == goal.lpos
func good() -> bool:
return (ball.lpos.x == 2 and ball.lvel.x <= 3) or won()
func _process(_delta: float) -> void:
$Move.visible = player().lpos.y != 1 and good() and not won()
$Push.visible = player().lpos.y == 1 and good() and not won()
$Undo.visible = not good()
$Wait.visible = won()
$ControlsMove.visible = $Move.visible or $Push.visible