Ejemplo n.º 1
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)
Ejemplo n.º 2
0
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)
Ejemplo n.º 3
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'))
Ejemplo n.º 4
0
def main():
    #
    # register the resources
    registerGraphics()
    broadcaster = serge.events.getEventBroadcaster()
    broadcaster.registerEventsFromModule(common)
    #
    # Create the engine
    engine = startEngine()
    #
    # Initialize the main logic
    startscreen.main()
    #
    # Run the engine
    engine.run(G('framerate'))
Ejemplo n.º 5
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)
Ejemplo n.º 6
0
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)
Ejemplo n.º 7
0
def main(options, args):
    """Run the game"""
    #
    # Debug options
    if options.any:
        game.Game.check_spelling = False
    if options.suggest:
        keypad.KeyPad.can_suggest = True
    gamestart.Start.possible_holes = map(int, options.holes.split(','))

    ### Sounds ###

    serge.sound.Register.setPath('sound')
    r = serge.sound.Register.registerItem
    r('start', 'start.wav')
    r('begin', 'begin.wav')
    r('letter', 'letter.wav')
    r('word', 'word.wav')
    r('hole', 'hole.wav')
    r('good-hole', 'good_hole.wav')
    r('poor-hole', 'poor_hole.wav')
    r('unletter', 'unletter.wav')
    r('error', 'error.wav')
    r('bad-letter', 'badletter.wav')
    r('end-game', 'end_game.wav')
    r('sand', 'sand.wav')
    r('water', 'water.wav')

    ### Graphics ###

    serge.visual.Register.setPath('graphics')
    r = serge.visual.Register.registerItem
    rf = serge.visual.Register.registerFromFiles
    r('start-bg', 'start_bg.png')
    r('course', 'course1.png')
    r('hole2', 'hole1.png')
    r('hole1', 'hole1.png')
    r('logo', 'logo.png')
    rf('game1', 'game1_%d.png', 2)
    rf('game2', 'game2_%d.png', 2)
    rf('game3', 'game3_%d.png', 2)
    rf('button', 'button%d.png', 2)
    r('button_back', 'button_back.png')
    r('big_button_back', 'big_button.png')
    rf('letter', 'letter_%d.png', 2)
    r('help-page', 'helppage.png')
    r('escape-page', 'helppage.png')
    r('scores-page', 'scorespage.png')
    r('end-game-page', 'endgamepage.png')
    r('grass', 'grass.png')
    r('sand', 'sand.png')
    r('water', 'water.png')
    r('hole', 'hole.png')
    r('past', 'past.png')
    r('icon', 'wordgolf.ico')

    #
    thegame = game.Game(game.holes[0], 1, 3)
    engine = serge.engine.Engine(title='Word Golf', icon='icon')
    renderer = engine.getRenderer()

    course = serge.render.VirtualLayer('course', 0)
    renderer.addLayer(course)
    keys = serge.render.VirtualLayer('keys', 1)
    renderer.addLayer(keys)
    ui = serge.render.VirtualLayer('ui', 2)
    renderer.addLayer(ui)
    result = serge.render.VirtualLayer('results', 3)
    renderer.addLayer(result)

    camera = renderer.getCamera()
    camera.setSpatial(0, 0, 640, 480)

    ### The main world for the game ###

    game_world = serge.world.World('game')
    main = serge.zone.Zone()
    main.active = True
    game_world.addZone(main)

    pad = keypad.KeyPad(game_world, thegame)
    game_world.addActor(pad)

    ### The world for the end of game display ###

    end_world = serge.world.World('end')
    main = serge.zone.Zone()
    main.active = True
    end_world.addZone(main)

    game_over = gameover.Results(thegame, end_world)
    end_world.addActor(game_over)

    ### The world for the start of game display ###

    start_world = serge.world.World('start')
    main = serge.zone.Zone()
    main.active = True
    start_world.addZone(main)
    start = gamestart.Start(thegame, start_world)
    start_world.addActor(start)

    ### The world for help ###

    help_world = serge.world.World('help')
    z = serge.zone.Zone()
    z.active = True
    help_world.addZone(z)
    help = helppage.HelpPage(thegame, help_world)
    help_world.addActor(help)

    ### The world for escape ###

    escape_world = serge.world.World('escape')
    z = serge.zone.Zone()
    z.active = True
    escape_world.addZone(z)
    escape = escapepage.EscapePage(thegame, escape_world)
    escape_world.addActor(escape)

    ### The world for high scores ###

    scores_world = serge.world.World('scores')
    z = serge.zone.Zone()
    z.active = True
    scores_world.addZone(z)
    scores = scorespage.ScoresPage(thegame, scores_world)
    scores_world.addActor(escape)
    scores_world.activateWorld = scores.activateWorld

    # Tell the keypad about the high scores table
    pad.score = scores
    pad.gamestart = start
    scores.gamestart = start
    scores.pad = pad
    scores.updateTable()
    game_over.pad = pad
    game_over.results.visual.pad = pad

    engine.addWorld(start_world)
    engine.addWorld(end_world)
    engine.addWorld(game_world)
    engine.addWorld(help_world)
    engine.addWorld(escape_world)
    engine.addWorld(scores_world)
    engine.setCurrentWorld(start_world)

    thegame.tryHole()

    #serge.builder.builder.main(engine)
    engine.run(options.framerate)
