ld-56/main.gd

39 lines
1.1 KiB
GDScript3
Raw Normal View History

2024-10-07 05:05:27 +00:00
extends Node2D
@onready var zones = Data.data.zones
const CURSOR = preload("res://components/Cursor/Cursor.tscn")
const ZONE = preload("res://src/Zone.tscn")
func _ready() -> void:
Triggerer.listen("spawn_window", _on_spawn_window)
Triggerer.listen("quit", _on_quit)
DisplayServer.window_set_title("Home")
get_viewport().transparent_bg = true
func _process(delta: float) -> void:
if Input.is_action_just_pressed("test"):
Triggerer.trigger("spawn_window", {"key": ["farm", "desert", "lake", "forest"].pick_random()})
func _on_spawn_window(data) -> void:
var zone = zones[data.key]
var new_window = ZONE.instantiate()
new_window.key = data.key
new_window.size = Vector2(int(zone.size[0]) * 12 * 4, int(zone.size[1]) * 12 * 4)
new_window.position = Vector2(int(zone.spawn_position[0]), int(zone.spawn_position[1]))
var new_cursor = CURSOR.instantiate()
new_window.add_child(new_cursor)
get_tree().root.add_child(new_window)
func _on_timer_timeout() -> void:
Triggerer.trigger("spawn_window", {"key": ["farm", "desert", "lake", "forest"].pick_random()})
func _on_quit(_data) -> void:
get_tree().quit()