def render(board): global tilePath tileset.tilePath = tilePath windowX = board['width'] * 32 windowY = board['height'] * 32 window = pygame.display.set_mode((windowX, windowY)) pygame.display.set_caption(board['filename'] + ' - ' + str(board['width']) + 'x' + str(board['height'])) screen = pygame.display.get_surface() screen.fill((0,0,0)) offsetX = 0 offsetY = 0 tilesets = dict() x = 0 y = 0 renderedTiles = 0 for layer in board['tileData']: for yData in layer: for xData in yData: tile = xData if tile > 0 and tile < len(board['tilesets']) and board['tilesets'][tile] != '': data = getTileData(board['tilesets'][tile]) if data != False: if data['file'] not in tilesets.keys(): tilesets[data['file']] = tileset.load(data['file']) renderer.renderTile(screen, tilesets[data['file']], data['tile'] - 1, x*32, y*32) renderedTiles += 1 x += 1 y += 1 x = 0 y = 0 x = 0 pygame.display.update()
# coding=UTF-8 import os, sys, pygame import formats.tileset as tileset import renderers.tilesetRenderer as renderer # Tell the tileset format loader which path to use for loading tilesets: tileset.tilePath = os.path.realpath('../testFiles/tiles/') + '/' # Load the tileset file: testBoard = tileset.load('RPGMaker951.tst') # Initialise pygame: pygame.init() # Render the tileset: renderer.render(testBoard) # Pygame event loop: clock = pygame.time.Clock() while True: clock.tick(60) for event in pygame.event.get(): if event.type == pygame.QUIT: sys.exit(0)