-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathButtons.py
More file actions
32 lines (27 loc) · 1.11 KB
/
Buttons.py
File metadata and controls
32 lines (27 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import pygame.gfxdraw
BLACK = (0, 0, 0)
WHITE = (255, 255, 255)
class AddUnitButton:
def __init__(self, screen, x, y):
self.surf_ = pygame.Surface((35, 35))
self.colour_ = BLACK
self.is_pressed_ = False
self.place_ = (x, y)
self.click_zone_ = (x + 15, y + 15)
self.screen_ = screen
self.target_ = self.surf_.get_rect(centerx=self.click_zone_[0], centery=self.click_zone_[1])
def draw_button(self):
self.screen_.blit(self.surf_, self.place_)
plus_pic = pygame.font.SysFont('arial', 50).render(str("+"), False, WHITE, None)
self.screen_.blit(plus_pic, (self.place_[0] + 3, self.place_[1] - 12))
class AddUnitStringButton:
def __init__(self, screen, x, y):
self.colour_ = BLACK
self.is_active_ = False
self.place_ = (x, y)
self.click_zone_ = (x + 15, y + 15)
self.screen_ = screen
self.surf_ = pygame.Surface((150, 35))
self.target_ = self.surf_.get_rect(centerx=self.click_zone_[0], centery=self.click_zone_[1])
def draw_button(self):
self.screen_.blit(self.surf_, self.place_)