-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbullet.py
47 lines (31 loc) · 1.2 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
35
36
37
38
39
40
41
42
43
44
45
46
47
import constants as c
import arcade
class Bullet(arcade.Sprite):
def __init__(self,type,x,y,speed,damage):
self.type = type
self.speed_change = 1
self.damage = damage
self.x = x + 10
self.y = y + 10
if self.type == 2:
super().__init__("images/utilities/baseball.png", 0.08)
elif self.type == 3 or self.type == 6:
super().__init__("images/utilities/snowball.png", 0.13)
self.speed_change = .95
else:
super().__init__("images/utilities/baseball.png", 0.08)
#important to set the center coords here
self.center_x = self.x
self.center_y = self.y
self.position = [self.center_x,self.center_y]
self.change_x = speed
def reset(self):
self.center_x = self.x
self.center_y = self.y
def move(self):
for bullet in self.bullet_list:
bullet.center_x += c.BULLET_SPEED
if bullet.center_x > c.SCREEN_WIDTH:
#reset to defender starting point
self.reset()
#self.bullet_list.remove(bullet)