Dec-23-2018, 04:29 PM
(This post was last modified: Dec-23-2018, 04:29 PM by Prof_Jar_Jar.)
Hey there!
I don't get this:
I have a code that goes like this (simplified, but essentially that):
But when I run that and I click on the wrong button in the game, it prints WC as running down to 0, but then restores it to 3 and drops out of the loop, the second time it hits 0, but without printing 'Fail'.
So it basically says in the print line "WC is O" and the next line "if WC == 0" doesnt get activated.
I am so confused and would be very thankful for any help!
----------------------------------------------------------------
Update: When I just run this:
it works, but when I run this:
the problem I described above occurs
Maybe that's helping? For me it's just confusing...
I don't get this:
I have a code that goes like this (simplified, but essentially that):
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
def q(): loop = True CC = 0 WC = 3 while loop = = True : for event in pygame.event.get(): if event. type = = pygame.MOUSEBUTTONUP: mposx,mposy = pygame.mouse.get_pos() if 200 < mposx < 300 and 150 < mposy < 200 : print ( 'Correct' ) CC = CC + 1 if 400 < mposx < 500 and 150 < mposy < 200 : print ( 'Wrong' ) WC = WC - 1 print (CC) print (WC) if CC = = 10 : loop = False check = True return check print ( 'Win' ) if WC = = 0 : loop = False check = False return check print ( 'Fail' ) pygame.display.update() clock.tick( 30 ) |
So it basically says in the print line "WC is O" and the next line "if WC == 0" doesnt get activated.
I am so confused and would be very thankful for any help!
----------------------------------------------------------------
Update: When I just run this:
1 2 |
q() print ( 'End' ) |
1 2 3 4 |
q() check = q() print (check) print ( 'End' ) |
Maybe that's helping? For me it's just confusing...