diff options
Diffstat (limited to 'html/tower/js/gameState.js')
-rw-r--r-- | html/tower/js/gameState.js | 42 |
1 files changed, 37 insertions, 5 deletions
diff --git a/html/tower/js/gameState.js b/html/tower/js/gameState.js index a1ab765..49708ee 100644 --- a/html/tower/js/gameState.js +++ b/html/tower/js/gameState.js @@ -43,21 +43,53 @@ const ParticleTypes = { } }; +const EnemyTypes = { + BASIC: { + color: '#ff0000', + baseHealth: { min: 2, max: 6 }, + speed: { min: 1, max: 1.5 }, + damage: 0, + isRanged: false + }, + RANGED: { + color: '#8e44ad', // Purple + baseHealth: { min: 1, max: 4 }, + speed: { min: 0.7, max: 1.2 }, + damage: 0.3, + attackRange: 3, + attackSpeed: 1, // attacks per second + isRanged: true + } +}; + function createTower(type, position) { return { ...TowerTypes[type], + type, position, - lastAttackTime: 0 + lastAttackTime: 0, + currentHealth: 10, + maxHealth: 10 }; } function createEnemy(startPosition) { + // 20% chance for ranged enemy + const type = Math.random() < 0.2 ? 'RANGED' : 'BASIC'; + const enemyType = EnemyTypes[type]; + const health = Math.floor(Math.random() * + (enemyType.baseHealth.max - enemyType.baseHealth.min + 1)) + + enemyType.baseHealth.min; + 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 + currentHealth: health, + maxHealth: health, + speed: enemyType.speed.min + Math.random() * (enemyType.speed.max - enemyType.speed.min), + pathIndex: 0, + type, + lastAttackTime: 0, + damage: enemyType.damage }; } |