Пример #1
0
    def __init__(self):
        pygame.init()
        self.screen = pygame.display.set_mode((735, 800))
        pygame.display.set_caption("Pac-man")
        self.settings = Settings()

        self.radius = 1
        self.start = 2
        self.end = 10
        self.begin = pygame.time.get_ticks()
        self.wait = 800

        self.stats = Stats(self.settings)

        self.pb = Button(self.screen)

        self.maze = Maze(self.screen, 'images/maze.txt', 'images/cube0.png',
                         'images/gate0.png', 'images/dot0.png')

        self.sb = Scoreboard(self.settings, self.screen, self.stats, self.maze,
                             self.pb)

        self.player = Player(self.settings, self.screen, self.stats, self.sb,
                             self.maze)
        self.red = Red(self.screen, self.stats, self.player, self.sb,
                       self.maze)
        self.blue = Blue(self.screen, self.stats, self.player)
        self.orange = Orange(self.screen, self.stats, self.player)
        self.pink = Pink(self.screen, self.stats, self.player)

        self.menu = Menu(self.screen, self.stats, self.sb, self.pb, self.maze)
Пример #2
0
    def create_ghost(self):
        self.red = Red(self.screen, self.stats, self.pacman, self.sb,
                       self.maze)

        self.red.centerx = self.screen_rect.left - 100
        self.red.rect.centery = self.screen_rect.centery

        self.red.index = 4

        self.blue = Blue(self.screen, self.stats, self.pacman)

        self.blue.centerx = self.screen_rect.left - 125
        self.blue.rect.centery = self.screen_rect.centery

        self.blue.index = 4

        self.orange = Orange(self.screen, self.stats, self.pacman)

        self.orange.centerx = self.screen_rect.left - 150
        self.orange.rect.centery = self.screen_rect.centery

        self.orange.index = 4

        self.pink = Pink(self.screen, self.stats, self.pacman)

        self.pink.centerx = self.screen_rect.left - 175
        self.pink.rect.centery = self.screen_rect.centery

        self.pink.index = 4
Пример #3
0
    def __init__(self):
        pygame.init()
        pygame.mixer.pre_init(44100, 16, 2, 4096)
        self.settings = Settings()
        self.settings.start_intro_music()
        self.screen = pygame.display.set_mode((self.settings.screen_width, self.settings.screen_height))
        pygame.display.set_caption("Pacman Portal")
        self.clock = pygame.time.Clock()
        self.radius = 1
        self.start = 1
        self.end = 10
        self.begin = pygame.time.get_ticks()
        self.wait = 800

        self.startup = Start(self.screen, self.settings)
        self.stats = Stats(self.settings)
        self.sb = Scoreboard(self.settings, self.screen, self.stats)

        self.maze = Maze(self.screen, mazefile='images/pacman_portal_maze.txt',
                         brickfile='square', orangeportalfile='portal_orange', blueportalfile='portal_blue',
                         shieldfile='shield', pointfile='point_pill', gatefile="gate")
        self.pacman = Pacman(self.screen, mazefile='images/pacman_portal_maze.txt')

        self.red = Red(self.screen, mazefile='images/pacman_portal_maze.txt')
        self.blue = Blue(self.screen, mazefile='images/pacman_portal_maze.txt')
        self.orange = Orange(self.screen, mazefile='images/pacman_portal_maze.txt')
        self.pink = Pink(self.screen, mazefile='images/pacman_portal_maze.txt')
        self.inc = 0
