PirateTreasureHunt/DebugLayer.gd

40 lines
1.4 KiB
GDScript
Raw Normal View History

2021-06-12 17:48:58 +02:00
extends Node2D
var NavTarget
func _ready():
NavTarget = get_node("NavTarget")
func draw_nav_target_box():
var rect = Rect2 (NavTarget.GridCoords * Globals.GRID_SIZE, Vector2(Globals.GRID_SIZE, Globals.GRID_SIZE))
draw_rect (rect, "#99000044", true)
func _process(_delta):
update()
func _draw():
var offset = -Vector2(Globals.WIDTH, Globals.HEIGHT) * 0.5
draw_nav_target_box()
draw_set_transform(offset, 0, Vector2.ONE)
# outer bounds
draw_line(Vector2(0,0), Vector2(Globals.WIDTH, 0), Globals.GRID_COLOR)
draw_line(Vector2(0,Globals.HEIGHT), Vector2(Globals.WIDTH, Globals.HEIGHT), Globals.GRID_COLOR)
draw_line(Vector2(0,0), Vector2(0, Globals.HEIGHT), Globals.GRID_COLOR)
draw_line(Vector2(Globals.WIDTH,0), Vector2(Globals.WIDTH, Globals.HEIGHT), Globals.GRID_COLOR)
# inner lines
var columns = floor (Globals.WIDTH / Globals.GRID_SIZE)
var rows = floor (Globals.HEIGHT / Globals.GRID_SIZE)
for x in range (columns):
draw_line (Vector2(x * Globals.GRID_SIZE, 0), Vector2(x * Globals.GRID_SIZE, Globals.HEIGHT), Globals.GRID_COLOR)
for y in range (rows):
draw_line (Vector2(0, y * Globals.GRID_SIZE), Vector2(Globals.WIDTH, y * Globals.GRID_SIZE), Globals.GRID_COLOR)
draw_line(Vector2(0, Globals.HEIGHT * 0.5), Vector2(Globals.WIDTH, Globals.HEIGHT * 0.5), "#aa0000", 3)
draw_line(Vector2(Globals.WIDTH * 0.5, 0), Vector2(Globals.WIDTH * 0.5, Globals.HEIGHT), "#00aa00", 3)