Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- all_sprites_list = pygame.sprite.Group()
- bullets = []
- bullet_list = pygame.sprite.Group()
- bullet_speed = 10
- class Bullet(pygame.sprite.Sprite):
- def __init__(self):
- super().__init__()
- self.image = pygame.Surface([4,10])
- self.image.fill(red)
- self.rect = self.image.get_rect()
- def update(self):
- if self.rect.x > chx:
- self.rect.x -= bullet_speed
- elif self.rect.x < chx:
- self.rect.x += bullet_speed
- if self.rect.y > chy:
- self.rect.y -= bullet_speed
- elif self.rect.y < chy:
- self.rect.y += bullet_speed
- if event.type == pygame.MOUSEBUTTONDOWN:
- bullet = Bullet()
- if weapon == "hg" and hg_move == True:
- bullet.rect.x = hgrect.x
- bullet.rect.y = hgrect.y
- all_sprites_list.add(bullet)
- bullet_list.add(bullet)
Add Comment
Please, Sign In to add comment