37
|
1 import os
|
|
2
|
|
3 import pygame
|
38
|
4 from pygame import image
|
37
|
5 from pygame.sprite import Sprite
|
|
6
|
|
7 from gamelib import data
|
|
8 from gamelib.gui_base import *
|
|
9
|
|
10
|
|
11 class ImageDrawable(Drawable):
|
38
|
12
|
|
13 def __init__(self, rect, image):
|
|
14 super(ImageDrawable, self).__init__(rect)
|
|
15 self.image = image
|
|
16
|
|
17 def draw(self, surface):
|
|
18 surface.blit(self.image, (self.rect[0], self.rect[1]))
|
|
19
|
37
|
20
|
38
|
21 class BigButton(TextButton):
|
|
22 WIDTH = 128
|
|
23 HEIGHT = 64
|
|
24 BG_IMAGE_NORMAL = image.load(data.filepath('images/button_normal.png'))
|
|
25 BG_IMAGE_DOWN = image.load(data.filepath('images/button_down.png'))
|
|
26
|
|
27 def __init__(self, pos, text):
|
|
28 rect1 = (0, 0, self.WIDTH, self.HEIGHT)
|
|
29 n = ImageDrawable(rect1, self.BG_IMAGE_NORMAL)
|
|
30 d = ImageDrawable(rect1, self.BG_IMAGE_DOWN)
|
|
31 rect2 = (pos[0], pos[1], self.WIDTH, self.HEIGHT)
|
|
32 super(BigButton, self).__init__(rect2, n, d, text)
|