当前位置: 首页>>代码示例>>Python>>正文


Python World.db['new_game']方法代码示例

本文整理汇总了Python中world.World.db['new_game']方法的典型用法代码示例。如果您正苦于以下问题:Python World.db['new_game']方法的具体用法?Python World.db['new_game']怎么用?Python World.db['new_game']使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在world.World的用法示例。


在下文中一共展示了World.db['new_game']方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: world_init

# 需要导入模块: from world import World [as 别名]
# 或者: from world.World import db['new_game'] [as 别名]
 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 
开发者ID:Deep-Phield-Softworks,项目名称:XeroSum,代码行数:53,代码来源:game.py

示例2: World

# 需要导入模块: from world import World [as 别名]
# 或者: from world.World import db['new_game'] [as 别名]
        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()
开发者ID:Deep-Phield-Softworks,项目名称:XeroSum,代码行数:32,代码来源:main.py


注:本文中的world.World.db['new_game']方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。