final changes for better touch function
This commit is contained in:
16
main.py
16
main.py
@@ -106,7 +106,7 @@ async def touch(event):
|
|||||||
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def is_SPACE_event(event):
|
async def is_SPACE_event(event):
|
||||||
|
|
||||||
# Tastatur oder Joystick A
|
# Tastatur oder Joystick A
|
||||||
if (event.type == pygame.KEYDOWN and event.key == pygame.K_SPACE) or \
|
if (event.type == pygame.KEYDOWN and event.key == pygame.K_SPACE) or \
|
||||||
@@ -119,7 +119,7 @@ def is_SPACE_event(event):
|
|||||||
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def is_LEFT_event(event):
|
async def is_LEFT_event(event):
|
||||||
# Tastatur oder Joystick links
|
# Tastatur oder Joystick links
|
||||||
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
|
||||||
@@ -129,7 +129,7 @@ def is_LEFT_event(event):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
def is_UP_event(event):
|
async def is_UP_event(event):
|
||||||
global touch_start, touch_start_time
|
global touch_start, touch_start_time
|
||||||
|
|
||||||
if ((event.type == pygame.KEYDOWN and event.key == pygame.K_UP) or
|
if ((event.type == pygame.KEYDOWN and event.key == pygame.K_UP) or
|
||||||
@@ -502,7 +502,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 is_SPACE_event(event) or await touch(event) == "snap":
|
elif await is_SPACE_event(event) or await touch(event) == "snap":
|
||||||
waiting = False
|
waiting = False
|
||||||
|
|
||||||
async def fail_current_case():
|
async def fail_current_case():
|
||||||
@@ -651,7 +651,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 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:
|
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()
|
||||||
@@ -714,12 +714,12 @@ async def main():
|
|||||||
if pygame.FINGERUP and touch_start:
|
if pygame.FINGERUP and touch_start:
|
||||||
result = await touch(event)
|
result = await touch(event)
|
||||||
|
|
||||||
if 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
|
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:
|
if current_case and current_case.allow_snap and can_use_tilt and can_tip:
|
||||||
await current_case.animate_tip()
|
await current_case.animate_tip()
|
||||||
can_use_tilt = False
|
can_use_tilt = False
|
||||||
elif 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 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():
|
if await current_case.animate_place_on_top():
|
||||||
transition_counter = transition_fps
|
transition_counter = transition_fps
|
||||||
@@ -736,7 +736,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_SPACE_event(event) or result == "snap":
|
elif await is_SPACE_event(event) or result == "snap":
|
||||||
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
|
||||||
|
|||||||
Reference in New Issue
Block a user