Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- func player_proximity():
- var player_pos
- player_pos = world_to_map(player.get_position())
- for x in range(grid_size.x):
- for y in range(grid_size.y):
- player_proximity[x][y] = 990
- #Create unexplored set
- var unexplored_set = []
- for x in range(grid_size.x):
- for y in range(grid_size.y):
- if is_cell_not_wall(Vector2(x, y)) == true:
- unexplored_set.append(Vector2(x, y))
- debug_array = unexplored_set
- player_proximity[player_pos.x][player_pos.y] = 0
- #hunt for lowest proximity value
- var current_min = 0
- var AllAdjacentCells = []
- var UnexploredAdjacentCells = []
- var SearchRange = 16
- for f in range(SearchRange):
- for x in range(grid_size.x):
- for y in range(grid_size.y):
- if player_proximity[x][y] == current_min: #&& unexplored_set.has(Vector2(x, y))
- unexplored_set.erase(Vector2(x, y))
- print (x, y) #"it's a start" - DmD
- AllAdjacentCells = get_adjacent_cells(Vector2(x, y))
- for z in range(AllAdjacentCells.size()):
- if unexplored_set.has(AllAdjacentCells[z]):
- UnexploredAdjacentCells.append(AllAdjacentCells[z])
- #print(UnexploredAdjacentCells)
- for f in range(UnexploredAdjacentCells.size()):
- player_proximity[(UnexploredAdjacentCells[f].x)][UnexploredAdjacentCells[f].y] = current_min+1
- unexplored_set.erase(Vector2(UnexploredAdjacentCells[f].x, UnexploredAdjacentCells[f].y))
- current_min += 1
- AllAdjacentCells.clear()
- UnexploredAdjacentCells.clear()
- #print(player_proximity.min())
- #print(unexplored_set)
- pass
Advertisement
Add Comment
Please, Sign In to add comment