so i'm doing the states of my game right now :
import pygame
import sys
screen=pygame.display.set_mode((1200,700))
play_image=pygame.Surface((100,200))
play_image.fill('red')
play_rect=play_image.get_rect(topleft=(200,200))
retry_image=pygame.Surface((100,200))
retry_image.fill('red')
retry_rect=retry_image.get_rect(topleft=(200,200))
game_over=False
menustatus=True
while menustatus:
for event in pygame.event.get():
if event.type==pygame.QUIT:
pygame.quit()
pygame.font.quit()
sys.exit()
mouse_pos=pygame.mouse.get_pos()
mousecheck=pygame.mouse.get_pressed()
if play_rect.collidepoint(mouse_pos) and mousecheck[0]:
game_over=True
menustatus=False
screen.blit(play_image,play_rect)
pygame.display.update()
while game_over:
for event in pygame.event.get():
if event.type==pygame.QUIT:
pygame.quit()
pygame.font.quit()
sys.exit()
mouse_pos=pygame.mouse.get_pos()
mousecheck=pygame.mouse.get_pressed()
if retry_rect.collidepoint(mouse_pos) and mousecheck[0]:
menustatus=True
game_over=False
screen.blit(retry_image,retry_rect)
pygame.display.update()
problem is, when i click the red rectangle, which is a placeholder for my play button to head into the gameover screen, it crashes instead of showing me a game over screen