comparison gamelib/gui.py @ 38:7e18a67995f6

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