-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbomb.py
35 lines (26 loc) · 970 Bytes
/
bomb.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import pygame
class Bomb:
def __init__(self, bomb_size):
self.bomb_size = bomb_size
self.bomb_img = pygame.image.load("bomb.png")
self.bomb_img = pygame.transform.scale(self.bomb_img, (bomb_size, bomb_size))
self.block = self.bomb_img.get_rect()
self.is_cleared = False
self.x = 0
self.y = 0
def draw(self, screen, x, y):
if not self.is_cleared:
self.block.x = x
self.block.y = y
screen.blit(self.bomb_img, self.block)
def check_collision(self, mouse_position):
return self.block.collidepoint(mouse_position)
def get_color(self):
return (0,0,0) # return black which should never match with any blocks
def clear(self):
self.is_cleared = True
def copy(self):
new_bomb = Bomb(self.bomb_size)
if self.is_cleared:
new_bomb.clear()
return new_bomb