What i'm trying to do is draw a new screen when the user clicks 'start', 'controls' or quit. The first screen welcomes the user and asks them to 'click here to start the game', which is stated over a button. Even though the user advances to the next page, the previous button isn't visible but if you click where the button previously was, it still brings you to the next page even though I want the 'start' button to be that function. I currently have the next pages as screen.fill(RED) just to test the code.
#Main Menu Loop
while not done and display_menu:
for event in pygame.event.get():
if event.type == pygame.QUIT:
done = True
if event.type == pygame.MOUSEBUTTONDOWN:
if event.button == 1:
if rect4.collidepoint(event.pos):
start_page +1
if event.type == pygame.MOUSEBUTTONDOWN:
if event.button == 1:
if rect1.collidepoint(event.pos):
start_page +=1
if rect2.collidepoint(event.pos):
start_page +=2
if start_page == 4:
display_menu = False
# Set the screen background
screen.fill(BLACK)
if start_page == 1:
screen.blit(bg2, (0, 0))
pygame.draw.rect(screen, RED, rect4)
text = font3.render("Click HERE to start Game!", True, WHITE)
screen.blit(text, [125, 400])
if start_page == 2:
screen.blit(bg, (0, 0))
#Drawing the Button
pygame.draw.rect(screen, BLACK, rect1)
pygame.draw.rect(screen, BLACK, rect2)
pygame.draw.rect(screen, BLACK, rect3)
#Text in Button
text = font3.render("START", True, WHITE)
screen.blit(text, [335, 325])
text = font4.render("CONTROLS", True, WHITE)
screen.blit(text, [320, 425])
text = font3.render("QUIT", True, WHITE)
screen.blit(text, [335, 525])
if start_page == 3:
screen.fill(GREEN)
if start_page == 4:
screen.fill(RED)
clock.tick(60)
pygame.display.flip()
I'm open for any suggestions. Thanks