Hi folks, my proposed problem I need help solving boils down to this: On game start, set player position to center of tilemap. If this tile is water however, find the nearest tile which is not water, and set the players position to that tile.
Now my current proposed solution is thus:
i = 1
while(valid tile not found){
Check each tile with distance i away from tile on x and y coordinate.
If valid, valid tile not found = false
Else i++
}
While I will think this will work in finding a valid position for my player to spawn at, it isn’t efficient (will find a close valid point, not nessesarily the closest) and feels like a real brute force method. I’m trying to find either a method of solving this using Pythagorean to measure distance (instead of iterating and returning first valid) while being less computationally efficient, or using the height map I also have to find the closest point of land. The latter might be possible, but I forget how to solve a possible valley problem in the search.
Anyway, any help would be appreciated