|
@@ -17,6 +17,11 @@ enum Direction {
|
|
|
LEFT = 3
|
|
|
}
|
|
|
|
|
|
+enum Side {
|
|
|
+ LEFT = -1
|
|
|
+ RIGHT = 1
|
|
|
+}
|
|
|
+
|
|
|
# Movement
|
|
|
var posix
|
|
|
var posiy
|
|
@@ -55,12 +60,12 @@ func _unhandled_input(event):
|
|
|
if event.is_action(turn_left_action):
|
|
|
tween.rotate_char(self, rotation_degrees - 90)
|
|
|
|
|
|
- dire_delta = -1
|
|
|
+ dire_delta = Side.LEFT
|
|
|
get_tree().set_input_as_handled()
|
|
|
elif event.is_action(turn_right_action):
|
|
|
tween.rotate_char(self, rotation_degrees + 90)
|
|
|
|
|
|
- dire_delta = 1
|
|
|
+ dire_delta = Side.RIGHT
|
|
|
get_tree().set_input_as_handled()
|
|
|
|
|
|
func _on_game_start():
|
|
@@ -83,13 +88,13 @@ func move():
|
|
|
|
|
|
generate_wall()
|
|
|
|
|
|
- if dire_delta == -1 and !has_block_on_side(dire_delta):
|
|
|
+ if dire_delta == Side.LEFT and !has_block_on(Side.LEFT):
|
|
|
# TODO Undo sprite turn if blocked
|
|
|
dire += dire_delta
|
|
|
if dire < 0:
|
|
|
dire = 3
|
|
|
|
|
|
- elif dire_delta == 1 and !has_block_on_side(dire_delta):
|
|
|
+ elif dire_delta == Side.RIGHT and !has_block_on(Side.RIGHT):
|
|
|
dire += dire_delta
|
|
|
if dire > 3:
|
|
|
dire = 0
|
|
@@ -104,7 +109,7 @@ func move():
|
|
|
tween.move_char(self, target_pos)
|
|
|
tween.start()
|
|
|
|
|
|
-func has_block_on_side(left_or_right:int):
|
|
|
+func has_block_on(left_or_right:int):
|
|
|
var bposx:int = posix - diry * left_or_right
|
|
|
var bposy:int = posiy + dirx * left_or_right
|
|
|
|