Skip to content

Commit 97abda4

Browse files
committed
Refactor game initialization; replace direct animate call with startGame function to enhance clarity and control
1 parent ade9aaa commit 97abda4

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

src/index.js

+9-6
Original file line numberDiff line numberDiff line change
@@ -706,11 +706,7 @@ function animate() {
706706
}
707707

708708
};
709-
710-
// canvas.focus();
711-
712-
animate();
713-
709+
//
714710
window.addEventListener('keydown', ({ key }) => {
715711
switch (key) {
716712
case 'w':
@@ -751,4 +747,11 @@ window.addEventListener('keyup', ({ key }) => {
751747

752748
// window.addEventListener('keydown', handleKeyDown);
753749
// window.addEventListener('keyup', handleKeyUp);
754-
console.log(pacman.velocity);
750+
console.log(pacman.velocity);
751+
752+
function startGame() {
753+
canvas.focus();
754+
animate();
755+
};
756+
757+
startGame();

0 commit comments

Comments
 (0)