Пример #4
0
    def test_valassi5(self):
        bluesolver = Blue("valassi5.txt")
        printout = self.__getprintResults(bluesolver)
        expectedprintout = "\n Results:\n\
\n\
 Chi^2= 1.23 for 2 d.o.f, chi^2/d.o.f= 0.62, P(chi^2)= 0.5404\n\
\n\
   Average:    10.6377    11.1358 \n\
\n\
Error composition:\n\
      stat:     0.8636     0.8963 \n\
       exp:     0.2714     0.2820 \n\
      syst:     0.2714     0.2820 \n\
     total:     0.9053     0.9397 \n\
\n\
 Variables:        BeA        BeB      BtauA      BtauB \n\
 Weights a:     0.8195     0.1805     0.0897    -0.0897 \n\
 Weights b:     0.8076    -0.8076     0.0981     0.9019 \n\
     Pulls:    -0.1377     0.9549    -0.5453     0.9556 \n\
\n\
Correlations:\n\
 1.000  0.949 \n\
 0.949  1.000 \n"

        self.assertEqual(printout, expectedprintout)
        return
Пример #5
0
    def test_valassi4(self):
        bluesolver = Blue("valassi4.txt")
        printout = self.__getprintResults(bluesolver)
        expectedprintout = "\n Results:\n\
\n\
 Chi^2= 6.07 for 2 d.o.f, chi^2/d.o.f= 3.04, P(chi^2)= 0.0480\n\
\n\
   Average:    11.4448    15.9803 \n\
\n\
Error composition:\n\
      stat:     0.9053     0.9404 \n\
      syst:     0.0000     0.0000 \n\
     total:     0.9053     0.9404 \n\
\n\
 Variables:        BeA        BeB      BtauA      BtauB \n\
 Weights a:     0.8197     0.1803    -0.0897     0.0897 \n\
 Weights b:    -0.8075     0.8075     0.0983     0.9017 \n\
     Pulls:    -0.9448     0.6851    -2.1601    -0.6601 \n\
\n\
Correlations:\n\
 1.000 -0.948 \n\
-0.948  1.000 \n"

        self.assertEqual(printout, expectedprintout)
        return
Пример #6
0
    def test_valassi3(self):
        bluesolver = Blue("valassi3.txt")
        printout = self.__getprintResults(bluesolver)
        expectedprintout = "\n Results:\n\
\n\
 Chi^2= 1.23 for 2 d.o.f, chi^2/d.o.f= 0.61, P(chi^2)= 0.5408\n\
\n\
   Average:    10.6373    11.1353 \n\
\n\
Error composition:\n\
      stat:     0.9053     0.9404 \n\
      syst:     0.0000     0.0000 \n\
     total:     0.9053     0.9404 \n\
\n\
 Variables:        BeA        BeB      BtauA      BtauB \n\
 Weights a:     0.8197     0.1803     0.0897    -0.0897 \n\
 Weights b:     0.8075    -0.8075     0.0983     0.9017 \n\
     Pulls:    -0.1373     0.9542    -0.5451     0.9549 \n\
\n\
Correlations:\n\
 1.000  0.948 \n\
 0.948  1.000 \n"

        self.assertEqual(printout, expectedprintout)
        return
Пример #7
0
    def test_valassi2(self):
        bluesolver = Blue("valassi2.txt")
        printout = self.__getprintResults(bluesolver)
        expectedprintout = "\n Results:\n\
\n\
 Chi^2= 2.11 for 2 d.o.f, chi^2/d.o.f= 1.06, P(chi^2)= 0.3475\n\
\n\
   Average:    10.6813    11.7500 \n\
\n\
Error composition:\n\
      stat:     0.9832     2.1213 \n\
      syst:     0.0000     0.0000 \n\
     total:     0.9832     2.1213 \n\
\n\
 Variables:        BeA        BeB      BtauA      BtauB \n\
 Weights a:     0.9396     0.0604     0.0000     0.0000 \n\
 Weights b:     0.0000     0.0000     0.5000     0.5000 \n\
     Pulls:    -0.1813     0.9396    -0.7500     0.7500 \n\
\n\
Correlations:\n\
 1.000  0.000 \n\
 0.000  1.000 \n"

        self.assertEqual(printout, expectedprintout)
        return
