Fix black wall tops, pillar art, player anchor, and whole-sheet bullets
ci / verify (push) Successful in 46s

Bullets rendered as the entire sprite sheet, which was the clue that named the
cause: a MultiMeshInstance2D cannot show a sub-region of a texture. Its mesh UVs
run 0..1 across whatever texture it is handed, and an AtlasTexture does not
help -- the draw resolves to the underlying atlas and the region is discarded.
Frames are now pre-sliced into 32 standalone 16x16 textures at startup, so each
frame is one texture assignment per kind and no region is involved. My previous
two attempts fixed the atlas contents while the renderer was structurally
incapable of showing one cell of it.

Black voids above walls: wall_top_mid has 12 of its 16 rows transparent. It is a
cap meant to be laid over a wall, not a tile, and drawn alone it was three
quarters nothing. Floor is now drawn beneath every tile so transparency shows
ground rather than clear colour, the wall face is drawn from the opaque
wall_mid, and the cap is overlaid only where open floor lies above.

Pillars used a wall segment and read as stray blocks; they now use the column
tile, which looks like something you walk around.

The player hitbox appeared at the head because it was: the knight occupies rows
8..27 of a 28-row cell, so anchoring on the cell centre put the draw origin
about 4px above the body's centre. Added a per-sprite anchor offset that cancels
it, with a test that recomputes the offset from the art so a re-cut sheet fails
rather than silently misplacing the character.

Tests pin the two tileset facts that caused this: the cap is mostly transparent
(so it may never be drawn alone) and the wall face is fully opaque (so it may).

166 tests. check.sh, test.sh and smoke.sh pass.
This commit is contained in:
2026-09-04 00:22:01 +02:00
parent 801f328093
commit ff5e527ad4
4 changed files with 117 additions and 22 deletions
+53 -1
View File
@@ -29,7 +29,7 @@ func test_the_game_runs_without_the_restricted_art() -> void:
func test_terrain_rects_are_inside_the_tileset() -> void:
var rects: Array[Rect2] = [Art.WALL, Art.WALL_TOP, Art.PIT, Art.BARRICADE]
var rects: Array[Rect2] = [Art.WALL, Art.WALL_CAP, Art.PIT, Art.BARRICADE, Art.PILLAR]
rects.append_array(Art.FLOOR_VARIANTS)
for r in rects:
assert_true(_fits(Art.TILESET, r), "terrain rect %s is outside the atlas" % r)
@@ -112,3 +112,55 @@ func test_the_shoot_sound_is_shorter_than_the_fire_cooldown_allows_to_overlap()
var cooldown := float(SimConfig.PLAYER_FIRE_COOLDOWN) * SimConfig.TICK_DELTA
assert_lt(Art.SFX_SHOOT.get_length(), cooldown * 4.0,
"held fire would stack more than a few voices of this sound at once")
## The wall cap is mostly transparent by design -- it is an overlay for the top
## edge of a wall, not a tile. Drawing it on its own is what produced a black
## void along every wall, so this records why it must never be used alone.
func test_the_wall_cap_is_mostly_transparent() -> void:
var img := Art.TILESET.get_image()
var clear := 0
for y in int(Art.WALL_CAP.size.y):
for x in int(Art.WALL_CAP.size.x):
var a := img.get_pixel(int(Art.WALL_CAP.position.x) + x,
int(Art.WALL_CAP.position.y) + y).a
if a < 0.15:
clear += 1
assert_gt(clear, 100,
"if this ever becomes opaque the cap could stand alone, but while it " +
"is mostly empty it must always be drawn over floor and wall")
## The wall face, by contrast, has to be solid: it is the one tile drawn with
## nothing but floor beneath it.
func test_the_wall_face_is_opaque() -> void:
var img := Art.TILESET.get_image()
var clear := 0
for y in int(Art.WALL.size.y):
for x in int(Art.WALL.size.x):
if img.get_pixel(int(Art.WALL.position.x) + x,
int(Art.WALL.position.y) + y).a < 0.15:
clear += 1
assert_eq(clear, 0, "the wall face must not have holes in it")
## The player anchor exists because the knight is bottom-heavy in its cell.
## If the art is ever re-cut, this catches the anchor silently becoming wrong.
func test_the_player_anchor_matches_where_the_knight_actually_is() -> void:
var img := Art.TILESET.get_image()
var top := -1
var bottom := -1
for y in int(Art.PLAYER_IDLE.size.y):
for x in int(Art.PLAYER_IDLE.size.x):
if img.get_pixel(int(Art.PLAYER_IDLE.position.x) + x,
int(Art.PLAYER_IDLE.position.y) + y).a > 0.15:
if top < 0:
top = y
bottom = y
break
assert_gte(top, 0, "the idle frame should not be empty")
var body_centre := (float(top) + float(bottom)) * 0.5
var cell_centre := Art.PLAYER_IDLE.size.y * 0.5
assert_almost_eq(Art.PLAYER_ANCHOR.y, cell_centre - body_centre, 1.0,
"anchor should cancel the offset between the cell's centre and the " +
"character's, or the hitbox sits away from the body")