diff options
author | elioat <elioat@tilde.institute> | 2024-12-18 16:14:01 -0500 |
---|---|---|
committer | elioat <elioat@tilde.institute> | 2024-12-18 16:14:01 -0500 |
commit | 241ee7f764994f7c02b576835be91ace68feea9c (patch) | |
tree | b7b611559f4eae2442e56aca4c6bb9a5a6b4a671 | |
parent | e8b1a10f45e25aef021b3b164582b609c0ed36a7 (diff) | |
download | tour-241ee7f764994f7c02b576835be91ace68feea9c.tar.gz |
*
-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)); |