Пример #8
0
    def test_valassi1(self):
        bluesolver = Blue("valassi1.txt")
        printout = self.__getprintResults(bluesolver)
        expectedprintout = "\n Results:\n\
\n\
 Chi^2= 2.02 for 2 d.o.f, chi^2/d.o.f= 1.01, P(chi^2)= 0.3633\n\
\n\
   Average:    10.8000    11.7500 \n\
\n\
Error composition:\n\
      stat:     0.9487     2.1213 \n\
      syst:     0.0000     0.0000 \n\
     total:     0.9487     2.1213 \n\
\n\
 Variables:        BeA        BeB      BtauA      BtauB \n\
 Weights a:     0.9000     0.1000     0.0000     0.0000 \n\
 Weights b:     0.0000     0.0000     0.5000     0.5000 \n\
     Pulls:    -0.3000     0.9000    -0.7500     0.7500 \n\
\n\
Correlations:\n\
 1.000  0.000 \n\
 0.000  1.000 \n"

        self.assertEqual(printout, expectedprintout)
        return
Пример #9
0
    def test_valassi6(self):
        bluesolver = Blue("valassi6.txt")
        printout = self.__getprintResults(bluesolver)
        expectedprintout = "\n Results:\n\
\n\
 Chi^2= 6.08 for 2 d.o.f, chi^2/d.o.f= 3.04, P(chi^2)= 0.0479\n\
\n\
   Average:    11.4453    15.9812 \n\
\n\
Error composition:\n\
      stat:     0.8636     0.8963 \n\
       exp:     0.2714     0.2820 \n\
      syst:     0.2714     0.2820 \n\
     total:     0.9053     0.9397 \n\
\n\
 Variables:        BeA        BeB      BtauA      BtauB \n\
 Weights a:     0.8195     0.1805    -0.0897     0.0897 \n\
 Weights b:    -0.8076     0.8076     0.0981     0.9019 \n\
     Pulls:    -0.9453     0.6855    -2.1604    -0.6610 \n\
\n\
Correlations:\n\
 1.000 -0.949 \n\
-0.949  1.000 \n"

        self.assertEqual(printout, expectedprintout)
        return
Пример #10
0
    def get_color(self, color_name):
        if color_name == "blue":
            return Blue()
        if color_name == "red":
            return Red()
        if color_name == "green":
            return Green()

        print("Unknown color")

        return None
Пример #11
0
    def test_valassi7( self ):
        bluesolver= Blue( "valassi7.txt" )
        printout= self.__getprintResults( bluesolver )
        expectedprintout= "\n Results:\n\
\n\
 Chi^2= 2.20 for 3 d.o.f, chi^2/d.o.f= 0.73, P(chi^2)= 0.5329\n\
\n\
   Average:    10.9592\n\
\n\
Error composition:\n\
      stat:     0.7907\n\
       exp:     0.3529\n\
      syst:     0.3529\n\
     total:     0.8659\n\
\n\
 Variables:        BeA        BeB      BtauA      BtauB\n\
   Weights:     0.7498     0.0835     0.0833     0.0835\n\
     Pulls:    -0.4592     0.8477    -0.4864     1.0145\n"
        self.assertEqual( printout, expectedprintout )
        return
Пример #12
0
 def setUp(self):
     self.__blue = Blue("test.txt")
     return
Пример #13
0
 def setUp( self ):
     self.__blue= Blue( "test.txt" )
     return
