Created
August 2, 2016 22:01
-
-
Save spiiin/dfabd3cd7554c1bc0bdb1c0133e723b4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from operator import itemgetter | |
NAME_TABLE_SIZE = 960 | |
def getAllScreenBlocks(tiles): | |
#функция выбора индексов блока | |
def getNextItem2x2(firstIndex, maxIndex): | |
i = firstIndex | |
while i < maxIndex: | |
for x in xrange(16): | |
yield i | |
i += 2 | |
i += 32 | |
#ограничиваем генератор индексов размером Name Table | |
getNextFromPage = lambda fi : getNextItem2x2(fi, NAME_TABLE_SIZE) | |
#начальные индексы тайлов в блоке | |
startIndexes = (0,1,32,33) | |
#создаём генератор индексов блоков | |
blockIndexesIters = [getNextFromPage(x) for x in startIndexes] | |
#выбираем индексы блоков | |
blocksIndexes = zip(*blockIndexesIters) | |
#получаем номера тайлов блоков по их индексам | |
blocks = [itemgetter(*b)(tiles) for b in blocksIndexes] | |
return blocks |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment