24 lines
582 B
GDScript
24 lines
582 B
GDScript
extends Node2D
|
|
export var map_size = Vector2(32, 16)
|
|
var tiles = []
|
|
signal size_updated(tiles)
|
|
|
|
func _ready() -> void:
|
|
spawn()
|
|
|
|
func spawn():
|
|
var Tile = preload("res://World/Tiles/Tile.tscn")
|
|
for x in range(0, map_size.x):
|
|
for y in range (0, map_size.y):
|
|
var tile = Tile.instance()
|
|
tile.set_tile_id(Vector2(x,y))
|
|
# tile is coast if its on one of the outer borders
|
|
if x == 0 or x == map_size.x -1 or y == 0 or y==map_size.y -1:
|
|
tile.is_coast = true
|
|
tiles.append(tile)
|
|
add_child(tile)
|
|
update_size()
|
|
|
|
func update_size():
|
|
emit_signal("size_updated", tiles)
|