~bigbes/game-prototype-ftl

3144cda7fcb30beaa78e85783d0af8994484edfe — Eugene Blikh 30 days ago f9d6b61
systems-power: hoist HUD cellBottom out of inner loop

Reviewer flagged the per-iteration recomputation of cellBottom inside
drawHud's column/cell loops; the value was loop-invariant. Hoist to a
file-scope const and simplify the algebra.

systems-power
1 files changed, 2 insertions(+), 3 deletions(-)

M render.go
M render.go => render.go +2 -3
@@ 97,6 97,8 @@ func drawHud(screen *ebiten.Image, sys []System) {
	const cellW = 12
	const cellH = 10
	const cellGap = 2
	// cellBottom is the y of the bottom-most cell's top edge; loop-invariant.
	const cellBottom = VirtualH - cellGap
	outline := color.RGBA{255, 255, 255, 255}

	// Role labels in display order (index == int(RoomRole)).


@@ 112,9 114,6 @@ func drawHud(screen *ebiten.Image, sys []System) {

		// Cells stacked bottom-up. Row 0 is at the bottom of the HUD strip.
		for j := 0; j < s.MaxLevel; j++ {
			// Compute y so that row 0 is at the bottom. We allocate space
			// starting below the label (label height ~12px).
			cellBottom := HudY + (VirtualH - HudY) - cellGap
			cy := cellBottom - (j+1)*(cellH+cellGap)
			cx := colLeft + 4