Пример #14
0
class blueTest( unittest.TestCase ):

    def setUp( self ):
        self.__blue= Blue( "test.txt" )
        return

    def test_calcAverage( self ):
        value= self.__blue.calcAverage()
        expectedvalue= 170.70919692
        self.assertAlmostEqual( value, expectedvalue )
        return

    def test_calcWeights( self ):
        wm= self.__blue.calcWeightsMatrix()
        weights= wm.ravel().tolist()[0]
        expectedweights= [ 1.3390306603614366, -0.16163492961906992, 
                           -0.17739573074236697 ]
        for weight, expectedweight in zip( weights, expectedweights ):
            self.assertAlmostEqual( weight, expectedweight )
        return

    def test_calcChisq( self ):
        chisq= self.__blue.calcChisq()
        expectedchisq= 0.770025093468
        self.assertAlmostEqual( chisq, expectedchisq )
        return

    def test_errorAnalysis( self ):
        herrors, wm= self.__blue.errorAnalysis()
        keys= herrors.keys()
        expectedherrors= { '00stat': 0.4114006127938109, 
                           '01err1': 1.132605331048375, 
                           '02err2': 0.62562331148619099,
                           '03err3': 2.5071108260136228, 
                           '04err4': 0.82049571716089753, 
                           'syst': 2.9381996663923697, 
                           'systcov': 2.9381996663923693, 
                           'total': 2.9668615983552984, 
                           'totalcov': 2.9668615983552984 }
        expectedkeys= expectedherrors.keys()
        self.assertEqual( sorted(keys), sorted(expectedkeys) )
        for key in keys:
            error= sqrt( herrors[key] )
            self.assertAlmostEqual( error, expectedherrors[key] )
        return

    def test_printResults( self ):
        import StringIO, sys
        output= StringIO.StringIO()
        sys.stdout= output
        self.__blue.printResults()
        self.__blue.printErrorsAndWeights( True )
        sys.stdout= sys.__stdout__
        printout= output.getvalue()
        expectedprintout= "\n Results:\n\
\n\
 Chi^2= 0.77 for 2 d.o.f, chi^2/d.o.f= 0.39, P(chi^2)= 0.6804\n\
\n\
   Average:   170.7092\n\
\n\
Error composition:\n\
            +/- errors   dI/df/I offd. sums\n\
      stat:     0.4114     0.000\n\
      err1:     1.1326     0.114\n\
      err2:     0.6256     0.140\n\
      err3:     2.5071     0.532\n\
      err4:     0.8205     0.387\n\
      syst:     2.9382\n\
     total:     2.9669\n\
\n\
 Variables:       Val1       Val2       Val3\n\
   Weights:     1.3390    -0.1616    -0.1774\n\
  DeltaI/I:     0.8954     0.3989     0.3019    -0.5962\n\
     Pulls:     0.2522     0.5089     0.7020\n\
\n\
 dI/df/I offdiagonals per error source:\n\
      err1:\n\
           Val2    Val3\n\
   Val1  0.0595  0.0653\n\
   Val2         -0.0110\n\
\n\
      err2:\n\
           Val2    Val3\n\
   Val1  0.0664  0.0923\n\
   Val2         -0.0186\n\
\n\
      err3:\n\
           Val2    Val3\n\
   Val1  0.2833  0.3109\n\
   Val2         -0.0626\n\
\n\
      err4:\n\
           Val2    Val3\n\
   Val1  0.1997  0.2494\n\
   Val2         -0.0623\n\
\n\
     total:\n\
           Val2    Val3\n\
   Val1  0.6088  0.7178\n\
   Val2         -0.1545\n\n"
        self.assertEqual( printout, expectedprintout )
        return
