| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100 | extends Area2Dvar direction = Vector2()const DEG_UP = 0const DEG_RIGHT = 90const DEG_DOWN = 180const DEG_LEFT = 270const DEG_LIST = [DEG_UP, DEG_RIGHT, DEG_DOWN, DEG_LEFT]const DIR_UP = 0const DIR_RIGHT = 1const DIR_DOWN = 2const DIR_LEFT = 3var posixvar posiyvar dirx = 0var diry = 0var dire = DIR_UPvar gridvar is_moving = falsevar tweenvar target_pos = Vector2()var blocks = []var is_blocked:bool = falsevar rayFrontvar rayLeftvar rayRightfunc _ready():	grid = get_parent()		posix = int (position.x / 64)	posiy = int (position.y / 64)	turn(DIR_UP)	tween = $Tween	tween.connect_into(self)	rayFront = $RayFront	rayLeft = $RayLeft	rayRight = $RayRightfunc _physics_process(delta):	if Input.is_action_pressed("ui_left"):		if !is_moving:			dire -= 1			if dire < 0:				dire = 3			tween.rotate_char(self, rotation_degrees - 90)			is_moving = true	elif Input.is_action_pressed("ui_right"):		if !is_moving:			dire += 1			if dire > 3:				dire = 0			tween.rotate_char(self, rotation_degrees + 90)			is_moving = true	if Input.is_action_pressed("ui_up"):		turn(dire)		if !is_moving and !rayFront.is_colliding():			posix += dirx			posiy += diry			target_pos = Vector2(posix * 64 + 32, posiy * 64 + 32)			tween.move_char(self, target_pos)			is_moving = truefunc _on_tween_completed(o, k):	is_moving = falsefunc turn(dir:int):	dirx = 0	diry = 0	if dir == DIR_UP:		diry -= 1	elif dir == DIR_RIGHT:		dirx += 1	elif dir == DIR_DOWN:		diry += 1	else:		dirx -= 1
 |