Ejemplo n.º 8
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)
Ejemplo n.º 9
0
def main(options, args):
    """Run the game"""
    #
    # Debug options
    if options.any:
        game.Game.check_spelling = False
    if options.suggest:
        keypad.KeyPad.can_suggest = True
    gamestart.Start.possible_holes = map(int, options.holes.split(','))
    
    ### Sounds ###

    serge.sound.Register.setPath('sound')
    r = serge.sound.Register.registerItem
    r('start', 'start.wav')
    r('begin', 'begin.wav')
    r('letter', 'letter.wav')
    r('word', 'word.wav')
    r('hole', 'hole.wav')
    r('good-hole', 'good_hole.wav')
    r('poor-hole', 'poor_hole.wav')
    r('unletter', 'unletter.wav')
    r('error', 'error.wav')
    r('bad-letter', 'badletter.wav')
    r('end-game', 'end_game.wav')
    r('sand', 'sand.wav')
    r('water', 'water.wav')

    ### Graphics ###

    serge.visual.Register.setPath('graphics')
    r = serge.visual.Register.registerItem
    rf = serge.visual.Register.registerFromFiles
    r('start-bg', 'start_bg.png')
    r('course', 'course1.png')
    r('hole2', 'hole1.png')
    r('hole1', 'hole1.png')
    r('logo', 'logo.png')
    rf('game1', 'game1_%d.png', 2)
    rf('game2', 'game2_%d.png', 2)
    rf('game3', 'game3_%d.png', 2)
    rf('button', 'button%d.png', 2)
    r('button_back', 'button_back.png')
    r('big_button_back', 'big_button.png')
    rf('letter', 'letter_%d.png', 2)
    r('help-page', 'helppage.png')
    r('escape-page', 'helppage.png')
    r('scores-page', 'scorespage.png')
    r('end-game-page', 'endgamepage.png')
    r('grass', 'grass.png')
    r('sand', 'sand.png')
    r('water', 'water.png')
    r('hole', 'hole.png')
    r('past', 'past.png')    
    r('icon', 'wordgolf.ico')
    
    #
    thegame = game.Game(game.holes[0], 1, 3)
    engine = serge.engine.Engine(title='Word Golf', icon='icon')
    renderer = engine.getRenderer()

    course = serge.render.VirtualLayer('course', 0)
    renderer.addLayer(course)
    keys = serge.render.VirtualLayer('keys', 1)
    renderer.addLayer(keys)
    ui = serge.render.VirtualLayer('ui', 2)
    renderer.addLayer(ui)
    result = serge.render.VirtualLayer('results', 3)
    renderer.addLayer(result)

    camera = renderer.getCamera()
    camera.setSpatial(0, 0, 640, 480)



    ### The main world for the game ###

    game_world = serge.world.World('game')
    main = serge.zone.Zone()
    main.active = True
    game_world.addZone(main)

    pad = keypad.KeyPad(game_world, thegame)
    game_world.addActor(pad)

    ### The world for the end of game display ###

    end_world = serge.world.World('end')
    main = serge.zone.Zone()
    main.active = True
    end_world.addZone(main)

    game_over = gameover.Results(thegame, end_world)
    end_world.addActor(game_over)

    ### The world for the start of game display ###

    start_world = serge.world.World('start')
    main = serge.zone.Zone()
    main.active = True
    start_world.addZone(main)
    start = gamestart.Start(thegame, start_world)
    start_world.addActor(start)

    ### The world for help ###

    help_world = serge.world.World('help')
    z = serge.zone.Zone()
    z.active = True
    help_world.addZone(z)
    help = helppage.HelpPage(thegame, help_world)
    help_world.addActor(help)

    ### The world for escape ###

    escape_world = serge.world.World('escape')
    z = serge.zone.Zone()
    z.active = True
    escape_world.addZone(z)
    escape = escapepage.EscapePage(thegame, escape_world)
    escape_world.addActor(escape)

    ### The world for high scores ###

    scores_world = serge.world.World('scores')
    z = serge.zone.Zone()
    z.active = True
    scores_world.addZone(z)
    scores = scorespage.ScoresPage(thegame, scores_world)
    scores_world.addActor(escape)
    scores_world.activateWorld = scores.activateWorld

    # Tell the keypad about the high scores table
    pad.score = scores
    pad.gamestart = start
    scores.gamestart = start
    scores.pad = pad
    scores.updateTable()
    game_over.pad = pad
    game_over.results.visual.pad = pad

    engine.addWorld(start_world)
    engine.addWorld(end_world)
    engine.addWorld(game_world)
    engine.addWorld(help_world)
    engine.addWorld(escape_world)
    engine.addWorld(scores_world)
    engine.setCurrentWorld(start_world)

    thegame.tryHole()

    #serge.builder.builder.main(engine)
    engine.run(options.framerate)
