Guest User

Untitled

a guest
Jan 23rd, 2019
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. all_sprites_list = pygame.sprite.Group()
  2.  
  3. bullets = []
  4. bullet_list = pygame.sprite.Group()
  5. bullet_speed = 10
  6.  
  7. class Bullet(pygame.sprite.Sprite):
  8. def __init__(self):
  9. super().__init__()
  10.  
  11. self.image = pygame.Surface([4,10])
  12. self.image.fill(red)
  13. self.rect = self.image.get_rect()
  14.  
  15.  
  16. def update(self):
  17. if self.rect.x > chx:
  18. self.rect.x -= bullet_speed
  19. elif self.rect.x < chx:
  20. self.rect.x += bullet_speed
  21. if self.rect.y > chy:
  22. self.rect.y -= bullet_speed
  23. elif self.rect.y < chy:
  24. self.rect.y += bullet_speed
  25.  
  26. if event.type == pygame.MOUSEBUTTONDOWN:
  27. bullet = Bullet()
  28. if weapon == "hg" and hg_move == True:
  29. bullet.rect.x = hgrect.x
  30. bullet.rect.y = hgrect.y
  31. all_sprites_list.add(bullet)
  32. bullet_list.add(bullet)
Add Comment
Please, Sign In to add comment