def addedToWorld(self, world):
     """The screen was added to the world"""
     super(HelpScreen, self).addedToWorld(world)
     #
     # Logo
     L = theme.getTheme('help-screen').getProperty
     logo = serge.blocks.utils.addSpriteActorToWorld(world, 'logo', 'logo', 'icon', 'ui', 
         center_position=L('logo-position'))
     #
     # Background
     bh = serge.blocks.utils.addSpriteActorToWorld(world, 'bg', 'bg', L('screen-background-sprite'), 'background', 
         center_position=L('screen-background-position'))
     #
     # Help text
     text = serge.blocks.utils.addSpriteActorToWorld(world, 'text', 'text', 'help-text', 'ui', 
         center_position=L('text-position'))
     #
     # Back link
     back = serge.blocks.utils.addVisualActorToWorld(world, 'button', 'back', 
         serge.visual.Text('Back', L('back-colour'), font_size=L('back-font-size')),
         'ui', 
         center_position=L('help-position'))
     back.linkEvent(serge.events.E_LEFT_CLICK, serge.blocks.utils.backToPreviousWorld('click'))
     #
     # Trees
     tree.addTrees(L, world)
Exemple #2
0
 def addedToWorld(self, world):
     """The screen was added to the world"""
     super(HelpScreen, self).addedToWorld(world)
     #
     # Logo
     L = theme.getTheme('help-screen').getProperty
     logo = serge.blocks.utils.addSpriteActorToWorld(world, 'logo', 'logo', 'small-icon', 'foreground', 
         center_position=L('logo-position'))
     #
     # Title
     logo = serge.blocks.utils.addVisualActorToWorld(world, 'title', 'title', 
         serge.visual.Text(L('title'), L('title-colour'), font_size=L('title-font-size')),
         'foreground', 
         center_position=L('title-position'))
     #
     # Help text
     text = serge.blocks.utils.addSpriteActorToWorld(world, 'text', 'text', 'help-text', 'foreground', 
         center_position=L('text-position'))
     #
     # Back link
     back = serge.blocks.utils.addVisualActorToWorld(world, 'button', 'back', 
         serge.visual.Text('Back', L('back-colour'), font_size=L('back-font-size')),
         'foreground', 
         center_position=L('help-position'))
     back.linkEvent(serge.events.E_LEFT_CLICK, serge.blocks.utils.backToPreviousWorld('click'))
Exemple #3
0
 def addedToWorld(self, world):
     """The start screen was added to the world"""
     super(StartScreen, self).addedToWorld(world)
     #
     # Logo
     the_theme = theme.getTheme('start-screen')
     L = the_theme.getProperty
     logo = serge.blocks.utils.addSpriteActorToWorld(
         world,
         'logo',
         'logo',
         'icon',
         'foreground',
         center_position=L('logo-position'))
     #
     serge.blocks.utils.addTextItemsToWorld(world, [
         (L('title'), 'title'),
         ('v' + common.version, 'version'),
         ('Start', 'start',
          serge.blocks.utils.worldCallback('main-screen', 'click')),
         ('Help', 'help',
          serge.blocks.utils.worldCallback('help-screen', 'click')),
         ('Credits', 'credits',
          serge.blocks.utils.worldCallback('credits-screen', 'click')),
         ('Achievements', 'achievements',
          serge.blocks.utils.worldCallback('achievements-screen', 'click')),
     ], the_theme, 'foreground')
 def addedToWorld(self, world):
     """The screen was added to the world"""
     super(HelpScreen, self).addedToWorld(world)
     #
     # Logo
     the_theme = theme.getTheme('help-screen')
     L = the_theme.getProperty
     logo = serge.blocks.utils.addSpriteActorToWorld(world, 'logo', 'logo', 'logo', 'foreground',
         center_position=L('logo-position'))
     title = serge.blocks.utils.addSpriteActorToWorld(world, 'logo', 'title', 'title', 'foreground',
         center_position=L('title-position'))
     bg = serge.blocks.utils.addSpriteActorToWorld(
         world, 'bg', 'bg', 'dark-background',
         layer_name='background',
         center_position=(G('screen-width') / 2, G('screen-height') / 2),
     )
     #
     # Help text
     text = serge.blocks.utils.addSpriteActorToWorld(world, 'text', 'text', 'help-keys', 'foreground',
         center_position=L('text-position'))
     #
     serge.blocks.utils.addTextItemsToWorld(world, [
                 ('Cursor keys to move. SPACE to Bomb.', 'keys-title'),
                 ('Music Volume', 'music-title'),
             ],
             the_theme, 'foreground')
     #
     # Back link
     #
     back = serge.blocks.utils.addSpriteActorToWorld(
         world, 'back', 'back', 'back',
         layer_name='ui',
         center_position=L('back-position'),
     )
     back.linkEvent(serge.events.E_LEFT_CLICK, common.tweenBackWorlds('start-screen'))
     #
     # Volume control
     self.down = serge.blocks.utils.addSpriteActorToWorld(
         world, 'btn', 'vol-down', 'vol-down',
         layer_name='ui',
         center_position=L('vol-down-position')
     )
     self.down.linkEvent(serge.events.E_LEFT_CLICK, self.changeVolume, -L('vol-change-amount'))
     self.up = serge.blocks.utils.addSpriteActorToWorld(
         world, 'btn', 'vol-up', 'vol-up',
         layer_name='ui',
         center_position=L('vol-up-position')
     )
     self.up.linkEvent(serge.events.E_LEFT_CLICK, self.changeVolume, +L('vol-change-amount'))
     #
     self.volume = serge.blocks.utils.addActorToWorld(
         world, serge.blocks.actors.NumericText(
             'text', 'volume', '%d%%', L('volume-colour'),
             font=L('volume-font'), font_size=L('volume-size'),
             value=G('volume', 'start-screen') * 100.0
         ),
         layer_name='ui',
         center_position=L('vol-position')
     )
 def addedToWorld(self, world):
     """The screen was added to the world"""
     super(CreditsScreen, self).addedToWorld(world)
     #
     # Logo
     the_theme = theme.getTheme('credits-screen')
     L = the_theme.getProperty
     logo = serge.blocks.utils.addSpriteActorToWorld(world, 'logo', 'logo', 'logo', 'foreground',
         center_position=L('logo-position'))
     title = serge.blocks.utils.addSpriteActorToWorld(world, 'logo', 'title', 'title', 'foreground',
         center_position=L('title-position'))
     bg = serge.blocks.utils.addSpriteActorToWorld(
         world, 'bg', 'bg', 'dark-background',
         layer_name='background',
         center_position=(G('screen-width') / 2, G('screen-height') / 2),
     )
     #
     # Text on the page
     serge.blocks.utils.addTextItemsToWorld(world, [
                 ('Game concept, design and coding', 'author-title'),
                 (AUTHOR, 'author'),
                 (URL, 'url', self.launchURL),
                 ('Music', 'music-title1'),
                 ('from the FreeMusicArchive.org', 'music-title2'),
                 ('Sound', 'sound-title1'),
                 ('From FreeSound.org', 'sound-title2'),
                 ('Built using', 'built-title'),
                 (BUILT_USING, 'built'),
                 ('Game engine', 'engine-title'),
                 (GAME_ENGINE, 'engine'),  
                 ('(v' + serge.common.version + ')', 'engine-version'),
                 ('Fonts', 'font-title1'),
                 ('from the OpenFontLibrary.org', 'font-title2'), 
                 ('Back', 'back', common.tweenBackWorlds('start-screen')),
             ],
             the_theme, 'foreground')
     #
     back = serge.blocks.utils.addSpriteActorToWorld(
         world, 'back', 'back', 'back',
         layer_name='ui',
         center_position=L('back-position'),
     )
     #
     x, y = L('music-position')
     for idx, track in enumerate(MUSIC):
         serge.blocks.utils.addVisualActorToWorld(world, 'title', 'music-item', 
             serge.visual.Text(track, L('music-colour'), 
             font_size=L('music-font-size')), 'foreground', 
             center_position=(x, y+idx*20))
     #
     x, y = L('font-position')
     for idx, font in enumerate(FONTS):
         serge.blocks.utils.addVisualActorToWorld(world, 'title', 'font-item', 
             serge.visual.Text(font, L('font-colour'), 
             font_size=L('font-font-size')), 'foreground', 
             center_position=(x, y+idx*20))
Exemple #6
0
 def addedToWorld(self, world):
     """The start screen was added to the world"""
     super(StartScreen, self).addedToWorld(world)
     #
     # Logo
     the_theme = theme.getTheme('start-screen')
     L = the_theme.getProperty
     logo = serge.blocks.utils.addSpriteActorToWorld(world, 'logo', 'logo', 'icon', 'foreground', 
         center_position=L('logo-position'))
     bg = serge.blocks.utils.addSpriteActorToWorld(world, 'bg', 'bg', 'map', 'background',
         center_position=L('bg-position'))
     #
     serge.blocks.utils.addTextItemsToWorld(world, [
                 ('v' + common.version, 'version'),
                 # ('Help', 'help',  serge.blocks.utils.worldCallback('help-screen', 'click')),
                 # ('Credits', 'credits',  serge.blocks.utils.worldCallback('credits-screen', 'click')),
                 # ('Achievements', 'achievements', serge.blocks.utils.worldCallback('achievements-screen', 'click')),
                 ('Choose filename', 'filename-label'),
             ],
             the_theme, 'foreground')
     #
     # The menu of files
     filenames = common.getFilenames('(\w+)')
     self.file_menu = serge.blocks.utils.addActorToWorld(
         world,
         serge.blocks.actors.ToggledMenu(
             'menu', 'file-menu', filenames,
             serge.blocks.layout.VerticalBar(
                 'vbar', 'vbar',
                 background_colour=L('menu-back-colour'),
                 background_layer='main',
                 item_width=L('menu-item-width'),
                 item_height=L('menu-item-height'),
             ),
             default=None,
             on_colour=L('menu-on-colour'),
             off_colour=L('menu-off-colour'),
             mouse_over_colour=L('menu-on-colour'),
             font_colour=L('menu-font-colour'),
             font_size=L('menu-font-size'),
             width=L('menu-width'),
             height=L('menu-height'),
             callback=self.startMain,
         ),
         layer_name='ui',
         center_position=L('menu-position'),
     )
     #
     # Focus manager
     self.focus_manager = serge.blocks.utils.addActorToWorld(
         world,
         serge.blocks.actors.FocusManager(
             'entry', 'focus-manager'
         )
     )
def getOverlays(world, text, visible=False):
    """Return some overlays to display when creating the main rendering"""
    overlay = serge.blocks.utils.addVisualActorToWorld(world, 'overlay', 'overlay', 
        serge.blocks.visualblocks.Rectangle((G('screen-width'), G('screen-height')), (0, 0, 0)),
        'overlay', 
        center_position=(G('screen-width')/2, G('screen-height')/2))
    overlay_text = serge.blocks.utils.addTextToWorld(world, text, 'overlay', theme.getTheme('overlay-screen'), 'overlay')
    overlays = serge.actor.ActorCollection([overlay, overlay_text])
    overlays.forEach().visible = visible
    #
    return overlays
 def addedToWorld(self, world):
     """Added to the world"""
     super(SmackTalker, self).addedToWorld(world)
     #
     the_theme = theme.getTheme(self.theme_name)
     L = the_theme.getProperty
     self.line_length = L('smack-line-length')
     #
     self.icon = serge.blocks.utils.addSpriteActorToWorld(
         world,
         'icon',
         'smack-icon',
         'head',
         center_position=L('smack-icon-position'),
         layer_name='ui',
     )
     self.addChild(self.icon)
     #
     self.bubble = serge.blocks.utils.addSpriteActorToWorld(
         world,
         'icon',
         'smack-bubble',
         'speech-bubble',
         center_position=L('smack-bubble-position'),
         layer_name='ui',
     )
     self.addChild(self.bubble)
     #
     self.text = serge.blocks.utils.addTextToWorld(
         world,
         'Some text that is potentially long\nwith line breaks',
         'smack-text',
         the_theme,
         layer_name='ui-front',
     )
     self.addChild(self.text)
     #
     self.generator = serge.blocks.textgenerator.TextGenerator()
     self.generator.addExamplesFromFile(
         os.path.join('game', 'smack-talk.txt'))
     #
     self.hide_timer = self.addChild(
         serge.blocks.actors.Timer(
             'timer',
             '%s-hide-timer' % self.name,
             L('smack-hide-interval'),
             callback=self.hideNow,
             started=False,
         ))
     #
     # Clear smack talker when leaving the screen
     world.linkEvent(serge.events.E_DEACTIVATE_WORLD,
                     lambda o, a: self.hideNow())
 def addedToWorld(self, world):
     """The screen was added to the world"""
     super(CreditsScreen, self).addedToWorld(world)
     #
     # Logo
     the_theme = theme.getTheme('credits-screen')
     L = the_theme.getProperty
     logo = serge.blocks.utils.addSpriteActorToWorld(world, 'logo', 'logo', 'icon', 'ui', 
         center_position=L('logo-position'))
     #
     # Background
     bh = serge.blocks.utils.addSpriteActorToWorld(world, 'bg', 'bg', L('screen-background-sprite'), 'background', 
         center_position=L('screen-background-position'))
     #
     # Text on the page
     serge.blocks.utils.addTextItemsToWorld(world, [
                 ('Game concept, design and coding', 'author-title'),
                 (AUTHOR, 'author'),
                 (URL, 'url', self.launchURL),
                 ('Music', 'music-title1'),
                 ('from the FreeMusicArchive.org', 'music-title2'),
                 ('Sound', 'sound-title1'),
                 ('From FreeSound.org', 'sound-title2'),
                 ('Built using', 'built-title'),
                 (BUILT_USING, 'built'),
                 ('Game engine', 'engine-title'),
                 (GAME_ENGINE, 'engine'),  
                 ('Fonts', 'font-title1'),
                 ('from the cooltext.com', 'font-title2'), 
                 ('Back', 'back', serge.blocks.utils.backToPreviousWorld('click')),                 
             ],
             the_theme, 'ui')
     #
     x, y = L('music-position')
     for idx, track in enumerate(MUSIC):
         serge.blocks.utils.addVisualActorToWorld(world, 'title', 'music-item', 
             serge.visual.Text(track, L('music-colour'), 
             font_size=L('music-font-size')), 'ui', 
             center_position=(x, y+idx*20))
     #
     x, y = L('font-position')
     for idx, font in enumerate(FONTS):
         serge.blocks.utils.addVisualActorToWorld(world, 'title', 'font-item', 
             serge.visual.Text(font, L('font-colour'), 
             font_size=L('font-font-size')), 'ui', 
             center_position=(x, y+idx*20))
     #
     # Trees
     tree.addTrees(L, world)
 def addedToWorld(self, world):
     """Added to the world"""
     super(RandomlyAppearingSmacker, self).addedToWorld(world)
     #
     the_theme = theme.getTheme(self.theme_name)
     L = the_theme.getProperty
     #
     # Parameters
     self.timer = self.addChild(serge.blocks.actors.Timer(
         'timer', 'timer-%s' % self.name,
         L('smack-delay'), L('smack-delay') + L('smack-offset'),
         self._showRandom
     ))
     if self._random_on:
         self.enableRandomShowing()
 def addedToWorld(self, world):
     """Added to the world"""
     super(RandomlyAppearingSmacker, self).addedToWorld(world)
     #
     the_theme = theme.getTheme(self.theme_name)
     L = the_theme.getProperty
     #
     # Parameters
     self.timer = self.addChild(
         serge.blocks.actors.Timer('timer', 'timer-%s' % self.name,
                                   L('smack-delay'),
                                   L('smack-delay') + L('smack-offset'),
                                   self._showRandom))
     if self._random_on:
         self.enableRandomShowing()
 def addedToWorld(self, world):
     """The start screen was added to the world"""
     super(NameScreen, self).addedToWorld(world)
     #
     self.manager = world.findActorByName('behaviours')
     #
     # Logo
     the_theme = theme.getTheme('name-screen')
     L = the_theme.getProperty
     logo = serge.blocks.utils.addSpriteActorToWorld(world, 'logo', 'logo', 'icon', 'ui', 
         center_position=L('logo-position'))
     #
     # Background
     bh = serge.blocks.utils.addSpriteActorToWorld(world, 'bg', 'bg', L('screen-background-sprite'), 'background', 
         center_position=L('screen-background-position'))
     #
     serge.blocks.utils.addTextItemsToWorld(world, [
                 ('Quick play - random cave', 'random', self.chooseRandomName),
                 ('Click to select a random cave', 'random-small'),
                 ('Enter a name for your cave', 'named', self.chooseName),
                 ('You will be able to return to your cave later', 'named-small'),
                 ('Previous caves', 'previous'),
                 ('Click below to return to a previously visited cave', 'previous-small'),
                 ('Back', 'back', serge.blocks.utils.backToPreviousWorld('click')),
     ], the_theme, 'ui')
     #
     # Name entry
     self.name_entry = serge.blocks.utils.addActorToWorld(world,     
         serge.blocks.actors.TextEntryWidget('entry', 'entry', L('entry-width'), L('entry-height'),
             colour=L('entry-font-colour'), font_size=L('entry-font-size'), font_name=L('entry-font-name'), 
                     justify='center', 
                     background_visual=serge.blocks.visualblocks.Rectangle((L('entry-width'), L('entry-height')),
                         L('entry-bg-colour'), L('entry-stroke-width'), L('entry-stroke-colour')),
                     background_layer='ui-back', show_cursor=True),
         center_position=L('entry-position'),
         layer_name='ui')
     self.name_entry.linkEvent(serge.events.E_ACCEPT_ENTRY, self.chooseName)
     #
     # The history table
     self.history = serge.blocks.utils.addActorToWorld(world, 
         self.globals.history,
         layer_name='ui', center_position=G('history-position', 'name-screen'))
     self.history.linkEvent(common.E_CAVE_SELECTED, self.chooseName)
     #
     # Overlay
     self.overlays = common.getOverlays(world, 'Building cave ...')
     #
     self.world.linkEvent(serge.events.E_ACTIVATE_WORLD, self.resetCamera)
 def addedToWorld(self, world):
     """The start screen was added to the world"""
     super(StartScreen, self).addedToWorld(world)
     #
     self.camera_timer = 0
     self.manager = world.findActorByName('behaviours')
     #
     # Logo
     the_theme = theme.getTheme('start-screen')
     L = the_theme.getProperty
     logo = serge.blocks.utils.addSpriteActorToWorld(world, 'logo', 'logo', 'logo', 'ui', 
         center_position=L('logo-position'))
     #
     serge.blocks.utils.addTextItemsToWorld(world, [
                 (L('title'), 'title'),
                 (L('title2'), 'title2'),
                 ('v' + common.version, 'version'),
                 ('Resume', 'resume',  self.resumePlay),
                 ('Start', 'start',  serge.blocks.utils.worldCallback('name-screen', 'click')),
                 ('Crystal collection', 'collection',  serge.blocks.utils.worldCallback('collection-screen', 'click')),
                 ('Help', 'help',  serge.blocks.utils.worldCallback('help-screen', 'click')),
                 ('Credits', 'credits',  serge.blocks.utils.worldCallback('credits-screen', 'click')),
                 ('Achievements', 'achievements', self.showAchievements),
             ],
             the_theme, 'ui')
     #
     self.start = world.findActorByName('start')
     self.resume = world.findActorByName('resume')
     self.resume.visible = False
     #
     self.music = serge.sound.Music.getItem('title-music')
     self.music.play(loops=-1)
     #
     self.world.linkEvent(serge.events.E_ACTIVATE_WORLD, self.worldActivated)
     #
     # Overlay
     self.overlays = common.getOverlays(world, 'Starting game ...', visible=True)
     #
     # Asynchronously build the graphical elements - this takes a while
     self.manager.assignBehaviour(self, serge.blocks.behaviours.TimedOneshotCallback(100, self.buildGraphics), 'build')
     #
     # FPS counter
     if self.options.cheat:
         fps = serge.blocks.utils.addActorToWorld(world,
             serge.blocks.actors.FPSDisplay(G('fps-x'), G('fps-y'), G('fps-colour'), G('fps-size')))
 def addedToWorld(self, world):
     """The start screen was added to the world"""
     super(PlayerScreen, self).addedToWorld(world)
     #
     # Logo
     the_theme = theme.getTheme('player-screen')
     L = the_theme.getProperty
     logo = serge.blocks.utils.addSpriteActorToWorld(world, 'logo', 'logo', 'icon', 'foreground', 
         center_position=L('logo-position'))
     #
     serge.blocks.utils.addTextItemsToWorld(world, [
                 (L('title'), 'title'),
                 ('v' + common.version, 'version'),
                 ('Start', 'start',  serge.blocks.utils.worldCallback('main-screen', 'click')),
                 ('Help', 'help',  serge.blocks.utils.worldCallback('help-screen', 'click')),
                 ('Credits', 'credits',  serge.blocks.utils.worldCallback('credits-screen', 'click')),
                 ('Achievements', 'achievements', serge.blocks.utils.worldCallback('achievements-screen', 'click')),
             ],
             the_theme, 'foreground')
