-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtiles.py
51 lines (40 loc) · 1.31 KB
/
tiles.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import pygame
import random
class Tile(pygame.sprite.Sprite):
def __init__(self, path, pos):
super().__init__()
self.path = path
self.image = pygame.image.load(path)
self.rect = self.image.get_rect()
self.rect.topleft = pos
def save(self):
self.image = None
def load(self):
self.image = pygame.image.load(self.path)
class Door(Tile):
def __init__(self, images, pos, unlocked):
super().__init__(images[unlocked], pos)
self.images = images
self.unlocked = unlocked
def unlock(self):
self.unlocked = True
self.image = pygame.image.load(self.images[self.unlocked])
def load(self):
self.image = pygame.image.load(self.images[self.unlocked])
class Chest(Tile):
def __init__(self, image, pos):
super().__init__(image, pos)
def give_bonus(self, player):
num = random.randint(1, 3)
self.kill()
if num == 1:
inc = random.randint(3, 7)
player.health += inc
return "+{} Health Bonus".format(inc)
elif num == 2:
inc = random.randint(1, 3)
player.attack_damage += inc
return "+{} Attack Bonus".format(inc)
elif num == 3:
player.defense += 1
return "+1 Damage Bonus"