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


Python World.load方法代码示例

本文整理汇总了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()
开发者ID:Norgg,项目名称:alltheboxes,代码行数:17,代码来源:alltheboxes.py

示例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
开发者ID:mkb0517,项目名称:Platformer,代码行数:33,代码来源:main.py

示例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")
开发者ID:toloco,项目名称:snipets,代码行数:66,代码来源:overlord.py

示例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()
开发者ID:Nitro311,项目名称:DeepSpace,代码行数:32,代码来源:main.py


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