-
Notifications
You must be signed in to change notification settings - Fork 1
/
gm_enemy.py
39 lines (34 loc) · 1.08 KB
/
gm_enemy.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import pygame
import os
from config import HEIGHT, soundFolder
from gm_laser import Laser
from asset_loader import (
RED_SPACE_SHIP,
RED_LASER,
GREEN_SPACE_SHIP,
GREEN_LASER,
BLUE_SPACE_SHIP,
BLUE_LASER,
)
from gm_abs_ship import Ship
class Enemy(Ship):
COLOR_MAP = {
"red": (RED_SPACE_SHIP, RED_LASER),
"green": (GREEN_SPACE_SHIP, GREEN_LASER),
"blue": (BLUE_SPACE_SHIP, BLUE_LASER),
}
def __init__(self, x, y, color, health=100):
super().__init__(x, y, health)
self.ship_img, self.laser_img = self.COLOR_MAP[color]
self.mask = self.createMask()
self.velocity = 1
def checkBelowScreen(self):
return self.y + self.height > HEIGHT
def shoot(self):
if self.cool_down_counter == 0:
laser = Laser(int(self.x - 20), self.y, self.laser_img)
self.lasers.append(laser)
self.cool_down_counter = 1
if self.y > 0:
laserEffect = pygame.mixer.Sound(os.path.join(soundFolder,"__laser_modif.wav"))
laserEffect.play()