Dateien hochladen nach „“

master
Justus Jan Nico Wolff 2022-08-20 10:32:32 +02:00
parent 9f715125dc
commit 944c6fdcc4
1 changed files with 20 additions and 6 deletions

View File

@ -31,8 +31,19 @@ class game():
exit()
self.osmodule = __import__("os")
self.keyboard = __import__("keyboard")
self.sounddevice = __import__("sounddevice")
self.soundfile = __import__("soundfile")
try:
self.sounddevice = __import__("sounddevice")
except OSError:
print("ERROR: Could not find port audio library. so that means that no audio can be played.")
input("enter to continue")
self.sounddevice = False
try:
self.soundfile = __import__("soundfile")
except OSError:
print("ERROR: Could not find sndfile library. so that means that no audio can be played.")
input("enter to continue")
self.sounddevice = False
self.pressedkeys = {}
for i in string.ascii_letters:
self.pressedkeys[i] = False
@ -140,10 +151,13 @@ class game():
self.objects.append(obj)
def playsound(self, path, waitforfinish=False):
data, fs = self.soundfile.read(path, dtype='float32')
self.sounddevice.play(data, fs)
if waitforfinish:
self.sounddevice.wait()
if self.sounddevice != False:
data, fs = self.soundfile.read(path, dtype='float32')
self.sounddevice.play(data, fs)
if waitforfinish:
self.sounddevice.wait()
else:
return
class object():
def __init__(self, character, gravity=0.1, x=0, y=0, antixforce=0.1):