test_tiles.py 文件源码

python
阅读 35 收藏 0 点赞 0 评论 0

项目:sappho 作者: lily-mayfield 项目源码 文件源码
def test_render(self):
        csv = textwrap.dedent(self.TILEMAP_CSV).strip()
        tilemap = (sappho.tiles.TileMap.
                   from_csv_string_and_tilesheet(csv, self.tilesheet))

        # Create a surface that has 1x2 strips of red, green, and
        # blue to against the rendered tilemap. This surface has
        # to have the SRCALPHA flag and a depth of 32 to match
        # the surface returned by the render function.
        test_surface = pygame.surface.Surface((3, 2), pygame.SRCALPHA, 32)
        test_surface.fill((255, 0, 0), pygame.Rect(0, 0, 1, 2))
        test_surface.fill((0, 255, 0), pygame.Rect(1, 0, 1, 2))
        test_surface.fill((0, 0, 255), pygame.Rect(2, 0, 1, 2))

        # Render the tilemap
        output_surface = tilemap.to_surface()

        # Compare the two surfaces
        assert(compare_surfaces(test_surface, output_surface))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号