about summary refs log tree commit diff stats
path: root/html/tower/js/gameState.js
diff options
context:
space:
mode:
Diffstat (limited to 'html/tower/js/gameState.js')
-rw-r--r--html/tower/js/gameState.js82
1 files changed, 82 insertions, 0 deletions
diff --git a/html/tower/js/gameState.js b/html/tower/js/gameState.js
new file mode 100644
index 0000000..a1ab765
--- /dev/null
+++ b/html/tower/js/gameState.js
@@ -0,0 +1,82 @@
+const GamePhase = {
+    PLACEMENT: 'placement',
+    COMBAT: 'combat'
+};
+
+const TowerTypes = {
+    BASIC: {
+        name: 'Basic Tower',
+        cost: 20,
+        range: 3,
+        damage: 1,
+        attackSpeed: 1,
+        color: '#4a90e2'
+    },
+    SNIPER: {
+        name: 'Sniper Tower',
+        cost: 40,
+        range: 6,
+        damage: 2,
+        attackSpeed: 0.5,
+        color: '#9b59b6'
+    },
+    RAPID: {
+        name: 'Rapid Tower',
+        cost: 35,
+        range: 2,
+        damage: 0.5,
+        attackSpeed: 2,
+        color: '#2ecc71'
+    }
+};
+
+const ParticleTypes = {
+    DEATH_PARTICLE: {
+        lifetime: 1000, // milliseconds
+        speed: 0.1,
+        colors: ['#e74c3c', '#c0392b', '#f1c40f', '#e67e22']
+    },
+    PROJECTILE: {
+        lifetime: 300,
+        speed: 0.3,
+        color: '#ffffff'
+    }
+};
+
+function createTower(type, position) {
+    return {
+        ...TowerTypes[type],
+        position,
+        lastAttackTime: 0
+    };
+}
+
+function createEnemy(startPosition) {
+    return {
+        position: { ...startPosition },
+        currentHealth: Math.floor(Math.random() * 5) + 2, // 2-6 health
+        maxHealth: this.currentHealth,
+        speed: 1 + Math.random() * 0.5, // 1-1.5 speed
+        pathIndex: 0
+    };
+}
+
+function createParticle(type, position, angle) {
+    return {
+        position: { ...position },
+        velocity: {
+            x: Math.cos(angle) * type.speed,
+            y: Math.sin(angle) * type.speed
+        },
+        color: Array.isArray(type.colors) 
+            ? type.colors[Math.floor(Math.random() * type.colors.length)]
+            : type.color,
+        createdAt: performance.now(),
+        lifetime: type.lifetime,
+        size: 3 + Math.random() * 2
+    };
+}
+
+// Add to gameState object
+gameState.particles = [];
+gameState.projectiles = []; 
\ No newline at end of file