-
Notifications
You must be signed in to change notification settings - Fork 2
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
[SOK-40] Game map #23
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
height: 30, | ||
speed: 1, | ||
export const initializeEnemies = (): Enemy[] => { | ||
return [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Возможно лучше дефолтны объект создать, и копировать его, подменяя позицию.
Что-то типо:
{ ...enemyParams, x: 1, y: 2}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Да, не подумал об этом, так действительно лучше
@@ -31,15 +31,20 @@ export const gameLoop = ( | |||
drawPlayer(context, playerRef.current) | |||
drawEnemies(context, enemiesRef.current) | |||
|
|||
// Проверка на столкновения между игроком и врагами | |||
let collisionOccurred = false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Вроде же всегда будет false, значит всегда заходит в if
, затем меняется на true
. А зачем эта переменная?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Переписал
const horizontalCount = Math.ceil(obstacle.width / SPRITE_SIZE) | ||
const verticalCount = Math.ceil(obstacle.height / SPRITE_SIZE) | ||
|
||
for (let i = 0; i < horizontalCount; i++) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Возможно forEach
чуть проще воспринимать.
Array.from({length: horizontalCount}).forEach((_, index))
Но может быть это на любителя.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Поменял
…irst enemy position
### Какую задачу решаем
Скриншоты/видяшка (если есть)
TBD (если есть)