Skip to content

Commit bc87304

Browse files
committed
shoot bullet
1 parent 115e4a1 commit bc87304

1 file changed

Lines changed: 18 additions & 1 deletion

File tree

navigation/Minigames/pacman.md

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -497,7 +497,24 @@ Author: Aarush
497497
case 'd':
498498
currentDirection = { dx: 1, dy: 0, dir: 'right' };
499499
break;
500-
}
500+
}
501+
502+
// Shoot bullet with Shift key (either left or right shift)
503+
if (e.key === 'Shift') {
504+
if (pacman.dx !== 0 || pacman.dy !== 0) {
505+
const exists = bullets.some(
506+
b => b.x === pacman.x && b.y === pacman.y && b.dx === pacman.dx && b.dy === pacman.dy
507+
);
508+
if (!exists) {
509+
bullets.push({
510+
x: pacman.x,
511+
y: pacman.y,
512+
dx: pacman.dx,
513+
dy: pacman.dy
514+
});
515+
}
516+
}
517+
}
501518
});
502519

503520
function updatePacman(force) {

0 commit comments

Comments
 (0)