better touch function

This commit is contained in:
2025-05-03 00:18:32 +02:00
parent 05e3b842b8
commit bc9670def7

12
main.py
View File

@@ -702,14 +702,18 @@ async def main():
for event in pygame.event.get():
if event.type == pygame.QUIT:
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 or(event.type == pygame.MOUSEBUTTONDOWN and event.button == 1):
elif event.type == pygame.KEYDOWN or event.type == pygame.JOYBUTTONDOWN or event.type == pygame.JOYHATMOTION or event.type == pygame.FINGERDOWN or touch_start or (event.type == pygame.MOUSEBUTTONDOWN and event.button == 1):
if state == 1: # PLAYING
if is_LEFT_event(event) or touch(event) == "ontop":
if pygame.FINGERUP and touch_start:
result = touch(event)
else:
result = None
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 is_UP_event(event) or touch(event) == "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
@@ -726,7 +730,7 @@ async def main():
stacked_cases.append(current_case)
spawn_case_in_game()
shake_timer = 10
elif is_SPACE_event(event) or touch(event) == "snap":
elif is_SPACE_event(event) or result == "snap":
if current_case and current_case.allow_snap:
await current_case.animate_snap()
can_use_tilt = True