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)] == "⬆":
|
elif game.map["{}:{}".format(self.object.y+1, self.object.x)] == "⬆":
|
||||||
self.temp = True
|
self.temp = True
|
||||||
game.update()
|
game.update()
|
||||||
ammo += 2
|
|
||||||
if self.temp:
|
if self.temp:
|
||||||
self.object.targetx = 100000
|
self.object.targetx = 100000
|
||||||
except:
|
except:
|
||||||
|
@ -55,9 +54,7 @@ class bullet():
|
||||||
|
|
||||||
asteroidcount = 0
|
asteroidcount = 0
|
||||||
count = 0
|
count = 0
|
||||||
ammocount = 0
|
|
||||||
acm = 10
|
acm = 10
|
||||||
ammo = 10
|
|
||||||
while True:
|
while True:
|
||||||
game.update()
|
game.update()
|
||||||
if game.pressedkeys["d"] == True:
|
if game.pressedkeys["d"] == True:
|
||||||
|
@ -69,13 +66,9 @@ while True:
|
||||||
for i in player:
|
for i in player:
|
||||||
i.targetx = i.x - 1
|
i.targetx = i.x - 1
|
||||||
if game.pressedkeys["q"] == True:
|
if game.pressedkeys["q"] == True:
|
||||||
if ammo != 0:
|
bullets.append(bullet())
|
||||||
bullets.append(bullet())
|
|
||||||
ammo -= 1
|
|
||||||
asteroidcount += 1
|
asteroidcount += 1
|
||||||
count += 1
|
count += 1
|
||||||
if ammo == 0:
|
|
||||||
ammocount += 1
|
|
||||||
if asteroidcount == acm:
|
if asteroidcount == acm:
|
||||||
asteroidcount = 0
|
asteroidcount = 0
|
||||||
asteroids.append(asteroid())
|
asteroids.append(asteroid())
|
||||||
|
@ -85,14 +78,10 @@ while True:
|
||||||
time.sleep(3)
|
time.sleep(3)
|
||||||
print("well if its so easy try this out:")
|
print("well if its so easy try this out:")
|
||||||
time.sleep(3)
|
time.sleep(3)
|
||||||
if ammocount == 30:
|
|
||||||
ammocount = 0
|
|
||||||
ammo += 1
|
|
||||||
|
|
||||||
for i in asteroids:
|
for i in asteroids:
|
||||||
i.update()
|
i.update()
|
||||||
|
|
||||||
for i in bullets:
|
for i in bullets:
|
||||||
i.update()
|
i.update()
|
||||||
print("ammo: {}".format(ammo))
|
|
||||||
time.sleep(0.05)
|
time.sleep(0.05)
|
||||||
|
|
|
@ -31,7 +31,12 @@ class game():
|
||||||
exit()
|
exit()
|
||||||
self.osmodule = __import__("os")
|
self.osmodule = __import__("os")
|
||||||
self.keyboard = __import__("keyboard")
|
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.soundfile = __import__("soundfile")
|
||||||
self.pressedkeys = {}
|
self.pressedkeys = {}
|
||||||
for i in string.ascii_letters:
|
for i in string.ascii_letters:
|
||||||
|
@ -140,10 +145,13 @@ class game():
|
||||||
self.objects.append(obj)
|
self.objects.append(obj)
|
||||||
|
|
||||||
def playsound(self, path, waitforfinish=False):
|
def playsound(self, path, waitforfinish=False):
|
||||||
data, fs = self.soundfile.read(path, dtype='float32')
|
if self.sounddevice != False:
|
||||||
self.sounddevice.play(data, fs)
|
data, fs = self.soundfile.read(path, dtype='float32')
|
||||||
if waitforfinish:
|
self.sounddevice.play(data, fs)
|
||||||
self.sounddevice.wait()
|
if waitforfinish:
|
||||||
|
self.sounddevice.wait()
|
||||||
|
else:
|
||||||
|
return
|
||||||
|
|
||||||
class object():
|
class object():
|
||||||
def __init__(self, character, gravity=0.1, x=0, y=0, antixforce=0.1):
|
def __init__(self, character, gravity=0.1, x=0, y=0, antixforce=0.1):
|
||||||
|
|
Loading…
Reference in New Issue