-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbullet.py
More file actions
33 lines (27 loc) · 1002 Bytes
/
Copy pathbullet.py
File metadata and controls
33 lines (27 loc) · 1002 Bytes
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
"imports"
class Bullet:
"Class Bullet"
def __init__(self, x, y, image, screen, pygame):
self.image = image
self.screen = screen
self.pygame = pygame
self.rect = pygame.Rect(x, y, 33, 30)
self.hitbox = (self.rect.x, self.rect.y, 33, 30)
self.state = "ready"
def draw(self):
"Bullet Drawing"
if self.state == "fire":
self.screen.blit(self.image, (self.rect.x, self.rect.y))
self.hitbox = (self.rect.x, self.rect.y, 33, 30)
self.rect = self.pygame.Rect(self.rect.x, self.rect.y, 33, 30)
self.pygame.draw.rect(self.screen, (255, 0, 0), self.hitbox, 2)
def move(self):
"Bullet Movement"
if self.state == "fire":
self.rect.y = self.rect.y-3
if self.rect.y < 10:
self.state = "gone"
def set_bullet(self, enemyx, enemyy):
"Set Bullet coordonates"
self.rect.x = enemyx+18
self.rect.y = enemyy