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

Method display

src/gamesbyexample/zombiebitefight.py:120–144  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

118
119
120 def display(self):
121 for zombie in self.zombies:
122 bext.goto(zombie._x, zombie._y)
123 bext.fg(zombie.color)
124 # Display the zombie's text character:
125 if zombie.direction == NORTH:
126 print(FACE_UP, end='')
127 elif zombie.direction == SOUTH:
128 print(FACE_DOWN, end='')
129 elif zombie.direction == EAST:
130 print(FACE_RIGHT, end='')
131 elif zombie.direction == WEST:
132 print(FACE_LEFT, end='')
133
134 # Display a count of each kind of zombie:
135 # TODO - potential bug - erase full first
136 bext.goto(0, HEIGHT)
137 count = {}
138 for zombie in self.zombies:
139 count.setdefault(zombie.__class__, 0)
140 count[zombie.__class__] += 1
141 for zombieType in sorted(count.keys(), key=lambda x: x.__name__):
142 bext.fg(zombieType.color)
143 print(zombieType.__name__ + ': ' + str(count[zombieType]) + ' ', end='')
144 print('', flush=True)
145
146 def runSimulation(self):
147 try:

Callers 1

runSimulationStepMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected