Пример #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
 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)