Mercurial > sypikslang
annotate gamelib/gui.py @ 41:e285b1e31a08
Add can_attempt method for future flexibility
author | Neil Muller <drnlmuller@gmail.com> |
---|---|
date | Mon, 07 May 2012 13:59:50 +0200 |
parents | d82d3e54a4ef |
children | 38f41d046c6f |
rev | line source |
---|---|
38 | 1 from pygame import image |
37 | 2 |
3 from gamelib import data | |
39
d82d3e54a4ef
fixed more pep8 issues
Rizmari Versfeld <rizziepit@gmail.com>
parents:
38
diff
changeset
|
4 from gamelib.gui_base import Drawable, TextButton |
37 | 5 |
6 | |
7 class ImageDrawable(Drawable): | |
38 | 8 |
9 def __init__(self, rect, image): | |
10 super(ImageDrawable, self).__init__(rect) | |
11 self.image = image | |
12 | |
13 def draw(self, surface): | |
14 surface.blit(self.image, (self.rect[0], self.rect[1])) | |
15 | |
37 | 16 |
38 | 17 class BigButton(TextButton): |
18 WIDTH = 128 | |
19 HEIGHT = 64 | |
20 BG_IMAGE_NORMAL = image.load(data.filepath('images/button_normal.png')) | |
21 BG_IMAGE_DOWN = image.load(data.filepath('images/button_down.png')) | |
22 | |
23 def __init__(self, pos, text): | |
24 rect1 = (0, 0, self.WIDTH, self.HEIGHT) | |
25 n = ImageDrawable(rect1, self.BG_IMAGE_NORMAL) | |
26 d = ImageDrawable(rect1, self.BG_IMAGE_DOWN) | |
27 rect2 = (pos[0], pos[1], self.WIDTH, self.HEIGHT) | |
28 super(BigButton, self).__init__(rect2, n, d, text) |