summaryrefslogtreecommitdiffstats
path: root/demo
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2020-07-21 09:16:24 +0200
committerJérémy Zurcher <jeremy@asynk.ch>2020-07-21 09:16:24 +0200
commitb7f765ebe28dd8dea3e4c094c46681fdfec56fc3 (patch)
tree1d2f39f52ab78e2eb1f7c6cf18e21089240b4a9d /demo
parent7c0292f085fb6a590c64f105647bb8bdd536fef8 (diff)
downloadgodot-hexgrid-b7f765ebe28dd8dea3e4c094c46681fdfec56fc3.zip
godot-hexgrid-b7f765ebe28dd8dea3e4c094c46681fdfec56fc3.tar.gz
HexMap.configure(…) -> HexMap._init(…)
Diffstat (limited to 'demo')
-rw-r--r--demo/Map.gd14
1 files changed, 6 insertions, 8 deletions
diff --git a/demo/Map.gd b/demo/Map.gd
index 81c5c36..22ad0fd 100644
--- a/demo/Map.gd
+++ b/demo/Map.gd
@@ -34,9 +34,6 @@ var show_influence : bool
func _ready():
drag = null
unit = Unit.new()
- board = HexBoard.new()
- board.tile_factory_fct = funcref(self, "get_tile")
- board.v = false
rotate_map()
func reset() -> void:
@@ -56,7 +53,7 @@ func reset() -> void:
compute()
func rotate_map() -> void:
- texture = load(MAPH if board.v else MAPV)
+ texture = load(MAPH if is_instance_valid(board) and board.v else MAPV)
configure()
reset()
@@ -67,20 +64,21 @@ func set_mode(l : bool, m : bool, i : bool) -> void:
compute()
func configure() -> void:
+ var v : bool = (is_instance_valid(board) and board.v)
var v0 : Vector2 = Vector2(50, 100)
if centered:
var ts : Vector2 = texture.get_size()
- if board.v:
+ if v:
v0.x -= ts.y / 2
v0.y -= ts.x / 2
else:
v0 -= ts / 2
- if board.v:
+ if v:
hex_rotation = 30
- board.configure(10, 4, 100, v0, false)
+ board = HexBoard.new(10, 4, 100, v0, false, funcref(self, "get_tile"))
else:
hex_rotation = 0
- board.configure(10, 7, 100, v0, true)
+ board = HexBoard.new(10, 7, 100, v0, true, funcref(self, "get_tile"))
func texture_size() -> Vector2:
return texture.get_size()