extends TileMap # Declare member variables here. Examples: # var a = 2 # var b = "text" var height = 2 const start = 2 var size = 0 const letters = {"d":0,"s":1,"u":2} # Called when the node enters the scene tree for the first time. func _ready(): if Global.ct.empty(): size = Global.settingsfile.get_value("World","size",30) else: size = Global.ct.length() var dir = int(0) # 0 is down 1 is straight 2 is up for i in range(size): dir = round(rand_range(0,2)) if not Global.ct.empty(): dir = letters[Global.ct[i]] if dir == 0:#down set_cell(start+i,height,0) set_cell(start+i,height+1,2) set_cell(start+i,height+2,2) set_cell(start+i,height+3,2) height += 1 elif dir == 1:#straight set_cell(start+i,height,1) set_cell(start+i,height+1,2) set_cell(start+i,height+2,2) elif dir == 2:#up height -= 1 set_cell(start+i,height,0,true) set_cell(start+i,height+1,2) set_cell(start+i,height+2,2) set_cell(start+i,height+3,2) if randf() > 0.2:#spwan rabbit var spawn = map_to_world(Vector2(start+i,height-1)) get_parent().spawn_prey(spawn) if randf() < 0.3 and dir == 1:#spwan tree set_cell(start+i,height-1,3) set_cell(start+i,height-2,4) set_cell(start+size,height+1,2) set_cell(start+size,height,2) set_cell(start+size,height-1,1) get_parent().get_node("pred/Camera").limit_right = map_to_world(Vector2(start+size,0)).x # Called every frame. 'delta' is the elapsed time since the previous frame. #func _process(delta): # pass