0

im creating code for a covid simulator but am a little stuck on the menu.

So far my code for the menu is as followed:

import pygame
pygame.init()

font_title = pygame.font.SysFont("arial", 35)
font_para = pygame.font.SysFont("monospace", 15)

BLACK = (0, 0, 0)
WHITE = (255,255, 255)
RED = (255, 0, 0)
GREEN = (0, 255, 0)
BLUE = (0, 0, 255)

menu = pygame.display.set_mode((999, 800))
pygame.display.set_caption('WELCOME TO COVID-19 SIMULATOR')

clock = pygame.time.Clock()

def Label(screen, text, size, font, color, x, y):
    label = font.render(text, size, color)
    screen.blit(label, (x, y))

Flag = True
def Menu():
    while Flag == True:
        title = Label(menu, "COVID-19 SIMULATOR: Main Menu", 1, font_title, WHITE, 275, 150)

        own_sim = pygame.Rect(350, 290, 290, 40)
        saved_sim = pygame.Rect(350, 390, 290, 40)
        referrences = pygame.Rect(350, 490, 290, 40)

        x_mouse, y_mouse = pygame.mouse.get_pos()
        if own_sim.collidepoint((x_mouse, y_mouse)):
            if click:
                own_sim()
        if saved_sim.colllidepoint((x_mouse, y_mouse)):
            if click:
                saved_sim()
        if referrences.collidepoint((x_mouse, y_mouse)):
            if click:
                referrences()
        
        pygame.draw.rect(menu, RED, own_sim)
        pygame.draw.rect(menu, RED, saved_sim)
        pygame.draw.rect(menu, RED, referrences)

        pygame.display.flip()
        clock.tick(60)

Menu()

I need my red boxes to have have text on, which i cant manage to do, and when they are clicked i want them to call another subprogram. I would be very grateful for any help, thanks in advance.

1 Answers1

0

There is a typo in your code. collidepoint is written with ll, not with lll:

if saved_sim.colllidepoint((x_mouse, y_mouse)):

if saved_sim.collidepoint((x_mouse, y_mouse)):
Rabbid76
  • 202,892
  • 27
  • 131
  • 174