summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--HexBoard.gd17
-rw-r--r--README.md2
2 files changed, 18 insertions, 1 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))
diff --git a/README.md b/README.md
index cd7300d..92cfcb4 100644
--- a/README.md
+++ b/README.md
@@ -10,7 +10,7 @@ base map made with [gimp](https://www.gimp.org) and my plugin [hexmap](https://g
## features
- [x] Distance
- - [ ] Adjacents
+ - [x] Adjacents
- [x] Line Of Sight
- [ ] Reachable Tiles ::: BFS
- [ ] Shortest Path ::: A*