def main(options, args):
    """Start the engine and the game"""
    registerSounds()
    registerMusic()
    registerGraphics()
    #
    if options.musicoff:
        serge.sound.Music.pause()
        serge.sound.Sounds.pause()
    #
    # Create the engine
    engine = startEngine(options)
    #
    # Initialise the main logic
    mainscreen.main(options)
    startscreen.main(options)
    creditsscreen.main(options)
    resumescreen.main(options)
    tutorialscreen.main(options)
    levelscreen.main(options)
    #
    if options.straight:
        engine.setCurrentWorldByName('main-screen')
    if options.tutorial:
        engine.setCurrentWorldByName('tutorial-screen')        
    #   
    if options.debug:
        serge.builder.builder.main(engine, options.framerate)
    else:
        engine.run(options.framerate)
 def doStart(self, obj, arg):
     """Go to the start"""
     self.log.info('Clicked on start')
     world = self.engine.getWorld('main-screen')
     world.clearActors()
     mainscreen.main(self.options)
     self.engine.setCurrentWorldByName('start-screen')
Exemple #3
0
def main(options, args):
    """Start the engine and the game"""
    registerSounds()
    registerMusic()
    registerGraphics()
    registerEvents()
    #
    # Change theme settings
    if options.theme:
        theme.updateFromString(options.theme)
    #
    # Create the engine
    engine = startEngine(options)
    engine.linkEvent(serge.events.E_BEFORE_STOP, stoppingNow)
    #
    # 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.musicoff:
        mute.toggleSound()
    #
    # Initialise the main logic
    registerAchievements(options)
    mainscreen.main(options)
    startscreen.main(options)
    helpscreen.main(options)
    creditsscreen.main(options)
    #
    if options.debug:
        serge.builder.builder.main(engine, options.framerate)
    else:
        engine.run(options.framerate)
Exemple #4
0
 def __call__(self, world, actor, interval):
     mouse = serge.engine.CurrentEngine().getMouse()
     if mouse.isClicked(serge.input.M_LEFT):
         for button in mouse.getActorsUnderMouse(world):
             self.log.info('button type:'+button.tag)
             if button.tag == 'list-item':
                 # join in a room
                 button.hightlight()
                 olctlhub.send(['join-room', int(button.name)])
             else:
                 if button.name == 'refresh':
                     olctlhub.send(['view-rooms'])
                     olctlhub.send(['my-room'])
                 elif button.name == 'new':
                     olctlhub.send(['new-room']
                         )
                     olctlhub.send(['view-rooms'])
                 elif button.name == 'start':
                     olctlhub.send(['start'])
                 elif button.name == 'practice':
                     mainscreen.main(0, None)
                 elif button.name == 'play-online':
                     waitingscreen.main()
                 elif button.name == 'inc':
                     button.control.inc()
                 elif button.name == 'dec':
                     button.control.dec()
 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 levelSelect(self, obj, level_name):
     """Selected a level"""
     self.log.info('Selected level %s with %d moves' % (level_name, self.options.number))
     self.options.level = level_name.replace('level-', '')
     mainscreen.main(self.options)
     self.engine.setCurrentWorldByName('main-screen')
     serge.sound.Music.setPlaylist(self.level_playlist)
 def updateActor(self, interval, world):
     # OZM
     try:
         recieved = olctlhub.sock.recv(1024, socket.MSG_DONTWAIT)
     except:
         return
     recieved = json.loads(recieved)
     if recieved[1] == 'room-list':
         self.roomList.updateList(recieved[2])
     elif recieved[1] == 'start' or recieved[1] == 'keys':
         self.log.info('we will start')
         mainscreen.main(int(recieved[2]) - 1)
Exemple #8
0
def main():
    #
    # register the resources
    registerGraphics()
    #
    # Create the engine
    engine = startEngine()
    #
    # Initialize the main logic
    mainscreen.main()
    #
    # Run the engine
    engine.run(G('framerate'))
Exemple #9
0
def main(options, args):
    """Start the engine and the game"""
    #
    # Create the high scores
    if options.high_score:
        createHighScores(options)
    #
    # Create the engine
    engine = startEngine(options)
    engine.linkEvent(serge.events.E_BEFORE_STOP, stoppingNow)
    #
    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.musicoff:
        mute.toggleSound()
    #
    # Initialise the main logic
    registerAchievements(options)
    mainscreen.main(options)
    startscreen.main(options)
    helpscreen.main(options)
    creditsscreen.main(options)
    #
    if options.debug:
        serge.builder.builder.main(engine, options.framerate)
    else:
        engine.run(options.framerate)
