示例#1
0
    def test_factory(self):
        class MockImage(img.PngFactory):
            def __init__(self, screen):
                super().__init__('title_card',
                                 screen,
                                 path_type=img.PathType.COMMON)

        image = img.load(self.screen, factory=MockImage)
        self.assertIsInstance(image, MockImage)
示例#2
0
 def __init__(self, screen):
     super().__init__(screen)
     self._hidden_objects = {
         name: cls(self._surface)
         for name, cls in self._HIDDEN_OBJECTS.items()
     }
     self._state = {name: object() for name in self._STATE}
     self.player = img.load('player', self._surface,
                            (state.RECT.h / 2, state.RECT.h / 2),
                            (-0.5, -0.5))
     self._scroll_speed: Optional[interactions.Speed] = None
     self._player_feet_rect = pygame.Rect(
         self.player.RECT.x, self.player.RECT.bottom - _PLAYER_FEET_HEIGHT,
         self.player.RECT.w, _PLAYER_FEET_HEIGHT)
示例#3
0
文件: side_bar.py 项目: rchen152/maze
 def set_item(self, name):
     self._item = _Item(name, img.load(
         os.path.join('item', name), self._screen,
         (self.RECT.centerx, self.RECT.centery), (-0.5, -0.5)))
示例#4
0
 def __init__(self, screen):
     keypad = img.load(screen, factory=room.KeyPad)
     keypad.text = '9710'  # opens the keypad so 'OK' will be centered
     keypad.text = 'OK'
     super().__init__(screen, color.GREY, keypad)
示例#5
0
 def test_shift(self):
     image = img.load('title_card',
                      self.screen,
                      shift=(1, 1),
                      path_type=img.PathType.COMMON)
     self.assertFalse(image.collidepoint((0, 0)))
示例#6
0
 def test_position(self):
     image = img.load('title_card',
                      self.screen, (-1, -1),
                      path_type=img.PathType.COMMON)
     self.assertTrue(image.collidepoint((-1, -1)))
示例#7
0
 def test_collidepoint(self):
     image = img.load('title_card',
                      self.screen,
                      path_type=img.PathType.COMMON)
     self.assertTrue(image.collidepoint((0, 0)))
     self.assertFalse(image.collidepoint((-1, -1)))
示例#8
0
 def test_draw(self):
     image = img.load('title_card',
                      self.screen,
                      path_type=img.PathType.COMMON)
     image.draw()
     self.screen.blit.assert_called_once()
示例#9
0
 def test_load(self):
     img.load('title_card', self.screen, path_type=img.PathType.COMMON)