本文整理汇总了Python中world.World.cleanup方法的典型用法代码示例。如果您正苦于以下问题:Python World.cleanup方法的具体用法?Python World.cleanup怎么用?Python World.cleanup使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类world.World
的用法示例。
在下文中一共展示了World.cleanup方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Main
# 需要导入模块: from world import World [as 别名]
# 或者: from world.World import cleanup [as 别名]
#.........这里部分代码省略.........
Func(self.gfLogo.hide),
Func(self.request, "Menu"),
Func(helper.show_cursor),
name="fadeInOut")
self.fadeInOut.start()
def enterMenu(self):
if self.musicMenu.status() == AudioSound.READY:
self.musicMenu.play()
self.seqMenuFadeIn = Parallel(
Func(self.menu.show),
self.menuCoverFadeInInterval)
self.seqMenuFadeIn.start()
def exitMenu(self):
self.menu.hide()
def enterOptions(self):
self.seqOptionsFadeIn = Parallel(
Func(self.options.show),
self.menuCoverFadeInInterval)
self.seqOptionsFadeIn.start()
def exitOptions(self):
self.options.hide()
def enterStart(self):
self.world = World()
self.world.start()
def exitStart(self):
self.world.stop()
self.world.cleanup()
del self.world
self.fadeMusicIn.start()
def __escape(self):
"""A function that should be called when hitting the esc key or
any other similar event happens"""
if self.fadeInOut.isPlaying():
self.fadeInOut.finish()
self.pandaLogo.hide()
self.gfLogo.hide()
elif self.state == "Menu":
self.quit()
else:
self.__fadeToMain()
def quit(self):
if self.appRunner:
self.appRunner.stop()
else:
exit(0)
def __writeConfig(self):
"""Save current config in the prc file or if no prc file exists
create one. The prc file is set in the prcFile variable"""
page = None
particles = str(base.particleMgrEnabled)
textSpeed = str(base.textWriteSpeed)
volume = str(round(base.musicManager.getVolume(), 2))
mouseSens = str(base.mouseSensitivity)
customConfigVariables = [
"", "particles-enabled", "text-write-speed", "audio-mute",
"audio-volume", "control-type", "mouse-sensitivity"]
示例2: __init__
# 需要导入模块: from world import World [as 别名]
# 或者: from world.World import cleanup [as 别名]
class Domination:
""" Initializes the game. Keeps track of events. """
def __init__(self, options):
self.options = options
if options['record']:
replay.start(options['record'], options['level'])
elif options['replay']:
options['level'], rand_state = replay.open(options['replay'])
utils.RANDOM.setstate(rand_state)
self.output_file = options['output']
self.viewport = Viewport()
self.world = World(options['red'], options['blue'], options['level'])
self.viewport.set_world(self.world)
self.running = True
self.world_lock = threading.Lock()
def game_loop(self):
step = 0
while(self.running):
#if the world lock is set, only update the GUI, don't move agents.
if self.world_lock.acquire(False):
self.on_simulation_step()
if step % SIMULATION_RESOLUTION == 0:
threading.Thread(target=self.on_action).start()
#on_action will release the lock after all agents have
#declared their action or the time ran out.
else:
self.world_lock.release()
step += 1
replay.step()
for event in pygame.event.get():
self.on_event(event)
self.on_render()
if step > MAX_TIMESTEPS:
self.running = False
self.on_cleanup()
def on_event(self, event):
if event.type == KEYS_EVENT:
self.on_keys()
if event.type == VIDEORESIZE:
self.viewport.resize(event.size)
if event.type == QUIT:
self.running = False
def on_action(self):
self.world.action_step()
self.world_lock.release()
def on_keys(self):
move_speed = 10
keys = pygame.key.get_pressed()
if keys[K_UP]:
self.viewport.move_offset((0,-move_speed))
if keys[K_RIGHT]:
self.viewport.move_offset((move_speed,0))
if keys[K_DOWN]:
self.viewport.move_offset((0,move_speed))
if keys[K_LEFT]:
self.viewport.move_offset((-move_speed,0))
if ((keys[K_RALT] or keys[K_LALT]) and keys[K_F4]) or keys[K_ESCAPE]:
self.running = False
def on_simulation_step(self):
self.world.simulation_step()
def on_render(self):
if not self.options['invisible']:
self.world.render(self.viewport)
pygame.display.update()
def on_cleanup(self):
replay.end()
self.world.cleanup()
with open(self.output_file, "w") as f:
for team in self.world.teams:
f.write(str(team) + "\n")
pygame.quit()