Last active
February 19, 2024 17:46
-
-
Save hiulit/9c13e15b7a3bd8a2afa28641323e3731 to your computer and use it in GitHub Desktop.
Get the surrounding tiles from a given tile (in grid-based coordinates)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func get_surrounding_tiles(current_tile): | |
var surrounding_tiles = [] | |
var target_tile | |
for y in 3: | |
for x in 3: | |
target_tile = current_tile + Vector2(x - 1, y - 1) | |
if current_tile == target_tile: | |
continue | |
surrounding_tiles.append(target_tile) | |
return surrounding_tiles |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment