2024-04-23 20:14:24 -04:00
|
|
|
import arcade
|
|
|
|
import random
|
|
|
|
from AlienBullet import AlienBullet
|
|
|
|
class Alien(arcade.Sprite):
|
|
|
|
|
|
|
|
def __init__(self, x, y, SCREEN_SCALE, DEBUG, AlienType):
|
|
|
|
super().__init__()
|
|
|
|
|
|
|
|
self.center_x = x * SCREEN_SCALE
|
|
|
|
self.center_y = y * SCREEN_SCALE
|
|
|
|
self.scScale = SCREEN_SCALE
|
|
|
|
self.deBuggin = DEBUG
|
|
|
|
self.alienType = AlienType
|
|
|
|
self.alien_sprite = None
|
|
|
|
self.wait = 0
|
|
|
|
self.isAlive = True
|
|
|
|
self.bullet = None
|
|
|
|
self.sizeX = 0
|
|
|
|
self.sizeY = 0
|
|
|
|
|
|
|
|
if self.alienType == "LA":
|
|
|
|
self.sizeX = 6 * self.scScale
|
|
|
|
self.sizeY = 4 * self.scScale
|
|
|
|
self.image_source = "assets/Sprites/Enemy/LA1.png"
|
|
|
|
if self.deBuggin:
|
|
|
|
print(str(self.image_source))
|
|
|
|
if self.alienType == "MA":
|
|
|
|
self.sizeX = 5 * self.scScale
|
|
|
|
self.sizeY = 4 * self.scScale
|
|
|
|
self.image_source = "assets/Sprites/Enemy/MA1.png"
|
|
|
|
if self.deBuggin:
|
|
|
|
print(str(self.image_source))
|
|
|
|
if self.alienType == "SA":
|
|
|
|
self.sizeX = 4 * self.scScale
|
|
|
|
self.sizeY = 4 * self.scScale
|
|
|
|
self.image_source = "assets/Sprites/Enemy/SA1.png"
|
|
|
|
if self.deBuggin:
|
|
|
|
print(str(self.image_source))
|
|
|
|
|
|
|
|
self.alien_sprite = arcade.Sprite(self.image_source, self.scScale)
|
|
|
|
|
2024-04-26 09:16:45 -04:00
|
|
|
|
|
|
|
|
2024-04-23 20:14:24 -04:00
|
|
|
def update(self, x, sign, movedown):
|
|
|
|
|
|
|
|
if self.alienType == "LA" and self.wait > 0:
|
|
|
|
if self.image_source == "assets/Sprites/Enemy/LA1.png":
|
|
|
|
self.image_source = "assets/Sprites/Enemy/LA2.png"
|
|
|
|
self.alien_sprite = arcade.Sprite(self.image_source, self.scScale)
|
|
|
|
else:
|
|
|
|
self.image_source = "assets/Sprites/Enemy/LA1.png"
|
|
|
|
self.alien_sprite = arcade.Sprite(self.image_source, self.scScale)
|
|
|
|
if self.alienType == "MA" and self.wait > 0:
|
|
|
|
if self.image_source == "assets/Sprites/Enemy/MA1.png":
|
|
|
|
self.image_source = "assets/Sprites/Enemy/MA2.png"
|
|
|
|
self.alien_sprite = arcade.Sprite(self.image_source, self.scScale)
|
|
|
|
else:
|
|
|
|
self.image_source = "assets/Sprites/Enemy/MA1.png"
|
|
|
|
self.alien_sprite = arcade.Sprite(self.image_source, self.scScale)
|
|
|
|
if self.alienType == "SA" and self.wait > 0:
|
|
|
|
if self.image_source == "assets/Sprites/Enemy/SA1.png":
|
|
|
|
self.image_source = "assets/Sprites/Enemy/SA2.png"
|
|
|
|
self.alien_sprite = arcade.Sprite(self.image_source, self.scScale)
|
|
|
|
else:
|
|
|
|
self.image_source = "assets/Sprites/Enemy/SA1.png"
|
|
|
|
self.alien_sprite = arcade.Sprite(self.image_source, self.scScale)
|
|
|
|
self.wait = 1
|
|
|
|
if movedown:
|
|
|
|
self.center_y -= 8 * self.scScale
|
|
|
|
if x:
|
2024-04-29 16:29:36 -04:00
|
|
|
self.center_x += 2 * self.scScale * sign
|
2024-04-23 20:14:24 -04:00
|
|
|
self.alien_sprite.center_x = self.center_x
|
|
|
|
self.alien_sprite.center_y = self.center_y
|
|
|
|
|
|
|
|
def getSizeX(self):
|
|
|
|
return self.sizeX
|
|
|
|
def getSizeY(self):
|
|
|
|
return self.sizeY
|
|
|
|
|
|
|
|
def checkBullet(self):
|
|
|
|
try:
|
|
|
|
if self.bullet != None:
|
|
|
|
if self.bullet.getY() < -50:
|
|
|
|
self.bullet = None
|
|
|
|
if self.deBuggin:
|
|
|
|
print("Bullet Killed")
|
|
|
|
except Exception as e:
|
|
|
|
pass
|
|
|
|
def spawnBullet(self):
|
|
|
|
self.bullet = AlienBullet(self.scScale, self.deBuggin, self.center_x, self.center_y)
|
|
|
|
|
|
|
|
def getX(self):
|
|
|
|
return self.center_x
|
|
|
|
def getY(self):
|
|
|
|
return self.center_y
|
|
|
|
|
|
|
|
def getType(self):
|
|
|
|
return self.alienType
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|