Basically I'm making a game with a title screen that changes, having a random .PNG in a range of 1-4, I'm using randrange to find which image it'll use, and then running if statements on specific images, as two of them allow for a character to stand there. Except, when running said if statements, it's doing this for all of the images, instead of just one. I printed the value that's randomly picked inside the if statement and get 2 (1 and 4 are the values that are accepted by the if statement). Here's the code:
BGKEY = random.randrange(1,4)
BGSCREEN = pg.image.load("directory"+BGKEY+".PNG").convert_alpha()
EnCharBG = False
if BGKEY == 1 or 4:
BGCharKey = random.randint(1,2)
EnCharBG = True
print(BGKEY)
The problem is I expect BGKEY to be 1 or 4 if EnCharBG is true, but it's not, it's any number in that range. What I have done wrong or misunderstood?
Aucun commentaire:
Enregistrer un commentaire