vendredi 30 mars 2018

Python "if" statement. Ignore specific input if certain criteria is already met

I need to add a line to this so that if octave == 1 and pygame.K_s is pressed it will ignore the input. Currently it crashes because it's expecting a > 0 value or something like that. I've tried adding if octave == 1 & even.key == pygame.k_s: octave +=1 and it does keep it from crashing, but then I can no longer go back to octave 1 once I pass it. Here's the portion of the code I'm having issues with.

        if event.key == pygame.K_a: octave += 1
        if event.key == pygame.K_s: octave -= 1
        if event.key == pygame.K_q: scale += 0.005
        if event.key == pygame.K_w: scale -= 0.005
        if event.key == pygame.K_SPACE:
            if mode == 1: mode = 2
            elif mode == 2: mode = 3
            elif mode == 3: mode = 1

Aucun commentaire:

Enregistrer un commentaire