extends Spatial # Declare member variables here. Examples: # var a = 2 # var b = "text" # var list_creature = [] func generate_map(pos : Vector3): Config.msg_info("Generate Map") # Clear old map for n in $map.get_children(): $map.remove_child(n) n.queue_free() # Push new map for y in range(-20, 21): for x in range(-20, 21): var z = (x + y) * (x - y) if z < 0: z = -z var position:Vector3 = 10.0 * Vector3( x, 0.0, y ) var name = "res://scenes/game/area_0_0.tscn" if int(z/3) % 3 == 0: if z % 2 == 0: name = "res://scenes/game/area_0_0.tscn" else: name = "res://scenes/game/area_0_1.tscn" elif int(z/3) % 3 == 1: if z % 2 == 0: name = "res://scenes/game/area_1_0.tscn" else: name = "res://scenes/game/area_1_1.tscn" else: if z % 2 == 0: name = "res://scenes/game/area_1_2.tscn" else: name = "res://scenes/game/area_2_2.tscn" Config.msg_info("Map:" + str(x) + ":" + str(y) + " -> " + name + " : "+ str(z) + " / " + str(int(z/3)%3)) var map:Spatial = load( name ).instance() map.set_translation(position) $map.add_child( map ) func add_creature(name:String, model:String, position:Vector3, orientation:Vector3): var creature:Spatial = load( model ).instance() creature.set_name(name) creature.set_rotation(orientation) creature.set_translation(position) # list_creature.push_back(creature) $creatures.add_child(creature) func move_creature(name, model, posx, posy, posz): var position:Vector3 = Vector3( posx, posy, posz ) if $creatures.has_node(name): var creature:Spatial = $creatures.get_node(name) var pos : Vector3 = $creature.get_global_transform().origin # $creatures.get_node(name).get_ # Called when the node enters the scene tree for the first time. func _ready(): var current: Vector3 = Vector3( 0.0, 0.0, 0.0 ) generate_map(current) self.add_creature("RA_1", "res://scenes/player/creature_raference.tscn", Vector3( 1.0, 1.0, 1.0 ), Vector3( 0.0, 0.0, 0.0 )) self.add_creature("RA_2", "res://scenes/player/creature_raference.tscn", Vector3( 2.0, 0.01, 5.0 ), Vector3( 0.0, 1.0, 0.0 )) self.add_creature("RA_3", "res://scenes/player/creature_raference.tscn", Vector3( 1.0, 0.01, 5.0 ), Vector3( 0.0, -3.141592, 0.0 )) self.add_creature("Arche_1", "res://scenes/player/creature_arche.tscn", Vector3( -2.0, 0.01, 2.0 ), Vector3( 0.0, -3.141592, 0.0 )) self.add_creature("Isidor_1", "res://scenes/player/creature_isidor.tscn", Vector3( -2.0, 0.01, 5.0 ), Vector3( 0.0, -3.141592, 0.0 )) $player.connect("menu_options_pressed", self, "_on_menu_options") func _on_menu_options(): Config.msg_info("Received menu options") if $menu_options.is_visible(): $menu_options.hide() else: $menu_options.show() # Called every frame. 'delta' is the elapsed time since the previous frame. func _process(delta): #Config.msg_info("update Map") pass