diff options
Diffstat (limited to 'html/tower/js/gameState.js')
-rw-r--r-- | html/tower/js/gameState.js | 33 |
1 files changed, 21 insertions, 12 deletions
diff --git a/html/tower/js/gameState.js b/html/tower/js/gameState.js index 0f379f6..63270fa 100644 --- a/html/tower/js/gameState.js +++ b/html/tower/js/gameState.js @@ -109,16 +109,25 @@ function createParticle(type, position, angle) { }; } -// Add to gameState object -gameState.particles = []; -gameState.projectiles = []; -gameState.enemiesDestroyed = 0; -gameState.enemiesEscaped = 0; -gameState.path = []; // This will be populated when the path is generated - -gameState.awardEnemyDestroyed = function() { - this.enemiesDestroyed++; - // Random reward between 5 and 10 - const reward = Math.floor(Math.random() * 6) + 5; - this.currency += reward; +// Initialize game state at the bottom of the file +const gameState = { + grid: Array(20).fill().map(() => Array(20).fill('empty')), + path: [], + towers: [], + enemies: [], + currency: 100, + phase: 'placement', + isGameOver: false, + particles: [], + projectiles: [], + enemiesDestroyed: 0, + enemiesEscaped: 0, + + // Define the function as part of the initial object + awardEnemyDestroyed() { + this.enemiesDestroyed++; + // Random reward between 1 and 3 + const reward = Math.floor(Math.random() * 3) + 1; + this.currency += reward; + } }; \ No newline at end of file |