My game loop is getting stuck on the click detection function, it wont do anything but that after loading the images.
Edit: !!! Odd thing is, it works when a put 'print("")' in the gameloop with all the functions.!!!
import pygame
import time
import random
pygame.display.set_caption('Pizza Clicker')
RESOLUTION = (137, 78)
PIZZARE = (6, 15)
pygame.init()
from pygame.locals import*
window = pygame.display.set_mode (RESOLUTION, pygame.SCALED)
#Functions
def Quit():
global running
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
def Images(BackG, PizzaU):
window.fill((255,255,255))
backgrounds = []
backgrounds.append(pygame.image.load('ClickerBackground.png'))
pizzas = []
pizzas.append(pygame.image.load('0Pizza.png'))
pizzas.append(pygame.image.load('1Pizza.png'))
Images.P = pizzas[int(PizzaU)]
window.blit(backgrounds[BackG], (0, 0))
window.blit(Images.P,(PIZZARE))
pygame.display.update()
def ClickDetect():
pizzarect = Images.P.get_rect(center = (21, 30))
curpos = pygame.mouse.get_pos()
for event in pygame.event.get():
if event.type == pygame.MOUSEBUTTONDOWN:
if pizzarect.collidepoint(curpos):
print("Click.")
running = True
background = 0
pizzarect = 0
curpos = 0
while running:
Quit()
Images(0, 0)
ClickDetect()
pygame.quit()
Ive tried making a thing like
Z = 1
While Z == 1:
#Code Runs
Z -= 1
But that doesn't seem to work, i'm not sure what exactly it is stuck on in the function.
Thanks!