| 76 | print() |
| 77 | |
| 78 | def 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 | |