Exemple #15
0
 def addedToWorld(self, world):
     """Added the actor to the world"""
     super(RunningWindow, self).addedToWorld(world)
     #
     the_theme = theme.getTheme('main-screen')
     L = the_theme.getProperty
     #
     # Hide button
     self.hide = serge.actor.Actor('button', 'hide')
     self.hide.visual = serge.blocks.visualblocks.RectangleText(
         'X',
         L('hide-button-colour'),
         L('hide-button-size'),
         L('hide-button-rect-colour'),
         L('hide-button-font-size'),
         stroke_colour=L('hide-button-stroke-colour'),
         stroke_width=L('hide-button-stroke-width'),
     )
     self.hide.setLayerName('ui-front')
     self.mountActor(self.hide, L('status-hide-position'))
     self.hide.linkEvent(serge.events.E_LEFT_CLICK, self.hideClick)
     #
     # Main title
     self.title = serge.actor.Actor('text', 'title')
     self.title.visual = serge.blocks.visualblocks.RectangleText(
         'Title of running window',
         L('status-title-colour'),
         L('status-title-size'),
         L('status-title-rect-colour'),
         L('status-title-font-size'),
         stroke_colour=L('status-title-stroke-colour'),
         stroke_width=L('status-title-stroke-width'),
     )
     self.title.setLayerName('ui-front')
     self.mountActor(self.title, L('status-title-position'))
     #
     # Progress indicator
     self.progress_indicator = serge.actor.Actor('progress', 'progress')
     self.progress_indicator.visual = serge.blocks.visualblocks.ProgressBar(
         L('progress-size'), L('progress-value-ranges'))
     self.progress_indicator.setLayerName('ui-progress')
     self.progress_indicator.visual.value = 0
     self.mountActor(self.progress_indicator, L('progress-position'))
 def addedToWorld(self, world):
     """Added to the world"""
     super(SmackTalker, self).addedToWorld(world)
     #
     the_theme = theme.getTheme(self.theme_name)
     L = the_theme.getProperty
     self.line_length = L('smack-line-length')
     #
     self.icon = serge.blocks.utils.addSpriteActorToWorld(
         world, 'icon', 'smack-icon', 'head',
         center_position=L('smack-icon-position'),
         layer_name='ui',
     )
     self.addChild(self.icon )
     #
     self.bubble = serge.blocks.utils.addSpriteActorToWorld(
         world, 'icon', 'smack-bubble', 'speech-bubble',
         center_position=L('smack-bubble-position'),
         layer_name='ui',
     )
     self.addChild(self.bubble)
     #
     self.text = serge.blocks.utils.addTextToWorld(
         world, 'Some text that is potentially long\nwith line breaks', 'smack-text', the_theme,
         layer_name='ui-front',
     )
     self.addChild(self.text)
     #
     self.generator = serge.blocks.textgenerator.TextGenerator()
     self.generator.addExamplesFromFile(os.path.join('game', 'smack-talk.txt'))
     #
     self.hide_timer = self.addChild(serge.blocks.actors.Timer(
         'timer', '%s-hide-timer' % self.name,
         L('smack-hide-interval'),
         callback=self.hideNow,
         started=False,
     ))
     #
     # Clear smack talker when leaving the screen
     world.linkEvent(serge.events.E_DEACTIVATE_WORLD, lambda o, a: self.hideNow())
 def addedToWorld(self, world):
     """Added the history to the world"""
     super(History, self).addedToWorld(world)
     #
     # Make a bar to display the caves
     the_theme = theme.getTheme('name-screen')
     L = the_theme.getProperty
     self.layout = serge.blocks.utils.addActorToWorld(world, 
         serge.blocks.layout.VerticalBar('bar', 'bar', L('names-width'), L('names-height')),
         layer_name='ui-back',
         center_position=L('names-position'))
     #
     # Add all name slots
     self.slots = []
     for idx in range(L('names-number')):
         slot = self.layout.addActor(serge.blocks.actors.StringText('slot', 'slot-%d' % idx, 
                 '', '%s', L('names-colour'), L('names-font-name'), L('names-font-size')))
         slot.linkEvent(serge.events.E_LEFT_CLICK, self.nameClicked, idx)
         self.slots.append(slot)  
     #
     # The current page
     self.current_page = 0              
     #
     world.linkEvent(serge.events.E_ACTIVATE_WORLD, self.updateNames)
Exemple #18
0
 def updateViews(self, obj=None, arg=None):
     """Update the views of the generator"""
     #
     # Update terrain generator
     self.updateTerrainGenerator()
     #
     # Clear up old actors
     self.world.clearActorsWithTags(['transient'])
     self.status.visible = False
     self.output.visual.clearSurface()
     #
     the_theme = theme.getTheme('main-screen')
     L = the_theme.getProperty
     #
     # Builders menu
     self.builder_names = [builder.name for builder in self.generator.getSortedBuilders()]
     self.builder_menu = serge.blocks.utils.addActorToWorld(
         self.world,
         serge.blocks.actors.ToggledMenu(
             'transient', 'builder-menu',
             self.builder_names,
             serge.blocks.layout.VerticalBar(
                 'transient', 'builder-layout',
                 # height=L('menu-height'),
                 # width=L('menu-width'),
                 background_colour=L('menu-back-colour'),
                 background_layer='background',
                 item_width=L('menu-item-width'),
                 item_height=L('menu-item-height')
             ),
             self.builder_names[0],
             on_colour=L('menu-on-colour'),
             off_colour=L('menu-off-colour'),
             mouse_over_colour=L('menu-mouse-colour'),
             callback=self.builderMenuClick,
             font_colour=L('menu-font-colour'),
             font_size=L('menu-font-size'),
             width=L('menu-width'),
             height=L('menu-height'),
         ),
         center_position=L('builder-menu-position'),
         layer_name='ui',
     )
     #
     # Renderers menu
     self.renderer_names = [renderer.name for renderer in self.generator.getSortedRenderers()]
     self.renderer_menu = serge.blocks.utils.addActorToWorld(
         self.world,
         serge.blocks.actors.ToggledMenu(
             'transient', 'renderer-menu',
             self.renderer_names,
             serge.blocks.layout.VerticalBar(
                 'transient', 'renderer-layout',
                 # height=L('menu-height'),
                 # width=L('menu-width'),
                 background_colour=L('menu-back-colour'),
                 background_layer='background',
                 item_width=L('menu-item-width'),
                 item_height=L('menu-item-height')
             ),
             self.renderer_names[0],
             on_colour=L('menu-on-colour'),
             off_colour=L('menu-off-colour'),
             mouse_over_colour=L('menu-mouse-colour'),
             callback=self.rendererMenuClick,
             font_colour=L('menu-font-colour'),
             font_size=L('menu-font-size'),
             width=L('menu-width'),
             height=L('menu-height'),
         ),
         center_position=L('renderer-menu-position'),
         layer_name='ui',
     )
     #
     # The dynamic parameters list
     self.dynamic.updateFrom(self.generator)
