diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3f58583 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +.score +NUL +env +__pycache__ diff --git a/game.py b/game.py index 5254dcd..3774776 100755 --- a/game.py +++ b/game.py @@ -174,6 +174,7 @@ def main() -> int: music.kill() lost_sfx() die() + capture.release() return score for positions in finger_positions: @@ -206,5 +207,27 @@ def main() -> int: show_frame(frame, to_stdout=(not sys.stdout.isatty())) i += 1 +def found_hands() -> bool: + capture: cv2.VideoCapture = cv2.VideoCapture(0) + hands = mp_hands.Hands(max_num_hands=1) + success, frame = capture.read() + if not success: + return False + + positions = list(get_finger_positions(frame, hands)) + return positions != [] + if __name__ == '__main__': - save_score(main()) + highscore = 0 + + while True: + if found_hands(): + # save_score(main()) + score = main() + highscore = max(highscore, score) + print(f"You're score was: {score}.") + print(f"The highscore is: {highscore}.") + cv2.destroyAllWindows() + print(f"\033[3{random.randint(1,8)}mShow your Hands\033[m") + sleep(1) + diff --git a/requirements.txt b/requirements.txt index 248b063..7c08670 100755 --- a/requirements.txt +++ b/requirements.txt @@ -22,3 +22,5 @@ pyparsing==3.0.9 python-dateutil==2.8.2 six==1.16.0 sounddevice==0.4.6 +requests==2.31.0 + diff --git a/start.sh b/start.sh new file mode 100755 index 0000000..77e2a3f --- /dev/null +++ b/start.sh @@ -0,0 +1 @@ +python3 game.py 2>NUL