Changeset 492:b02d51e06c17


Ignore:
Timestamp:
04/09/11 20:37:59 (12 years ago)
Author:
Stefano Rivera <stefano@…>
Branch:
default
Phase:
public
Rebase:
34323435343266666162636339336232323130336237366437316232643431323065663562376165
Message:

Add Victory CutScene (and refactor CutScenes)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • skaapsteker/cutscene.py

    r479 r492  
    1111from .widgets.text import Text, ButtonSet, TextButton, unindent_text
    1212
     13
    1314class CutScene(Scene):
    1415    def __init__(self, game_state, soundsystem):
    1516        super(CutScene, self).__init__(game_state, soundsystem)
    16         self._background_img = data.load_image('backgrounds/' + self.background)
    17         fill = pygame.Surface(self._background_img.get_size(), flags=SRCALPHA)
    18         fill.fill((255, 255, 255, 128))
    19         self._background_img.convert_alpha(fill)
    20         self._background_img.blit(fill, (0, 0))
    21         self._background_img.convert_alpha()
    22         self._start_time = pygame.time.get_ticks()
    23         self._run_time = 60000 # ms
    24 
    2517        self._background_music = self.music
    26 
    27         text_widget = Text(unindent_text(self.text),
    28                            pygame.Rect(20, 20,
    29                                        constants.SCREEN[0] - 40,
    30                                        constants.SCREEN[1] - 40),
    31                            size=24, shadow='gray', wrap=True)
    32         self.widgets.append(text_widget)
    3318
    3419        button_set = ButtonSet()
     
    4328        from .menuscene import MenuScene
    4429        ChangeScene.post((MenuScene,))
     30
     31    def dispatch(self, ev):
     32        if ev.type is KEYDOWN:
     33            if ev.key in(K_q, K_ESCAPE):
     34                self.done()
     35        super(CutScene, self).dispatch(ev)
     36
     37    def enter(self):
     38        if self._background_music:
     39            self._soundsystem.play_background_music(self._background_music)
     40
     41
     42class TextCutScene(CutScene):
     43    def __init__(self, game_state, soundsystem):
     44        super(TextCutScene, self).__init__(game_state, soundsystem)
     45        self._background_img = data.load_image('backgrounds/' + self.background)
     46        fill = pygame.Surface(self._background_img.get_size(), flags=SRCALPHA)
     47        fill.fill((255, 255, 255, 128))
     48        self._background_img.convert_alpha(fill)
     49        self._background_img.blit(fill, (0, 0))
     50        self._background_img.convert_alpha()
     51        self._start_time = pygame.time.get_ticks()
     52        self._run_time = 60000 # ms
     53
     54        text_widget = Text(unindent_text(self.text),
     55                           pygame.Rect(20, 20,
     56                                       constants.SCREEN[0] - 40,
     57                                       constants.SCREEN[1] - 40),
     58                           size=24, shadow='gray', wrap=True)
     59        self.widgets.append(text_widget)
    4560
    4661    def draw(self, surface, engine):
     
    5772                     pygame.Rect((pos, bottom), viewport.size))
    5873
    59         super(CutScene, self).draw(surface, engine)
    60 
    61     def dispatch(self, ev):
    62         if ev.type is KEYDOWN:
    63             if ev.key in(K_q, K_ESCAPE):
    64                 self.done()
    65         super(CutScene, self).dispatch(ev)
    66 
    67     def enter(self):
    68         if self._background_music:
    69             self._soundsystem.play_background_music(self._background_music)
     74        super(TextCutScene, self).draw(surface, engine)
    7075
    7176
    72 class OpeningCutScene(CutScene):
     77class OpeningCutScene(TextCutScene):
    7378    text = u"""
    7479    Many moons ago, an evil nine-tailed kitsune, a fearsome fox god, ruled the
     
    95100
    96101
    97 class UsageCutScene(CutScene):
     102class UsageCutScene(TextCutScene):
    98103    text = u"""
    99104    Arrow keys control your movement.
     
    107112
    108113
    109 class CreditsCutScene(CutScene):
     114class CreditsCutScene(TextCutScene):
    110115    text = u"""
    111116    Credits:
     
    136141    background = 'background_03_back.png'
    137142    music = None
     143
     144
     145class VictoryCutScene(CutScene):
     146    music = None
     147
     148    def __init__(self, game_state, soundsystem):
     149        super(VictoryCutScene, self).__init__(game_state, soundsystem)
     150        self._background_img = data.load_image('backgrounds/victory-menu.png')
     151
     152    def draw(self, surface, engine):
     153        surface.blit(self._background_img, (0, 0))
     154        super(VictoryCutScene, self).draw(surface, engine)
Note: See TracChangeset for help on using the changeset viewer.