miaoda-game-belt-core
v0.2.0
Published
Engine-agnostic 2.5D belt-scroll spatial model: separates a ground plane (x lateral, depth into-screen) from a height axis (jump / launch off the ground), converts them to a screen point (screenY = groundY - height) with a shadow anchored at the ground, r
Maintainers
Readme
miaoda-game-belt-core
An engine-independent 2.5D belt-scroll model for beat-'em-ups. It keeps lateral position, floor depth, and jump height separate so gameplay can use lanes while rendering a convincing raised sprite.
pnpm add miaoda-game-belt-coreThe projection is screenX = x, screenY = y - z; a shadow uses screenY = y, and draw order uses ground depth y.
import {BeltBody, inLane, sortByDepth} from 'miaoda-game-belt-core';
const player = new BeltBody({x: 0, y: 300, bounds: {minY: 260, maxY: 420}});
player.walk(moveX * speed * dt, moveY * speed * dt);
if (jumpPressed) player.jump(700);
const landed = player.step(dt);
const state = player.snapshot;
for (const entity of sortByDepth(entities, e => e.body)) render(entity);
if (inLane(player, enemy, 24)) tryAttack(enemy);x is lateral, y is floor depth, and z is height. walk applies direct intent; push(vx, vy, vz) adds decaying knockback slide and optional launch; jump works only while grounded; step(dt) integrates gravity and returns true on landing. snapshot is a copied position/velocity/grounded state suitable for UI or saves.
inLane, laneOffset, and laneBand gate depth tolerance before a lateral hit check. toScreen, shadowScreen, depthSortKey, and sortByDepth provide rendering inputs. This package does not resolve collisions or hits, choose attack states, render sprites, or pathfind.
Combine it with miaoda-game-combat2d-core for lateral hit resolution, miaoda-game-brawler-core for attack state, and your renderer/juice package for visuals. The game owns the bridge between those systems.
