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))
评论列表
文章目录