I'm making tic tac toe with python. If you click a specific square inside the game, an x image is supposed to be blitted onto the screen. I did this by using pygame.MOUSEBUTTONDOWN and specifying the coordinates. When I click on a square, the image gets blitted onto the screen. The problem is that when I click on another square, another x is blitted in this square but the x in the other square disappears. here's the code:
if event.type == pygame.MOUSEBUTTONDOWN and 250 < mouse_pos[0] < 300 and 250 > mouse_pos[1] > 199:
mouse_clicked1 = True
if event.type == pygame.MOUSEBUTTONDOWN and 301 < mouse_pos[0] < 351 and 249 > mouse_pos[1] > 201:
mouse_clicked2 = True
if event.type == pygame.MOUSEBUTTONDOWN and 399 > mouse_pos[0] > 351 and 250 > mouse_pos[1] > 199:
mouse_clicked3 = True
if event.type == pygame.MOUSEBUTTONDOWN and 251 < mouse_pos[0] < 301 and 310 > mouse_pos[1] > 252:
mouse_clicked4 = True
if event.type == pygame.MOUSEBUTTONDOWN and 303 < mouse_pos[0] < 351 and 310 > mouse_pos[1] > 252:
mouse_clicked5 = True
if event.type == pygame.MOUSEBUTTONDOWN and 353 < mouse_pos[0] < 400 and 312 > mouse_pos[1] > 250:
mouse_clicked6 = True
if event.type == pygame.MOUSEBUTTONDOWN and 251 < mouse_pos[0] < 300 and 372 > mouse_pos[1] > 314:
mouse_clicked7 = True
if event.type == pygame.MOUSEBUTTONDOWN and 302 < mouse_pos[0] < 350 and 372 > mouse_pos[1] > 313:
mouse_clicked8 = True
if event.type == pygame.MOUSEBUTTONDOWN and 352 < mouse_pos[0] < 399 and 369 > mouse_pos[1] > 310:
mouse_clicked9 = True
drawing = False
if mouse_clicked1:
screen.blit(x, object_top_left)
top_left = True
if mouse_clicked2:
screen.blit(x, object_top)
top = True
if mouse_clicked3:
screen.blit(x, object_top_right)
top_right = True
if mouse_clicked4:
screen.blit(x, object_left)
left = True
if mouse_clicked5:
screen.blit(x, object_middle)
middle = True
if mouse_clicked6:
screen.blit(x, object_right)
right = True
if mouse_clicked7:
screen.blit(x, object_bottom_left)
bottom_left = True
if mouse_clicked8:
screen.blit(x, object_bottom)
bottom = True
if mouse_clicked9:
screen.blit(x, object_bottom_right)
bottom_right = True