keycounter

This commit is contained in:
Michael S. 2024-02-25 11:43:30 +01:00
parent 401201aba3
commit c1d072e173

51
main.py
View file

@ -110,34 +110,39 @@ buttonhovered = [False, False, False, False, False, False]
buttons_to_render = 6 # button begrenzung buttons_to_render = 6 # button begrenzung
dropdown = True dropdown = True
before_buttonhovered = False before_buttonhovered = False
key_counter = 0
pressed_keys = pygame.key.get_pressed()
show_debug = False show_debug = False
running = True running = True
if __name__ == "__main__": if __name__ == "__main__":
while running: while running:
## key managment ## key managment
pressed_keys = pygame.key.get_pressed() key_counter += 1
if True in pressed_keys: if key_counter == 5:
if pressed_keys[pygame.K_ESCAPE]: key_counter = 0
exit() pressed_keys = pygame.key.get_pressed()
if pressed_keys[pygame.K_PLUS] and not before_pressed_keys[pygame.K_PLUS]: if True in pressed_keys:
pixelsize += 2 if pressed_keys[pygame.K_ESCAPE]:
remake_feld() exit()
if pressed_keys[pygame.K_MINUS] and not before_pressed_keys[pygame.K_MINUS]: if pressed_keys[pygame.K_PLUS] and not before_pressed_keys[pygame.K_PLUS]:
pixelsize -= 2 pixelsize += 2
remake_feld() remake_feld()
if pressed_keys[pygame.K_d] and not before_pressed_keys[pygame.K_d]: if pressed_keys[pygame.K_MINUS] and not before_pressed_keys[pygame.K_MINUS]:
show_debug = not show_debug pixelsize -= 2
if pressed_keys[pygame.K_SPACE] and not before_pressed_keys[pygame.K_SPACE]: remake_feld()
if using_element == "a": if pressed_keys[pygame.K_d] and not before_pressed_keys[pygame.K_d]:
using_element = "#" show_debug = not show_debug
else: if pressed_keys[pygame.K_SPACE] and not before_pressed_keys[pygame.K_SPACE]:
using_element = "a" if using_element == "a":
if pressed_keys[pygame.K_r] and not before_pressed_keys[pygame.K_r]: using_element = "#"
if display_mode == "border": else:
display_mode = "loop" using_element = "a"
else: if pressed_keys[pygame.K_r] and not before_pressed_keys[pygame.K_r]:
display_mode = "border" if display_mode == "border":
remake_feld() display_mode = "loop"
else:
display_mode = "border"
remake_feld()
## event managment ## event managment
for event in pygame.event.get(): for event in pygame.event.get():