def switchToMain(self, world, actor, interval): """Switch to the main world""" name = self.globals.last_cave_name self.log.info('Switching to cave %s' % name) # # Generate the random seed if name != 'RANDOM-CAVE': seed = int(sha.sha(name).hexdigest(), 16) # # Update the high score self.history.visitCave(name) else: seed = random.randrange(0, 100000) theme.setProperty('level-seed', seed) # # Replace the old cave self.engine.removeWorldNamed('main-screen') serge.blocks.utils.createWorldsForEngine(self.engine, ['main-screen']) mainscreen.main(self.options) # # Mute button for sound mute = self.world.findActorByName('mute-button') serge.blocks.utils.addMuteButtonToWorlds(mute, center_position=G('mute-button-position'), world_names=['main-screen']) # # Go for it self.engine.setCurrentWorldByName('main-screen') self.overlays.forEach().visible = False
def __init__(self, level, devmode, number): """Initialise the screen""" super(MainScreen, self).__init__('item', 'main-screen') self._current_level = level self._devmode = devmode self._paused = False self._lives = G('initial-lives') if number: theme.setProperty('player-moves', number, 'level-%s' % level)
def main(options, args, observation): """Start the engine and the game""" # # Set the levels to use - this allows us to switch to AI testing # levels rather than the main levels if options.test: import tests theme.setProperty('start-level', 1) common.levels = tests # # Check networkx install if not serge.blocks.utils.checkNetworkXVersion(1.8): return # # Create the high scores if options.high_score: createHighScores(options) # # Create the engine engine = startEngine(options) engine.linkEvent(serge.events.E_BEFORE_STOP, stoppingNow) engine.addWorld(common.TWEENER) # registerSounds() registerMusic() registerGraphics() registerEvents() # # Record a movie if options.movie: serge.blocks.utils.RecordDesktop(options.movie) # # Change theme settings if options.theme: theme.updateFromString(options.theme) # # Muting mute = serge.blocks.actors.MuteButton('mute-button', 'ui', alpha=G('mute-button-alpha')) serge.blocks.utils.addMuteButtonToWorlds( mute, center_position=G('mute-button-position')) # if options.muted: mute.toggleSound() if options.music_off: serge.sound.Music.toggle() # # Initialise the main logic registerAchievements(options) mainscreen.main(options, observation) startscreen.main(options) helpscreen.main(options) creditsscreen.main(options) levelscreen.main(options) actionreplayscreen.main(options) randomlevelscreen.main(options) # if options.debug: serge.builder.builder.main(engine, options.framerate) else: engine.run(options.framerate)