Пример #15
0
class Menu:
    def __init__(self, screen, stats, sb, play_button, maze):
        self.settings = Settings()
        self.screen = screen
        self.screen_rect = screen.get_rect()
        self.button = play_button
        self.stats = stats
        self.sb = sb

        self.maze = maze

        self.menu_color = (0, 0, 0)
        self.text_color = (250, 250, 210)
        self.font = pygame.font.SysFont(None, 150)

        self.title = "Pac-man"

        self.prep_screen()

    def prep_screen(self):
        self.title_image = self.font.render(self.title, True, self.text_color,
                                            self.menu_color)
        self.title_image_rect = self.title_image.get_rect()
        self.title_image_rect.centerx = self.screen_rect.centerx
        self.title_image_rect.centery = self.screen_rect.top + 100

        self.create_pacman()
        self.create_ghost()

    def draw_menu(self):
        self.screen.fill((0, 0, 0))
        self.screen.blit(self.title_image, self.title_image_rect)
        self.button.draw_button()
        self.animate_pacman()
        self.animate_ghost()

    def create_pacman(self):
        self.pacman = Player(self.settings, self.screen, self.stats, self.sb,
                             self.maze)

        self.pacman.centerx = self.screen_rect.left
        self.pacman.rect.centery = self.screen_rect.centery

        self.pacman.index = 4

    def create_ghost(self):
        self.red = Red(self.screen, self.stats, self.pacman, self.sb,
                       self.maze)

        self.red.centerx = self.screen_rect.left - 100
        self.red.rect.centery = self.screen_rect.centery

        self.red.index = 4

        self.blue = Blue(self.screen, self.stats, self.pacman)

        self.blue.centerx = self.screen_rect.left - 125
        self.blue.rect.centery = self.screen_rect.centery

        self.blue.index = 4

        self.orange = Orange(self.screen, self.stats, self.pacman)

        self.orange.centerx = self.screen_rect.left - 150
        self.orange.rect.centery = self.screen_rect.centery

        self.orange.index = 4

        self.pink = Pink(self.screen, self.stats, self.pacman)

        self.pink.centerx = self.screen_rect.left - 175
        self.pink.rect.centery = self.screen_rect.centery

        self.pink.index = 4

    def animate_pacman(self):
        self.pacman.screen_animate()
        self.pacman.blitme()

    def animate_ghost(self):
        self.red.screen_animate()
        self.red.blitme()

        self.blue.screen_animate()
        self.blue.blitme()

        self.orange.screen_animate()
        self.orange.blitme()

        self.pink.screen_animate()
        self.pink.blitme()
Пример #16
0
class Game:
    BLACK = (0, 0, 0)

    def __init__(self):
        pygame.init()
        pygame.mixer.pre_init(44100, 16, 2, 4096)
        self.settings = Settings()
        self.settings.start_intro_music()
        self.screen = pygame.display.set_mode((self.settings.screen_width, self.settings.screen_height))
        pygame.display.set_caption("Pacman Portal")
        self.clock = pygame.time.Clock()
        self.radius = 1
        self.start = 1
        self.end = 10
        self.begin = pygame.time.get_ticks()
        self.wait = 800

        self.startup = Start(self.screen, self.settings)
        self.stats = Stats(self.settings)
        self.sb = Scoreboard(self.settings, self.screen, self.stats)

        self.maze = Maze(self.screen, mazefile='images/pacman_portal_maze.txt',
                         brickfile='square', orangeportalfile='portal_orange', blueportalfile='portal_blue',
                         shieldfile='shield', pointfile='point_pill', gatefile="gate")
        self.pacman = Pacman(self.screen, mazefile='images/pacman_portal_maze.txt')

        self.red = Red(self.screen, mazefile='images/pacman_portal_maze.txt')
        self.blue = Blue(self.screen, mazefile='images/pacman_portal_maze.txt')
        self.orange = Orange(self.screen, mazefile='images/pacman_portal_maze.txt')
        self.pink = Pink(self.screen, mazefile='images/pacman_portal_maze.txt')
        self.inc = 0

    def __str__(self): return 'Game(Pacman Portal), maze=' + str(self.maze) + ')'

    def open_portal(self, x, y, color):
        for r in range(self.start, self.end):
            pygame.gfxdraw.circle(self.screen, x, y, r, color)
        now = pygame.time.get_ticks()
        if now < self.begin + self.wait:
            self.inc = 1
        elif now < self.begin + 4 * self.wait:
            self.inc = 0
        else:
            self.inc = -1
        self.start += self.inc
        self.start = max(1, self.start)
        self.end += self.inc

    def play(self):
        clock = pygame.time.Clock()
        eloop = EventLoop(finished=False)
        while not eloop.finished:
            eloop.check_events(self.screen, self.pacman, self.startup)
            if self.startup.playing:
                pygame.mixer.music.stop()
                if not self.settings.flag_chomp:
                    self.settings.chomp_music()
                    self.settings.flag_chomp = True
                self.settings.chomp_music()
                self.pacman.update(self.maze, self.settings, self.stats, self.sb, self.red, self.blue, self.orange,
                                   self.pink)
                self.red.update(self.maze, self.settings, self.stats, self.pacman, self.startup, self.blue, self.pink,
                                self.orange, self.sb)
                self.blue.update(self.maze, self.settings, self.stats, self.pacman, self.startup, self.red, self.pink,
                                 self.orange, self.sb)
                self.orange.update(self.maze, self.settings, self.stats, self.pacman, self.startup, self.blue,
                                   self.pink, self.red, self.sb)
                self.pink.update(self.maze, self.settings, self.stats, self.pacman, self.startup, self.blue, self.red,
                                 self.orange, self.sb)

            self.update_screen()
            clock.tick(155)

    def update_screen(self):
        if not self.startup.playing:
            self.startup.draw_bg()
            self.startup.draw_button()
        else:
            self.screen.fill(Game.BLACK)
            self.maze.blitme()
            self.pacman.blitme()
            self.red.blitme()
            self.blue.blitme()
            self.orange.blitme()
            self.pink.blitme()
            self.open_portal(100, 100, (240, 100, 20))
            self.sb.show_score()
        pygame.display.flip()
