refactor worldgen, still not optimal

This commit is contained in:
Antti Hakkarainen 2023-02-10 20:32:00 +02:00
parent 4030f040b6
commit 83343c9be6
6 changed files with 195 additions and 179 deletions

View file

@ -9,16 +9,20 @@
class_name Main
extends Node
signal set_camera_position(pos:Vector2)
# The idea is for the user to be able to choose the map from GUI later
var map_filename: String = "res://maps/varkaus_256x256px_test.png"
#var map_filename: String = "res://maps/tampere_10x10km_1000px.png"
var map_filename:String = "res://maps/tampere_200px_crop.png"
var _world := World.new()
var _world_generator := WorldGeneration.new()
func _init():
DisplayServer.window_set_size(
#Vector2i(Globals.DEFAULT_X_RES, Globals.DEFAULT_Y_RES)
Vector2i(3800,2000)
)
# DisplayServer.window_set_size(
# #Vector2i(Globals.DEFAULT_X_RES, Globals.DEFAULT_Y_RES)
# Vector2i(3800,2000)
# )
pass
# Called when the node enters the scene tree for the first time.
func _ready():
@ -30,6 +34,13 @@ func _ready():
if !_world_generator.generate_world(map_filename):
push_error(Globals.ERROR_WHILE_GENERATING_MAP)
quit_game()
# center camera to world map
emit_signal(
"set_camera_position",
Vector2(Globals.map_image_size.x / 2.0 * Globals.TILE_SIZE_X,
Globals.map_image_size.y / 2.0 * Globals.TILE_SIZE_Y)
)
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(_delta):