diff options
author | elioat <elioat@tilde.institute> | 2024-12-18 16:24:46 -0500 |
---|---|---|
committer | elioat <elioat@tilde.institute> | 2024-12-18 16:24:46 -0500 |
commit | 143f92e75a51605bfe79edd792c0ecf9fd2891ac (patch) | |
tree | 9d2c00e7b663901fd772c5d04a0a5100d56abb20 | |
parent | 734d82c140b7dca8b3e8b9ca1f5427910558bfa0 (diff) | |
download | tour-143f92e75a51605bfe79edd792c0ecf9fd2891ac.tar.gz |
*
-rw-r--r-- | html/plains/game.js | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/html/plains/game.js b/html/plains/game.js index 12742d4..deaebad 100644 --- a/html/plains/game.js +++ b/html/plains/game.js @@ -749,8 +749,8 @@ const createBubbleAttack = (state, animationTime) => { }; }; -// Add this helper function near other weapon-related functions -const checkEnemyCollision = (enemy, sourceX, sourceY, range) => { +// Update the collision helper to handle different damage amounts +const checkEnemyCollision = (enemy, sourceX, sourceY, range, damage = 0) => { if (enemy.stunned) return false; const dx = enemy.x - sourceX; @@ -759,7 +759,7 @@ const checkEnemyCollision = (enemy, sourceX, sourceY, range) => { if (distance < enemy.size + range) { const knockbackAngle = Math.atan2(dy, dx); - enemySystem.handleEnemyDamage(enemy, 1, 1, knockbackAngle); + enemySystem.handleEnemyDamage(enemy, damage, 1, knockbackAngle); return true; } return false; @@ -770,9 +770,9 @@ const weaponSystems = { const updatedBubbles = state.player.bubbles .filter(bubble => animationTime - bubble.createdAt < CONFIG.bubble.lifetime) .map(bubble => { - // Check for enemy collisions + // Check for enemy collisions with 0 damage state.enemies.forEach(enemy => { - checkEnemyCollision(enemy, bubble.x, bubble.y, CONFIG.bubble.size); + checkEnemyCollision(enemy, bubble.x, bubble.y, CONFIG.bubble.size, 0); }); return updateBubble(bubble, animationTime); }); @@ -799,9 +799,9 @@ const weaponSystems = { const newAngle = state.player.swordAngle + CONFIG.sword.swingSpeed; const swingComplete = newAngle > Math.atan2(state.player.direction.y, state.player.direction.x) + Math.PI / 2; - // Check all enemies for sword collision + // Check all enemies for sword collision with 1 damage const updatedEnemies = state.enemies.map(enemy => { - checkEnemyCollision(enemy, state.player.x, state.player.y, CONFIG.sword.length); + checkEnemyCollision(enemy, state.player.x, state.player.y, CONFIG.sword.length, 1); return enemy; }); |