-
Notifications
You must be signed in to change notification settings - Fork 1
/
Bullet.py
34 lines (25 loc) · 1.07 KB
/
Bullet.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
from Fireball import Fireball
from Settings import GlobalConstants
class Bullets(GlobalConstants):
def __init__(self, player):
self.PLAYER = player
self.bull_end = []
super().__init__()
def shoot(self):
self.BULLETS.append(Fireball(self.PLAYER.x + (self.PLAYER.get_width() / 2 - self.BULLET_WIDTH / 2),
self.PLAYER.y))
def tick(self):
self.bull_end.clear()
for bull_pos in range(len(self.BULLETS)):
self.BULLETS[bull_pos].move()
if (self.BULLETS[bull_pos].y < self.MARGIN * (1/2) and self.BULLETS[bull_pos].get_name() == "Fireball") or \
(self.BULLETS[bull_pos].get_name() in ["Red_fireball", "Bomb"] and self.BULLETS[bull_pos].y >=
self.SCREEN_LENGTH - self.MARGIN * 3):
self.bull_end.append(bull_pos)
j = 0
for b in sorted(self.bull_end):
self.BULLETS.pop(b - j)
j += 1
def draw(self):
for bull_object in self.BULLETS:
bull_object.draw(0)