Exemple #19
0
 def setParameters(self, parameters):
     """Set the parameters to display"""
     #
     the_theme = theme.getTheme('main-screen')
     L = the_theme.getProperty
     self.world.clearActorsWithTags(['transient-text'])
     self.parameters = []
     #
     # Create page lookup
     self.parameter_pages = {}
     page_names = []
     for _, _, _, page in parameters:
         if not page in self.parameter_pages:
             self.parameter_pages[page] = len(self.parameter_pages)
             page_names.append(page)
     self.log.debug('Found %d parameter pages' % len(self.parameter_pages))
     #
     # Update the page control
     self.page_menu.setupMenu(page_names)
     #
     for idx, (name, value, description, page) in enumerate(parameters):
         #
         # The name
         layout = self.parameter_layouts[self.parameter_pages[page]]
         text = layout.addActor(
             serge.blocks.actors.StringText(
                 'transient-text',
                 'transient-%s' % name,
                 name,
                 colour=L('dynamic-text-colour'),
                 font_size=L('dynamic-text-font-size'),
             ), )
         text.setLayerName('ui-over')
         #
         # The entry
         item = layout.addActor(
             serge.blocks.actors.TextEntryWidget(
                 'transient-text',
                 'transient-entry-%s' % name,
                 L('parameter-width'),
                 L('parameter-height'),
                 L('dynamic-entry-colour'),
                 L('dynamic-entry-font-size'),
                 background_visual=serge.blocks.visualblocks.Rectangle(
                     (L('parameter-width'), L('parameter-height')),
                     L('dynamic-entry-stroke-colour'),
                     L('dynamic-entry-stroke-width'),
                 ),
                 show_cursor=True,
                 background_layer='ui-back',
                 has_focus=idx == 0))
         item.setLayerName('ui-over')
         item.setText(value)
         item.description = description
         self.parameters.append(item)
         #
         self.focus_manager.addChild(item)
     #
     # Set the first parameter page as active
     if page_names:
         self.page_menu.selectItem(page_names[0])
     #
     # Don't bother to show the page control if there is only one page
     self.page_menu.active = len(page_names) > 1
Exemple #20
0
 def addedToWorld(self, world):
     """The widget was added to the world"""
     super(DynamicParameterList, self).addedToWorld(world)
     #
     self.world = world
     self.status = world.findActorByName('main-screen').status
     the_theme = theme.getTheme('main-screen')
     L = the_theme.getProperty
     #
     title = self.mountActor(
         serge.blocks.actors.StringText(
             'text',
             'text',
             'Parameters',
             colour=L('dynamic-title-colour'),
             font_size=L('dynamic-title-font-size'),
         ), L('dynamic-title-position'))
     title.setLayerName('ui')
     #
     # Page layout
     self.page_menu = serge.blocks.utils.addActorToWorld(
         self.world,
         serge.blocks.actors.ToggledMenu(
             'menu',
             'file-menu',
             [''],
             serge.blocks.layout.HorizontalBar(
                 'hbar',
                 'page-menu-bar',
                 background_colour=L('page-menu-back-colour'),
                 background_layer='main',
                 item_width=L('page-menu-item-width'),
                 item_height=L('page-menu-item-height'),
             ),
             default=None,
             on_colour=L('page-menu-on-colour'),
             off_colour=L('page-menu-off-colour'),
             mouse_over_colour=L('page-menu-on-colour'),
             font_colour=L('page-menu-font-colour'),
             font_size=L('page-menu-font-size'),
             width=L('page-menu-width'),
             height=L('page-menu-height'),
             callback=self.pageSelected,
         ),
         layer_name='ui-over',
         center_position=L('page-menu-position'),
     )
     #
     # The layout of parameters - we make a number of pages
     self.parameter_layouts = []
     for _ in range(L('dynamic-page-count')):
         parameter_layout = self.mountActor(
             serge.blocks.layout.VerticalBar(
                 'vbar',
                 'vbar',
                 item_width=L('parameter-width'),
                 item_height=L('parameter-height')),
             L('parameter-position'),
         )
         parameter_layout.setLayerName('ui-over')
         self.parameter_layouts.append(parameter_layout)
     #
     # Focus manager
     self.focus_manager = serge.blocks.utils.addActorToWorld(
         world, serge.blocks.actors.FocusManager('entry', 'focus-manager'))
     self.focus_manager.linkEvent(serge.events.E_GOT_FOCUS, self.getFocus)
     #
     self.setParameters([])
 def addedToWorld(self, world):
     """Added to the world"""
     super(MainScreen, self).addedToWorld(world)
     self.manager = world.findActorByName('behaviours')
     self.achievements = serge.blocks.achievements.getManager()
     serge.blocks.achievements.addAchievementsBannerToWorld(world, 'ui', 'ui-back', theme, self.manager)
     #
     world.setPhysicsStepsize(G('physics-step-size'))
     #
     self.status = serge.blocks.utils.addActorToWorld(world, status.Status('status', 'status'))
     #
     self.random_seed = G('level-seed')
     self.generateMap()
     #
     # Count the number of crystals that are in the cave
     self.status.total_crystals = len(world.findActorsByTag('crystal'))
     #
     # Player
     self.player = player.Player('player', 'player', maximum_reach=G('player-max-reach'), surface_tags=['rock'], 
         jump_impulse=G('player-jump-impulse'), walk_impulse=G('player-walk-impulse'), can_scramble=False)
     self.player.setSpriteName('walking')
     self.player.setPhysical(serge.physical.PhysicalConditions(
         mass=20.0, force=climbing.G*20, visual_size=False, group=climbing.G_ROPES, elasticity=0.1, 
         friction=G('player-friction'), width=G('player-effective-radius'), height=G('player-effective-radius')))
     self.player.setLayerName('actors')
     self.player.moveTo(*G('player-initial-position'))
     self.player.linkEvent(common.E_PLAYER_DIED, self.playerDied)
     self.player.linkEvent(common.E_CAVE_SOLVED, self.caveSolved)
     self.player.linkEvent(serge.events.E_COLLISION, self.playerCollided)
     world.addActor(self.player)
     #
     # Text
     self.main_text = serge.blocks.utils.addTextToWorld(
         world, 'You died!', 'main-text', theme.getTheme('main-screen'), 'ui')
     self.sub_text = serge.blocks.utils.addTextToWorld(
         world, 'Press ENTER to restart', 'sub-text', theme.getTheme('main-screen'), 'ui')
     self.main_text.active = False
     self.sub_text.active = False
     #
     # Bugs
     self.bugs = [serge.blocks.utils.addActorToWorld(world,
         bug.Bug('bug', 'bug', 'base-bug', self),
         center_position=self.cave.getStartPosition())
             for idx in range(G('number-bugs'))]
     #
     # The HUD
     self.hud = serge.blocks.utils.addActorToWorld(world, hud.HUD('hud', 'hud', self.status))
     self.hud.linkEvent(common.E_ADD_LIGHT, self.addLight)
     #
     # Adding ropes
     self.cave.linkEvent(common.E_ROCK_CLICKED, self.addRope)
     self.cave.linkEvent(common.E_ROCK_RIGHT_CLICKED, self.switchRope)
     #
     self.world.linkEvent(serge.events.E_ACTIVATE_WORLD, self.worldActivated)
     self.world.linkEvent(serge.events.E_DEACTIVATE_WORLD, self.worldDeactivated)
     #
     # Sounds 
     self.addSoundTexture(world)
     #
     # Overlay
     self.overlays = common.getOverlays(world, 'Building cave ...', visible=True)
     #
     # Cheating
     if self.options.cheat:
         fps = serge.blocks.utils.addActorToWorld(world,
             serge.blocks.actors.FPSDisplay(G('fps-x'), G('fps-y'), G('fps-colour'), G('fps-size')))
Exemple #22
0
 def addedToWorld(self, world):
     """Added to the world"""
     super(ActionReplayScreen, self).addedToWorld(world)
     the_theme = theme.getTheme('action-replay-screen')
     L = the_theme.getProperty
      #
     # Background
     self.bg = serge.blocks.utils.addSpriteActorToWorld(
         world, 'bg', 'bg', 'replay-background',
         layer_name='background',
         center_position=(G('screen-width') / 2, G('screen-height') / 2),
     )
     #
     # A grid to hold the transport buttons
     self.transport_grid = serge.blocks.utils.addActorToWorld(
         world,
         serge.blocks.layout.HorizontalBar('hbar', 'hbar', L('bar-width'), L('bar-height'),
                                           background_colour=L('bar-background-colour'),
                                           background_layer='main'),
         center_position=L('bar-position'),
         layer_name='ui',
     )
     #
     # The transport buttons themselves
     self.buttons = serge.actor.ActorCollection()
     for name in ('backward-btn-end', 'backward-btn-fast', 'backward-btn-normal', 'backward-btn-slow',
                  'forward-btn-stop', 'forward-btn-slow', 'forward-btn-normal', 'forward-btn-fast',
                  'forward-btn-end'):
         btn = self.transport_grid.addActor(serge.actor.Actor('btn', name))
         btn.setSpriteName(name)
         btn.setLayerName('ui')
         btn.linkEvent(serge.events.E_LEFT_CLICK, self.buttonClick, name)
         self.buttons.append(btn)
     #
     self.buttonClick(None, 'forward-btn-stop')
     #
     # Current frame
     self.frame_counter = serge.blocks.utils.addActorToWorld(
         world,
         serge.blocks.actors.FormattedText(
             'text', 'frame-counter',
             '%(current)d of %(total)d',
             L('current-colour'),
             font_name=L('current-font'), font_size=L('current-font-size'),
             current=0, total=len(self.frames), justify='center'
         ),
         layer_name='ui',
         center_position=L('current-position')
     )
     #
     # Slider for scrubbing
     self.slider_back = serge.blocks.utils.addSpriteActorToWorld(
         world, 'bg', 'slide-back', 'slider-back',
         center_position=L('slider-back-position'),
         layer_name='main'
     )
     self.slider = serge.blocks.utils.addSpriteActorToWorld(
         world, 'slider', 'slider', 'slider',
         center_position=L('slider-back-position'),
         layer_name='ui'
     )
     self.drag = serge.blocks.dragndrop.DragController()
     self.drag.addActor(
         self.slider, self.dragSlider, self.dropSlider,
         x_constraint=(self.slider_back.x - self.slider_back.width / 2, self.slider_back.x + self.slider_back.width / 2),
         y_constraint=(self.slider_back.y, self.slider_back.y)
     )
     world.addActor(self.drag)
     #
     # The main display of the replay
     self.replay = serge.blocks.utils.addActorToWorld(
         world, serge.actor.Actor('window', 'replay-window'),
         center_position=L('replay-position'),
         layer_name='main',
     )
     self.replay.visual = serge.visual.SurfaceDrawing(L('replay-width'), L('replay-height'))
     #
     world.linkEvent(serge.events.E_ACTIVATE_WORLD, self.activateWorld)
     #
     # Cheating
     if self.options.cheat:
         fps = serge.blocks.utils.addActorToWorld(world,
             serge.blocks.actors.FPSDisplay(G('fps-x'), G('fps-y'), G('fps-colour'), G('fps-size')))
