This commit is contained in:
cubernetes 2023-08-11 17:07:56 +02:00
parent 8b9636305c
commit 80f5f36e47
4 changed files with 31 additions and 1 deletions

4
.gitignore vendored Normal file
View File

@ -0,0 +1,4 @@
.score
NUL
env
__pycache__

25
game.py
View File

@ -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)

View File

@ -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

1
start.sh Executable file
View File

@ -0,0 +1 @@
python3 game.py 2>NUL