Dateien hochladen nach „“
parent
4d817c8d94
commit
4008b82f8d
13
asteroids.py
13
asteroids.py
|
@ -30,7 +30,6 @@ class asteroid():
|
|||
elif game.map["{}:{}".format(self.object.y+1, self.object.x)] == "⬆":
|
||||
self.temp = True
|
||||
game.update()
|
||||
ammo += 2
|
||||
if self.temp:
|
||||
self.object.targetx = 100000
|
||||
except:
|
||||
|
@ -55,9 +54,7 @@ class bullet():
|
|||
|
||||
asteroidcount = 0
|
||||
count = 0
|
||||
ammocount = 0
|
||||
acm = 10
|
||||
ammo = 10
|
||||
while True:
|
||||
game.update()
|
||||
if game.pressedkeys["d"] == True:
|
||||
|
@ -69,13 +66,9 @@ while True:
|
|||
for i in player:
|
||||
i.targetx = i.x - 1
|
||||
if game.pressedkeys["q"] == True:
|
||||
if ammo != 0:
|
||||
bullets.append(bullet())
|
||||
ammo -= 1
|
||||
bullets.append(bullet())
|
||||
asteroidcount += 1
|
||||
count += 1
|
||||
if ammo == 0:
|
||||
ammocount += 1
|
||||
if asteroidcount == acm:
|
||||
asteroidcount = 0
|
||||
asteroids.append(asteroid())
|
||||
|
@ -85,14 +78,10 @@ while True:
|
|||
time.sleep(3)
|
||||
print("well if its so easy try this out:")
|
||||
time.sleep(3)
|
||||
if ammocount == 30:
|
||||
ammocount = 0
|
||||
ammo += 1
|
||||
|
||||
for i in asteroids:
|
||||
i.update()
|
||||
|
||||
for i in bullets:
|
||||
i.update()
|
||||
print("ammo: {}".format(ammo))
|
||||
time.sleep(0.05)
|
||||
|
|
|
@ -31,7 +31,12 @@ class game():
|
|||
exit()
|
||||
self.osmodule = __import__("os")
|
||||
self.keyboard = __import__("keyboard")
|
||||
self.sounddevice = __import__("sounddevice")
|
||||
try:
|
||||
self.sounddevice = __import__("sounddevice")
|
||||
except OSError:
|
||||
print("ERROR: Could not port audio library. so that means that no audio can be played.")
|
||||
input("enter to continue")
|
||||
self.sounddevice = False
|
||||
self.soundfile = __import__("soundfile")
|
||||
self.pressedkeys = {}
|
||||
for i in string.ascii_letters:
|
||||
|
@ -140,10 +145,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):
|
||||
|
|
Loading…
Reference in New Issue