-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEnemigo.py
33 lines (25 loc) · 997 Bytes
/
Enemigo.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
import random
from GameObject import GameObject
from Disparo import Disparo
class Enemigo(GameObject):
def __init__(self, caracter, x, y):
super().__init__(caracter, x, y);
self.direcion = 0;
self.disparos = [];
def update(self):
if self.direcion == 0:
self.posicion.y += 1;
self.direcion = 1;
elif self.direcion == 1:
self.posicion.y -= 1;
self.direcion = 0;
if random.randint(0, 100) > 90:
self.disparos.append(Disparo("J", self.posicion.x + 1, self.posicion.y, 1));
def update_disparos(self, posicion_player):
for disparo in self.disparos:
disparo.update();
if posicion_player.x == disparo.posicion.x and posicion_player.y == disparo.posicion.y:
self.disparos.remove(disparo);
return True;
if disparo.posicion.x < 0 or disparo.posicion.x > 14:
self.disparos.remove(disparo);