From fd02dd21d4e669322212a923cbb88c7d47eb76af Mon Sep 17 00:00:00 2001 From: cubernetes Date: Fri, 11 Aug 2023 16:38:54 +0200 Subject: [PATCH] Up to date --- game.py | 24 ++++++++++++++++++++---- requirements.txt | 6 ++++++ 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/game.py b/game.py index bc9748a..5254dcd 100755 --- a/game.py +++ b/game.py @@ -3,6 +3,7 @@ import sys import random +from time import sleep import numpy as np import cv2 import requests @@ -100,14 +101,27 @@ def show_frame(frame: np.ndarray, to_stdout: bool=False) -> None: cv2.imshow("Image", frame) cv2.waitKey(1) +def collect_vfx() -> None: + requests.post('http://10.11.250.225:8080/api/v1/composition/layers/2/clips/5/connect') + sleep(1) + requests.post('http://10.11.250.225:8080/api/v1/composition/layers/2/clips/7/connect') + +def die_vfx() -> None: + requests.post('http://10.11.250.225:8080/api/v1/composition/layers/2/clips/6/connect') + sleep(3) + requests.post('http://10.11.250.225:8080/api/v1/composition/layers/2/clips/7/connect') + def green() -> None: - threading.Thread(target=requests.get, args=('http://10.11.250.225:8080/api/v1/composition/layers/2/clips/5/connect')).start() + threading.Thread(target=collect_vfx).start() + +def die() -> None: + threading.Thread(target=die_vfx).start() def main() -> int: music = start_game_sfx() capture: cv2.VideoCapture = cv2.VideoCapture(0) - hands: mp.solutions.hands.Hands = mp_hands.Hands(max_num_hands=2) + hands: mp.solutions.hands.Hands = mp_hands.Hands(max_num_hands=3) collected_42: bool = True noise_42img: int = 5 img42_x: int = -img42_side_len - 1 - noise_42img @@ -118,7 +132,7 @@ def main() -> int: finger_y: int = -1 no_collect_ratio = 0 no_finger_ratio = 0 - timer = 1000 + timer = 200 i: int = 0 while True: @@ -156,8 +170,10 @@ def main() -> int: no_fingers = 0 if ratio > 0.99: - music.kill() + if music: + music.kill() lost_sfx() + die() return score for positions in finger_positions: diff --git a/requirements.txt b/requirements.txt index 0ac831d..0e630cc 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,10 +1,13 @@ absl-py==1.4.0 attrs==23.1.0 +certifi==2023.7.22 cffi==1.15.1 +charset-normalizer==3.2.0 contourpy==1.1.0 cycler==0.11.0 flatbuffers==23.5.26 fonttools==4.42.0 +idna==3.4 kiwisolver==1.4.4 matplotlib==3.7.2 mediapipe==0.10.3 @@ -20,5 +23,8 @@ pycparser==2.21 PyGObject==3.44.1 pyparsing==3.0.9 python-dateutil==2.8.2 +requests==2.31.0 six==1.16.0 sounddevice==0.4.6 +soundfile==0.12.1 +urllib3==2.0.4