is
cannot be used to assign value, but merely check a value. When you type bullseye is True
it will return True if bullseye is true, and False if bullseye is not True. That's the logic behind an if statement. You write a statement like that and it returns true or false in which the if statement can then decide what to do from there. To assign a value you must use the "=" operator. Ex. bullseye_close = True
.If I may also add, as this grows, if you continue to use this method, it will only grow more difficult to manage. One way I like to simplify if statements is through dictionaries. This is just an example in pygame, but you should be able to see the concept that I'm showing.
keyToString = {pygame.K_l: "l", pygame.K_o: "o", pygame.K_e: "e", pygame.K_c: "c"} for event in pygame.event.get(): #Simply gets all the events (For example a key being pressed) if event == pygame.QUIT: #If a player exits the game sys.exit() if event in keyToString: print("The letter %s was pressed" %keyToString[event])Now imagine if I had 26 different letters and only using if statements vs this method, see how much more efficient it is? Hopefully this helps.