Mercurial > sypikslang
comparison gamelib/gui.py @ 37:9c4bf1f15431
gui stuff
author | Rizmari Versfeld <rizziepit@gmail.com> |
---|---|
date | Sun, 06 May 2012 22:05:40 +0200 |
parents | |
children | 7e18a67995f6 |
comparison
equal
deleted
inserted
replaced
35:2754c453b39b | 37:9c4bf1f15431 |
---|---|
1 import os | |
2 | |
3 import pygame | |
4 from pygame.sprite import Sprite | |
5 | |
6 from gamelib import data | |
7 from gamelib.gui_base import * | |
8 | |
9 | |
10 class ImageDrawable(Drawable): | |
11 | |
12 def __init__(self, rect, image): | |
13 super(ImageDrawable, self).__init__(rect) | |
14 self.image = image | |
15 | |
16 def draw(self, surface): | |
17 surface.blit(self.image, (self.rect[0], self.rect[1])) | |
18 | |
19 | |
20 class MainMenuButton(TextButton): | |
21 WIDTH = 128 | |
22 HEIGHT = 64 | |
23 BACKGROUND_IMAGE_NORMAL = pygame.image.load(data.filepath('images/button_normal.png')) | |
24 BACKGROUND_IMAGE_DOWN = pygame.image.load(data.filepath('images/button_down.png')) | |
25 | |
26 def __init__(self, pos, text): | |
27 rect = (0, 0, self.WIDTH, self.HEIGHT) | |
28 drawable_normal = ImageDrawable(rect, self.BACKGROUND_IMAGE_NORMAL) | |
29 drawable_down = ImageDrawable(rect, self.BACKGROUND_IMAGE_DOWN) | |
30 super(MainMenuButton, self).__init__((pos[0],pos[1], self.WIDTH, self.HEIGHT), drawable_normal, drawable_down, text) | |
31 |