diff options
Diffstat (limited to 'html/plains')
-rw-r--r-- | html/plains/game.js | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/html/plains/game.js b/html/plains/game.js index 1f9b27e..993ba45 100644 --- a/html/plains/game.js +++ b/html/plains/game.js @@ -753,7 +753,23 @@ const weaponSystems = { updateBubbles: (state, animationTime) => { const updatedBubbles = state.player.bubbles .filter(bubble => animationTime - bubble.createdAt < CONFIG.bubble.lifetime) - .map(bubble => updateBubble(bubble, animationTime)); + .map(bubble => { + // Check for enemy collisions + state.enemies.forEach(enemy => { + if (!enemy.stunned) { + const dx = enemy.x - bubble.x; + const dy = enemy.y - bubble.y; + const distance = Math.sqrt(dx * dx + dy * dy); + + if (distance < enemy.size + CONFIG.bubble.size) { + const knockbackAngle = Math.atan2(dy, dx); + enemySystem.handleEnemyDamage(enemy, 1, 1, knockbackAngle); + } + } + }); + + return updateBubble(bubble, animationTime); + }); const newParticles = updatedBubbles .flatMap(bubble => generateBubbleParticles(bubble, animationTime)); |