def main(options, args):
    """Start the engine and the game"""
    #
    if not options.log:
        serge.common.logger.setLevel(logging.ERROR)
    #
    # Set rotation type for sprites - smooth_rotate seems to cause ghosting problems
    # so use the base one, which looks fine even though there is some aliasing
    serge.visual.Sprite.rotate = serge.visual.Sprite.base_rotate
    #
    # Create the engine
    engine = startEngine(options)
    #
    registerSounds()
    registerMusic()
    registerGraphics()
    #
    # Muting the sound
    if options.musicoff or options.musiconlyoff:
        serge.sound.Music.pause()
    if options.musicoff:
        serge.sound.Sounds.pause()
        #
    # Change theme settings
    if options.theme:
        theme.updateFromString(options.theme)
        #
    broadcaster = serge.events.getEventBroadcaster()
    broadcaster.registerEventsFromModule(common)
    #
    # Initialise the main logic
    creditsscreen.main(options)
    mainscreen.main(options)
    highscorescreen.main(options)
    registerAchievements(options)
    #
    if options.movie:
        serge.blocks.utils.RecordDesktop(options.movie)
        #
    if options.debug:
        serge.builder.builder.main(engine, options.framerate)
    else:
        engine.run(options.framerate)
Exemple #11
0
    def updateActor(self, interval, world):
        try:
            recieved = olctlhub.sock.recv(1024, socket.MSG_DONTWAIT)
        except:
            return
        recieved = json.loads(recieved)
        if recieved[1] == 'room-list':
            self.roomList.updateList(recieved[2])
        elif recieved[1] == 'my-room':
            # DEBUG
            print recieved
            if recieved[2][0] == -1: return

            self.current_room_num.updateText('room #'+str(recieved[2][0]))
            self.current_room_players.updateText(str(recieved[2][1])+' players')
            self.current_room_track.value = [recieved[2][2]]
            self.current_room_track.updateText()
        elif recieved[1] == 'start':
            self.log.info('we will start')
            # param: players number and track
            mainscreen.main(int(recieved[2][0]) - 1, recieved[2][1], True)
        elif recieved[1] == 'keys':
            self.log.info('Other players have started but I\'m not. Trying to start...')
            olctlhub.send(["start-me"])
Exemple #12
0
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)
def main(options, args):
    """Start the engine and the game"""
    #
    # For ropes and things we typically need a higher number of iterations
    serge.zone.PHYSICS_ITERATIONS = 100
    #
    # Create the engine
    engine = startEngine(options)
    engine.linkEvent(serge.events.E_BEFORE_STOP, stoppingNow)
    #
    registerSounds()
    registerMusic()
    registerGraphics()
    registerEvents()
    #
    # 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.musicoff:
        mute.toggleSound()
    #
    # Initialise the main logic
    globals = serge.blocks.singletons.Store.registerItem('globals')  
    globals.history = history.History('history', 'history')
    globals.last_cave_name = 'RANDOM-CAVE'
    #
    registerAchievements(options)
    if options.skip:
        mainscreen.main(options)
    else:
        startscreen.main(options)
        #
        # Force a rendering of the overlay - this puts
        # up the "loading ..." screen so the user has something
        # to see while we create the cave and trees etc
        w = engine.getWorld('start-screen')
        w.log.info('Rendering overlay')
        w.renderTo(engine.getRenderer(), 1000)
        engine.getRenderer().render()
        pygame.display.flip()
    #
    helpscreen.main(options)
    creditsscreen.main(options)
    namescreen.main(options)
    collectionscreen.main(options)
    #   
    #
    if options.movie:
        serge.blocks.utils.RecordDesktop(options.movie)
    if options.debug:
        serge.builder.builder.main(engine, options.framerate)
    else:
        try:
            engine.run(options.framerate)
        except:
            # Make sure this event is raised so that any workers can be killed
            engine.processEvent((serge.events.E_BEFORE_STOP, None))
            raise
    #
    # Display profile statistic if needed
    if options.engine_profile:
        prof = engine.getProfiler()
        data = [(prof.byTag(n).get('renderActor', (0,0))[1], n) for n in prof.getTags()]
        data.sort()
        data.reverse()
        print '\n\nEngine profiling\n\nTag\tTime(s)'
        for tme, tag in data:
            print '%s\t%s' % (tag, tme)
        print '\n\n'