Ejemplo n.º 10
0
        """Update ourself"""
        if self.keyboard.isClicked(pygame.K_LEFT):
            b.setAngle(b.getAngle()+15, True)
            #b1.getPhysical().body.angle += 0.2
            self.log.debug('Moving angle + %d' % b.getAngle())
            #list(world.zones)[0]._rtf = 0.001
        if self.keyboard.isClicked(pygame.K_RIGHT):
            b.setAngle(b.getAngle()-15, True)
            #b1.getPhysical().body.angle += 0.2
            self.log.debug('Moving angle + %d' % b.getAngle())
            #list(world.zones)[0]._rtf = 0.001
        if self.keyboard.isClicked(pygame.K_UP):
            b.move(20,0)
            self.log.debug('Moving %s' % b.x)
        if self.keyboard.isClicked(pygame.K_DOWN):
            b.move(-20,0)
            self.log.debug('Moving %s' % b.x)
        if self.keyboard.isClicked(pygame.K_SPACE):
            for a in b.getChildren():
                self.log.debug('Added gravity to %s' % a)
                a.getPhysical().body.apply_force((10000,90000))
            b.getPhysical().body.apply_force((10000,90000))
            
        self.log.debug('%s, %s, (%s, %s)' % (b.getAngle(), b1.getAngle(), b.getPhysical().body.angle, b1.getPhysical().body.angle))
              
d = DoIt('doit', 'doit')
world.addActor(d)

#import pdb; pdb.set_trace()
engine.run(60)
Ejemplo n.º 11
0
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'