Exemple #23
0
 def addedToWorld(self, world):
     """The screen was added to the world"""
     super(FileSelectScreen, self).addedToWorld(world)
     #
     L = theme.getTheme('file-select-screen').getProperty
     #
     # The menu of files
     filenames = common.getFilenames('(\w+)')
     self.file_menu = serge.blocks.utils.addActorToWorld(
         self.world,
         serge.blocks.actors.ToggledMenu(
             'menu',
             'file-menu',
             filenames,
             serge.blocks.layout.VerticalBar(
                 'vbar',
                 'file-menu-bar',
                 background_colour=L('menu-back-colour'),
                 background_layer='main',
                 item_width=L('menu-item-width'),
                 item_height=L('menu-item-height'),
             ),
             default=None,
             on_colour=L('menu-on-colour'),
             off_colour=L('menu-off-colour'),
             mouse_over_colour=L('menu-on-colour'),
             font_colour=L('menu-font-colour'),
             font_size=L('menu-font-size'),
             width=L('menu-width'),
             height=L('menu-height'),
             callback=self.fileSelected,
         ),
         layer_name='ui',
         center_position=L('file-menu-position'),
     )
     #
     # Render Filename
     self.filename = serge.blocks.utils.addActorToWorld(
         self.world,
         serge.blocks.actors.TextEntryWidget(
             'entry',
             'filename',
             L('filename-width'),
             L('filename-height'),
             L('filename-colour'),
             L('filename-font-size'),
             background_visual=serge.blocks.visualblocks.Rectangle(
                 (L('filename-width') + 2 * L('filename-stroke-width'),
                  L('filename-height') + 2 * L('filename-stroke-width')),
                 L('filename-back-colour'),
                 L('filename-stroke-width'),
                 L('filename-stroke-colour'),
             ),
             background_layer='main',
             show_cursor=True,
             has_focus=True,
         ),
         layer_name='ui',
         center_position=L('filename-position'),
     )
     self.filename.setText('dungeon-1.png')
     self.filename.setCursorAtEnd()
     self.filename.linkEvent(serge.events.E_ACCEPT_ENTRY, self.doitClick)
     #
     # Do it button
     self.do_it = serge.blocks.utils.addVisualActorToWorld(
         world,
         'button',
         'do-it',
         serge.blocks.visualblocks.RectangleText(
             'Do it',
             L('buttons-colour'),
             L('buttons-size'),
             L('buttons-rect-colour'),
             L('buttons-font-size'),
             stroke_colour=L('buttons-stroke-colour'),
             stroke_width=L('buttons-stroke-width'),
         ),
         layer_name='ui',
         center_position=L('do-it-position'),
     )
     self.do_it.linkEvent(serge.events.E_LEFT_CLICK, self.doitClick)
     #
     # Cancel button
     self.cancel = serge.blocks.utils.addVisualActorToWorld(
         world,
         'button',
         'cancel',
         serge.blocks.visualblocks.RectangleText(
             'Cancel',
             L('buttons-colour'),
             L('buttons-size'),
             L('buttons-rect-colour'),
             L('buttons-font-size'),
             stroke_colour=L('buttons-stroke-colour'),
             stroke_width=L('buttons-stroke-width'),
         ),
         layer_name='ui',
         center_position=L('cancel-position'),
     )
     self.cancel.linkEvent(serge.events.E_LEFT_CLICK, self.cancelClick)
     self.world.linkEvent(serge.events.E_ACTIVATE_WORLD, self.onActivation)
 def addedToWorld(self, world):
     """The start screen was added to the world"""
     super(CollectionScreen, self).addedToWorld(world)
     #
     self.manager = world.findActorByName('behaviours')
     self.history = self.globals.history
     #
     # Logo
     the_theme = theme.getTheme('collection-screen')
     self.L = L = the_theme.getProperty
     logo = serge.blocks.utils.addSpriteActorToWorld(world, 'logo', 'logo', 'icon', 'ui', 
         center_position=L('logo-position'))
     #
     # Background
     bh = serge.blocks.utils.addSpriteActorToWorld(world, 'bg', 'bg', L('screen-background-sprite'), 'background', 
         center_position=L('screen-background-position'))
     #
     serge.blocks.utils.addTextItemsToWorld(world, [
                 ('Your collection of named crystals', 'title'),
                 ('Next Page', 'next', self.nextPage),
                 ('Previous Page', 'previous', self.previousPage),
                 ('Page ...', 'page'),
                 ('Back', 'back', serge.blocks.utils.backToPreviousWorld('click')),
     ], the_theme, 'ui')
     #
     self.page = world.findActorByName('page')
     #
     # The grid
     self.grid = grid = serge.blocks.utils.addActorToWorld(world,
         serge.blocks.layout.Grid('grid', 'grid', size=L('grid-size'), width=L('grid-width'),
             height=L('grid-height'), background_colour=L('background-colour')),
         center_position=L('grid-position'), layer_name='ui-back')
     #
     # Populate with slots
     w, h = L('grid-size')
     for x in range(w):
         for y in range(h):
             #
             # Layout of the labels
             slot = serge.blocks.layout.VerticalBar('slot', 'vbar', width=L('slot-width'), height=L('slot-height'),
                 background_colour=L('slot-background-colour'), background_layer='ui-back')
             grid.addActor((x, y), slot, 'ui')
             #
             # Text labels
             t1 = serge.blocks.actors.StringText(
                 'label', 'text', 'Title', colour=L('t1-colour'), font_size=L('t1-font-size'))
             t2 = serge.blocks.actors.StringText(
                 'label', 'text', 'Details', colour=L('t2-colour'), font_size=L('t2-font-size'))
             slot.addActor(t1)
             slot.addActor(t2)
             t1.setLayerName('ui')
             t2.setLayerName('ui')
             slot.long_description = ''
     #
     self.selected_slot = None
     #
     # Extra detail window
     self.detail = serge.blocks.utils.addVisualActorToWorld(world, 'text', 'detail',
         serge.blocks.visualblocks.RectangleText('Details', L('detail-colour'), 
             (L('detail-width'), L('detail-height')), L('detail-backcolour'), L('detail-font-size')),
             layer_name='overlay')
     self.detail.visible = False
     #
     # Trees
     tree.addTrees(L, world)
     #
     self.current_page = 0
     self.page_size = w*h
     self.page_width = w
     self.page_height = h
     self.populateCurrentPage()
     #
     self.world.linkEvent(serge.events.E_ACTIVATE_WORLD, self.resetCamera)
 def addedToWorld(self, world):
     """We were added to the world"""
     super(HighScoreScreen, self).addedToWorld(world)
     self.manager = world.findActorByName('behaviours')
     L = theme.getTheme('high-score-screen').getProperty
     #
     self.main_title = serge.blocks.utils.addSpriteActorToWorld(
         world, 'title', 'main-title', 'logo', 'ui', L('logo-position'))
     #
     self.title = serge.blocks.utils.addActorToWorld(
         world,
         serge.blocks.actors.StringText(
             'text', 'title', 'Web High Scores', colour=L('title-colour'),
             font_size=L('title-size'), justify='center',
         ),
         layer_name='ui',
         center_position=L('title-position')
     )
     #
     self.back = serge.blocks.utils.addActorToWorld(
         world,
         serge.blocks.actors.StringText(
             'text', 'back', 'Back', colour=L('back-colour'),
             font_size=L('back-font-size'), justify='center',
             font_name=L('back-font-name')
         ),
         layer_name='ui',
         center_position=L('back-position')
     )
     self.back.linkEvent(serge.events.E_LEFT_CLICK, serge.blocks.utils.backToPreviousWorld())
     #
     # The table
     player_name = serge.blocks.utils.getUniqueID()
     self.table = serge.blocks.utils.addActorToWorld(
         world,
         serge.blocks.onlinescores.SimpleHSTableView(
             'hs-table', 'hs-table', L('app-url'), L('app-game'), L('app-category'),
             player_name, L('max-scores'),
             serge.blocks.layout.VerticalBar(
                 'vbar', 'vbar', L('table-width'), item_height=L('table-item-height')
             ),
             theme.getTheme('high-score-screen'),
             fmt='%(num)02d ... %(score)06d'
         ),
         layer_name='ui',
         center_position=L('table-position')
     )
     self.table.layout.setLayerName('ui')
     self.table.ensurePlayer()
     self.table.updateScores()
     common.HIGH_SCORE_TABLE = self.table
     #
     # Best
     self.best = serge.blocks.utils.addActorToWorld(
         world,
         serge.blocks.actors.NumericText(
             'text', 'best', 'Your best: %06d', colour=L('hs-font-player-colour'),
             font_size=L('best-font-size'), justify='center',
             font_name=L('best-font-name'),
             value=0
         ),
         layer_name='ui',
         center_position=L('best-position')
     )
     #
     # Refresh button
     self.refresh = serge.blocks.utils.addActorToWorld(
         world,
         serge.blocks.actors.StringText(
             'btn', 'refresh', 'Refresh', colour=L('refresh-colour'),
             font_size=L('refresh-size'), justify='center',
             font_name=L('refresh-name'),
         ),
         layer_name='ui',
         center_position=L('refresh-position')
     )
     self.refresh.linkEvent(serge.events.E_LEFT_CLICK, self.refreshScores)
 def addedToWorld(self, world):
     """The level screen was added to the world"""
     super(RandomLevelScreen, self).addedToWorld(world)
     #
     # Logo
     the_theme = theme.getTheme('random-level-screen')
     L = the_theme.getProperty
     logo = serge.blocks.utils.addSpriteActorToWorld(
         world,
         'logo',
         'logo',
         'logo',
         'foreground',
         center_position=L('logo-position'))
     title = serge.blocks.utils.addSpriteActorToWorld(
         world,
         'logo',
         'title',
         'title',
         'foreground',
         center_position=L('title-position'))
     bg = serge.blocks.utils.addSpriteActorToWorld(
         world,
         'bg',
         'bg',
         'dark-background',
         layer_name='background',
         center_position=(G('screen-width') / 2, G('screen-height') / 2),
     )
     # Preview of level
     self.level_preview = serge.blocks.utils.addVisualActorToWorld(
         world,
         'level-preview',
         'level-preview',
         serge.visual.SurfaceDrawing(
             L('level-preview-width'),
             L('level-preview-height'),
         ),
         layer_name='ui',
         center_position=L('level-preview-position'),
     )
     #
     # Size menu
     self.size_options = L('size-options')
     self.size_menu = serge.blocks.utils.addActorToWorld(
         world,
         serge.blocks.actors.ToggledMenu(
             'size-menu',
             'size-menu',
             ['Small', 'Medium', 'Large'],
             serge.blocks.layout.VerticalBar(
                 'bar',
                 'bar',
                 L('size-width'),
                 L('size-height'),
             ),
             default='Medium',
             on_colour=L('menu-on-colour'),
             off_colour=L('menu-off-colour'),
             callback=self.sizeSelected,
             font_colour=L('menu-font-colour'),
             mouse_over_colour=L('menu-mouse-over-colour'),
             font_size=L('size-font-size'),
             font_name=L('menu-font'),
             width=L('size-item-width'),
             height=L('size-item-height'),
         ),
         center_position=L('size-position'),
         layer_name='ui')
     #
     # Amount of open space menu
     self.space_options = L('space-options')
     self.space_menu = serge.blocks.utils.addActorToWorld(
         world,
         serge.blocks.actors.ToggledMenu(
             'space-menu',
             'space-menu',
             ['Open', 'Blocked'],
             serge.blocks.layout.VerticalBar(
                 'bar',
                 'bar',
                 L('space-width'),
                 L('space-height'),
             ),
             default='Open',
             on_colour=L('menu-on-colour'),
             off_colour=L('menu-off-colour'),
             callback=self.spaceSelected,
             font_colour=L('menu-font-colour'),
             mouse_over_colour=L('menu-mouse-over-colour'),
             font_size=L('space-font-size'),
             height=L('space-item-height'),
             font_name=L('menu-font'),
             width=L('space-item-width'),
         ),
         center_position=L('space-position'),
         layer_name='ui')
     # Generate button
     generate = serge.blocks.utils.addSpriteActorToWorld(
         world,
         'generate',
         'generate',
         'generate',
         layer_name='ui',
         center_position=L('generate-position'),
     )
     generate.linkEvent(serge.events.E_LEFT_CLICK, self.generateLevel)
     # Select button
     select = serge.blocks.utils.addSpriteActorToWorld(
         world,
         'select',
         'select',
         'select',
         layer_name='ui',
         center_position=L('select-position'),
     )
     select.linkEvent(serge.events.E_LEFT_CLICK, self.selectLevel)
     #
     # Resume button
     self.resume = serge.blocks.utils.addSpriteActorToWorld(
         world,
         'resume',
         'resume',
         'resume',
         layer_name='ui',
         center_position=L('resume-position'),
     )
     self.resume.linkEvent(serge.events.E_LEFT_CLICK,
                           common.tweenWorlds('main-screen'))
     # Back button
     back = serge.blocks.utils.addSpriteActorToWorld(
         world,
         'back',
         'back',
         'back',
         layer_name='ui',
         center_position=L('back-position'),
     )
     back.linkEvent(serge.events.E_LEFT_CLICK,
                    common.tweenBackWorlds('level-screen'))
     #
     # Smack talking
     self.smack = smacktalker.RandomlyAppearingSmacker(
         'smack', 'smack', 'random-level-screen',
         'waiting-for-random-level')
     world.addActor(self.smack)
     self.smack.visible = False
     #
     self.initialised = True
     self.generateLevel()
     #
     # Events
     world.linkEvent(serge.events.E_ACTIVATE_WORLD, self.activatedWorld)
 def addedToWorld(self, world):
     """The level screen was added to the world"""
     super(RandomLevelScreen, self).addedToWorld(world)
     #
     # Logo
     the_theme = theme.getTheme('random-level-screen')
     L = the_theme.getProperty
     logo = serge.blocks.utils.addSpriteActorToWorld(world, 'logo', 'logo', 'logo', 'foreground',
         center_position=L('logo-position'))
     title = serge.blocks.utils.addSpriteActorToWorld(world, 'logo', 'title', 'title', 'foreground',
         center_position=L('title-position'))
     bg = serge.blocks.utils.addSpriteActorToWorld(
         world, 'bg', 'bg', 'dark-background',
         layer_name='background',
         center_position=(G('screen-width') / 2, G('screen-height') / 2),
     )
     # Preview of level
     self.level_preview = serge.blocks.utils.addVisualActorToWorld(
         world, 'level-preview', 'level-preview',
         serge.visual.SurfaceDrawing(
             L('level-preview-width'), L('level-preview-height'),
         ),
         layer_name='ui',
         center_position=L('level-preview-position'),
     )
     #
     # Size menu
     self.size_options = L('size-options')
     self.size_menu = serge.blocks.utils.addActorToWorld(
         world,
         serge.blocks.actors.ToggledMenu(
             'size-menu', 'size-menu',
             ['Small', 'Medium', 'Large'],
             serge.blocks.layout.VerticalBar(
                 'bar', 'bar', L('size-width'), L('size-height'),
             ),
             default='Medium',
             on_colour=L('menu-on-colour'),
             off_colour=L('menu-off-colour'),
             callback=self.sizeSelected,
             font_colour=L('menu-font-colour'),
             mouse_over_colour=L('menu-mouse-over-colour'),
             font_size=L('size-font-size'),
             font_name=L('menu-font'),
             width=L('size-item-width'),
             height=L('size-item-height'),
         ),
         center_position=L('size-position'),
         layer_name='ui'
     )
     #
     # Amount of open space menu
     self.space_options = L('space-options')
     self.space_menu = serge.blocks.utils.addActorToWorld(
         world,
         serge.blocks.actors.ToggledMenu(
             'space-menu', 'space-menu',
             ['Open', 'Blocked'],
             serge.blocks.layout.VerticalBar(
                 'bar', 'bar', L('space-width'), L('space-height'),
             ),
             default='Open',
             on_colour=L('menu-on-colour'),
             off_colour=L('menu-off-colour'),
             callback=self.spaceSelected,
             font_colour=L('menu-font-colour'),
             mouse_over_colour=L('menu-mouse-over-colour'),
             font_size=L('space-font-size'),
             height=L('space-item-height'),
             font_name=L('menu-font'),
             width=L('space-item-width'),
         ),
         center_position=L('space-position'),
         layer_name='ui'
     )
     # Generate button
     generate = serge.blocks.utils.addSpriteActorToWorld(
         world, 'generate', 'generate', 'generate',
         layer_name='ui',
         center_position=L('generate-position'),
     )
     generate.linkEvent(serge.events.E_LEFT_CLICK, self.generateLevel)
     # Select button
     select = serge.blocks.utils.addSpriteActorToWorld(
         world, 'select', 'select', 'select',
         layer_name='ui',
         center_position=L('select-position'),
     )
     select.linkEvent(serge.events.E_LEFT_CLICK, self.selectLevel)
     #
     # Resume button
     self.resume = serge.blocks.utils.addSpriteActorToWorld(
         world, 'resume', 'resume', 'resume',
         layer_name='ui',
         center_position=L('resume-position'),
     )
     self.resume.linkEvent(serge.events.E_LEFT_CLICK, common.tweenWorlds('main-screen'))
     # Back button
     back = serge.blocks.utils.addSpriteActorToWorld(
         world, 'back', 'back', 'back',
         layer_name='ui',
         center_position=L('back-position'),
     )
     back.linkEvent(serge.events.E_LEFT_CLICK, common.tweenBackWorlds('level-screen'))
     #
     # Smack talking
     self.smack = smacktalker.RandomlyAppearingSmacker('smack', 'smack', 'random-level-screen',
                                                       'waiting-for-random-level')
     world.addActor(self.smack)
     self.smack.visible = False
     #
     self.initialised = True
     self.generateLevel()
     #
     # Events
     world.linkEvent(serge.events.E_ACTIVATE_WORLD, self.activatedWorld)
