4444file .close ()
4545high_score = init_high
4646
47+
4748# draw game over and restart text
4849def draw_over ():
4950 pygame .draw .rect (screen , "black" , [50 , 50 , 300 , 100 ], 0 , 10 )
@@ -76,12 +77,18 @@ def draw_pieces(board):
7677 color = colors [value ]
7778 else :
7879 color = color ["other" ]
79- pygame .draw .rect (screen , color , [j * 95 + 20 , i * 95 + 20 , 75 , 75 ], 0 , 5 )
80+ pygame .draw .rect (
81+ screen , color , [j * 95 + 20 , i * 95 + 20 , 75 , 75 ], 0 , 5
82+ )
8083 if value > 0 :
8184 value_len = len (str (value ))
82- font = pygame .font .Font ("freesansbold.ttf" , 48 - (5 * value_len ))
85+ font = pygame .font .Font (
86+ "freesansbold.ttf" , 48 - (5 * value_len )
87+ )
8388 value_text = font .render (str (value ), True , value_color )
84- text_rect = value_text .get_rect (center = (j * 95 + 57 , i * 95 + 57 ))
89+ text_rect = value_text .get_rect (
90+ center = (j * 95 + 57 , i * 95 + 57 )
91+ )
8592 screen .blit (value_text , text_rect )
8693 pygame .draw .rect (
8794 screen , "black" , [j * 95 + 20 , i * 95 + 20 , 75 , 75 ], 2 , 5
@@ -93,7 +100,8 @@ def draw_pieces(board):
93100def is_game_over (board ):
94101 for i in range (3 ):
95102 for j in range (3 ):
96- if board [i ][j ] == board [i + 1 ][j ] or board [i ][j ] == board [i ][j + 1 ]:
103+ if (board [i ][j ] == board [i + 1 ][j ] or
104+ board [i ][j ] == board [i ][j + 1 ]):
97105 return False
98106
99107 for j in range (3 ):
@@ -103,7 +111,7 @@ def is_game_over(board):
103111 for i in range (3 ):
104112 if board [i ][3 ] == board [i + 1 ][3 ]:
105113 return False
106- ## if there's no valid move left, the game is over
114+ # if there's no valid move left, the game is over
107115 return True
108116
109117
0 commit comments