-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathenemy.py
48 lines (37 loc) · 1.02 KB
/
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
40
41
42
43
44
45
46
47
48
"""
Arcade 1942
File: enemy.py
Author: Luis Gandarillas
"""
import constants
from bullet import Bullet
class Enemy:
def __init__(self):
self.__is_alive = True
self.__bullets = []
self.__bullet_type = constants.BULLET_ENEMY
def __lower_height(self):
self.__point.y += self.__speed_y
def __increase_height(self):
self.__point.y -= self.__speed_y
def __turn_right(self):
self.__point.x += self.__speed_x
def __turn_left(self):
self.__point.x -= self.__speed_x
def __die(self):
self.__is_alive = False
def __disappear(self, lst):
l = lst
for e in l:
e.update()
if e.is_alive == False:
l.remove(e)
return l
def __shoot(self):
if self.__point.y % 20 == 0:
self.__bullets.append(Bullet(self.__point.x + self.__width / 2 - 5,
self.__point.y + self.__height,
self.__bullet_type))
self.__bullets.append(Bullet(self.__point.x + self.__width/2 + 5,
self.__point.y + self.__height,
self.__bullet_type))