Пример #17
0
class blueTest(unittest.TestCase):

    maxDiff = None

    def setUp(self):
        self.__blue = Blue("test.txt")
        return

    def test_calcAverage(self):
        value = float(self.__blue.calcAverage())
        expectedvalue = 170.70919692
        self.assertAlmostEqual(value, expectedvalue)
        return

    def test_calcWeights(self):
        wm = self.__blue.calcWeightsMatrix()
        weights = wm.ravel().tolist()[0]
        expectedweights = [
            1.3390306603614366, -0.16163492961906992, -0.17739573074236697
        ]
        for weight, expectedweight in zip(weights, expectedweights):
            self.assertAlmostEqual(weight, expectedweight)
        return

    def test_calcChisq(self):
        chisq = self.__blue.calcChisq()
        expectedchisq = 0.770025093468
        self.assertAlmostEqual(chisq, expectedchisq)
        return

    def test_errorAnalysis(self):
        herrors, wm = self.__blue.errorAnalysis()
        keys = herrors.keys()
        expectedherrors = {
            '00stat': 0.4114006127938109,
            '01err1': 1.132605331048375,
            '02err2': 0.62562331148619099,
            '03err3': 2.5071108260136228,
            '04err4': 0.82049571716089753,
            'syst': 2.9381996663923697,
            'systcov': 2.9381996663923693,
            'total': 2.9668615983552984,
            'totalcov': 2.9668615983552984
        }
        expectedkeys = expectedherrors.keys()
        self.assertEqual(sorted(keys), sorted(expectedkeys))
        for key in keys:
            error = sqrt(herrors[key])
            self.assertAlmostEqual(error, expectedherrors[key])
        return

    def test_printResults(self):
        import io, sys
        output = io.StringIO()
        sys.stdout = output
        self.__blue.printResults()
        self.__blue.printErrorsAndWeights(True)
        sys.stdout = sys.__stdout__
        printout = output.getvalue()
        expectedprintout = "\n Results:\n\
\n\
 Chi^2= 0.77 for 2 d.o.f, chi^2/d.o.f= 0.39, P(chi^2)= 0.6804\n\
\n\
   Average:   170.7092 \n\
\n\
Error composition:\n\
            +/- errors   dI/df/I offd. sums\n\
      stat:     0.4114     0.000 \n\
      err1:     1.1326     0.114 \n\
      err2:     0.6256     0.140 \n\
      err3:     2.5071     0.532 \n\
      err4:     0.8205     0.387 \n\
      syst:     2.9382 \n\
     total:     2.9669 \n\
\n\
 Variables:       Val1       Val2       Val3 \n\
   Weights:     1.3390    -0.1616    -0.1774 \n\
  DeltaI/I:     0.8954     0.3989     0.3019    -0.5962\n\
     Pulls:     0.2522     0.5089     0.7020 \n\
\n\
 dI/df/I offdiagonals per error source:\n\
      err1:\n\
           Val2    Val3 \n\
   Val1  0.0595  0.0653 \n\
   Val2         -0.0110 \n\
\n\
      err2:\n\
           Val2    Val3 \n\
   Val1  0.0664  0.0923 \n\
   Val2         -0.0186 \n\
\n\
      err3:\n\
           Val2    Val3 \n\
   Val1  0.2833  0.3109 \n\
   Val2         -0.0626 \n\
\n\
      err4:\n\
           Val2    Val3 \n\
   Val1  0.1997  0.2494 \n\
   Val2         -0.0623 \n\
\n\
     total:\n\
           Val2    Val3 \n\
   Val1  0.6088  0.7178 \n\
   Val2         -0.1545 \n\
\n"

        self.assertEqual(printout, expectedprintout)
        return
