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

Function main

src/gamesbyexample/floorpainters.py:53–80  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

51
52
53def main():
54 theFloor = getNewFloor()
55 paintedAreas = set()
56
57 # Generate painters:
58 painters = []
59 for color in THE_PAINTERS:
60 painters.append(Painter(color, theFloor))
61
62 bext.fg('black')
63 bext.clear()
64 while True: # Main simulation loop.
65 for painter in painters:
66 # Keep track of the painted floors:
67 paintedAreas.add((painter.x, painter.y))
68 if len(paintedAreas) == WIDTH * HEIGHT:
69 # Move the text cursor to the bottom right so that
70 # new text doesn't overwrite our painting.
71 bext.goto(bext.width() - 1, bext.height() - 1)
72 print() # Print a newline.
73 print('Seed: {} Width: {} Height: {}'.format(SEED,
74 (WIDTH + 1) * 2, HEIGHT))
75 sys.exit() # The floor is completely painted, so quit.
76
77 painter.move()
78
79 sys.stdout.flush()
80 time.sleep(PAUSE_LENGTH)
81
82
83def getNewFloor():

Callers 1

floorpainters.pyFile · 0.70

Calls 4

getNewFloorFunction · 0.85
PainterClass · 0.85
clearMethod · 0.80
moveMethod · 0.80

Tested by

no test coverage detected