oma-lander/game/hud.lua
28allday 790ca87bfb Lunar Lander: complete Love2D game with Omarchy integration
Faithful recreation of Atari Lunar Lander (1979) with vector wireframe aesthetic.
Auto-detects Omarchy system theme and font on launch.

Features:
- Dynamic zoom camera (zooms in as you approach the surface)
- Procedural jagged terrain with flat landing pads (2X, 3X, 5X multipliers)
- Apollo-style wireframe lander with thrust flame
- Gravity, thrust, rotation physics
- Landing evaluation: good (speed/angle/pad check), hard, crash
- Fuel management (750 starting, +50 for good landings)
- Crash debris particles, thrust exhaust particles
- Star field background
- HUD: altitude, horizontal/vertical speed, fuel bar, score, time
- Persistent high scores with 3-letter initial entry
- Procedural sound effects (thrust, landing chimes, crash, fuel warning)
- Full-screen scaling, system font detection

Controls: Arrows/WASD rotate+thrust, Space abort, Enter start

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-13 14:42:13 +01:00

59 lines
2.1 KiB
Lua

local World = require("game.world")
local Palette = require("rendering.palette")
local Fonts = require("rendering.fonts")
local HUD = {}
function HUD.draw(altitude, hspeed, vspeed)
local p = Palette.get()
local sw, sh = World.screenW, World.screenH
local pad = 12
love.graphics.setFont(Fonts.small)
-- Left column: SCORE, TIME, FUEL
love.graphics.setColor(p.hud)
love.graphics.print("SCORE " .. string.format("%d", World.score), pad, pad)
love.graphics.print("TIME " .. string.format("%.0f", World.time), pad, pad + Fonts.small:getHeight() + 4)
-- Fuel bar
local fuelY = pad + (Fonts.small:getHeight() + 4) * 2
local fuelMax = 750
local fuelFrac = math.max(0, World.fuel / fuelMax)
local barW = sw * 0.15
local barH = Fonts.small:getHeight() * 0.7
love.graphics.print("FUEL", pad, fuelY)
local barX = pad + Fonts.small:getWidth("FUEL") + 8
love.graphics.setColor(p.dim)
love.graphics.rectangle("line", barX, fuelY + 2, barW, barH)
if World.fuel < 150 and math.floor(love.timer.getTime() * 4) % 2 == 0 then
love.graphics.setColor(p.warning)
else
love.graphics.setColor(p.pad)
end
love.graphics.rectangle("fill", barX + 1, fuelY + 3, (barW - 2) * fuelFrac, barH - 2)
love.graphics.setColor(p.hud)
love.graphics.print(string.format("%.0f", World.fuel), barX + barW + 8, fuelY)
-- Right column: ALTITUDE, HORIZONTAL SPEED, VERTICAL SPEED
local rx = sw - pad
local function rightPrint(text, y)
local w = Fonts.small:getWidth(text)
love.graphics.print(text, rx - w, y)
end
love.graphics.setColor(p.hud)
rightPrint(string.format("ALTITUDE %.0f", altitude), pad)
local hdir = hspeed > 0.5 and " >" or (hspeed < -0.5 and "< " or " ")
rightPrint(string.format("HORIZ SPEED %s%.1f", hdir, math.abs(hspeed)), pad + Fonts.small:getHeight() + 4)
local vdir = vspeed > 0.5 and " v" or (vspeed < -0.5 and " ^" or " ")
rightPrint(string.format("VERT SPEED %s%.1f", vdir, math.abs(vspeed)), pad + (Fonts.small:getHeight() + 4) * 2)
end
return HUD