Sandbox Mode is a new feature that allows developers and testers to create controlled environments where specific game systems are disabled at the engine level.
+
+
+
โ Disable wave spawning system
+
โ Disable weather effects
+
โ Disable UI updates
+
โ Disable audio playback
+
โ Prevent automatic game over
+
โ Maintain full backward compatibility
+
+
+
+
+
How It Works
+
+
Normal Game (Unchanged)
+
// All systems active, game behaves normally
+const game = new Game();
+
+
Sandbox Mode (New)
+
// Wave, weather, UI, audio disabled
+// No game over on player death
+const game = new Game({ sandboxMode: true });
+
+
+
+
Before vs After
+
+
+
+
โ Old Way (Manual)
+
// Create game
+const game = new Game();
+
+// Manually disable each system
+game.systems.wave.update = () => {};
+game.systems.weather.update = () => {};
+game.systems.ui.update = () => {};
+game.audioManager.play = () => {};
+game.audioManager.stopAll = () => {};
+
+// Override methods on prototype
+Game.prototype.setupUIListeners =
+ function() { /* disabled */ };
+
+// Still had game over issues
+// Inconsistent across sandboxes
+
+
+
+
โ New Way (Clean)
+
// One line, everything handled
+const game = new Game({
+ sandboxMode: true
+});
+
+// That's it!
+// Systems disabled at engine level
+// Game over prevented
+// Consistent behavior
+// Backward compatible
// Initialize game with dev mode
function initDevSandbox() {
- console.log('[DevSandbox] Initializing professional combat sandbox...');
+ console.log('[DevSandbox] Initializing professional combat sandbox with sandboxMode...');
- // Create game instance
- game = new Game();
+ // Create game instance with sandboxMode enabled
+ // This cleanly disables wave spawning, weather, UI updates, and audio at engine level
+ game = new Game({ sandboxMode: true });
- // Disable UI and Audio initialization methods BEFORE startGame
- console.log('[DevSandbox] Disabling UI and Audio systems...');
-
- // Override methods that touch DOM elements
+ // Override setupUIListeners to prevent DOM errors
game.setupUIListeners = function() {
console.log('[DevSandbox] UI listeners disabled');
};
- // Replace UI system with stub that does nothing
- game.systems.ui = {
- showScreen: () => {},
- showWaveAnnouncement: () => {},
- showLevelUp: () => {},
- showGameOver: () => {},
- showPauseMenu: () => {},
- hidePauseMenu: () => {},
- showScoreboard: () => {},
- hideScoreboard: () => {},
- showNameEntryDialog: () => {},
- hideNameEntryDialog: () => {},
- updateHUD: () => {},
- update: () => {},
- waveSystem: null
- };
-
- // Disable audio initialization
- game.audioManager = {
- init: () => {},
- playSound: () => {},
- playMusic: () => {},
- stopMusic: () => {},
- stopAll: () => {},
- setVolume: () => {},
- startBackgroundMusic: () => {},
- stopBackgroundMusic: () => {}
- };
-
// Store original update method
originalUpdate = game.update.bind(game);
diff --git a/dev/combat-sandbox.html b/dev/combat-sandbox.html
index f7ce4fb..129a146 100644
--- a/dev/combat-sandbox.html
+++ b/dev/combat-sandbox.html
@@ -231,7 +231,7 @@
Info
// Initialize the sandbox
function init() {
- console.log('[Combat Sandbox] Initializing with real Game class...');
+ console.log('[Combat Sandbox] Initializing with sandboxMode...');
// Override setupUIListeners on prototype before instantiation
// This prevents errors with missing UI DOM elements
@@ -239,42 +239,10 @@
// Initialize game with dev mode
function initDevSandbox() {
- console.log('[DevSandbox] Initializing professional combat sandbox with sandboxMode...');
+ console.log('[DevSandbox] Initializing professional combat sandbox...');
- // Create game instance with sandboxMode enabled
- // This cleanly disables wave spawning, weather, UI updates, and audio at engine level
- game = new Game({ sandboxMode: true });
+ // Create game instance
+ game = new Game();
- // Override setupUIListeners to prevent DOM errors
+ // Disable UI and Audio initialization methods BEFORE startGame
+ console.log('[DevSandbox] Disabling UI and Audio systems...');
+
+ // Override methods that touch DOM elements
game.setupUIListeners = function() {
console.log('[DevSandbox] UI listeners disabled');
};
+ // Replace UI system with stub that does nothing
+ game.systems.ui = {
+ showScreen: () => {},
+ showWaveAnnouncement: () => {},
+ showLevelUp: () => {},
+ showGameOver: () => {},
+ showPauseMenu: () => {},
+ hidePauseMenu: () => {},
+ showScoreboard: () => {},
+ hideScoreboard: () => {},
+ showNameEntryDialog: () => {},
+ hideNameEntryDialog: () => {},
+ updateHUD: () => {},
+ update: () => {},
+ waveSystem: null
+ };
+
+ // Disable audio initialization
+ game.audioManager = {
+ init: () => {},
+ playSound: () => {},
+ playMusic: () => {},
+ stopMusic: () => {},
+ stopAll: () => {},
+ setVolume: () => {},
+ startBackgroundMusic: () => {},
+ stopBackgroundMusic: () => {}
+ };
+
// Store original update method
originalUpdate = game.update.bind(game);
diff --git a/dev/combat-sandbox.html b/dev/combat-sandbox.html
index 129a146..056cd75 100644
--- a/dev/combat-sandbox.html
+++ b/dev/combat-sandbox.html
@@ -243,6 +243,17 @@
Info
// This cleanly disables wave spawning, weather, UI updates, and audio at engine level
game = new Game({ sandboxMode: true });
+ // Override additional UI methods that try to access DOM elements
+ // These are called by the game but reference elements that don't exist in sandbox
+ if (game.systems.ui) {
+ game.systems.ui.updateHUD = function() {};
+ game.systems.ui.showScreen = function() {};
+ game.systems.ui.showWaveAnnouncement = function() {};
+ game.systems.ui.showLevelUp = function() {};
+ game.systems.ui.showGameOver = function() {};
+ console.log('[Combat Sandbox] UI methods overridden to prevent DOM errors');
+ }
+
// Set selected ship
game.gameState.selectedShip = 'ION_FRIGATE';