Пример #18
0
class Game:
    def __init__(self):
        pygame.init()
        self.screen = pygame.display.set_mode((735, 800))
        pygame.display.set_caption("Pac-man")
        self.settings = Settings()

        self.radius = 1
        self.start = 2
        self.end = 10
        self.begin = pygame.time.get_ticks()
        self.wait = 800

        self.stats = Stats(self.settings)

        self.pb = Button(self.screen)

        self.maze = Maze(self.screen, 'images/maze.txt', 'images/cube0.png',
                         'images/gate0.png', 'images/dot0.png')

        self.sb = Scoreboard(self.settings, self.screen, self.stats, self.maze,
                             self.pb)

        self.player = Player(self.settings, self.screen, self.stats, self.sb,
                             self.maze)
        self.red = Red(self.screen, self.stats, self.player, self.sb,
                       self.maze)
        self.blue = Blue(self.screen, self.stats, self.player)
        self.orange = Orange(self.screen, self.stats, self.player)
        self.pink = Pink(self.screen, self.stats, self.player)

        self.menu = Menu(self.screen, self.stats, self.sb, self.pb, self.maze)

    def open_portal(self, x, y, color):
        for r in range(self.start, self.end):
            pygame.gfxdraw.circle(self.screen, x, y, r, color)
        now = pygame.time.get_ticks()
        if now < self.begin + self.wait:
            self.inc = 1
        elif now < self.begin + 4 * self.wait:
            self.inc = 0
        else:
            self.inc = -1

        self.start += self.inc
        self.start = max(1, self.start)
        self.end += self.inc

    def play(self):
        clock = pygame.time.Clock()
        eloop = EventLoop(finished=False)

        self.menu.prep_screen()

        while not eloop.finished:
            eloop.check_events(self.settings, self.screen, self.stats, self.sb,
                               self.player, self.pb, self.maze)

            if self.stats.game_active:
                self.player.update(self.maze)
                self.red.update()
                self.blue.update()
                self.orange.update()
                self.pink.update()

            self.display_game()
            clock.tick(20)

    def display_game(self):
        self.screen.fill((0, 0, 0))
        self.maze.blitme()
        self.open_portal(365, 550, (240, 100, 20))
        self.player.blitme()
        self.red.blitme()
        self.blue.blitme()
        self.orange.blitme()
        self.pink.blitme()
        self.sb.show_score()

        if not self.stats.game_active:
            self.menu.draw_menu()
            if self.stats.HS_active:
                self.display_HS_menu()

        pygame.display.flip()

    def display_HS_menu(self):
        self.screen.fill((0, 0, 0))
        self.sb.prep_list()
        self.sb.display_list()