first time asking a question. I am pretty new to python and I have made this script which is very basic but somehow does not work. the pygame.QUIT() function works but the other ones including K_e, K_9 and K_0 do not produce any result, or at least don't print anythong to the console. Here is the code.
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
exit()
if event.type == pygame.K_e:
if editing_mode:
editing_mode = False
else:
editing_mode = True
print(editing_mode)
if event.type == pygame.K_e:
selected_block -= 1
print(selected_block)
if event.type == pygame.K_0:
selected_block += 1
print(selected_block)
Another line in my loop a little bit further works perfectly. here it is:
keys = pygame.key.get_pressed()
if keys[pygame.K_a]:
speed_x -= 6
if keys[pygame.K_d]:
speed_x += 6
I only want the event to happen once when the keys E, 9 and 0 are pressed and this is why I used different loops. Thank you for your help.
I tried pressing the keys but nothing was printed even if the pygame.quit function works. I tried using the editing mode, after enabling it by pressing e even if nothing was printed and it did not work.