Skip to content

Instantly share code, notes, and snippets.

@olymk2
Created June 23, 2016 20:30
Show Gist options
  • Save olymk2/0f4925272c8c988cc8abccbdc4287b79 to your computer and use it in GitHub Desktop.
Save olymk2/0f4925272c8c988cc8abccbdc4287b79 to your computer and use it in GitHub Desktop.
example pygame generator
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