From c1d072e17368a7df653eb19ab3d07b317b5e0dc8 Mon Sep 17 00:00:00 2001 From: Megamichi Date: Sun, 25 Feb 2024 11:43:30 +0100 Subject: [PATCH] keycounter --- main.py | 51 ++++++++++++++++++++++++++++----------------------- 1 file changed, 28 insertions(+), 23 deletions(-) diff --git a/main.py b/main.py index 1077758..d250a8c 100644 --- a/main.py +++ b/main.py @@ -110,34 +110,39 @@ buttonhovered = [False, False, False, False, False, False] buttons_to_render = 6 # button begrenzung dropdown = True before_buttonhovered = False +key_counter = 0 +pressed_keys = pygame.key.get_pressed() show_debug = False running = True if __name__ == "__main__": while running: ## key managment - pressed_keys = pygame.key.get_pressed() - if True in pressed_keys: - if pressed_keys[pygame.K_ESCAPE]: - exit() - if pressed_keys[pygame.K_PLUS] and not before_pressed_keys[pygame.K_PLUS]: - pixelsize += 2 - remake_feld() - if pressed_keys[pygame.K_MINUS] and not before_pressed_keys[pygame.K_MINUS]: - pixelsize -= 2 - remake_feld() - if pressed_keys[pygame.K_d] and not before_pressed_keys[pygame.K_d]: - show_debug = not show_debug - if pressed_keys[pygame.K_SPACE] and not before_pressed_keys[pygame.K_SPACE]: - if using_element == "a": - using_element = "#" - else: - using_element = "a" - if pressed_keys[pygame.K_r] and not before_pressed_keys[pygame.K_r]: - if display_mode == "border": - display_mode = "loop" - else: - display_mode = "border" - remake_feld() + key_counter += 1 + if key_counter == 5: + key_counter = 0 + pressed_keys = pygame.key.get_pressed() + if True in pressed_keys: + if pressed_keys[pygame.K_ESCAPE]: + exit() + if pressed_keys[pygame.K_PLUS] and not before_pressed_keys[pygame.K_PLUS]: + pixelsize += 2 + remake_feld() + if pressed_keys[pygame.K_MINUS] and not before_pressed_keys[pygame.K_MINUS]: + pixelsize -= 2 + remake_feld() + if pressed_keys[pygame.K_d] and not before_pressed_keys[pygame.K_d]: + show_debug = not show_debug + if pressed_keys[pygame.K_SPACE] and not before_pressed_keys[pygame.K_SPACE]: + if using_element == "a": + using_element = "#" + else: + using_element = "a" + if pressed_keys[pygame.K_r] and not before_pressed_keys[pygame.K_r]: + if display_mode == "border": + display_mode = "loop" + else: + display_mode = "border" + remake_feld() ## event managment for event in pygame.event.get():