diff game/js/main.js @ 27:75deda08db90 0.9.1

game debug functions separated into own file; release build option, distribution script
author ark
date 2026-10-20 17:19 +0200
parents fe680946164b
children 85d23328a215
line wrap: on
line diff
--- a/game/js/main.js	Tue Oct 20 16:06:50 2026 +0200
+++ b/game/js/main.js	Tue Oct 20 17:19:40 2026 +0200
@@ -5,7 +5,6 @@
 (function () {
     "use strict";
 
-    var cfg = MM.config;
     var STEP = 1 / 60;
     // most simulation steps per frame and game speed step; the rest of a
     // long frame is dropped, so the game slows down instead of freezing
@@ -15,15 +14,17 @@
     var ctx = canvas.getContext("2d");
     var game = null;
     var L = null;
-    var view = { dpr: 1, now: 0, refused: null, hover: null, stats: { ms: 0 } };
+    var view = { dpr: 1, now: 0, refused: null, hover: null };
 
-    // the first map is the debug start map; only it starts at the debug
+    // the first map, the wave it starts at and the seed, 0 for a new seed
+    // per map. js/debug.js may set them; only the first map starts at the
     // start wave
-    var FIRST = MM.util.clamp(cfg.debug.start_map, 0, MM.maps.length - 1);
+    var start = MM.debug ? MM.debug.start : { map: 0, wave: 1, seed: 0 };
+    var FIRST = MM.util.clamp(start.map, 0, MM.maps.length - 1);
 
     function startMap(m) {
-        var seed = cfg.debug.seed || (Math.random() * 4294967296) >>> 0;
-        game = new MM.Game(m, seed, m === FIRST ? cfg.debug.start_wave : 1);
+        var seed = start.seed || (Math.random() * 4294967296) >>> 0;
+        game = new MM.Game(m, seed, m === FIRST ? start.wave : 1);
         resize();
     }
 
@@ -77,7 +78,7 @@
         MM.ui.draw(ctx, game, L, view);
         MM.render.drawFlights(ctx, game, L, view);
 
-        view.stats.ms = view.stats.ms * 0.9 + (performance.now() - t0) * 0.1;
+        if (MM.debug) MM.debug.frameTime(performance.now() - t0);
         requestAnimationFrame(frame);
     }