def tileGetClipData(self, tileIndex, tl=None, t=None): if tileIndex == None: topleft = tl type = t else: topleft = self.tiles[tileIndex][0] type = self.tiles[tileIndex][1] locale = 0 ABOVE = 1 LEFT = 2 RIGHT = 4 baseIndex = self.tileGetBaseIndex(type) for tile in self.tiles: if not type & 4: # Check for tiles above if tile[1] & 1: aboveHeight = 12 else: aboveHeight = 4 xRange = range(topleft[0], topleft[0] + TILE_WIDTH) yRange = range(topleft[1] - 1, topleft[1] + 1) if (tile[0][1] + aboveHeight in yRange) and ((tile[0][0] in xRange) or (tile[0][0] + TILE_WIDTH - 1 in xRange)): if not locale & ABOVE: locale += ABOVE if not type & 8: # Check for tiles of the same type to the left and right if type & COMBINE_FLAG: if tile[1] == type: if tile[0] == (topleft[0] - TILE_WIDTH, topleft[1]): locale += LEFT elif tile[0] == (topleft[0] + TILE_WIDTH, topleft[1]): locale += RIGHT index = baseIndex if locale & ABOVE: if (locale & LEFT) and (locale & RIGHT): index += 6 elif locale & LEFT: index += 7 elif locale & RIGHT: index += 5 else: index += 1 else: if type & 4: if (locale & LEFT) and (locale & RIGHT): index += 2 elif locale & LEFT: index += 3 elif locale & RIGHT: index += 1 else: if (locale & LEFT) and (locale & RIGHT): index += 3 elif locale & LEFT: index += 4 elif locale & RIGHT: index += 2 if (locale & ABOVE) or (type & 4) or (type & 8): addPip = False else: addPip = True return index, addPip