【发布时间】:2019-03-07 11:03:01
【问题描述】:
我正在尝试创建井字游戏。
函数“board_print”显示游戏板,但由于某种原因,我无法单击右上角的“退出”按钮或单击板上的任何位置...为什么?
pygame.init()
LEFT = 1
SCROLL = 2
RIGHT = 3
backgrouמd = [255, 174, 201]
black = (0,0,0)
line_color = (0, 0, 255)
w = 800
h = 800
X_img = r'C:\Users\aviro\Desktop\coollogo_com-20139270.png'
O_img = r'C:\Users\aviro\Desktop\coollogo_com-1453599.png'
o_pose_list = []
x_pose_list = []
finish = False
size = (w, h)
screen = pygame.display.set_mode(size)
game_end_count = 0
slash = 0
backslash = 0
row0 = 0
row1 = 0
row2 = 0
line0 = 0
line1 = 0
line2 = 0
board = ([[' ', ' ', ' '], [' ', ' ', ' '], [' ', ' ', ' ']])
ans_list = []
x_key = ('0', '1', '2')
user_ans = ""
o_image = pygame.image.load(O_img).convert_alpha()
x_image = pygame.image.load(X_img)
x_turn = False
# game engine
while game_end_count <= 9 or not finish:
for pose in x_pose_list:
screen.blit(x_image, pose)
for pose in o_pose_list:
screen.blit(o_image, pose)
board_print()
x_turn = not x_turn
for event in pygame.event.get():
if event.type == pygame.QUIT:
finish = True
elif x_turn:
while True:
if event.type == pygame.MOUSEBUTTONDOWN:
if event.button == LEFT:
x_pose_list.append(pygame.mouse.get_pos())
break
elif not x_turn:
while True:
if event.type == pygame.MOUSEBUTTONDOWN:
if event.button == LEFT:
o_pose_list.append(pygame.mouse.get_pos())
break
【问题讨论】:
-
很久以前就解决了