|
@@ -46,7 +46,7 @@ func _ready():
|
|
|
posix = int (position.x / 64)
|
|
|
posiy = int (position.y / 64)
|
|
|
|
|
|
- turn(dire)
|
|
|
+ update_dirxy()
|
|
|
|
|
|
tween.connect_into(self)
|
|
|
|
|
@@ -94,7 +94,7 @@ func move():
|
|
|
if dire > 3:
|
|
|
dire = 0
|
|
|
|
|
|
- turn(dire)
|
|
|
+ update_dirxy()
|
|
|
dire_delta = 0
|
|
|
|
|
|
posix += dirx
|
|
@@ -111,17 +111,19 @@ func has_block_on_side(left_or_right:int):
|
|
|
# TODO : use enum for blocks
|
|
|
return grid.get_cell(bposx, bposy) == 1
|
|
|
|
|
|
-func turn(dir:int):
|
|
|
+func update_dirxy():
|
|
|
dirx = 0
|
|
|
diry = 0
|
|
|
- if dir == Direction.UP:
|
|
|
+ if dire == Direction.UP:
|
|
|
diry -= 1
|
|
|
- elif dir == Direction.RIGHT:
|
|
|
+ elif dire == Direction.RIGHT:
|
|
|
dirx += 1
|
|
|
- elif dir == Direction.DOWN:
|
|
|
+ elif dire == Direction.DOWN:
|
|
|
diry += 1
|
|
|
- else:
|
|
|
+ elif dire == Direction.LEFT:
|
|
|
dirx -= 1
|
|
|
+ else:
|
|
|
+ push_error("dire out of range")
|
|
|
|
|
|
func die():
|
|
|
alive = false
|