Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

solution #542

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

solution #542

wants to merge 4 commits into from

Conversation

NataliMax
Copy link

No description provided.

@NataliMax
Copy link
Author

DEMO LINK

Copy link

@anastasiiavorobiova anastasiiavorobiova left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great start! Keep doing: arrows don't work, a user can just start or restart the game. Feel free to ask for help in the chat

@NataliMax
Copy link
Author

It`s work with 'a' ,'d', 'w', 's'. please try

Copy link

@denys-danyliuk denys-danyliuk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Game has ended even though I have available steps left, you should investigate into this
Знімок екрана 2023-10-23 о 16 25 09

Copy link

@denys-danyliuk denys-danyliuk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

problem about which I wrote earlier still exists
Знімок екрана 2023-10-24 о 09 39 31

Comment on lines 233 to 256
document.addEventListener('keydown', e => {
switch (e.key) {
case 'a': {
moveHorizontally(left);
break;
}

case 'd': {
moveHorizontally(right);
break;
}

case 'w': {
moveVertically(up);
break;
}

case 's': {
moveVertically(down);
break;
}
}
loseCheck();
});

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add also ability to use arrows, will be really good improvement

Comment on lines 266 to 327
// const gameTable = document.querySelector('.game-field');

// let touchStartX = 0;
// let touchStartY = 0;

// document.addEventListener('touchmove', (e) => {
// e.preventDefault();
// });

// gameTable.addEventListener('touchmove', (e) => {
// e.preventDefault();
// });

// gameTable.addEventListener('touchstart', (e) => {
// touchStartX = e.touches[0].clientX;
// touchStartY = e.touches[0].clientY;
// });

// gameTable.addEventListener('touchend', (e) => {
// const touchEndX = e.changedTouches[0].clientX;
// const touchEndY = e.changedTouches[0].clientY;
// const touchDiffX = touchEndX - touchStartX;
// const touchDiffY = touchEndY - touchStartY;
// const breakPoint = 50;

// if (Math.abs(touchDiffX) > Math.abs(touchDiffY)) {
// if (touchDiffX > breakPoint) {
// moveHorizontally(right);
// loseCheck();
// } else if (touchDiffX < -1 * breakPoint) {
// moveHorizontally(left);
// loseCheck();
// } else if (touchDiffY > breakPoint) {
// moveVertically(down);
// loseCheck();
// } else if (touchDiffY < -1 * breakPoint) {
// moveVertically(up);
// loseCheck();
// }

// switch (true) {
// case (touchDiffX > breakPoint):
// moveHorizontally(right);
// break;
// case (touchDiffX < -1 * breakPoint):
// moveHorizontally(left);
// break;
// case (touchDiffY > breakPoint):
// moveVertically(down);
// break;
// case (touchDiffY < -1 * breakPoint):
// moveVertically(up);
// break;
// default: return 0;
// }
// loseCheck();
// }
// });

// document.addEventListener('touchmove', (e) => {
// e.preventDefault();
// });

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove commented code

@NataliMax NataliMax requested a review from sTorba24 October 25, 2023 17:46
Comment on lines +235 to +243
case 'a': {
moveHorizontally(left);
break;
}

case 'ArrowLeft': {
moveHorizontally(left);
break;
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can combine these cases

Suggested change
case 'a': {
moveHorizontally(left);
break;
}
case 'ArrowLeft': {
moveHorizontally(left);
break;
}
case 'a':
case 'ArrowLeft': {
moveHorizontally(left);
break;
}

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately, the linter requires a 'break' after each 'case'. I asked this question in the chat, In this case it is impossible

@NataliMax NataliMax requested a review from etojeDenys October 26, 2023 07:07
Copy link

@etojeDenys etojeDenys left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants