Repciu

Untitled

Dec 13th, 2023
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. import pygame
  2. import copy
  3. class Klocek(pygame.sprite.Sprite):
  4. def __init__(self, x, y, zycie):
  5. super(Klocek, self).__init__()
  6. self.oryginalny_obraz = pygame.image.load("images/brick.png")
  7. self.pozycja = pygame.Rect(x, y, 96, 48)
  8. self.zycie = zycie
  9.  
  10. def aktualizuj(self):
  11. maska_koloru = 0
  12. if self.zycie == 3:
  13. maska_koloru = (128,0,0)
  14. if self.zycie == 2:
  15. maska_koloru = (0,128,0)
  16. if self.zycie == 1:
  17. maska_koloru = (0,0,128)
  18. self.obraz = copy.copy(self.oryginalny_obraz)
  19. self.obraz.fill(maska_koloru, special_flags=pygame.BLEND_ADD)
  20.  
  21. def update(self):
  22. self.aktualizuj()
  23.  
  24. def uderzenie(self):
  25. self.zycie -= 1
  26. if self.zycie <= 0:
  27. self.kill()
Advertisement
Add Comment
Please, Sign In to add comment