-
Notifications
You must be signed in to change notification settings - Fork 0
/
level.py
44 lines (36 loc) · 1.33 KB
/
level.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
from settings import *
from player import Player
from player2 import Player2
from tile import Tile
from checkpoint import CheckPoint
class Level:
def __init__(self):
# groups
self.collision_sprites = pygame.sprite.Group()
self.visible_sprites = pygame.sprite.Group()
self.enemy_sprites = pygame.sprite.Group()
self.check_points = pygame.sprite.Group()
# basic setup
self.screen = pygame.display.get_surface()
self.create_map()
def create_map(self):
for col_number,col in enumerate(LEVEL_MAP):
for row_number,row in enumerate(col):
y = col_number * TILE_SIZE
x = row_number * TILE_SIZE
if row == 'C':
CheckPoint((x,y),[self.check_points],'green')
if row == 'P':
self.player = Player((x,y),[self.visible_sprites],self.collision_sprites,self.enemy_sprites,self.check_points)
if row == '2':
self.player2 = Player2((x,y),[self.visible_sprites],self.collision_sprites,self.enemy_sprites,self.check_points)
if row == 'X':
Tile((x,y),[self.visible_sprites,self.collision_sprites],'grey')
if row == 'G':
Tile((x,y),[self.visible_sprites,self.collision_sprites],'yellow')
if row == 'E':
Tile((x,y),[self.visible_sprites,self.enemy_sprites],'red')
def run(self):
self.check_points.draw(self.screen)
self.visible_sprites.draw(self.screen)
self.visible_sprites.update()