diff --git a/main.py b/main.py index 73dcc7e..20a556d 100644 --- a/main.py +++ b/main.py @@ -80,7 +80,7 @@ async def touch(event): touch_start = (event.x * SCREEN_WIDTH, event.y * SCREEN_HEIGHT) touch_start_time = time.time() print("touch_start") - return None + return False elif event.type == pygame.FINGERUP and touch_start: end = (event.x * SCREEN_WIDTH, event.y * SCREEN_HEIGHT) @@ -101,8 +101,8 @@ async def touch(event): return "ontop" else: print("touch problem") - return None - return None + return False + return False async def is_SPACE_event(event): @@ -128,8 +128,7 @@ async def is_LEFT_event(event): async def is_UP_event(event): - global touch_start, touch_start_time - + # 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 (event.type == pygame.JOYBUTTONDOWN and event.button == 3)): @@ -501,7 +500,7 @@ async def show_instruction_screen(image): if event.type == pygame.QUIT: pygame.quit() sys.exit() - elif await is_SPACE_event(event) or result == "snap": + elif await is_SPACE_event(event) or (result == "snap"): print (result) waiting = False @@ -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 await is_SPACE_event(event) or await (touch(event) == "snap"): if ready_to_submit and prepared_form: print("Benutzer bestÃĪtigt, Punkte werden jetzt gesendet.") prepared_form.submit() @@ -713,16 +712,15 @@ async def main(): result = "none" if event.type == pygame.FINGERUP and touch_start: result = await touch(event) - print(result) elif event.type == pygame.FINGERDOWN and not touch_start: await touch(event) - if await is_LEFT_event(event) or result == "ontop": + if await 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 await 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 @@ -739,7 +737,8 @@ 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 await is_SPACE_event(event) or (result == "snap"): + print(result) if current_case and current_case.allow_snap: await current_case.animate_snap() can_use_tilt = True