diff options
Diffstat (limited to 'HexBoard.gd')
-rw-r--r-- | HexBoard.gd | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/HexBoard.gd b/HexBoard.gd index ce240f8..b890cc0 100644 --- a/HexBoard.gd +++ b/HexBoard.gd @@ -21,6 +21,7 @@ var tl : int # num of hexes in 2 consecutives rows var tile_factory_fct : FuncRef var angles : Dictionary +var adjacents : Array func configure(cols : int, rows : int, side : float, v0 : Vector2, vertical : bool) -> void: v = vertical @@ -90,6 +91,22 @@ func _key(x : int, y : int) -> int: i += (int(cr.x) - 1) return i +func adjacents(coords : Vector2) -> Array: + adjacents.clear() + coords.x += 1 + adjacents.append(get_tile(coords)) + coords.y += 1 + adjacents.append(get_tile(coords)) + coords.x -= 1 + adjacents.append(get_tile(coords)) + coords.x -= 1 + adjacents.append(get_tile(coords)) + coords.y -= 2 + adjacents.append(get_tile(coords)) + coords.x += 1 + adjacents.append(get_tile(coords)) + return adjacents + func is_on_map(coords : Vector2) -> bool: if v: return _is_on_map(int(coords.x), int(coords.y)) else: return _is_on_map(int(coords.y), int(coords.x)) |