test for touch function

This commit is contained in:
2025-05-02 17:19:50 +02:00
parent 4e45c54fd3
commit cba84f8e07

12
main.py
View File

@@ -70,7 +70,7 @@ def init_sounds():
case_images = {} case_images = {}
def is_snap_event(event): def is_SPACE_event(event):
global touch_start global touch_start
# Tastatur oder Joystick A # Tastatur oder Joystick A
@@ -458,8 +458,7 @@ async def show_instruction_screen(image):
if event.type == pygame.QUIT: if event.type == pygame.QUIT:
pygame.quit() pygame.quit()
sys.exit() sys.exit()
elif (event.type == pygame.KEYDOWN and event.key == pygame.K_SPACE) or \ elif is_SPACE_event(event):
(event.type == pygame.JOYBUTTONDOWN and event.button == 0):
waiting = False waiting = False
async def fail_current_case(): async def fail_current_case():
@@ -608,10 +607,7 @@ async def show_game_over(score):
if event.type == pygame.QUIT: if event.type == pygame.QUIT:
pygame.quit() pygame.quit()
sys.exit() sys.exit()
elif ( elif is_SPACE_event(event):
(event.type == pygame.KEYDOWN and event.key == pygame.K_SPACE) or
(event.type == pygame.JOYBUTTONDOWN and event.button == 0)
):
if ready_to_submit and prepared_form: if ready_to_submit and prepared_form:
print("Benutzer bestätigt, Punkte werden jetzt gesendet.") print("Benutzer bestätigt, Punkte werden jetzt gesendet.")
prepared_form.submit() prepared_form.submit()
@@ -695,7 +691,7 @@ async def main():
stacked_cases.append(current_case) stacked_cases.append(current_case)
spawn_case_in_game() spawn_case_in_game()
shake_timer = 10 shake_timer = 10
elif is_snap_event(event): elif is_SPACE_event(event):
if current_case and current_case.allow_snap: if current_case and current_case.allow_snap:
await current_case.animate_snap() await current_case.animate_snap()
can_use_tilt = True can_use_tilt = True