-
Notifications
You must be signed in to change notification settings - Fork 0
/
scenery.py
80 lines (68 loc) · 2.57 KB
/
scenery.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
import pygame
from settings import *
class Map:
def __init__(self):
self.data = []
with open("settings/map.txt", 'rt') as file:
for line in file:
self.data.append(line.strip())
self.tile_width = len(self.data[0])
self.tile_height = len(self.data)
self.width = self.tile_width * TILESIZE
self.height = self.tile_height * TILESIZE
class Tile(pygame.sprite.Sprite):
def __init__(self, x, y):
pygame.sprite.Sprite.__init__(self)
self.image = pygame.Surface((TILESIZE, TILESIZE))
self.image.set_alpha(0) # 0-255
self.rect = self.image.get_rect()
self.x = x
self.y = y
self.rect.x = x * TILESIZE
self.rect.y = y * TILESIZE
def draw(self, window):
window.blit(self.image, (self.rect.x, self.rect.y))
class Limit(Tile):
def __init__(self, x, y):
super().__init__(x, y)
class Stone(Tile):
def __init__(self, x, y):
super().__init__(x, y)
self.image = pygame.image.load('assets/objects/Brick_01.png')
self.image = pygame.transform.scale(self.image, (27,27))
self.image.set_alpha(255)
class Final(Tile):
def __init__(self, x, y):
super().__init__(x, y)
self.image.set_alpha(255)
class Greenery(Tile):
def __init__(self, x, y):
super().__init__(x, y)
self.image = pygame.image.load('assets/objects/greenery_2.png')
self.image = pygame.transform.scale(self.image, (28,44))
self.image.set_alpha(255)
class Plaque(Tile):
def __init__(self, x, y):
super().__init__(x, y)
self.image = pygame.image.load('assets/objects/Sign_01.png')
self.image = pygame.transform.scale(self.image, (33,33))
self.image.set_alpha(255)
class Barrel(Tile):
def __init__(self, x, y):
super().__init__(x, y)
self.image = pygame.image.load('assets/objects/decor_17.png')
self.image = pygame.transform.scale(self.image, (22,24))
self.image.set_alpha(255)
class Statue(Tile):
def __init__(self, x, y):
super().__init__(x, y)
self.image = pygame.image.load('assets/objects/Decor_Statue.png')
self.image = pygame.transform.scale(self.image, (60,60))
self.image.set_alpha(255)
class Goblin(Tile):
def __init__(self, x, y):
super().__init__(x, y)
self.image = pygame.image.load('assets/goblin/goblin_11.png')
self.image = pygame.transform.flip(self.image, True, False)
self.image = pygame.transform.scale(self.image, (160,160))
self.image.set_alpha(255)