I am on the final part of a massive project for school. I am creating a game of simon, where you must memorize colours and click them in the proper order.
After my animations for the squares flash, I have 'usergottaclick' set to true.
if other == True:
#And if event = Mousebuttondown
if usergottaclick == False:
if mousex >= 50 and mousex <= 150 and mousey >= 110 and mousey <= 160:
randomnum = random.randint(1,4)
addtosimons()
for i in range (0, roundnum):
if simonslist[i] == 1:
#Flashes red square
if simonslist[i] == 2:
#Flashes blue square
if simonslist[i] == 3:
#Flashes green square
if simonslist[i] == 4:
#Flashes yellow square
addroundnum()
usergottaclick = True
This is my code for when it is the users turn to click the squares:
def usersturn():
#This code is under if event = pygame.MOUSEBUTTONDOWN
global usergottaclick
if usergottaclick == True:
playerchoicelist = []
for i in range (0, roundnum -1 ):
if mousex >=200 and mousex <= 600 and mousey >= 0 and mousey <= 375:
clicknum = 1
playerchoicelist.append(clicknum)
pygame.draw.rect(screen, REDLIGHT, [200, 0, 400, 375])
pygame.display.update()
pygame.time.delay(500)
if playerchoicelist[i] != simonslist[i]:
print("Wrong")
changeusergottaclick()
subtractroundnum()
if mousex >=600 and mousex <= 1000 and mousey >= 0 and mousey <= 375:
clicknum = 2
playerchoicelist.append(clicknum)
pygame.draw.rect(screen, BLUELIGHT, [600, 0, 400, 375])
pygame.display.update()
pygame.time.delay(500)
if playerchoicelist[i] != simonslist[i]:
print("Wrong")
changeusergottaclick()
subtractroundnum()
if mousex >=200 and mousex <= 600 and mousey >= 375 and mousey <= 750:
clicknum = 3
playerchoicelist.append(clicknum)
pygame.draw.rect(screen, GREENLIGHT, [200, 375, 400, 375])
pygame.display.update()
pygame.time.delay(500)
if playerchoicelist[i] != simonslist[i]:
print("Wrong")
changeusergottaclick()
subtractroundnum()
if mousex >=600 and mousex <= 1000 and mousey >= 375 and mousey <= 750:
clicknum = 4
playerchoicelist.append(clicknum)
pygame.draw.rect(screen, YELLOWLIGHT, [600, 375, 400, 375])
pygame.display.update()
pygame.time.delay(500)
if playerchoicelist[i] != simonslist[i]:
print("Wrong")
changeusergottaclick()
subtractroundnum()
else:
changeusergottaclick()
What you need to focus on is the fact that the square the user clicks is added on to playerchoicelist.
But when I run this, it is acting as if event is always pygame.mousebuttondown , and just clicks the square as many times as the loop allows it to (as many times as roundnum is set to).
How do i get it so that they can only click one square at a time, then have to click again to click another?
Thank you so much to whoever helps, this is for my mark.