-
Notifications
You must be signed in to change notification settings - Fork 0
/
house.py
30 lines (26 loc) · 909 Bytes
/
house.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
import pygame as pg
from pygame.sprite import spritecollide
from block import Block
class House(Block):
def __init__(self, pos, harvestable_group, mob_group,
house_group):
super().__init__()
self.name = "House"
self.image = './images/house4.png'
self.boom = './sounds/boom.ogg'
self.setImage(self.image)
self.setSize()
self.setPosition(pos)
if spritecollide(self, harvestable_group, False):
self = None
elif spritecollide(self, mob_group, True):
house_group.add(self) # Drop a house on a mob to kill it
pg.mixer.Sound(self.boom).play()
elif spritecollide(self, house_group, False):
self = None
else:
house_group.add(self)
def setPosition(self, pos):
self.rect.topleft = pos
def __repr__(self):
return self.name