Exemple #28
0
 def addedToWorld(self, world):
     """Added to the world"""
     super(MainScreen, self).addedToWorld(world)
     #
     the_theme = theme.getTheme('main-screen')
     L = the_theme.getProperty
     serge.blocks.utils.addTextItemsToWorld(
         world, [
             ('Builders', 'builders'),
             ('Renderers', 'renderers'),
         ],
         the_theme, 'foreground',
     )
     #
     # Run all button
     self.run_all = serge.blocks.utils.addVisualActorToWorld(
         world, 'button', 'run-all',
         serge.blocks.visualblocks.RectangleText(
             'Run All', L('buttons-colour'), L('buttons-size'),
             L('buttons-rect-colour'), L('buttons-font-size'),
             stroke_colour=L('buttons-stroke-colour'),
             stroke_width=L('buttons-stroke-width'),
         ),
         layer_name='ui',
         center_position=L('run-all-position'),
     )
     self.run_all.linkEvent(serge.events.E_LEFT_CLICK, self.runAllClick)
     #
     # Render button
     self.render = serge.blocks.utils.addVisualActorToWorld(
         world, 'button', 'render',
         serge.blocks.visualblocks.RectangleText(
             'Render', L('buttons-colour'), L('buttons-size'),
             L('buttons-rect-colour'), L('buttons-font-size'),
             stroke_colour=L('buttons-stroke-colour'),
             stroke_width=L('buttons-stroke-width'),
         ),
         layer_name='ui',
         center_position=L('render-position'),
     )
     self.render.linkEvent(serge.events.E_LEFT_CLICK, self.renderClick)
     #
     # Load button
     self.load = serge.blocks.utils.addVisualActorToWorld(
         world, 'button', 'load',
         serge.blocks.visualblocks.RectangleText(
             'Load', L('buttons-colour'), L('buttons-size'),
             L('buttons-rect-colour'), L('buttons-font-size'),
             stroke_colour=L('buttons-stroke-colour'),
             stroke_width=L('buttons-stroke-width'),
         ),
         layer_name='ui',
         center_position=L('load-position'),
     )
     self.load.linkEvent(serge.events.E_LEFT_CLICK, self.loadClick)
     #
     # Save button
     self.save = serge.blocks.utils.addVisualActorToWorld(
         world, 'button', 'save',
         serge.blocks.visualblocks.RectangleText(
             'Save', L('buttons-colour'), L('buttons-size'),
             L('buttons-rect-colour'), L('buttons-font-size'),
             stroke_colour=L('buttons-stroke-colour'),
             stroke_width=L('buttons-stroke-width'),
         ),
         layer_name='ui',
         center_position=L('save-position'),
     )
     self.save.linkEvent(serge.events.E_LEFT_CLICK, self.saveClick)
     #
     # Main output
     self.output = serge.blocks.utils.addVisualActorToWorld(
         world, 'output', 'output',
         serge.visual.SurfaceDrawing(
             L('output-width'), L('output-height'),
         ),
         layer_name='main',
         center_position=L('output-position'),
     )
     #
     # The running indicator
     self.status = serge.blocks.utils.addActorToWorld(
         world,
         runningwindow.RunningWindow('status', 'status'),
         layer_name='ui-back',
         center_position=L('status-position')
     )
     self.status.visible = False
     self.status.linkEvent(runningwindow.E_SHOULD_STOP, self.stopRequested)
     #
     # The list of dynamic parameters
     self.dynamic = serge.blocks.utils.addActorToWorld(
         world,
         dynamicparameters.DynamicParameterList('parameters', 'parameters'),
         layer_name='ui',
         center_position=L('dynamic-parameters-position'),
     )
     #
     # Filename entry or selection
     #
     world.linkEvent(serge.events.E_ACTIVATE_WORLD, self.updateViews)
     #
     # Thread to update current status
     self.status_updater = threading.Thread(target=self.updateCurrentStatus)
     self.status_updater.setDaemon(True)
     self.status_updater.start()
     #
     # Cheating
     if self.options.cheat:
         fps = serge.blocks.utils.addActorToWorld(world,
             serge.blocks.actors.FPSDisplay(G('fps-x'), G('fps-y'), G('fps-colour'), G('fps-size')))
 def addedToWorld(self, world):
     """The level screen was added to the world"""
     super(LevelScreen, self).addedToWorld(world)
     #
     # Logo
     the_theme = theme.getTheme('level-screen')
     L = the_theme.getProperty
     logo = serge.blocks.utils.addSpriteActorToWorld(world, 'logo', 'logo', 'logo', 'foreground',
         center_position=L('logo-position'))
     title = serge.blocks.utils.addSpriteActorToWorld(world, 'logo', 'title', 'title', 'foreground',
         center_position=L('title-position'))
     bg = serge.blocks.utils.addSpriteActorToWorld(
         world, 'bg', 'bg', 'dark-background',
         layer_name='background',
         center_position=(G('screen-width') / 2, G('screen-height') / 2),
     )
     #
     # Find all the levels
     levels = common.levels.LEVEL_FILES[:-1]
     self.level_grid = serge.blocks.utils.addActorToWorld(
         world,
         serge.blocks.layout.MultiGrid('grid', 'grid', size=L('grid-size'), width=L('grid-width'),
                                  height=L('grid-height')),
         center_position=L('grid-position'),
         layer_name='ui',
     )
     w, h = self.level_grid.getSize()
     for idx in range(1, len(levels) + 1):
         x, y = ((idx - 1) % w, (idx - 1) // w)
         tile = self.level_grid.addActor(
             (x, y),
             serge.actor.Actor('tile', 'tile-%s' % idx),
         )
         if self.options.test:
             tile.setSpriteName('general-board')
         else:
             tile.setSpriteName('level-%d' % idx)
         tile.linkEvent(serge.events.E_LEFT_CLICK, self.selectLevel, idx)
         title = self.level_grid.addActor(
             (x, y),
             serge.blocks.actors.StringText(
                 'title', 'title-%s' % idx, common.levels.LEVELS[idx - 1][0],
                 colour=L('title-colour'), font_name=L('title-font'),
                 font_size=int(L('title-font-size') * (0.5 if self.options.test else 1.0))),
         )
         title.y += L('title-offset-y')
     #
     # Random level button
     random_level = serge.blocks.utils.addSpriteActorToWorld(
         world, 'random-level', 'random-level', 'random-level',
         layer_name='ui',
         center_position=L('random-level-position'),
         actor_class=serge.actor.MountableActor,
     )
     random_level.linkEvent(serge.events.E_LEFT_CLICK, common.tweenWorlds('random-level-screen'))        #
     random_title = random_level.mountActor(
         serge.blocks.actors.StringText(
             'title', 'title-random', 'Random Generated Maze',
             colour=L('title-colour'), font_name=L('title-font'),
             font_size=int(L('title-font-size') * (0.5 if self.options.test else 1.0))),
         (0, L('title-offset-y'))
     )
     random_title.setLayerName('ui')
     # Back button
     back = serge.blocks.utils.addSpriteActorToWorld(
         world, 'back', 'back', 'back',
         layer_name='ui',
         center_position=L('back-position'),
     )
     back.linkEvent(serge.events.E_LEFT_CLICK, common.tweenBackWorlds('start-screen'))
     #
     # Resume button
     self.resume = serge.blocks.utils.addSpriteActorToWorld(
         world, 'resume', 'resume', 'resume',
         layer_name='ui',
         center_position=L('resume-position'),
     )
     self.resume.linkEvent(serge.events.E_LEFT_CLICK, common.tweenWorlds('main-screen'))
     #
     # Events
     world.linkEvent(serge.events.E_ACTIVATE_WORLD, self.activatedWorld)
     world.linkEvent(serge.events.E_DEACTIVATE_WORLD, self.deactivatedWorld)
 def addedToWorld(self, world):
     """The screen was added to the world"""
     super(CreditsScreen, self).addedToWorld(world)
     #
     # Logo
     the_theme = theme.getTheme('credits-screen')
     L = the_theme.getProperty
     logo = serge.blocks.utils.addSpriteActorToWorld(
         world,
         'logo',
         'logo',
         'logo',
         'foreground',
         center_position=L('logo-position'))
     title = serge.blocks.utils.addSpriteActorToWorld(
         world,
         'logo',
         'title',
         'title',
         'foreground',
         center_position=L('title-position'))
     bg = serge.blocks.utils.addSpriteActorToWorld(
         world,
         'bg',
         'bg',
         'dark-background',
         layer_name='background',
         center_position=(G('screen-width') / 2, G('screen-height') / 2),
     )
     #
     # Text on the page
     serge.blocks.utils.addTextItemsToWorld(world, [
         ('Game concept, design and coding', 'author-title'),
         (AUTHOR, 'author'),
         (URL, 'url', self.launchURL),
         ('Music', 'music-title1'),
         ('from the FreeMusicArchive.org', 'music-title2'),
         ('Sound', 'sound-title1'),
         ('From FreeSound.org', 'sound-title2'),
         ('Built using', 'built-title'),
         (BUILT_USING, 'built'),
         ('Game engine', 'engine-title'),
         (GAME_ENGINE, 'engine'),
         ('(v' + serge.common.version + ')', 'engine-version'),
         ('Fonts', 'font-title1'),
         ('from the OpenFontLibrary.org', 'font-title2'),
         ('Back', 'back', common.tweenBackWorlds('start-screen')),
     ], the_theme, 'foreground')
     #
     back = serge.blocks.utils.addSpriteActorToWorld(
         world,
         'back',
         'back',
         'back',
         layer_name='ui',
         center_position=L('back-position'),
     )
     #
     x, y = L('music-position')
     for idx, track in enumerate(MUSIC):
         serge.blocks.utils.addVisualActorToWorld(
             world,
             'title',
             'music-item',
             serge.visual.Text(track,
                               L('music-colour'),
                               font_size=L('music-font-size')),
             'foreground',
             center_position=(x, y + idx * 20))
     #
     x, y = L('font-position')
     for idx, font in enumerate(FONTS):
         serge.blocks.utils.addVisualActorToWorld(
             world,
             'title',
             'font-item',
             serge.visual.Text(font,
                               L('font-colour'),
                               font_size=L('font-font-size')),
             'foreground',
             center_position=(x, y + idx * 20))
 def updateActor(self, interval, world):
     """Update this actor"""
     super(HelpScreen, self).updateActor(interval, world)
     the_theme = theme.getTheme('help-screen')
     L = the_theme.getProperty
     self.camera.moveTo(*L('screen-background-position'))
Exemple #32
0
 def addedToWorld(self, world):
     """The screen was added to the world"""
     super(CreditsScreen, self).addedToWorld(world)
     #
     # Logo
     the_theme = theme.getTheme('credits-screen')
     L = the_theme.getProperty
     logo = serge.blocks.utils.addSpriteActorToWorld(
         world,
         'logo',
         'logo',
         'small-icon',
         'foreground',
         center_position=L('logo-position'))
     #
     # Title
     logo = serge.blocks.utils.addVisualActorToWorld(
         world,
         'title',
         'title',
         serge.visual.Text(L('title'),
                           L('title-colour'),
                           font_size=L('title-font-size')),
         'foreground',
         center_position=L('title-position'))
     #
     # Text on the page
     serge.blocks.utils.addTextItemsToWorld(world, [
         ('Game concept, design and coding', 'author-title'),
         (AUTHOR, 'author'),
         (URL, 'url', self.launchURL),
         ('Music', 'music-title1'),
         ('from the FreeMusicArchive.org', 'music-title2'),
         ('Sound', 'sound-title1'),
         ('From FreeSound.org', 'sound-title2'),
         ('Built using', 'built-title'),
         (BUILT_USING, 'built'),
         ('Game engine', 'engine-title'),
         (GAME_ENGINE, 'engine'),
         ('Fonts', 'font-title1'),
         ('from the OpenFontLibrary.org', 'font-title2'),
         ('Back', 'back', serge.blocks.utils.backToPreviousWorld('click')),
     ], the_theme, 'foreground')
     #
     x, y = L('music-position')
     for idx, track in enumerate(MUSIC):
         serge.blocks.utils.addVisualActorToWorld(
             world,
             'title',
             'music-item',
             serge.visual.Text(track,
                               L('music-colour'),
                               font_size=L('music-font-size')),
             'foreground',
             center_position=(x, y + idx * 20))
     #
     x, y = L('font-position')
     for idx, font in enumerate(FONTS):
         serge.blocks.utils.addVisualActorToWorld(
             world,
             'title',
             'font-item',
             serge.visual.Text(font,
                               L('font-colour'),
                               font_size=L('font-font-size')),
             'foreground',
             center_position=(x, y + idx * 20))
Exemple #33
0
 def addedToWorld(self, world):
     """The screen was added to the world"""
     super(HelpScreen, self).addedToWorld(world)
     #
     # Logo
     the_theme = theme.getTheme('help-screen')
     L = the_theme.getProperty
     logo = serge.blocks.utils.addSpriteActorToWorld(
         world,
         'logo',
         'logo',
         'logo',
         'foreground',
         center_position=L('logo-position'))
     title = serge.blocks.utils.addSpriteActorToWorld(
         world,
         'logo',
         'title',
         'title',
         'foreground',
         center_position=L('title-position'))
     bg = serge.blocks.utils.addSpriteActorToWorld(
         world,
         'bg',
         'bg',
         'dark-background',
         layer_name='background',
         center_position=(G('screen-width') / 2, G('screen-height') / 2),
     )
     #
     # Help text
     text = serge.blocks.utils.addSpriteActorToWorld(
         world,
         'text',
         'text',
         'help-keys',
         'foreground',
         center_position=L('text-position'))
     #
     serge.blocks.utils.addTextItemsToWorld(world, [
         ('Cursor keys to move. SPACE to Bomb.', 'keys-title'),
         ('Music Volume', 'music-title'),
     ], the_theme, 'foreground')
     #
     # Back link
     #
     back = serge.blocks.utils.addSpriteActorToWorld(
         world,
         'back',
         'back',
         'back',
         layer_name='ui',
         center_position=L('back-position'),
     )
     back.linkEvent(serge.events.E_LEFT_CLICK,
                    common.tweenBackWorlds('start-screen'))
     #
     # Volume control
     self.down = serge.blocks.utils.addSpriteActorToWorld(
         world,
         'btn',
         'vol-down',
         'vol-down',
         layer_name='ui',
         center_position=L('vol-down-position'))
     self.down.linkEvent(serge.events.E_LEFT_CLICK, self.changeVolume,
                         -L('vol-change-amount'))
     self.up = serge.blocks.utils.addSpriteActorToWorld(
         world,
         'btn',
         'vol-up',
         'vol-up',
         layer_name='ui',
         center_position=L('vol-up-position'))
     self.up.linkEvent(serge.events.E_LEFT_CLICK, self.changeVolume,
                       +L('vol-change-amount'))
     #
     self.volume = serge.blocks.utils.addActorToWorld(
         world,
         serge.blocks.actors.NumericText('text',
                                         'volume',
                                         '%d%%',
                                         L('volume-colour'),
                                         font=L('volume-font'),
                                         font_size=L('volume-size'),
                                         value=G('volume', 'start-screen') *
                                         100.0),
         layer_name='ui',
         center_position=L('vol-position'))
Exemple #34
0
 def addedToWorld(self, world):
     """The level screen was added to the world"""
     super(LevelScreen, self).addedToWorld(world)
     #
     # Logo
     the_theme = theme.getTheme('level-screen')
     L = the_theme.getProperty
     logo = serge.blocks.utils.addSpriteActorToWorld(
         world,
         'logo',
         'logo',
         'logo',
         'foreground',
         center_position=L('logo-position'))
     title = serge.blocks.utils.addSpriteActorToWorld(
         world,
         'logo',
         'title',
         'title',
         'foreground',
         center_position=L('title-position'))
     bg = serge.blocks.utils.addSpriteActorToWorld(
         world,
         'bg',
         'bg',
         'dark-background',
         layer_name='background',
         center_position=(G('screen-width') / 2, G('screen-height') / 2),
     )
     #
     # Find all the levels
     levels = common.levels.LEVEL_FILES[:-1]
     self.level_grid = serge.blocks.utils.addActorToWorld(
         world,
         serge.blocks.layout.MultiGrid('grid',
                                       'grid',
                                       size=L('grid-size'),
                                       width=L('grid-width'),
                                       height=L('grid-height')),
         center_position=L('grid-position'),
         layer_name='ui',
     )
     w, h = self.level_grid.getSize()
     for idx in range(1, len(levels) + 1):
         x, y = ((idx - 1) % w, (idx - 1) // w)
         tile = self.level_grid.addActor(
             (x, y),
             serge.actor.Actor('tile', 'tile-%s' % idx),
         )
         if self.options.test:
             tile.setSpriteName('general-board')
         else:
             tile.setSpriteName('level-%d' % idx)
         tile.linkEvent(serge.events.E_LEFT_CLICK, self.selectLevel, idx)
         title = self.level_grid.addActor(
             (x, y),
             serge.blocks.actors.StringText(
                 'title',
                 'title-%s' % idx,
                 common.levels.LEVELS[idx - 1][0],
                 colour=L('title-colour'),
                 font_name=L('title-font'),
                 font_size=int(
                     L('title-font-size') *
                     (0.5 if self.options.test else 1.0))),
         )
         title.y += L('title-offset-y')
     #
     # Random level button
     random_level = serge.blocks.utils.addSpriteActorToWorld(
         world,
         'random-level',
         'random-level',
         'random-level',
         layer_name='ui',
         center_position=L('random-level-position'),
         actor_class=serge.actor.MountableActor,
     )
     random_level.linkEvent(serge.events.E_LEFT_CLICK,
                            common.tweenWorlds('random-level-screen'))  #
     random_title = random_level.mountActor(
         serge.blocks.actors.StringText(
             'title',
             'title-random',
             'Random Generated Maze',
             colour=L('title-colour'),
             font_name=L('title-font'),
             font_size=int(
                 L('title-font-size') *
                 (0.5 if self.options.test else 1.0))),
         (0, L('title-offset-y')))
     random_title.setLayerName('ui')
     # Back button
     back = serge.blocks.utils.addSpriteActorToWorld(
         world,
         'back',
         'back',
         'back',
         layer_name='ui',
         center_position=L('back-position'),
     )
     back.linkEvent(serge.events.E_LEFT_CLICK,
                    common.tweenBackWorlds('start-screen'))
     #
     # Resume button
     self.resume = serge.blocks.utils.addSpriteActorToWorld(
         world,
         'resume',
         'resume',
         'resume',
         layer_name='ui',
         center_position=L('resume-position'),
     )
     self.resume.linkEvent(serge.events.E_LEFT_CLICK,
                           common.tweenWorlds('main-screen'))
     #
     # Events
     world.linkEvent(serge.events.E_ACTIVATE_WORLD, self.activatedWorld)
     world.linkEvent(serge.events.E_DEACTIVATE_WORLD, self.deactivatedWorld)