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

[SOK-40] Game map #23

Merged
merged 2 commits into from
Oct 11, 2024
Merged

[SOK-40] Game map #23

merged 2 commits into from
Oct 11, 2024

Conversation

VladToby
Copy link
Collaborator

### Какую задачу решаем

Скриншоты/видяшка (если есть)

Снимок экрана 2024-10-10 в 21 59 14

TBD (если есть)

@VladToby VladToby changed the base branch from main to develop October 11, 2024 15:23
Copy link
Collaborator

@k0ndratov k0ndratov left a comment

Choose a reason for hiding this comment

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

Круто. Игра приобритает законченный вид.

Возможно только стоит позицию этого танка чуть подвинуть, так как не понятно куда ему стрелять. Либо в стену, либо в другого врага.

image

height: 30,
speed: 1,
export const initializeEnemies = (): Enemy[] => {
return [
Copy link
Collaborator

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}

Copy link
Collaborator Author

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
Copy link
Collaborator

Choose a reason for hiding this comment

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

Вроде же всегда будет false, значит всегда заходит в if, затем меняется на true. А зачем эта переменная?

Copy link
Collaborator Author

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++) {
Copy link
Collaborator

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))

Но может быть это на любителя.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Поменял

@VladToby VladToby requested a review from k0ndratov October 11, 2024 19:22
@VladToby VladToby merged commit 97d8b74 into develop Oct 11, 2024
1 check passed
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.

2 participants