MCPcopy Create free account
hub / github.com/asweigart/PythonStdioGames / displayLevel

Function displayLevel

src/gamesbyexample/sokoban.py:192–207  ·  view source on GitHub ↗
(levelNum, maxLevelNum, levelData)

Source from the content-addressed store, hash-verified

190
191
192def displayLevel(levelNum, maxLevelNum, levelData):
193 # Draw the current level.
194 solvedCrates = 0
195 unsolvedCrates = 0
196 print('Level #' + str(levelNum + 1), 'of', maxLevelNum)
197 for y in range(levelData[HEIGHT]):
198 for x in range(levelData[WIDTH]):
199 if levelData.get((x, y), EMPTY) == CRATE:
200 unsolvedCrates += 1
201 elif levelData.get((x, y), EMPTY) == CRATE_ON_GOAL:
202 solvedCrates += 1
203 prettyChar = CHAR_MAP[levelData.get((x, y), EMPTY)]
204 print(prettyChar, end='')
205 print()
206 totalCrates = unsolvedCrates + solvedCrates
207 print(solvedCrates, '/', totalCrates, 'solved.')
208
209
210def askForPlayerMove(maxLevelNum):

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected