better touch function

This commit is contained in:
2025-05-02 23:48:39 +02:00
parent c89835b1a0
commit da186f0dee

View File

@@ -95,7 +95,7 @@ def is_SPACE_event(event):
touch_start = None touch_start = None
touch_start_time = None touch_start_time = None
if distance < 30 and duration < 0.3: # 30 px und 300 ms if distance < 30 and duration < 0.5: # 30 px und 300 ms
return True return True
# Mausklick (nur Linksklick, für Desktop-Tests) # Mausklick (nur Linksklick, für Desktop-Tests)
@@ -633,7 +633,7 @@ async def main():
global running, can_use_tilt, can_use_on_top, game_finished global running, can_use_tilt, can_use_on_top, game_finished
global current_case, transition_counter, state global current_case, transition_counter, state
global screen, clock, font, instruction_image, background_image global screen, clock, font, instruction_image, background_image
global touch_start_time global touch_start
await init_game() await init_game()
load_case_images() load_case_images()
@@ -674,7 +674,7 @@ async def main():
for event in pygame.event.get(): for event in pygame.event.get():
if event.type == pygame.QUIT: if event.type == pygame.QUIT:
running = False running = False
elif event.type == pygame.KEYDOWN or event.type == pygame.JOYBUTTONDOWN or event.type == pygame.JOYHATMOTION or event.type == pygame.FINGERDOWN or touch_start_time>0: elif event.type == pygame.KEYDOWN or event.type == pygame.JOYBUTTONDOWN or event.type == pygame.JOYHATMOTION or event.type == pygame.FINGERDOWN or touch_start:
if state == 1: # PLAYING if state == 1: # PLAYING
if ((event.type == pygame.KEYDOWN and event.key == pygame.K_LEFT) or if ((event.type == pygame.KEYDOWN and event.key == pygame.K_LEFT) or
(event.type == pygame.JOYHATMOTION and event.value[0] == -1) or (event.type == pygame.JOYHATMOTION and event.value[0] == -1) or