Hi, I’m a newbie to coding in general but thought id give it a go. I’m making a game to help a family member train their eyes as they have and problems with this before, by clicking a black dot on the screen then it moving to another random location to then locate and click again so on and so forth. I seem to be having an issue with the click detection on the rectangle to then move the rectangle any suggestions or help with my code I have so far? I have searched online and implemented different things but isn’t working.
import pygame import sys import os import random import time pygame.init() SCREENWIDTH = 500 SCREENHEIGHT = 500 WHITE = \[255, 255, 255\] SCREENSIZE = \[SCREENWIDTH, SCREENHEIGHT\] SCREEN = pygame.display.set\_mode(SCREENSIZE) pygame.display.set\_caption("EYE Game") SCREEN.fill(WHITE) LENGTH = 20 WIDTH = 20 LOOPCOUNT = 1 MINPOS = 0 MAXPOS = 480 BLACK = \[0, 0, 0\] for i in range(LOOPCOUNT): LEFT = random.randint(MINPOS,MAXPOS) TOP = random.randint(MINPOS,MAXPOS) rect1 = pygame.Rect(LEFT, TOP, LENGTH, WIDTH) pygame.draw.rect(SCREEN, BLACK, rect1, SOLID) pygame.display.update() while True: for events in pygame.event.get(): if events.type == pygame.QUIT: pygame.quit() sys.exit() if events.type == pygame.MOUSEBUTTONDOWN: