31 lines
690 B
GDScript
31 lines
690 B
GDScript
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
|
|
|
|
func _ready():
|
|
var sprite = Sprite.new()
|
|
sprite.texture = TEXTURE_MAP[type]
|
|
sprite.name = "Img"
|
|
add_child(sprite)
|
|
|
|
func set_type(newtype):
|
|
$Img.texture = TEXTURE_MAP[newtype]
|
|
type = newtype
|