Exemplo n.º 1
0
def show_title_screen(screen, rect, image, menu, menu_rect, moves):
    # self.settings.KEY_REPEAT = self.settings.MENU_KEY_REPEAT
    events = EventGenerator()
    title = TitleScreen(screen, events, rect, image, menu, menu_rect, moves)
    title.run()
    screen.clear()
    pygame.display.update()
Exemplo n.º 2
0
 def test_anykey_negative(self):
     self.keypressed = False
     self.egen = EventGenerator()
     self.elis = AnyKeyListener(self.callback)
     self.egen.add_listener(self.elis)
     self.egen.add_scripted_event(QUIT_EVENT)
     self.egen.event_loop()
     assert not self.keypressed
Exemplo n.º 3
0
 def test_game_paused(self, screen):
     """Display pause box."""
     frame = Frame(screen, Rect(100, 100, 260, 160))
     egen = EventGenerator()
     egen.add_scripted_keys(['a'])
     gp = GamePausedBox(frame,
                        config.PAUSE_IMAGE,
                        text='test game paused signal',
                        egen=egen)
     gp.draw()
     pygame.display.update()
     gp.activate()
Exemplo n.º 4
0
 def setup(self):
     self.egen = EventGenerator()
     keymap = {
         pygame.K_a: self.hel,
         pygame.K_b: self.lo,
         pygame.K_c: self.world,
         pygame.K_d: self.space
     }
     self.elis = EventListener(keymap)
     self.egen.add_listener(self.elis)
     self.updated = 0
     self.result = ""
Exemplo n.º 5
0
 def __init__(self,
              frame,
              image=None,
              text="Game Paused - press any key to continue",
              egen=None):
     """Initializes the Pause Box."""
     self.image = ImageBox(frame, image)
     self.text = TextBox(frame, text)
     if egen == None:
         egen = EventGenerator()
     self.egen = egen
     self.elis = AnyKeyListener(self.pause_ended)
     self.egen.add_listener(self.elis)
Exemplo n.º 6
0
def show_highscores(new_score, screen, rect, filename, image, textpos):
    """
    Display high score list and gets a name if the score is high enough.
    """
    screen.clear()
    frame = Frame(screen, rect)
    events = EventGenerator()
    hs = HighscoreList(filename)
    hs = HighscoreBox(frame, events, hs, image, textpos)
    hs.enter_score(new_score)
    hs.activate()
    screen.clear()
    pygame.display.update()
Exemplo n.º 7
0
 def test_highscores(self, screen):
     """Enters something into the highscore list."""
     os.system('cp %s %s' % (HIGHSCORE_BACKUP, config.HIGHSCORE_FILE))
     hl = HighscoreList(config.HIGHSCORE_FILE)
     events = EventGenerator()
     events.add_scripted_keys(['B', 'C', chr(K_RETURN), chr(K_RETURN)])
     events.add_scripted_event(QUIT_EVENT)
     screen.clear()
     frame = Frame(screen, config.HIGHSCORE_RECT)
     hs = HighscoreBox(frame, events, hl, config.HIGHSCORE_IMAGE,
                       config.HIGHSCORE_TEXT_POS)
     hs.enter_score(33333)
     hs.activate()
     assert hl.scores[0] == (33333, 'BC')
Exemplo n.º 8
0
def event_gen():
    return EventGenerator()
Exemplo n.º 9
0
 def setUp(self):
     self.events = EventGenerator()
     self.result = ''
Exemplo n.º 10
0
 def setup(self):
     self.egen = EventGenerator()
     self.updated = 0
     self.result = ""