Mercurial > sypikslang
diff 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 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gamelib/gui.py Sun May 06 22:05:40 2012 +0200 @@ -0,0 +1,31 @@ +import os + +import pygame +from pygame.sprite import Sprite + +from gamelib import data +from gamelib.gui_base import * + + +class ImageDrawable(Drawable): + + def __init__(self, rect, image): + super(ImageDrawable, self).__init__(rect) + self.image = image + + def draw(self, surface): + surface.blit(self.image, (self.rect[0], self.rect[1])) + + +class MainMenuButton(TextButton): + WIDTH = 128 + HEIGHT = 64 + BACKGROUND_IMAGE_NORMAL = pygame.image.load(data.filepath('images/button_normal.png')) + BACKGROUND_IMAGE_DOWN = pygame.image.load(data.filepath('images/button_down.png')) + + def __init__(self, pos, text): + rect = (0, 0, self.WIDTH, self.HEIGHT) + drawable_normal = ImageDrawable(rect, self.BACKGROUND_IMAGE_NORMAL) + drawable_down = ImageDrawable(rect, self.BACKGROUND_IMAGE_DOWN) + super(MainMenuButton, self).__init__((pos[0],pos[1], self.WIDTH, self.HEIGHT), drawable_normal, drawable_down, text) + \ No newline at end of file