summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2020-07-10 10:33:35 +0200
committerJérémy Zurcher <jeremy@asynk.ch>2020-07-10 10:33:35 +0200
commit560b2702f1dfe2836c7127dbae7f7d3b515510c6 (patch)
treef1f03590885d1908a987fa01cfaac3190a3e5315
parente4284124ddfad218e989602bc46affc5492b0850 (diff)
downloadgodot-hexgrid-560b2702f1dfe2836c7127dbae7f7d3b515510c6.zip
godot-hexgrid-560b2702f1dfe2836c7127dbae7f7d3b515510c6.tar.gz
Hex : reorder overlays, add move
-rw-r--r--Hex.gd30
-rw-r--r--assets/move.pngbin0 -> 5145 bytes
2 files changed, 16 insertions, 14 deletions
diff --git a/Hex.gd b/Hex.gd
index f6b615d..d53730e 100644
--- a/Hex.gd
+++ b/Hex.gd
@@ -3,37 +3,35 @@ extends Tile
class_name Hex, "res://godot/Tile.png"
-var type : int = 0
+var type : int = -1
func _ready() -> void:
type = -1
func inspect() -> String:
var s : String = 'plain'
- if type == 2: s = 'city'
- elif type == 3: s = 'wood'
- elif type == 4: s = 'mountain'
+ if type == 0: s = 'city'
+ elif type == 1: s = 'wood'
+ elif type == 2: s = 'mountain'
return "%s e:%d h:%d c:%d\n -> [%d;%d]\n -> (%d;%d)" % [s, elevation(), height(), cost(), coords.x, coords.y, position.x, position.y]
func change() -> void:
- type += 1
- if type < 2: type = 2
- if type > 4: type = -1
- for i in range(2, 5):
- enable_overlay(i, i == type)
+ type = (type + 2) % 4 - 1
+ for i in range(3):
+ enable_overlay(i + 2, i == type)
func cost() -> int:
if type == -1: return 1
- return type - 1
+ return type + 1
func height() -> int:
- if type == 2: return 2
- elif type == 3: return 1
- elif type == 4: return 0
+ if type == 0: return 2
+ elif type == 1: return 1
+ elif type == 2: return 0
return 0
func elevation() -> int:
- if type == 4: return 2
+ if type == 2: return 2
return 0
func block_los(from : Tile, to : Tile, d : float, dt : float) -> bool:
@@ -51,3 +49,7 @@ func show_los(b) -> void:
else:
enable_overlay(0, false)
enable_overlay(1, false)
+
+func show_move(b) -> void:
+ if 5 < get_child_count():
+ enable_overlay(5, b)
diff --git a/assets/move.png b/assets/move.png
new file mode 100644
index 0000000..01db48d
--- /dev/null
+++ b/assets/move.png
Binary files differ