changeset 365:a43f571e8f5b

Dim cutscene background
author Stefano Rivera <stefano@rivera.za.net>
date Sat, 09 Apr 2011 14:39:18 +0200
parents 14142aee4c03
children 249ba3bd6904
files skaapsteker/cutscene.py
diffstat 1 files changed, 13 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/skaapsteker/cutscene.py	Sat Apr 09 14:30:36 2011 +0200
+++ b/skaapsteker/cutscene.py	Sat Apr 09 14:39:18 2011 +0200
@@ -2,8 +2,9 @@
 from __future__ import division
 
 import pygame
-from pygame.locals import K_ESCAPE, K_q, KEYDOWN
+from pygame.locals import K_ESCAPE, K_q, KEYDOWN, SRCALPHA
 
+from . import constants
 from . import data
 from .engine import ChangeScene, Scene
 from .widgets.text import Text, ButtonSet, TextButton, unindent_text
@@ -12,18 +13,27 @@
     def __init__(self, game_state, soundsystem, text, background, music=None):
         super(CutScene, self).__init__(game_state, soundsystem)
         self.background = data.load_image('backgrounds/' + background)
+        fill = pygame.Surface(self.background.get_size(), flags=SRCALPHA)
+        fill.fill((255, 255, 255, 128))
+        self.background.convert_alpha(fill)
+        self.background.blit(fill, (0, 0))
+        self.background.convert_alpha()
         self.start_time = pygame.time.get_ticks()
         self.run_time = 60000 # ms
 
         self._background_music = None
         self._background_music = music
 
-        text_widget = Text(text, pygame.Rect(20, 20, 800-40, 600-40),
+        text_widget = Text(text, pygame.Rect(20, 20,
+                                             constants.SCREEN[0] - 40,
+                                             constants.SCREEN[1] - 40),
                            size=24, shadow='gray', wrap=True)
         self.widgets.append(text_widget)
 
         button_set = ButtonSet()
-        button_set.append(TextButton("Continue", (300, 500), size=24, color='yellow'))
+        # TODO: Dynamic position
+        button_set.append(TextButton("Continue", (20, constants.SCREEN[1] - 68),
+                                     size=24, color='red'))
         button_set.callbacks.append(self.done)
         self.widgets.append(button_set)