Fixes
This commit is contained in:
parent
cb7b3eef41
commit
5f89bbea35
21
game.py
21
game.py
|
@ -7,6 +7,7 @@ from time import sleep
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import cv2
|
import cv2
|
||||||
import requests
|
import requests
|
||||||
|
from subprocess import Popen
|
||||||
|
|
||||||
from utils import *
|
from utils import *
|
||||||
|
|
||||||
|
@ -103,7 +104,7 @@ def show_frame(frame: np.ndarray, to_stdout: bool=False) -> None:
|
||||||
|
|
||||||
def collect_vfx() -> None:
|
def collect_vfx() -> None:
|
||||||
requests.post('http://10.11.250.225:8080/api/v1/composition/layers/2/clips/5/connect')
|
requests.post('http://10.11.250.225:8080/api/v1/composition/layers/2/clips/5/connect')
|
||||||
sleep(1)
|
sleep(2)
|
||||||
requests.post('http://10.11.250.225:8080/api/v1/composition/layers/2/clips/7/connect')
|
requests.post('http://10.11.250.225:8080/api/v1/composition/layers/2/clips/7/connect')
|
||||||
|
|
||||||
def die_vfx() -> None:
|
def die_vfx() -> None:
|
||||||
|
@ -173,7 +174,9 @@ def main() -> int:
|
||||||
if music:
|
if music:
|
||||||
music.kill()
|
music.kill()
|
||||||
lost_sfx()
|
lost_sfx()
|
||||||
die()
|
# die()
|
||||||
|
capture.release()
|
||||||
|
cv2.destroyAllWindows()
|
||||||
return score
|
return score
|
||||||
|
|
||||||
for positions in finger_positions:
|
for positions in finger_positions:
|
||||||
|
@ -191,10 +194,7 @@ def main() -> int:
|
||||||
side_len=70,
|
side_len=70,
|
||||||
stretch=2.0,
|
stretch=2.0,
|
||||||
)
|
)
|
||||||
if not collected_42 and (
|
if not collected_42 and touches_42(apex_x, apex_y, img42_x, img42_y):
|
||||||
touches_42(apex_x, apex_y, img42_x, img42_y)
|
|
||||||
or touches_42(finger_x, finger_y, img42_x, img42_y)
|
|
||||||
):
|
|
||||||
collected_42 = True
|
collected_42 = True
|
||||||
i = 0
|
i = 0
|
||||||
score += 42
|
score += 42
|
||||||
|
@ -203,6 +203,15 @@ def main() -> int:
|
||||||
timer = 60 + (timer - 60) * .9
|
timer = 60 + (timer - 60) * .9
|
||||||
collect_sfx()
|
collect_sfx()
|
||||||
green()
|
green()
|
||||||
|
if not collected_42 and touches_42(finger_x, finger_y, img42_x, img42_y):
|
||||||
|
collected_42 = True
|
||||||
|
i = 0
|
||||||
|
score += 42
|
||||||
|
if score == 4200 / 4: # that's 25 collects
|
||||||
|
initiate_rick()
|
||||||
|
timer = 50 + (timer - 50) * .9
|
||||||
|
collect_sfx()
|
||||||
|
green()
|
||||||
show_frame(frame, to_stdout=(not sys.stdout.isatty()))
|
show_frame(frame, to_stdout=(not sys.stdout.isatty()))
|
||||||
i += 1
|
i += 1
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
TERM_FONT='SauceCodePro Nerd Font Mono'
|
TERM_FONT='SauceCodePro Nerd Font Mono'
|
||||||
TERM_FONT_SIZE='10'
|
TERM_FONT_SIZE='10'
|
||||||
OUT_TERM='xterm-mono'
|
OUT_TERM='xterm-mono'
|
||||||
TERM_FULLSCREEN='-fullscreen'
|
# TERM_FULLSCREEN='-fullscreen'
|
||||||
xterm \
|
xterm \
|
||||||
-bg black \
|
-bg black \
|
||||||
-fg white \
|
-fg white \
|
||||||
|
@ -36,5 +36,5 @@ xterm \
|
||||||
--untimed \
|
--untimed \
|
||||||
--profile=low-latency \
|
--profile=low-latency \
|
||||||
- \
|
- \
|
||||||
|| { echo "There was an error" 1>&2; read X; };
|
|| { echo "There was an error" 1>&2; read X; } && { echo "There was no error"; };
|
||||||
}'
|
}'
|
||||||
|
|
32
utils.py
32
utils.py
|
@ -6,8 +6,8 @@ from typing import Generator
|
||||||
from types import ModuleType
|
from types import ModuleType
|
||||||
import threading
|
import threading
|
||||||
|
|
||||||
import sounddevice as sd
|
# import sounddevice as sd
|
||||||
import soundfile as sf
|
# import soundfile as sf
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import mediapipe as mp
|
import mediapipe as mp
|
||||||
|
@ -44,30 +44,34 @@ def save_score(score: int) -> None:
|
||||||
with open('./.score', 'w') as score_file:
|
with open('./.score', 'w') as score_file:
|
||||||
score_file.write(str(score))
|
score_file.write(str(score))
|
||||||
|
|
||||||
def play_audio(file_name: str) -> None:
|
# def play_audio(file_name: str) -> None:
|
||||||
# Read the audio file
|
# # Read the audio file
|
||||||
data, samplerate = sf.read(file_name)
|
# data, samplerate = sf.read(file_name)
|
||||||
|
#
|
||||||
# Play the audio file
|
# # Play the audio file
|
||||||
sd.play(data, samplerate)
|
# sd.play(data, samplerate)
|
||||||
sd.wait() # Wait for the audio playback to complete
|
# sd.wait() # Wait for the audio playback to complete
|
||||||
|
|
||||||
def start_game_sfx() -> None:
|
def start_game_sfx() -> Popen:
|
||||||
play_audio('./assets/sound/start.mp3')
|
Popen(['paplay', './assets/sound/start.mp3']).communicate()
|
||||||
|
# play_audio('./assets/sound/start.mp3')
|
||||||
time.sleep(.5)
|
time.sleep(.5)
|
||||||
threading.Thread(target=play_audio, args=('./assets/sound/background_music.mp3',), daemon=True).start()
|
return Popen(['paplay', './assets/sound/background_music.mp3'])
|
||||||
|
# threading.Thread(target=play_audio, args=('./assets/sound/background_music.mp3',), daemon=True).start()
|
||||||
|
|
||||||
def collect_sfx() -> None:
|
def collect_sfx() -> None:
|
||||||
pass
|
Popen(['paplay', './assets/sound/collect.mp3'])
|
||||||
# threading.Thread(target=play_audio, args=('./assets/sound/collect.mp3',), daemon=True).start()
|
# threading.Thread(target=play_audio, args=('./assets/sound/collect.mp3',), daemon=True).start()
|
||||||
|
|
||||||
def lost_sfx() -> None:
|
def lost_sfx() -> None:
|
||||||
play_audio('./assets/sound/lost.mp3')
|
Popen(['paplay', './assets/sound/lost.mp3']).communicate()
|
||||||
|
# play_audio('./assets/sound/lost.mp3')
|
||||||
|
|
||||||
def show_matrix() -> None:
|
def show_matrix() -> None:
|
||||||
Popen(['tmatrix'])
|
Popen(['tmatrix'])
|
||||||
|
|
||||||
def initiate_rick() -> None:
|
def initiate_rick() -> None:
|
||||||
|
Popen(['paplay', './assets/sound/rick.mp3'])
|
||||||
# threading.Thread(target=play_audio, args=('./assets/sound/rick.mp3',), daemon=True).start()
|
# threading.Thread(target=play_audio, args=('./assets/sound/rick.mp3',), daemon=True).start()
|
||||||
cap = cv2.VideoCapture('./assets/video/rick2.mp4')
|
cap = cv2.VideoCapture('./assets/video/rick2.mp4')
|
||||||
fps: int = int(cap.get(cv2.CAP_PROP_FPS))
|
fps: int = int(cap.get(cv2.CAP_PROP_FPS))
|
||||||
|
|
Loading…
Reference in New Issue