Skip to content

Instantly share code, notes, and snippets.

@hiulit
Last active February 19, 2024 17:46
Show Gist options
  • Save hiulit/9c13e15b7a3bd8a2afa28641323e3731 to your computer and use it in GitHub Desktop.
Save hiulit/9c13e15b7a3bd8a2afa28641323e3731 to your computer and use it in GitHub Desktop.
Get the surrounding tiles from a given tile (in grid-based coordinates)
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