MOD files as a sound library with channels in MMBasic
Music and effects running side by side without cutting each other off. The path I took uses PLAY MODSAMPLE and a small set of fixed channels.
Music and effects running side by side without cutting each other off. The path I took uses PLAY MODSAMPLE and a small set of fixed channels.
When the same array index shows up five times per iteration, hoist it into a variable. Small change, real effect for me.
Reaching for LOCAL feels like clean programming. Inside hot loops it turned out to be the wrong reflex for me.
Tiny dots, tiny cost, right? Once I profiled it, CIRCLE was one of the most expensive calls per frame. Here's what I did about it.
Pixel fonts don't scale cleanly, and they don't fit a vector game visually either. How I built a scalable typeface out of DATA statements.
Rotating each vertex by hand with COS and SIN is the obvious move. MATH V_ROTATE does the same job faster, with no per-point loop.
Setting an entire array to a single value, no loop. MATH SET is the quiet little command I now reach for more often than anything else in the MATH family.
On first launch a file may not exist yet, and the program shouldn't crash because of that. ON ERROR SKIP plus MM.ERRNO is the clean way.
A variable that keeps its value between calls without polluting global state. That's exactly what STATIC inside a sub gives you.
Spawning and freeing shots, particles, and asteroids on demand isn't really a thing in MMBasic. A fixed pool with active flags gets you the same flexibility.