-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtileset.py
More file actions
30 lines (23 loc) · 849 Bytes
/
Copy pathtileset.py
File metadata and controls
30 lines (23 loc) · 849 Bytes
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
from pygame.locals import *
from tile import Tile
class tileSet(object):
def __init__(self, tileset):
super(tileSet, self).__init__()
self.tileset = tileset
self.dictTileSet = dict()
self.dicttTile = dict()
def load_tile_table(self, width, height):
image = pygame.image.load(self.tileset).convert_alpha()
image_width, image_height = image.get_size()
i=0
for tile_x in range(0, image_width/width):
for tile_y in range(0, image_height/height):
rect = (tile_x*width, tile_y*height, width, height)
self.dictTileSet[i]=(image.subsurface(rect))
i = i+1
def genererDicoTile(self):
self.dicttTile[0] = Tile(False, self.dictTileSet[26])
self.dicttTile[1] = Tile(True, self.dictTileSet[22])
self.dicttTile[4] = Tile(False, self.dictTileSet[36])
return self.dicttTile