Finish correct implementation of rock falling, and complete enemy.
This commit is contained in:
parent
8ce9ada279
commit
0266957b22
6
Enemy.gd
6
Enemy.gd
@ -78,7 +78,7 @@ func follow_wall(player_pos):
|
||||
|
||||
func _physics_process(delta):
|
||||
mv_delta += delta
|
||||
if mv_delta >= 1:
|
||||
if mv_delta >= 0.6:
|
||||
mv_delta = 0
|
||||
var state = get_parent().get_state()
|
||||
var player_pos = state.player_pos
|
||||
@ -88,12 +88,16 @@ func _physics_process(delta):
|
||||
if path == null:
|
||||
return
|
||||
var mv_target = path[-1]
|
||||
if state.player_pos == mv_target:
|
||||
OS.window_size = Vector2(1024,600)
|
||||
get_tree().change_scene("res://Defeat.tscn")
|
||||
for offset in directions:
|
||||
if get_pos() + offset == mv_target:
|
||||
var old_pos = get_pos()
|
||||
self.translate(offset * Vector2(speed, speed))
|
||||
var new_pos = get_pos()
|
||||
state.move(old_pos, new_pos)
|
||||
state.enemy_pos = get_pos()
|
||||
break
|
||||
|
||||
func get_pos():
|
||||
|
30
Rock.gd
30
Rock.gd
@ -8,31 +8,43 @@ var last_mv_delta = 0
|
||||
func get_fall_offset():
|
||||
var state = get_parent().get_state()
|
||||
var tile_below = get_pos() + Vector2(0, 1)
|
||||
if state.player_pos == tile_below:
|
||||
OS.window_size = Vector2(1024,600)
|
||||
get_tree().change_scene("res://Defeat.tscn")
|
||||
if tile_below.y > len(state.level_map) - 1:
|
||||
if state.player_pos == tile_below or state.enemy_pos == tile_below:
|
||||
if falling:
|
||||
OS.window_size = Vector2(1024,600)
|
||||
get_tree().change_scene("res://Defeat.tscn")
|
||||
return null
|
||||
elif tile_below.y > len(state.level_map) - 1:
|
||||
return null
|
||||
if state.get_type(tile_below) == "Empty":
|
||||
return Vector2(0, 1)
|
||||
if state.get_type(tile_below) != "Rock":
|
||||
return null
|
||||
var left_tile = get_pos() + Vector2(-1, 0)
|
||||
if left_tile.x > 0 and state.get_type(left_tile) == "Empty":
|
||||
if state.player_pos == left_tile or state.enemy_pos == left_tile:
|
||||
pass
|
||||
elif left_tile.x > 0 and state.get_type(left_tile) == "Empty":
|
||||
var tile_left_below = get_pos() + Vector2(-1, 1)
|
||||
if state.get_type(tile_left_below) == "Empty":
|
||||
if state.player_pos == tile_left_below or \
|
||||
state.enemy_pos == tile_left_below:
|
||||
pass
|
||||
elif state.get_type(tile_left_below) == "Empty":
|
||||
return Vector2(-1, 0)
|
||||
var right_tile = get_pos() + Vector2(1, 0)
|
||||
if right_tile.x < len(state.level_map[0]) - 1 and \
|
||||
if state.player_pos == right_tile or state.enemy_pos == right_tile:
|
||||
pass
|
||||
elif right_tile.x < len(state.level_map[0]) - 1 and \
|
||||
state.get_type(right_tile) == "Empty":
|
||||
var tile_right_below = get_pos() + Vector2(1, 1)
|
||||
if state.get_type(tile_right_below) == "Empty":
|
||||
if state.player_pos == tile_right_below or \
|
||||
state.enemy_pos == tile_right_below:
|
||||
pass
|
||||
elif state.get_type(tile_right_below) == "Empty":
|
||||
return Vector2(1, 0)
|
||||
return null
|
||||
|
||||
func _physics_process(delta):
|
||||
last_mv_delta += delta
|
||||
if last_mv_delta >= 1:
|
||||
if last_mv_delta >= 0.2:
|
||||
last_mv_delta = 0
|
||||
var fall_offset = get_fall_offset()
|
||||
if fall_offset == null:
|
||||
|
Loading…
x
Reference in New Issue
Block a user