def world_init(self, name = 'Test', player_start_coordinate_key = '0_0_0'): world = World(name) if world.db['new_game']: #If 'new_game'... #Determine origin_key to activate chunks... if world.db['player'] == None: #If no player yet... origin_key = player_start_coordinate_key #Use given/default coordinates for origin_key else: #Else if player exists... origin_key =world.db['player'].coordinate_key #Use their coordinate_key #Generate a cube shape cubeargs = {'origin': origin_key, 'magnitude': [10,10,0], 'towards_neg_inf': False} shape = Cube(**cubeargs) world.db['view_shape'] = shape #Store shape for later use in self.view #Use shape to determine initial actuve chunks chunks = [] #For each coordinate key in shape.area_key_list for coordinate_key in shape.area_key_list: parent_chunk = find_parent(coordinate_key) if parent_chunk not in chunks: #If not... chunks.append(parent_chunk) #Add it... world.activate_chunk(*chunks) #Generate random base terrain for active chunks base = {'image_key': 'grass.png'} #feature(image_key, name = None, speed_modifier = 1.0, tall = 0, float_offset = [0.5,0.5], impassible = False, blocksLOS = False) rocks = {'image_key':'rocks.png', 'speed_modifier': 1.25, 'layer': 1.0} bushes = {'image_key': 'bush.png', 'speed_modifier': 1.50, 'layer': 1.1} trees = {'image_key': 'tallTree.png', 'tall': 20, 'float_offset': [0.5, 0.5], 'layer': 1.2, 'impassible': True, 'blocksLOS': True } for key in sorted(world.db['active_chunks'].keys()): print "##Chunk Building...##", key world.chunk_terrain_base_fill(key, **base) world.chunk_random_feature_fill(key, **rocks) world.chunk_random_feature_fill(key, **bushes) world.chunk_random_feature_fill(key, **trees) #Initialize player if world.db['player'] == None: player_args = {'world':world, 'coordinate_key': origin_key, 'image_key':'rose.png', 'shape': shape, 'name':'Rose' } player = Player(**player_args) world.add_element(origin_key, player) world.db['player'] = player world.db['new_game'] = False self.commit() return world
world.chunk_random_feature_fill(key, **bushes) world.chunk_random_feature_fill(key, **trees) ####TEST world INIT#### world = World("TEST") origin = [0,0,0] origin_key = make_key(origin) cubeargs = {'origin': origin_key, 'magnitude': [10,10,0], 'towards_neg_inf': False} shape = Cube(**cubeargs) #If world db shelf not in existence... if world.db['new_game']:##Run Test Terrain Gen player_args = {'world':world, 'coordinate_key': origin_key, 'image_key':'rose.png', 'name':'Rose' } player = Player(**player_args) world.add_element(origin_key, player) makeTestTerrain() world.db['new_game'] = False player_view = WorldView(world, shape, screen_size, px_offset, py_offset) ###DEBUG### print "ACTIVE CHUNKS #:", len(sorted(world.db['active_chunks'].keys())) print "ACTIVE CHUNK IDS:", sorted(world.db['active_chunks'].keys()) ###DEBUG### while True: main_loop()