Files
Grovewright/game/tests/test_pixel_things.gd
T
Steven Wroblewski deba758e87 Pixelgrafik für die Dinge der Vitrine
Toter Boden hat Risse, lebendiger Boden Gras, Blumen und einen
unregelmäßigen Rand. Moos funkelt, die Ranke trägt Blätter, die
Faserpflanze wächst in sechs Stufen bis zu den Fasern und wiegt sich,
das Weidetier zieht im Sprung die Beine an, und die Ruine leuchtet,
wenn sie erwacht.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-10-02 13:29:32 +02:00

60 lines
2.3 KiB
GDScript

extends TestCase
## The pixel art of the things of later milestones in the showcase.
## The highest row of `image` with a pixel that is not transparent.
static func _top(image: Image) -> int:
for y in image.get_height():
for x in image.get_width():
if image.get_pixel(x, y).a > 0.0:
return y
return image.get_height()
func test_a_plant_grows_taller_from_stage_to_stage() -> void:
var style := WarmStyle.new()
var tops: Array[int] = []
for stage in PixelStyle.GROWTH_STAGES:
tops.append(_top(style._plant_image(stage, 0).image))
for stage in range(1, tops.size()):
check(tops[stage] < tops[stage - 1], "stage %d is taller than stage %d: %s" % [stage, stage - 1, tops])
func test_grass_has_a_ragged_edge_only_toward_bare_ground() -> void:
var style := WarmStyle.new()
var inside := style._grass_image(255, 0).image
var lone := style._grass_image(0, 0).image
var tile := PixelStyle.TILE
var inside_gaps := 0
var lone_gaps := 0
for y in tile:
for x in tile:
inside_gaps += 1 if inside.get_pixel(x, y).a == 0.0 else 0
lone_gaps += 1 if lone.get_pixel(x, y).a == 0.0 else 0
check_eq(inside_gaps, 0, "living all around: no gaps")
check(lone_gaps > 4, "bare ground all around: a ragged, round edge (%d gaps)" % lone_gaps)
check_eq(lone.get_pixel(0, 0).a, 0.0, "round at the corner")
func test_dead_soil_is_the_bare_earth_with_cracks() -> void:
var style := WarmStyle.new()
var earth := style._earth(0, 0).image
var cracked := style._crack_soil(style._earth(0, 0), 0).image
check(cracked.get_data() != earth.get_data(), "cracks in every other tile")
check_eq(style._crack_soil(style._earth(1, 0), 1).image.get_data(), style._earth(1, 0).image.get_data(), "none in the others")
func test_an_animal_in_the_air_tucks_its_legs() -> void:
var style := WarmStyle.new()
var standing := style._grazer_image(false, false).image
var tucked := style._grazer_image(true, false).image
check(standing.get_pixel(5, 14).a > 0.0, "standing on its legs")
check_eq(tucked.get_pixel(5, 14).a, 0.0, "legs tucked in the air")
func test_the_ruin_glows_in_its_doorway() -> void:
var style := WarmStyle.new()
var light := style._ruin_glow().image
check(light.get_pixel(24, 31).a > 0.5, "bright in the middle of the doorway")
check_eq(light.get_pixel(3, 30).a, 0.0, "dark on the walls")