1
0
Fork 0

fixed small bug that allowed to enter waste diagonally

This commit is contained in:
Manu 2021-04-25 14:53:16 +02:00
parent 8ecb13ba0b
commit e0406d21ce
2 changed files with 30 additions and 24 deletions

View File

@ -60,10 +60,11 @@ class Tile:
return waste_line
func push(var direction :Vector2) -> void:
var waste_line := get_waste_line(direction)
var last = waste_line.pop_back()
last.push_r(direction, waste_line)
return
if can_push(direction):
var waste_line := get_waste_line(direction)
if not waste_line.empty():
var last = waste_line.pop_back()
last.push_r(direction, waste_line)
func push_r(var direction: Vector2, var waste_line := []) -> void:
var empty_tile = get_next_tile(direction)

View File

@ -62,10 +62,7 @@ func _process(delta):
sprite.animation = movement.animation
else:
var target = level.get_tile_v(tile_position + movement.direction)
if target.can_walk():
movement_queue.push_back(movement)
elif target.can_push(movement.direction):
target.push(movement.direction)
if target.can_walk() or target.can_push(movement.direction):
movement_queue.push_back(movement)
else:
sprite.animation = movement.animation
@ -76,25 +73,33 @@ func _process(delta):
if not movement_queue.empty():
var current_movement : Movement = movement_queue.front()
if current_target == null:
current_target = tile_position + current_movement.direction
var tile = level.get_tile_v(current_target)
if not tile.can_walk() and not tile.can_push(current_movement.direction):
print ("fuck you" + tile.can_push(current_movement.direction) as String)
current_target = null
movement_queue.pop_front()
else:
tile.push(current_movement.direction)
tile_position += current_movement.direction * delta * speed
var remaining : Vector2 = current_target - tile_position
if remaining.dot(current_movement.direction) <= 0:
tile_position = current_target
current_target = null
movement_queue.pop_front()
stepped = false
elif remaining.length() < 0.5 and not stepped:
step_count += 1
stepped = true
update_position()
last_move_time = OS.get_ticks_msec() / 1000.0
if current_target != null:
tile_position += current_movement.direction * delta * speed
var remaining : Vector2 = current_target - tile_position
if remaining.dot(current_movement.direction) <= 0:
tile_position = current_target
current_target = null
movement_queue.pop_front()
stepped = false
elif remaining.length() < 0.5 and not stepped:
step_count += 1
stepped = true
update_position()
last_move_time = OS.get_ticks_msec() / 1000.0
func update_position():