Mercurial > skaapsteker
comparison skaapsteker/cutscene.py @ 365:a43f571e8f5b
Dim cutscene background
author | Stefano Rivera <stefano@rivera.za.net> |
---|---|
date | Sat, 09 Apr 2011 14:39:18 +0200 |
parents | 62b98bea56bf |
children | 8631e38afc24 |
comparison
equal
deleted
inserted
replaced
364:14142aee4c03 | 365:a43f571e8f5b |
---|---|
1 # -*- coding: utf-8 -*- | 1 # -*- coding: utf-8 -*- |
2 from __future__ import division | 2 from __future__ import division |
3 | 3 |
4 import pygame | 4 import pygame |
5 from pygame.locals import K_ESCAPE, K_q, KEYDOWN | 5 from pygame.locals import K_ESCAPE, K_q, KEYDOWN, SRCALPHA |
6 | 6 |
7 from . import constants | |
7 from . import data | 8 from . import data |
8 from .engine import ChangeScene, Scene | 9 from .engine import ChangeScene, Scene |
9 from .widgets.text import Text, ButtonSet, TextButton, unindent_text | 10 from .widgets.text import Text, ButtonSet, TextButton, unindent_text |
10 | 11 |
11 class CutScene(Scene): | 12 class CutScene(Scene): |
12 def __init__(self, game_state, soundsystem, text, background, music=None): | 13 def __init__(self, game_state, soundsystem, text, background, music=None): |
13 super(CutScene, self).__init__(game_state, soundsystem) | 14 super(CutScene, self).__init__(game_state, soundsystem) |
14 self.background = data.load_image('backgrounds/' + background) | 15 self.background = data.load_image('backgrounds/' + background) |
16 fill = pygame.Surface(self.background.get_size(), flags=SRCALPHA) | |
17 fill.fill((255, 255, 255, 128)) | |
18 self.background.convert_alpha(fill) | |
19 self.background.blit(fill, (0, 0)) | |
20 self.background.convert_alpha() | |
15 self.start_time = pygame.time.get_ticks() | 21 self.start_time = pygame.time.get_ticks() |
16 self.run_time = 60000 # ms | 22 self.run_time = 60000 # ms |
17 | 23 |
18 self._background_music = None | 24 self._background_music = None |
19 self._background_music = music | 25 self._background_music = music |
20 | 26 |
21 text_widget = Text(text, pygame.Rect(20, 20, 800-40, 600-40), | 27 text_widget = Text(text, pygame.Rect(20, 20, |
28 constants.SCREEN[0] - 40, | |
29 constants.SCREEN[1] - 40), | |
22 size=24, shadow='gray', wrap=True) | 30 size=24, shadow='gray', wrap=True) |
23 self.widgets.append(text_widget) | 31 self.widgets.append(text_widget) |
24 | 32 |
25 button_set = ButtonSet() | 33 button_set = ButtonSet() |
26 button_set.append(TextButton("Continue", (300, 500), size=24, color='yellow')) | 34 # TODO: Dynamic position |
35 button_set.append(TextButton("Continue", (20, constants.SCREEN[1] - 68), | |
36 size=24, color='red')) | |
27 button_set.callbacks.append(self.done) | 37 button_set.callbacks.append(self.done) |
28 self.widgets.append(button_set) | 38 self.widgets.append(button_set) |
29 | 39 |
30 def done(self, selected=None, data=None): | 40 def done(self, selected=None, data=None): |
31 # Avoid circular import... | 41 # Avoid circular import... |