-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtilemap.py
More file actions
36 lines (32 loc) · 1.32 KB
/
tilemap.py
File metadata and controls
36 lines (32 loc) · 1.32 KB
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
import pygame
from pygame.locals import *
from tile import Tile
class tileMap(object):
"""docstring for tileMap"""
def __init__(self, listMatrix, dicoTile, fenetre):
super(tileMap, self).__init__()
self.tileMap = listMatrix
self.dicoTile = dicoTile
self.screen = fenetre
for x in range(len(self.tileMap)):
for height in range(len(self.tileMap[x])):
for width in range(len(self.tileMap[x][height])):
if self.tileMap[x][height][width] == '0':
surfaceC = self.dicoTile[0].getSurface().copy()
tile = Tile(False, surfaceC)
self.tileMap[x][height][width] = tile
elif self.tileMap[x][height][width] == '1':
surfaceC = self.dicoTile[1].getSurface().copy()
tile = Tile(True, surfaceC)
self.tileMap[x][height][width] = tile
elif self.tileMap[x][height][width] == '4':
surfaceC = self.dicoTile[4].getSurface().copy()
tile = Tile(False, surfaceC)
self.tileMap[x][height][width] = tile
def mapRender(self, camera):
for x in range(len(self.tileMap)):
for height in range(len(self.tileMap[x])):
for width in range(len(self.tileMap[x][height])):
self.tileMap[x][height][width].draw(self.screen, camera.apply(self.tileMap[x][height][width].setPositionAndGet(width*48, height*48)))
def getTile(self, posY, posX):
return self.tileMap[1][posY/48][posX/48]