Skip to content

Commit

Permalink
Add max width for reset options
Browse files Browse the repository at this point in the history
Set all random coords to integers
Toggle enemy to idle on player's death
Fix first enemy spawn call
  • Loading branch information
UstymUkhman committed Dec 26, 2022
1 parent 676b03d commit 2a6205c
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 6 deletions.
3 changes: 2 additions & 1 deletion src/characters/Enemy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -653,7 +653,8 @@ export default class Enemy extends Character
}

protected override get blockingAnimation (): boolean {
return this.attacking || this.falling || this.screaming || super.blockingAnimation;
return this.attacking || this.falling || this.screaming ||
this.playerDead || super.blockingAnimation;
}

private get material (): MeshStandardMaterial {
Expand Down
1 change: 1 addition & 0 deletions src/components/menu/Settings.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,7 @@
dl {
justify-content: space-between;
display: inline-flex;
max-width: 280px;
width: 60%;
margin: 0;
Expand Down
11 changes: 7 additions & 4 deletions src/managers/Enemies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,9 @@ export default class Enemies
private spawnedEnemies = 0;

public constructor (private readonly envMap: Texture) {
(new Enemy).loadCharacter(envMap).then(model => {
this.enemyModel = model;
this.spawnEnemy([0.0, 0.0]);
});
(new Enemy).loadCharacter(envMap).then(model =>
this.enemyModel = model
);

this.addEvents();
}
Expand Down Expand Up @@ -88,6 +87,10 @@ export default class Enemies
}
}

public spawnFirst (): void {
this.spawnEnemy([0.0, 0.0]);
}

public spawnMultiple (x: number, z: number, enemies = 2): void {
const spawned = this.enemies.length - 1;
enemies = Math.min(Configs.Gameplay.maxEnemies - spawned, enemies);
Expand Down
2 changes: 2 additions & 0 deletions src/managers/MainLoop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,9 @@ export default class MainLoop
this.player.loadCharacter(envMap).then(() => {
this.player.setPistol(this.level.walls, this.pistol);
Physics.setCharacter(this.player.collider, 90);

this.player.addRifle(this.rifle);
this.enemies.spawnFirst();

this.createRandomCoords();
RAF.add(this.loop);
Expand Down
2 changes: 1 addition & 1 deletion src/worker/getRandomCoord.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,6 @@ export const getRandomCoord = (params: LevelParams): LevelCoords => {
random(
Math.max(topRightX, bottomRightX),
Math.min(topLeftX, bottomLeftX)
), randomZ
) | 0, randomZ | 0
];
};

0 comments on commit 2a6205c

Please sign in to comment.