本文整理汇总了Python中world.World.load方法的典型用法代码示例。如果您正苦于以下问题:Python World.load方法的具体用法?Python World.load怎么用?Python World.load使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类world.World
的用法示例。
在下文中一共展示了World.load方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from world import World [as 别名]
# 或者: from world.World import load [as 别名]
def main():
world = World()
# yield world.wipe()
yield world.load()
server = Server(world, 9876)
server.listen()
def update():
world.update()
server.send_update()
update_task = PeriodicCallback(update, 1000)
update_task.start()
示例2: InputSystem
# 需要导入模块: from world import World [as 别名]
# 或者: from world.World import load [as 别名]
# create the main window
window = sf.RenderWindow(sf.VideoMode(800, 480), "Platformer")
window.key_repeat_enabled = False
view = window.default_view
input = InputSystem(window)
physics = Physics()
WORLD_FILENAME = "Content/world1.tsv"
try:
font = sf.Font.from_file("Content/8bit.ttf")
world = World(physics, font)
with open(WORLD_FILENAME, "r") as worldfile:
world.load(worldfile)
editor = WorldEditor(view, world)
# create some graphical text to display
frame_rate = sf.Text("0", font, 20)
except IOError:
exit(1)
input.add_key_handler(world.player)
input.add_key_handler(editor)
input.add_mouse_handler(editor)
clock = sf.Clock()
frame_accum = 0
示例3: main
# 需要导入模块: from world import World [as 别名]
# 或者: from world.World import load [as 别名]
def main(file, Nmonsters):
w = World()
w.load(file)
'''
Double dict city -> monster
monster -> city
improve performance
'''
cities = dict( (el,0) for el in w.getCities())
assert len(cities) > Nmonsters, "Not enought cities"
monsters = {}
left_cities = cities.keys()
for i in xrange(Nmonsters):
#Generating monster unique names
name = generate(6)
while name in monsters:
name = name + " " + generate(6)
c = choice(left_cities)
left_cities.remove(c)
cities[c] = name
monsters[name] = c
for cycle in xrange(1,10000):
x_monsters = monsters.keys()
while len(x_monsters) > 0 :
monster = x_monsters.pop()
#Next city
city = choice(w.getAdjs(monsters[monster]))
#Left city
cities[monsters[monster]] = 0
#Are the city already occuped by a monster?
if cities[city] != 0 :
#Fight
print "%s is fighting vs %s at %s" % (monster, cities[city], city)
#Remove if it isnt already processed
if cities[city] in x_monsters : x_monsters.remove(cities[city])
#Remove monsters from monster list
del monsters[monster]; del monsters[cities[city]]
#Destroy city
del cities[city]; w.destroy_city(city)
else:
monsters[monster] = city
cities[city] = monster
w.pretty_print(file+".out")
示例4: len
# 需要导入模块: from world import World [as 别名]
# 或者: from world.World import load [as 别名]
index = easygui.indexbox(msg="Pick Player", choices=players)
if index < len(world.players):
return world.players[index]
fieldnames = ["Name", "Coins"]
fieldvalues = ["BlackBeard " + str(random.randrange(1, 1000)), 9200]
results = easygui.multenterbox(msg="Customize your player", title="Guest Player", fields=fieldnames, values=fieldvalues)
player = Player()
player.location = world.stardock_location
player.area = Area.Space
player.gold_coins = int(results[1])
player.ship = Junk()
player.ship.moves = player.ship.total_moves
player.ship.resources = { "wheat": 10, "food": 18, "iron": 1000 }
player.name = results[0]
if index == len(players) - 1:
world.players += [player]
return player
if __name__ == "__main__":
configure_logging()
world = World.load("default")
player = choose_player(world)
action = SectorViewAction()
while not isinstance(action, GameQuitAction):
action = route_action(world, player, action)
world.save()