comparison gamelib/gui_base.py @ 236:ce1e23ea46e5

added generic background for all windows
author Rizmari Versfeld <rizziepit@gmail.com>
date Sun, 13 May 2012 00:17:07 +0200
parents 16ce5ed563c9
children 05afa7ae5df3
comparison
equal deleted inserted replaced
235:212bfbb96055 236:ce1e23ea46e5
1 import pygame 1 import pygame
2 from pygame.locals import SRCALPHA 2 from pygame.locals import SRCALPHA
3 from pygame import Surface, Rect 3 from pygame import Surface, Rect
4 from pygame.font import Font 4 from pygame.font import Font
5 from pygame import image
5 6
6 from gamelib import data 7 from gamelib import data
8 from gamelib.data import filepath
7 9
8 10
9 # different font sizes 11 # different font sizes
10 pygame.font.init() 12 pygame.font.init()
11 font_small = Font(data.filepath('fonts/DejaVuSans.ttf'), 10) 13 font_small = Font(data.filepath('fonts/DejaVuSans.ttf'), 10)
75 77
76 def __init__(self, screen): 78 def __init__(self, screen):
77 super(Window, self).__init__() 79 super(Window, self).__init__()
78 self.surface = Surface((screen.get_width(), screen.get_height())) 80 self.surface = Surface((screen.get_width(), screen.get_height()))
79 self.background_colour = None 81 self.background_colour = None
80 self.background_image = None 82 self.background_image = image.load(
83 filepath('images/background.jpg'))
81 self.pressed_child = None 84 self.pressed_child = None
82 85
83 def on_mouse_down(self, pos): 86 def on_mouse_down(self, pos):
84 child = self.get_child_by_pos(pos) 87 child = self.get_child_by_pos(pos)
85 if isinstance(child, Clickable): 88 if isinstance(child, Clickable):