import sys, pygame import parse pygame.init() gamemap = parse.parse_map("test.tmx") image = gamemap.tilesets[0].image width = int(gamemap.width) * int(gamemap.tilewidth) height = int(gamemap.height) * int(gamemap.tileheight) size = width, height black = 0, 0, 0 white = 255, 255, 255 screen = pygame.display.set_mode(size) image = gamemap.tilesets[0].image tileset = pygame.image.load(image.source) tiles = [] for tile in gamemap.layers[0].tiles: tiles.append(int(tile)) def calc_offset(gid, img): columns = int(img.width) / 16 rows = int(img.height) / 16 tile_count = columns * rows tileX, tileY = 0, 0 gid -= 1
# coding=utf-8 import sys, pygame import parse, rect from utils import calc_offset pygame.init() try: gamemap = parse.parse_map("collision.tmx") image = gamemap.tilesets[0].image except: print "error: skrev du in rätt filnamn?" raise width = int(gamemap.width) * int(gamemap.tilewidth) height = int(gamemap.height) * int(gamemap.tileheight) size = width, height black = 0, 0, 0 white = 255, 255, 255 screen = pygame.display.set_mode(size) image = gamemap.tilesets[0].image try: tileset = pygame.image.load(image.source) except: print "error: hittar inte bildfilen" raise tiles = [] for tile in gamemap.layers[0].tiles: