Changeset 647:aeb366d97774


Ignore:
Timestamp:
09/08/13 00:02:09 (8 years ago)
Author:
Stefano Rivera <stefano@…>
Branch:
default
Phase:
public
Amend:
32373764393833386438663536333765363938623938646366313930383661646535333834313632
Message:

Show splash image on startup

Location:
nagslang
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • nagslang/engine.py

    r505 r647  
    3838        pygame.event.post(pygame.event.Event(pgl.VIDEORESIZE,
    3939                                             size=(0, 0), w=0, h=0))
     40        self._current_screen.splash()
    4041
    4142    def change_screen(self, new_screen):
  • nagslang/game_object.py

    r628 r647  
    318318    def update(self, dt):
    319319        super(EphemeralNote, self).update(dt)
     320        if not self.check_timer('timeout'):
     321            return Result(remove=[self])
     322
     323
     324class SplashImage(GameObject):
     325    def __init__(self, image, timeout):
     326        super(SplashImage, self).__init__(
     327            None,
     328            render.NullRenderer(),
     329            puzzle.YesPuzzler(),
     330            render.ImageOverlay(image),
     331        )
     332        self.add_timer('timeout', timeout)
     333        self.start_timer('timeout')
     334
     335    def update(self, dt):
     336        super(SplashImage, self).update(dt)
    320337        if not self.check_timer('timeout'):
    321338            return Result(remove=[self])
  • nagslang/render.py

    r609 r647  
    243243
    244244
     245class ImageOverlay(Overlay):
     246    def __init__(self, image):
     247        self.image = image
     248
     249    def render(self, surface, display_offset, max_width):
     250        x = (surface.get_width() - self.image.get_width()) / 2
     251        y = (surface.get_height() - self.image.get_height()) / 2
     252        surface.blit(self.image, (x, y))
     253
     254
    245255class TiledRenderer(Renderer):
    246256    """Tile the given image to fit the given outline
  • nagslang/screens/area.py

    r634 r647  
    1414from nagslang.events import (
    1515    AddDrawableEvent, DeathEvent, DoorEvent, QuitEvent, ScreenChange)
     16from nagslang.game_object import SplashImage
    1617from nagslang.level import Level
    1718from nagslang.screens.base import Screen
     
    326327        x_pos = 130 + padding
    327328        surface.blit(inv_surf, (x_pos, y_pos))
     329
     330    def splash(self):
     331        AddDrawableEvent.post(SplashImage(resources.get_image('title.png'),
     332                              10))
Note: See TracChangeset for help on using the changeset viewer.