final changes for better touch function
This commit is contained in:
9
main.py
9
main.py
@@ -73,10 +73,9 @@ def init_sounds():
|
|||||||
|
|
||||||
case_images = {}
|
case_images = {}
|
||||||
|
|
||||||
def touch(event):
|
async def touch(event):
|
||||||
global touch_start, touch_start_time
|
global touch_start, touch_start_time
|
||||||
|
|
||||||
|
|
||||||
if event.type == pygame.FINGERDOWN and not touch_start:
|
if event.type == pygame.FINGERDOWN and not touch_start:
|
||||||
touch_start = (event.x * SCREEN_WIDTH, event.y * SCREEN_HEIGHT)
|
touch_start = (event.x * SCREEN_WIDTH, event.y * SCREEN_HEIGHT)
|
||||||
touch_start_time = time.time()
|
touch_start_time = time.time()
|
||||||
@@ -503,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 touch(event) == "snap":
|
elif is_SPACE_event(event) or await touch(event) == "snap":
|
||||||
waiting = False
|
waiting = False
|
||||||
|
|
||||||
async def fail_current_case():
|
async def fail_current_case():
|
||||||
@@ -652,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 touch(event) == "snap":
|
elif 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()
|
||||||
@@ -713,7 +712,7 @@ async def main():
|
|||||||
if state == 1: # PLAYING
|
if state == 1: # PLAYING
|
||||||
result = None
|
result = None
|
||||||
if pygame.FINGERUP and touch_start:
|
if pygame.FINGERUP and touch_start:
|
||||||
result = touch(event)
|
result = await touch(event)
|
||||||
|
|
||||||
if 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
|
can_tip = current_case.length_units * UNIT_HEIGHT <= TRAILER_HEIGHT
|
||||||
|
|||||||
Reference in New Issue
Block a user