Feature/advanced game mechanics #5

Merged
ilia merged 30 commits from feature/advanced-game-mechanics into main 2026-07-19 15:09:22 +00:00
2 changed files with 18 additions and 1 deletions
Showing only changes of commit b7ca56c99c - Show all commits
+1
View File
@@ -27,3 +27,4 @@ export const PERK_FALL_SPEED = 3;
export const PERK_DROP_CHANCE = 0.3; export const PERK_DROP_CHANCE = 0.3;
export const PERK_BALL_SPEED_DECREASE = 2; export const PERK_BALL_SPEED_DECREASE = 2;
export const PERK_TYPES = ['slow', 'wide', 'life', 'clone']; export const PERK_TYPES = ['slow', 'wide', 'life', 'clone'];
export const PERK_DURATION_SEC = 20;
+17 -1
View File
@@ -1,4 +1,11 @@
import { BALL_SPLIT_ANGLE, CONTAINER_WIDTH, PADDLE_WIDE_WIDTH, PERK_BALL_SPEED_DECREASE } from '../../config'; import {
BALL_SPLIT_ANGLE,
CONTAINER_WIDTH,
PADDLE_WIDE_WIDTH,
PADDLE_WIDTH,
PERK_BALL_SPEED_DECREASE,
PERK_DURATION_SEC,
} from '../../config';
import { clone } from '../../entities/ball/clone/clone'; import { clone } from '../../entities/ball/clone/clone';
import { Game } from '../../game'; import { Game } from '../../game';
import { calculateAABBCollision } from '../calculateAABBCollision/calculateAABBCollision'; import { calculateAABBCollision } from '../calculateAABBCollision/calculateAABBCollision';
@@ -51,10 +58,19 @@ export function updatePerks(game, containerHeight, deltaTime) {
ball.increaseSpeed(-1 * PERK_BALL_SPEED_DECREASE); ball.increaseSpeed(-1 * PERK_BALL_SPEED_DECREASE);
} }
} }
// ponytail: wall-clock timer, game never pauses so no need to tie to deltaTime
setTimeout(() => {
for (const ball of game.balls) {
ball.increaseSpeed(PERK_BALL_SPEED_DECREASE);
}
}, PERK_DURATION_SEC * 1000);
break; break;
case 'wide': case 'wide':
paddle.width = PADDLE_WIDE_WIDTH; paddle.width = PADDLE_WIDE_WIDTH;
paddle.moveTo(paddle.x, 0, CONTAINER_WIDTH); paddle.moveTo(paddle.x, 0, CONTAINER_WIDTH);
setTimeout(() => {
paddle.width = PADDLE_WIDTH;
}, PERK_DURATION_SEC * 1000);
break; break;
case 'life': case 'life':
game.livesAmount += 1; game.livesAmount += 1;