I'm making submarine game in pygame, but text in menu doesn't want to change color when I cover it with mouse. I tried to refresh display at that part, and changing where if sentences are, but nothing seemed to help. There wasn't any syntax errors. Here's the code:
import pygame
pygame.init()
screen = pygame.display.set_mode((600, 500), pygame.FULLSCREEN)
pygame.display.set_caption('Podmornca')
run = True
black = (0,0,0)
red = (255,0,0)
colour1 = black
colour2 = black
colour3 = black
location = pygame.mouse.get_pos()
background = pygame.image.load('meni.png')
clock = pygame.time.Clock()
font = pygame.font.SysFont('bauhaus93', 20)
text1 = font.render('SINGLE PLAYER', 1, barva1)
text2 = font.render('MULTIPLAYER', 1, barva2)
text3 = font.render('QUIT', 1, barva3)
pygame.display.update()
def grafika():
clock.tick(60)
screen.blit(background, (0,0))
screen.blit(text1, (100, 200))
screen.blit(text2, (100, 250))
screen.blit(text3, (100, 300))
pygame.display.update()
while run:
for event in pygame.event.get():
if event.type == pygame.QUIT:
run = False
if location == (100, 200):
colour1 = red
if polozaj == (100, 250):
colour2 = red
if location == (100, 300):
colour3 = red
grafika()
pygame.quit()
Can anyone tell me, where I messed up and how to fix it?