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

Function main

src/gamesbyexample/fishtank.py:60–93  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

58
59
60def main():
61 global FISHES, BUBBLERS, BUBBLES, KELPS, STEP
62 bext.bg('black')
63 bext.clear()
64
65 # Generate the global variables:
66 FISHES = []
67 for i in range(NUM_FISH):
68 FISHES.append(generateFish())
69
70 # NOTE: Bubbles are drawn, but not the bubblers themselves.
71 BUBBLERS = []
72 for i in range(NUM_BUBBLERS):
73 # Each bubbler starts at a random position.
74 BUBBLERS.append(random.randint(LEFT_EDGE, RIGHT_EDGE))
75 BUBBLES = []
76
77 KELPS = []
78 for i in range(NUM_KELP):
79 kelpx = random.randint(LEFT_EDGE, RIGHT_EDGE)
80 kelp = {'x': kelpx, 'segments': []}
81 # Generate each segment of the kelp:
82 for i in range(random.randint(6, HEIGHT - 1)):
83 kelp['segments'].append(random.choice(['(', ')']))
84 KELPS.append(kelp)
85
86 # Run the simulation:
87 STEP = 1
88 while True:
89 simulateAquarium()
90 drawAquarium()
91 time.sleep(1 / FRAMES_PER_SECOND)
92 clearAquarium()
93 STEP += 1
94
95
96def getRandomColor():

Callers 1

fishtank.pyFile · 0.70

Calls 5

generateFishFunction · 0.85
simulateAquariumFunction · 0.85
drawAquariumFunction · 0.85
clearAquariumFunction · 0.85
clearMethod · 0.80

Tested by

no test coverage detected