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

Function getPlayerBlobPoints

inprogress/stickyhands.py:78–101  ·  view source on GitHub ↗
(levelData, playerx, playery)

Source from the content-addressed store, hash-verified

76 print()
77
78def getPlayerBlobPoints(levelData, playerx, playery):
79 playerBlob = [(playerx, playery)]
80 pointsToCheck = [(playerx, playery)]
81 alreadyCheckedPoints = []
82
83 while len(pointsToCheck) > 0:
84 x, y = pointsToCheck.pop()
85
86 alreadyCheckedPoints.append((x, y))
87
88 if (x - 1, y) not in alreadyCheckedPoints and levelData[(x - 1, y)] == '$':
89 playerBlob.append((x - 1, y))
90 pointsToCheck.append((x - 1, y))
91 if (x + 1, y) not in alreadyCheckedPoints and levelData[(x + 1, y)] == '$':
92 playerBlob.append((x + 1, y))
93 pointsToCheck.append((x + 1, y))
94 if (x, y - 1) not in alreadyCheckedPoints and levelData[(x, y - 1)] == '$':
95 playerBlob.append((x, y - 1))
96 pointsToCheck.append((x, y - 1))
97 if (x, y + 1) not in alreadyCheckedPoints and levelData[(x, y + 1)] == '$':
98 playerBlob.append((x, y + 1))
99 pointsToCheck.append((x, y + 1))
100
101 return playerBlob
102
103
104

Callers 1

stickyhands.pyFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected