-
Notifications
You must be signed in to change notification settings - Fork 0
/
board.py
97 lines (80 loc) · 4.35 KB
/
board.py
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
import pygame
class Board():
def __init__(self,settings,screen):
self.screen = screen
self.screen_rect = self.screen.get_rect()
self.rect = pygame.Rect(0,0,settings.board_width,settings.board_height)
self.rect.center = self.screen_rect.center
self.rect_color = settings.board_color
self.text_color = settings.notice_color
self.font = settings.board_font
self.notice = ''
self.lining_1 = pygame.Rect(0,0,settings.yesorno_lining_width,
settings.yesorno_lining_height) #no_rect
self.lining_2 = pygame.Rect(0,0,settings.yesorno_lining_width,
settings.yesorno_lining_height) #yes_rect
self.yes_rect = pygame.Rect(0,0,settings.yesorno_width,
settings.yesorno_height)
self.no_rect = pygame.Rect(0,0,settings.yesorno_width,
settings.yesorno_height)
self.yes_text = 'Yes'
self.no_text = 'Cancel'
self.yes_color = settings.yesorno_color
self.no_color = settings.yesorno_color
self.yesorno_color = settings.yesorno_color
self.yesorno_colort = settings.yesorno_colort
self.yesorno_lining_color = settings.yesorno_lining_color
self.position(settings)
def position(self,settings):
'''arrange the position of the rects'''
self.lining_1.bottomright = self.rect.bottomright
self.lining_2.right = self.lining_1.left - settings.yesno_spacing
self.lining_2.bottom = self.rect.bottom
self.yes_rect.center = self.lining_2.center
self.no_rect.center = self.lining_1.center
def prep_text(self,msg):
self.msg_image = self.font.render(msg,True,self.text_color,
self.rect_color)
self.msg_image_rect = self.msg_image.get_rect()
self.msg_image_rect.center = self.rect.center
self.yes_image = self.font.render(self.yes_text,True,self.text_color,
self.yes_color)
self.yes_image_rect = self.yes_image.get_rect()
self.yes_image_rect.center = self.yes_rect.center
self.no_image = self.font.render(self.no_text,True,self.text_color,
self.no_color)
self.no_image_rect = self.no_image.get_rect()
self.no_image_rect.center = self.no_rect.center
def draw_board(self):
self.screen.fill(self.rect_color,self.rect)
self.screen.fill(self.yesorno_lining_color,self.lining_1)
self.screen.fill(self.yesorno_lining_color,self.lining_2)
self.screen.fill(self.yes_color,self.yes_rect)
self.screen.fill(self.no_color,self.no_rect)
self.screen.blit(self.msg_image,self.msg_image_rect)
self.screen.blit(self.yes_image,self.yes_image_rect)
self.screen.blit(self.no_image,self.no_image_rect)
def touched_yes(self):
self.yes_color = self.yesorno_colort
self.yes_image = self.font.render(self.yes_text,True,self.text_color,
self.yes_color)
self.yes_image_rect = self.yes_image.get_rect()
self.yes_image_rect.center = self.yes_rect.center
def normal_yes(self):
self.yes_color = self.yesorno_color
self.yes_image = self.font.render(self.yes_text,True,self.text_color,
self.yes_color)
self.yes_image_rect = self.yes_image.get_rect()
self.yes_image_rect.center = self.yes_rect.center
def touched_no(self):
self.no_color = self.yesorno_colort
self.no_image = self.font.render(self.no_text,True,self.text_color,
self.no_color)
self.no_image_rect = self.no_image.get_rect()
self.no_image_rect.center = self.no_rect.center
def normal_no(self):
self.no_color = self.yesorno_color
self.no_image = self.font.render(self.no_text,True,self.text_color,
self.no_color)
self.no_image_rect = self.no_image.get_rect()
self.no_image_rect.center = self.no_rect.center