Mercurial > sypikslang
comparison gamelib/gui_base.py @ 243:05afa7ae5df3
Standardise image loading to use data.load_image
author | Neil Muller <drnlmuller@gmail.com> |
---|---|
date | Sun, 13 May 2012 00:38:48 +0200 |
parents | ce1e23ea46e5 |
children | 330a63dc176e |
comparison
equal
deleted
inserted
replaced
242:0bc8592ee28c | 243:05afa7ae5df3 |
---|---|
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 from pygame import image |
6 | 6 |
7 from gamelib import data | 7 from gamelib.data import filepath, load_image |
8 from gamelib.data import filepath | |
9 | 8 |
10 | 9 |
11 # different font sizes | 10 # different font sizes |
12 pygame.font.init() | 11 pygame.font.init() |
13 font_small = Font(data.filepath('fonts/DejaVuSans.ttf'), 10) | 12 font_small = Font(filepath('fonts/DejaVuSans.ttf'), 10) |
14 font_medium = Font(data.filepath('fonts/DejaVuSans.ttf'), 14) | 13 font_medium = Font(filepath('fonts/DejaVuSans.ttf'), 14) |
15 font_large = Font(data.filepath('fonts/DejaVuSans.ttf'), 18) | 14 font_large = Font(filepath('fonts/DejaVuSans.ttf'), 18) |
16 font_auto = None | 15 font_auto = None |
17 | 16 |
18 | 17 |
19 class Drawable(object): | 18 class Drawable(object): |
20 | 19 |
77 | 76 |
78 def __init__(self, screen): | 77 def __init__(self, screen): |
79 super(Window, self).__init__() | 78 super(Window, self).__init__() |
80 self.surface = Surface((screen.get_width(), screen.get_height())) | 79 self.surface = Surface((screen.get_width(), screen.get_height())) |
81 self.background_colour = None | 80 self.background_colour = None |
82 self.background_image = image.load( | 81 self.background_image = load_image('images/background.jpg') |
83 filepath('images/background.jpg')) | |
84 self.pressed_child = None | 82 self.pressed_child = None |
85 | 83 |
86 def on_mouse_down(self, pos): | 84 def on_mouse_down(self, pos): |
87 child = self.get_child_by_pos(pos) | 85 child = self.get_child_by_pos(pos) |
88 if isinstance(child, Clickable): | 86 if isinstance(child, Clickable): |