예제 #1
0
파일: test_icon.py 프로젝트: gshopov/Pyruto
    def test_maintain_topleft_position(self):
        icon = Icon("orochimaru")
        position = icon.position

        icon.p1_flag = True
        icon.p2_falg = True
        icon.update()
        self.assertEqual(icon.rect.topleft, position)

        icon.p1_flag = True
        icon.p2_flag = False
        icon.update()
        self.assertEqual(icon.rect.topleft, position)

        icon.p1_flag = False
        icon.p2_flag = True
        icon.update()
        self.assertEqual(icon.rect.topleft, position)

        icon.p1_flag = False
        icon.p2_flag = False
        icon.update()
        self.assertEqual(icon.rect.topleft, position)
예제 #2
0
파일: test_icon.py 프로젝트: gshopov/Pyruto
    def test_highlighting(self):
        icon = Icon("orochimaru")

        icon.p1_flag = True
        icon.p2_flag = True
        icon.update()
        scaled_image = pygame.transform.smoothscale(icon.images[3][0],
                                                    (int(icon.images[3][1].w *
                                                         ICON_HIGHLIGHT),
                                                    int(icon.images[3][1].h *
                                                        ICON_HIGHLIGHT)))
        pixel_array_base = pygame.PixelArray(scaled_image)
        pixel_array_scale = pygame.PixelArray(icon.image)
        width, height = icon.image.get_size()
        for column in range(width):
            for row in range(height):
                self.assertAlmostEqual(pixel_array_base[column, row],
                                       pixel_array_scale[column, row])

        icon.p1_flag = True
        icon.p2_flag = False
        icon.update()
        scaled_image = pygame.transform.smoothscale(icon.images[1][0],
                                                    (int(icon.images[1][1].w *
                                                         ICON_HIGHLIGHT),
                                                    int(icon.images[1][1].h *
                                                        ICON_HIGHLIGHT)))
        pixel_array_base = pygame.PixelArray(scaled_image)
        pixel_array_scale = pygame.PixelArray(icon.image)
        width, height = icon.image.get_size()
        for column in range(width):
            for row in range(height):
                self.assertAlmostEqual(pixel_array_base[column, row],
                                       pixel_array_scale[column, row])

        icon.p1_flag = False
        icon.p2_flag = True
        icon.update()
        scaled_image = pygame.transform.smoothscale(icon.images[2][0],
                                                    (int(icon.images[2][1].w *
                                                         ICON_HIGHLIGHT),
                                                    int(icon.images[2][1].h *
                                                        ICON_HIGHLIGHT)))
        pixel_array_base = pygame.PixelArray(scaled_image)
        pixel_array_scale = pygame.PixelArray(icon.image)
        width, height = icon.image.get_size()
        for column in range(width):
            for row in range(height):
                self.assertAlmostEqual(pixel_array_base[column, row],
                                       pixel_array_scale[column, row])

        icon.p1_flag = False
        icon.p2_flag = False
        icon.update()
        pixel_array_base = pygame.PixelArray(icon.images[0][0])
        pixel_array_scale = pygame.PixelArray(icon.image)
        width, height = icon.image.get_size()
        for column in range(width):
            for row in range(height):
                self.assertAlmostEqual(pixel_array_base[column, row],
                                       pixel_array_scale[column, row])