COlors
This commit is contained in:
parent
ade4654112
commit
a86cc5e4f6
5
game.py
5
game.py
|
@ -5,6 +5,7 @@ import random
|
|||
|
||||
import numpy as np
|
||||
import cv2
|
||||
import requests
|
||||
|
||||
from utils import *
|
||||
|
||||
|
@ -99,6 +100,9 @@ def show_frame(frame: np.ndarray, to_stdout: bool=False) -> None:
|
|||
cv2.imshow("Image", frame)
|
||||
cv2.waitKey(1)
|
||||
|
||||
def green() -> None:
|
||||
threading.Thread(target=requests.get, args=('http://10.11.250.225:8080/api/v1/composition/layers/2/clips/5/connect')).start()
|
||||
|
||||
def main() -> int:
|
||||
music = start_game_sfx()
|
||||
|
||||
|
@ -182,6 +186,7 @@ def main() -> int:
|
|||
initiate_rick()
|
||||
timer = 60 + (timer - 60) * .9
|
||||
collect_sfx()
|
||||
green()
|
||||
show_frame(frame, to_stdout=(not sys.stdout.isatty()))
|
||||
i += 1
|
||||
|
||||
|
|
23
utils.py
23
utils.py
|
@ -6,10 +6,13 @@ from typing import Generator
|
|||
from types import ModuleType
|
||||
import threading
|
||||
|
||||
import sounddevice as sd
|
||||
import soundfile as sf
|
||||
|
||||
import numpy as np
|
||||
import mediapipe as mp
|
||||
import cv2
|
||||
from playsound import playsound
|
||||
# from playsound import playsound
|
||||
|
||||
mp_hands = mp.solutions.hands
|
||||
mp_draw: ModuleType = mp.solutions.drawing_utils
|
||||
|
@ -41,23 +44,31 @@ def save_score(score: int) -> None:
|
|||
with open('./.score', 'w') as score_file:
|
||||
score_file.write(str(score))
|
||||
|
||||
def play_audio(file_name: str) -> None:
|
||||
# Read the audio file
|
||||
data, samplerate = sf.read(file_name)
|
||||
|
||||
# Play the audio file
|
||||
sd.play(data, samplerate)
|
||||
sd.wait() # Wait for the audio playback to complete
|
||||
|
||||
def start_game_sfx() -> None:
|
||||
playsound('./assets/sound/start.mp3')
|
||||
play_audio('./assets/sound/start.mp3')
|
||||
time.sleep(.5)
|
||||
threading.Thread(target=playsound, args=('./assets/sound/background_music.mp3',), daemon=True).start()
|
||||
threading.Thread(target=play_audio, args=('./assets/sound/background_music.mp3',), daemon=True).start()
|
||||
|
||||
def collect_sfx() -> None:
|
||||
pass
|
||||
threading.Thread(target=playsound, 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:
|
||||
playsound('./assets/sound/lost.mp3')
|
||||
play_audio('./assets/sound/lost.mp3')
|
||||
|
||||
def show_matrix() -> None:
|
||||
Popen(['tmatrix'])
|
||||
|
||||
def initiate_rick() -> None:
|
||||
threading.Thread(target=playsound, 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')
|
||||
fps: int = int(cap.get(cv2.CAP_PROP_FPS))
|
||||
desired_delay: float = 1 / fps
|
||||
|
|
Loading…
Reference in New Issue