Created
June 23, 2016 20:30
-
-
Save olymk2/0f4925272c8c988cc8abccbdc4287b79 to your computer and use it in GitHub Desktop.
example pygame generator
This file contains hidden or 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
def fetch_tiles(startColumn, endColumn, rows=20): | |
tilesToDraw = tiles[0:rows, startColumn:endColumn] | |
for rowCount, row in enumerate(tilesToDraw): | |
for columnCount, column in enumerate(row): | |
yield rowCount, columnCount | |
# Draw the tile array to the screen | |
def drawScreenTiles(tiles, pixelsScrolled, levelPosition): | |
startColumn = levelPosition / tileSize | |
endColumn = startColumn + (screenWidth / tileSize) + 1 | |
tilesToDraw = tiles[0:20, startColumn:endColumn] | |
print(startColumn) | |
print(endColumn) | |
for rowCount, columnCount in fetch_tiles(startColumn, endColumn): | |
screen.blit(spriteSheet, (columnCount * tileSize - pixelsScrolled, rowCount * tileSize), getTile(62)) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment