68 lines
3.1 KiB
Python
68 lines
3.1 KiB
Python
|
import arcade
|
||
|
import random
|
||
|
BULLET_SPEED = 2
|
||
|
|
||
|
class AlienBullet(arcade.Sprite):
|
||
|
|
||
|
def __init__(self, SCREEN_SCALE, DEBUG, x, y):
|
||
|
super().__init__()
|
||
|
self.isAlive = True
|
||
|
self.deBuggin = DEBUG
|
||
|
self.scScale = SCREEN_SCALE
|
||
|
self.i = 0
|
||
|
self.image_source = None
|
||
|
if self.deBuggin:
|
||
|
print("Alien Bullet Spawning")
|
||
|
self.type = random.randint(1,3)
|
||
|
if self.type == 1:
|
||
|
self.image_souce = "assets/Sprites/Bullets/B1.png"
|
||
|
if self.type == 2:
|
||
|
self.image_souce = "assets/Sprites/Bullets/C1.png"
|
||
|
if self.type == 3:
|
||
|
self.image_souce = "assets/Sprites/Bullets/D1.png"
|
||
|
self.bullet_sprite = arcade.Sprite(self.image_source, self.scScale)
|
||
|
self.center_x = x
|
||
|
self.center_y = y
|
||
|
self.count = 0
|
||
|
|
||
|
def update(self):
|
||
|
self.count += 1
|
||
|
self.center_y -= BULLET_SPEED*self.scScale
|
||
|
# if self.deBuggin:
|
||
|
# print(str(self.center_y))
|
||
|
if self.count == 4:
|
||
|
if self.type == 1:
|
||
|
if self.image_souce == "assets/Sprites/Bullets/B1.png":
|
||
|
self.image_souce = "assets/Sprites/Bullets/B2.png"
|
||
|
elif self.image_souce == "assets/Sprites/Bullets/B2.png":
|
||
|
self.image_souce = "assets/Sprites/Bullets/B3.png"
|
||
|
elif self.image_souce == "assets/Sprites/Bullets/B3.png":
|
||
|
self.image_souce = "assets/Sprites/Bullets/B4.png"
|
||
|
elif self.image_souce == "assets/Sprites/Bullets/B4.png":
|
||
|
self.image_souce = "assets/Sprites/Bullets/B1.png"
|
||
|
if self.type == 2:
|
||
|
if self.image_souce == "assets/Sprites/Bullets/C1.png":
|
||
|
self.image_souce = "assets/Sprites/Bullets/C2.png"
|
||
|
elif self.image_souce == "assets/Sprites/Bullets/C2.png":
|
||
|
self.image_souce = "assets/Sprites/Bullets/C3.png"
|
||
|
elif self.image_souce == "assets/Sprites/Bullets/C3.png":
|
||
|
self.image_souce = "assets/Sprites/Bullets/C4.png"
|
||
|
elif self.image_souce == "assets/Sprites/Bullets/C4.png":
|
||
|
self.image_souce = "assets/Sprites/Bullets/C1.png"
|
||
|
if self.type == 3:
|
||
|
if self.image_souce == "assets/Sprites/Bullets/D1.png":
|
||
|
self.image_souce = "assets/Sprites/Bullets/D2.png"
|
||
|
elif self.image_souce == "assets/Sprites/Bullets/D2.png":
|
||
|
self.image_souce = "assets/Sprites/Bullets/D3.png"
|
||
|
elif self.image_souce == "assets/Sprites/Bullets/D3.png":
|
||
|
self.image_souce = "assets/Sprites/Bullets/D4.png"
|
||
|
elif self.image_souce == "assets/Sprites/Bullets/D4.png":
|
||
|
self.image_souce = "assets/Sprites/Bullets/D1.png"
|
||
|
self.count = 0
|
||
|
self.bullet_sprite = arcade.Sprite(self.image_souce, self.scScale)
|
||
|
self.bullet_sprite.center_x = self.center_x
|
||
|
self.bullet_sprite.center_y = self.center_y
|
||
|
def getX(self):
|
||
|
return self.center_x
|
||
|
def getY(self):
|
||
|
return self.center_y
|