PirateTreasureHunt/Globals.gd

43 lines
1009 B
GDScript

extends Node
const WIDTH=1024
const HEIGHT=1024
const GRID_SIZE=float(64.0)
const GRID_COLOR="#000000"
const SHOVEL_DURATION=1
var DebugLabel = null
var HexGrid = preload("../thirdparty/gdhexgrid/HexGrid.gd").new()
# Called when the node enters the scene tree for the first time.
func _ready():
pass # Replace with function body.
func ClearDebugLabel():
if DebugLabel == null:
return
DebugLabel.text = ""
func DebugLabelAdd(text):
if DebugLabel == null:
return
DebugLabel.text = DebugLabel.text + text + "\n"
func WorldToGridCoord(world_pos):
return Vector2(
floor (world_pos.x / Globals.GRID_SIZE),
floor (world_pos.y / Globals.GRID_SIZE)
)
func WorldToGridCenter(world_pos):
return WorldToGridCoord(world_pos) * GRID_SIZE + Vector2(GRID_SIZE, GRID_SIZE) * 0.5
func GridCenterToWorldCoord(grid_coord):
return grid_coord * GRID_SIZE + Vector2(GRID_SIZE, GRID_SIZE) * 0.5
# Called every frame. 'delta' is the elapsed time since the previous frame.
#func _process(delta):
# pass