diff --git a/main.py b/main.py index 8713d01..556f4ba 100644 --- a/main.py +++ b/main.py @@ -73,14 +73,14 @@ def init_sounds(): case_images = {} -async def touch(event): +def touch(event): global touch_start, touch_start_time if event.type == pygame.FINGERDOWN and not touch_start: touch_start = (event.x * SCREEN_WIDTH, event.y * SCREEN_HEIGHT) touch_start_time = time.time() print("touch_start") - return "False" + return False elif event.type == pygame.FINGERUP and touch_start: end = (event.x * SCREEN_WIDTH, event.y * SCREEN_HEIGHT) @@ -101,10 +101,10 @@ async def touch(event): return "ontop" else: print("touch problem") - return "touch problem" - return "False" + return False + return False -async def is_SPACE_event(event): +def is_SPACE_event(event): # Tastatur oder Joystick A if (event.type == pygame.KEYDOWN and event.key == pygame.K_SPACE) or \ @@ -117,7 +117,7 @@ async def is_SPACE_event(event): return False -async def is_LEFT_event(event): +def is_LEFT_event(event): # Tastatur oder Joystick links if ((event.type == pygame.KEYDOWN and event.key == pygame.K_LEFT) or (event.type == pygame.JOYHATMOTION and event.value[0] == -1) or @@ -127,7 +127,7 @@ async def is_LEFT_event(event): return False -async def is_UP_event(event): +def is_UP_event(event): # Tastatur oder Joystick oben if ((event.type == pygame.KEYDOWN and event.key == pygame.K_UP) or (event.type == pygame.JOYHATMOTION and event.value[1] == 1) or @@ -497,12 +497,11 @@ async def show_instruction_screen(image): await asyncio.sleep(0) for event in pygame.event.get(): await asyncio.sleep(0) - result = await touch(event) + result = touch(event) if event.type == pygame.QUIT: pygame.quit() sys.exit() - elif await is_SPACE_event(event) or (result == "snap"): - print ("test "+result) + elif is_SPACE_event(event) or (result == "snap"): waiting = False async def fail_current_case(): @@ -651,7 +650,7 @@ async def show_game_over(score): if event.type == pygame.QUIT: pygame.quit() sys.exit() - elif await is_SPACE_event(event) or (await touch(event) == "snap"): + elif is_SPACE_event(event) or (touch(event) == "snap"): if ready_to_submit and prepared_form: print("Benutzer bestÃĪtigt, Punkte werden jetzt gesendet.") prepared_form.submit() @@ -712,16 +711,16 @@ async def main(): if state == 1: # PLAYING result = "none" if event.type == pygame.FINGERUP and touch_start: - result = await touch(event) + result = touch(event) elif event.type == pygame.FINGERDOWN and not touch_start: - await touch(event) + touch(event) print(result) - if await is_LEFT_event(event) or (result == "ontop"): + if is_LEFT_event(event) or (result == "ontop"): can_tip = current_case.length_units * UNIT_HEIGHT <= TRAILER_HEIGHT if current_case and current_case.allow_snap and can_use_tilt and can_tip: await current_case.animate_tip() can_use_tilt = False - elif await is_UP_event(event) or (result == "tilt"): + elif is_UP_event(event) or (result == "tilt"): if current_case and current_case.allow_snap and can_use_on_top and current_case.can_place_on_top(): if await current_case.animate_place_on_top(): transition_counter = transition_fps @@ -738,7 +737,7 @@ async def main(): stacked_cases.append(current_case) spawn_case_in_game() shake_timer = 10 - elif await is_SPACE_event(event) or (result == "snap"): + elif is_SPACE_event(event) or (result == "snap"): if current_case and current_case.allow_snap: await current_case.animate_snap()