When running the following lines of code, a user should press the 'W' button to start meditating, and press the 'S' button to stop meditating, however what I'm finding is that if ANY button is pressed, the user starts or stops meditating depending on whether DL[19] = 4 or 0. This is a problem as I need the keys 'A' and 'D' to navigate through rooms. Any suggestions on how to fix this?
if DL[19] == 0: # no activity
displaydata1 = font.render(" 'W' Key: meditate", True, (255,255,255))
screen.blit(displaydata1, (coordinates[0], coordinates[1] + 14))
if event.type == pygame.KEYDOWN:
if pygame.K_w:
DL[19] = 4 # set activity to meditating
elif DL[19] == 4: # meditating
displaydata1 = font.render(" 'S' Key: stop meditating", True, (255,255,255))
screen.blit(displaydata1, (coordinates[0], coordinates[1] + 14))
if event.type == pygame.KEYDOWN:
if pygame.K_s:
DL[19] = 0 # set to no activity