miaoda-game-road-core
v0.3.0
Published
Engine-independent OutRun-style segmented road, hill occlusion, curve projection, and billboard geometry.
Downloads
746
Maintainers
Readme
miaoda-game-road-core
Engine-independent OutRun-style segmented roads. It builds a looping track from fixed-length slices, projects curves and hills, clips hidden geometry, and returns road trapezoids plus billboard anchors in painter order.
pnpm add miaoda-game-road-coreimport {CURVE, HILL, Road, RoadEngine} from 'miaoda-game-road-core';
const road = new Road(200).addStraight(40).addCurve(60, CURVE.MEDIUM, HILL.LOW).addHill(50, HILL.HIGH);
const engine = new RoadEngine(road, {roadWidth: 2000, drawDistance: 300});
engine.resize(1280, 720);
const frame = engine.frame({x: playerX, z: travelled}, sprites);x is lateral world position and z is forward world distance. Keep camera and sprite z values unbounded across laps: segmentAt(z) wraps lookup while projection preserves completed-lap relative depth. Do not pre-wrap them.
frame.quads and frame.sprites are ordered far-to-near for painter rendering. The game owns movement, collision, lap rules, art selection, and drawing; use the Cocos or Phaser adapter for Graphics output.
