'''pacmantest.py Jed Yang, 2016-10-14 Test the Pacman class we collaboratively wrote in class. ''' from graphics import * import time from random import randint from pacman import * def main(): winHeight = 300 winWidth = 500 win = GraphWin('Random Pacman', winWidth, winHeight, autoflush=False) win.setBackground(color_rgb(0,0,0)) # make lots of Pacmans and draw them in the window pacmans = [] for i in range(randint(3,7)): x = randint(0,winWidth) y = randint(0,winHeight) radius = randint(10,50) colour = color_rgb(randint(0,255), randint(0,255), randint(0,255)) velocity = randint(-10,10) pac = Pacman(x, y, radius, colour, velocity) pac.draw(win) pacmans.append(pac) print('Pacman test. Click the window to quit.') while True: # animate the Pacmans for pac in pacmans: pac.step() win.update() # must update window manually if autoflush is off if win.checkMouse(): # Why do I use checkMouse() instead of getMouse()? break time.sleep(0.02) main()