forked from zhoulisha/Sudoku-Project
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcell.py
51 lines (43 loc) · 1.25 KB
/
cell.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
# Cell Class
import pygame
import board as Board
WHITE = (250, 250, 250)
BLACK = (0, 0, 0)
RED = (252, 3, 3)
GREY = (162, 162, 162)
WIDTH = 450
BOARD_LENGTH = 450
SCREEN_LENGTH = 525
THIN_WIDTH = 5
BOLD_WIDTH = 10
HIGHLIGHT_WIDTH = 3
SQUARE_SIZE = WIDTH / 9
class Cell:
def __init__(self, value, row, col, screen):
self.value = value
self.row = row
self.col = col
self.screen = screen
self.sketched_value = 0
def set_cell_value(self, value):
if value <= 9:
self.value = value
def set_sketched_value(self, value):
self.sketched_value = value
def sketch_num(self, row, col, screen):
if self.value == 0:
return
font = pygame.font.Font(None, 40)
cell_surf = font.render(str(self.value), 0, BLACK)
cell_rect = cell_surf.get_rect(center=(50 * (col) + 25, 50 * (row) + 25))
screen.blit(cell_surf, cell_rect)
# user inputed numbers
def sketch_sketched_num(self, row, col, screen):
if self.sketched_value == 0:
return
small_font = pygame.font.Font(None, 20)
cell_surf = small_font.render(str(self.sketched_value), 0, GREY)
cell_rect = cell_surf.get_rect(center=(50 * (col) + 12, 50 * (row) + 12))
screen.blit(cell_surf, cell_rect)
def __repr__(self):
return self.value