Skip to content

Commit

Permalink
add task solution
Browse files Browse the repository at this point in the history
  • Loading branch information
KrainovaAnastasia committed Oct 27, 2024
1 parent 1ac5202 commit 1506fd6
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
Binary file added src/images/favicon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
content="width=device-width, initial-scale=1.0"
/>
<title>2048</title>
<link
rel="icon"
href="./images/favicon.png"
/>
<link
rel="stylesheet"
href="./styles/main.scss"
Expand Down
13 changes: 9 additions & 4 deletions src/scripts/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
const Game = require('../modules/Game.class');
const game = new Game();

const ARROW_RIGHT = 'ArrowRight';
const ARROW_LEFT = 'ArrowLeft';
const ARROW_UP = 'ArrowUp';
const ARROW_DOWN = 'ArrowDown';

const startRestartButton = document.getElementById('start-button');

const messageStart = document.querySelector('.message-start');
Expand Down Expand Up @@ -40,16 +45,16 @@ startRestartButton.addEventListener('click', () => {

document.addEventListener('keydown', (evnt) => {
switch (evnt.key) {
case 'ArrowLeft':
case ARROW_LEFT:
game.moveLeft();
break;
case 'ArrowRight':
case ARROW_RIGHT:
game.moveRight();
break;
case 'ArrowUp':
case ARROW_UP:
game.moveUp();
break;
case 'ArrowDown':
case ARROW_DOWN:
game.moveDown();
break;
}
Expand Down

0 comments on commit 1506fd6

Please sign in to comment.