From 241ee7f764994f7c02b576835be91ace68feea9c Mon Sep 17 00:00:00 2001 From: elioat Date: Wed, 18 Dec 2024 16:14:01 -0500 Subject: * --- html/plains/game.js | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'html') 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)); -- cgit 1.4.1-2-gfad0