|
@@ -3,9 +3,6 @@ extends Area2D
|
|
|
# Nodes
|
|
|
var grid:TileMap
|
|
|
onready var tween = $Tween
|
|
|
-onready var rayFront = $RayFront
|
|
|
-onready var rayLeft = $RayLeft
|
|
|
-onready var rayRight = $RayRight
|
|
|
|
|
|
# Misc
|
|
|
var cell_size
|
|
@@ -86,12 +83,13 @@ func move():
|
|
|
|
|
|
generate_wall()
|
|
|
|
|
|
- if dire_delta == -1 and !rayLeft.is_colliding():
|
|
|
+ if dire_delta == -1 and !has_block_on_side(dire_delta):
|
|
|
+ # TODO Undo sprite turn if blocked
|
|
|
dire += dire_delta
|
|
|
if dire < 0:
|
|
|
dire = 3
|
|
|
|
|
|
- elif dire_delta == 1 and !rayRight.is_colliding():
|
|
|
+ elif dire_delta == 1 and !has_block_on_side(dire_delta):
|
|
|
dire += dire_delta
|
|
|
if dire > 3:
|
|
|
dire = 0
|
|
@@ -106,6 +104,13 @@ func move():
|
|
|
tween.move_char(self, target_pos)
|
|
|
tween.start()
|
|
|
|
|
|
+func has_block_on_side(left_or_right:int):
|
|
|
+ var bposx:int = posix - diry * left_or_right
|
|
|
+ var bposy:int = posiy + dirx * left_or_right
|
|
|
+
|
|
|
+ # TODO : use enum for blocks
|
|
|
+ return grid.get_cell(bposx, bposy) == 1
|
|
|
+
|
|
|
func turn(dir:int):
|
|
|
dirx = 0
|
|
|
diry = 0
|