You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
47 lines
1.3 KiB
47 lines
1.3 KiB
import pygame
|
|
|
|
|
|
class Bullet1(pygame.sprite.Sprite):
|
|
def __init__(self, position):
|
|
pygame.sprite.Sprite.__init__(self)
|
|
|
|
self.image = pygame.image.load("images/bullet1.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/bullet2.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
|
|
|