-
Notifications
You must be signed in to change notification settings - Fork 6
/
bullet.py
45 lines (33 loc) · 1.23 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
import pygame
class Bullet(pygame.sprite.Sprite):
def __init__(self, position):
pygame.sprite.Sprite.__init__(self)
self.image = pygame.image.load("images/bullet_1.png").convert_alpha()
self.rect = self.image.get_rect()
self.rect.left,self.rect.top = position
self.speed = 12
self.active = False
self.mask = pygame.mask.from_surface(self.image)
def move(self):
self.rect.top -= self.speed
if self.rect.top < 0:
self.active = False
def reset(self,position):
self.rect.left,self.rect.top = position
self.active = True
class Bullet2(pygame.sprite.Sprite):
def __init__(self, position):
pygame.sprite.Sprite.__init__(self)
self.image = pygame.image.load("images/bullet_2.png").convert_alpha()
self.rect = self.image.get_rect()
self.rect.left,self.rect.top = position
self.speed = 14
self.active = False
self.mask = pygame.mask.from_surface(self.image)
def move(self):
self.rect.top -= self.speed
if self.rect.top < 0:
self.active = False
def reset(self,position):
self.rect.left,self.rect.top = position
self.active = True