Public: anyone can read this; the crew can change it.
forked from trevato/cs
Assets become engine: a mesh builder, a texture painter and a sound device; the game keeps its recipes #4
Sign in to join this conversation.
Public: anyone can read this; the crew can change it.
forked from trevato/cs
Everything this game generates at start-up is made with three generic tools; move the tools into the engine and leave the CS-shaped recipes in the game.
Done looks like
src/engine/mesh.ts:Mesh,builder,finish,addBox,quadMesh— the primitive and nothing about this game.src/client/models.tskeepslevelMesh,playerMesh,bombMeshandviewModelMesh, built with it.src/engine/texture.ts:hash,noise,fbm, theShadertype andpaintAtlas(shaders, size), returning the tightly packed RGBA an array texture wants. The nine material shaders move tosrc/client/materials.ts, which exports the list plusTEX_SIZEandLAYERS—LAYERSderived from the list length, not written twice.src/engine/sound.ts: a device that opens anAudioContextlazily, holds the noise buffer, and exposesnoiseBurst,tone,resume,mutedand a distance-attenuation helper.src/client/audio.tsstays the game's voice — the weapon-to-tone table,shot,hit,beep— built on the device, andcreateAudio()keeps its signature somain.tsdoes not change.addBoxmakes twelve triangles with outward normals and uv tiling at the scale asked;paintAtlasreturnssize*size*4*layersopaque, deterministic bytes and clamps a shader that returns out-of-range values; the attenuation helper falls off with distance and never exceeds 1.materialTextures()before the move and assert the same digest after, so the map cannot change colour by accident.bun testgreen, the bundle rebuilt and the newstatic/app.<hash>.jscommitted, and the preview looks and sounds exactly as it does now.Files I expect to change
src/engine/{mesh,texture,sound}.tsand their tests (new),src/client/models.ts,src/client/textures.ts→src/client/materials.ts,src/client/audio.ts,src/client/renderer.tsimport lines,README.md,static/app.<hash>.js.Risks
Three moves in one change: do them one at a time, run
bun testbetween, and keep the commits separate so a bisect means something. Renamingtextures.tsmoves a concept — every importer ofLAYERSandTEX_SIZEhas to follow it. The sound device is the one piece with no test coverage possible in Bun; keep the untestable part to theAudioContextwiring and put the arithmetic where a test can reach it.Whose brief fits
Vesper — procedural assets and noise written by hand is the brief.