hexland/Scripts/Hex.gd

33 lines
743 B
GDScript3
Raw Normal View History

2022-08-23 10:37:13 -05:00
extends Node2D
class_name Hex
const WIDTH = 220
const HEIGHT = 190
const HALFWIDTH = WIDTH / 2
const HALFHEIGHT = HEIGHT / 2
const TEXTURE_MAP = {
"hills": preload("res://Assets/brick-hex.png"),
"forest": preload("res://Assets/wood-hex.png"),
"mountains": preload("res://Assets/stone-hex.png"),
"fields": preload("res://Assets/wheat-hex.png"),
"pasture": preload("res://Assets/sheep-hex.png"),
"desert": preload("res://Assets/desert-hex.png"),
}
var type = "desert" setget set_type
2022-08-23 14:12:59 -05:00
var index = Vector2.ZERO
2022-08-23 10:37:13 -05:00
func _ready():
2022-08-23 14:40:20 -05:00
$Image.texture = TEXTURE_MAP[type]
2022-08-23 14:12:59 -05:00
func _process(_delta):
if Debug.on:
2022-08-23 14:40:20 -05:00
$DebugLabel.text = "(%+d, %+d)" % [index.x, index.y]
2022-08-23 10:37:13 -05:00
func set_type(newtype):
2022-08-23 14:40:20 -05:00
$Image.texture = TEXTURE_MAP[newtype]
2022-08-23 10:37:13 -05:00
type = newtype