37 lines
1 KiB
GDScript
37 lines
1 KiB
GDScript
class_name Grid extends Node2D
|
|
|
|
@export var ground_radius : float
|
|
@export var cell_height : float
|
|
@export var num_collumns : int
|
|
@export var debug : bool
|
|
|
|
var buildings : Array[Building] = []
|
|
|
|
func _draw() -> void:
|
|
if !debug:
|
|
return
|
|
|
|
for i in range(10):
|
|
draw_arc(Vector2.ZERO, ground_radius + i * cell_height, 0, TAU, 250, Color.SKY_BLUE, 1.0, true);
|
|
|
|
for i in range(num_collumns):
|
|
var angle = i * TAU / num_collumns;
|
|
draw_line(Vector2.ZERO, 10000 * Vector2.from_angle(angle), Color.SKY_BLUE);
|
|
|
|
func add_building_to_collumn(building : Building, collumn : int):
|
|
# find the height of the top building in the buildings list:
|
|
building.location = Vector2(collumn, 0)
|
|
var height = 0
|
|
|
|
# TODO: support other dimensions for buildings
|
|
|
|
# add the new building one higher than the previous
|
|
height += 1
|
|
building.location = Vector2i(collumn, height);
|
|
|
|
# for testing
|
|
func _ready() -> void:
|
|
var packed : PackedScene = preload("res://building.tscn")
|
|
var test_building = packed.instantiate()
|
|
test_building.location = Vector2(45, 1)
|
|
add_child(test_building)
|