Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import pygame
- import copy
- class Brick(pygame.sprite.Sprite):
- def __init__(self, x, y, hp):
- super(Brick, self).__init__()
- self.surfOrig = pygame.image.load("images/brick.png")
- #self.surf = pygame.image.load("images/brick.png")
- self.rect = pygame.Rect(x, y, 96, 48)
- self.hp = hp
- #aktualizacja
- def update(self):
- mask = 0
- if self.hp == 3:
- mask = (128, 0, 0)
- if self.hp == 2:
- mask = (0, 0, 128)
- if self.hp == 1:
- mask = (0, 128, 0)
- self.surf = copy.copy(self.surfOrig)
- self.surf.fill(mask, special_flags=pygame.BLEND_ADD)
- #funkcja wywolywana podczas zderzenia z kulka
- def hit(self):
- self.hp -= 1
- if self.hp <= 0:
- self.kill()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement