1
- # -*- coding: utf-8 -*-
2
- """
3
- Created on Sat Apr 10 19:44:45 2021
4
1
5
- @author: Lakhan Kumawat
6
- """
7
2
8
3
# -*- coding: utf-8 -*-
9
4
"""
14
9
import pygame , sys
15
10
from pygame .locals import *
16
11
import numpy as np
17
- #import WorkingModal as Wp
12
+
18
13
#------
19
14
#constants
20
15
#-------
@@ -186,6 +181,13 @@ def restart():
186
181
if event .type == pygame .QUIT : #if user clicks exit pygame.QUIT and sys exits
187
182
pygame .quit ()
188
183
sys .exit ()
184
+
185
+ board_full = is_board_full ()
186
+ if board_full and not game_over :
187
+ Won = font .render (" It's a Tie " , True ,blue ,green )
188
+ screen .blit (Won , winRect )
189
+ screen .blit (text , textRect )
190
+ screen .blit (leave ,leaveRect )
189
191
190
192
if event .type == pygame .MOUSEBUTTONDOWN and not game_over :
191
193
mouseX = event .pos [0 ] #x
@@ -199,25 +201,21 @@ def restart():
199
201
mark_square (clicked_row ,clicked_column , player )
200
202
if (check_win (player )):
201
203
game_over = True
202
- Won = font .render ("Player" + str (player )+ " Won" , True ,blue ,green )
204
+ Won = font .render ("Player" + str (player )+ " Won" , True ,blue ,green )
203
205
screen .blit (Won , winRect )
204
206
screen .blit (text , textRect )
205
207
screen .blit (leave ,leaveRect )
206
208
player = player % 2 + 1
207
- if not game_over :
208
- Won = font .render ("Player" + str (player )+ " Turn" , True ,blue ,green )
209
+ if not game_over and not board_full :
210
+ Won = font .render ("Player" + str (player )+ " Turn" , True ,blue ,green )
209
211
screen .blit (Won , winRect )
210
212
draw_figures ()
211
213
212
- """
213
- if is_board_full():
214
- Won= font.render(" It's a Tie ", True ,blue,green)
215
- screen.blit(Won, winRect)
216
- screen.blit(text, textRect)
217
- screen.blit(leave,leaveRect)
218
- """
219
-
220
-
214
+
215
+
216
+
217
+
218
+
221
219
222
220
#to restart the game
223
221
if event .type == pygame .KEYDOWN :
0 commit comments