Skip to content

Commit

Permalink
applied sfx
Browse files Browse the repository at this point in the history
  • Loading branch information
dowhep committed Jun 7, 2024
1 parent 0d2593a commit 5a07d1b
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 10 deletions.
12 changes: 12 additions & 0 deletions assets/sounds/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,22 @@ import walkRight4 from "./Step R 4.wav";
import walkRight5 from "./Step R 5.wav";
export { default as reverbImpulse } from "./AndrewsChurchConvReverb2.wav";
// TODO: boss swing, boss projectiles
import bossGrowl from "./Boss Growl.wav";
import bossMelee from "./Boss Melee.wav";
import bossRange from "./Boss Range.wav";
import death from "./Death.wav";
import arrow from "./Arrow Shoot.wav";

export const sounds = {
/** Player tries to attack but it's not aimed at anything. */
attackFail,

bossGrowl,
bossMelee,
bossRange,

death,
arrow,
/**
* A crafter ejects all items right after absorbing an item because it cannot
* form a valid recipe.
Expand Down
27 changes: 17 additions & 10 deletions server/entities/BigBossEntity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const BOSS_JUMP_SPEED = 10;

const BOSS_ATTACK_COOLDOWN = 50; // ticks

const BIG_BOSS_SCALE: { offset: [number, number, number], rotation: [number, number, number, number]} = {
const BIG_BOSS_SCALE: { offset: [number, number, number]; rotation: [number, number, number, number] } = {
offset: [0, 0, 0] as Vector3,
rotation: new Quaternion(0, 0, 0, 1).setFromAxisAngle(new Vec3(0, 1, 0), Math.PI).toArray(),
} as const;
Expand All @@ -44,7 +44,7 @@ export class BigBossEntity extends PlayerEntity {
constructor(game: Game, footPos: Vector3) {
const model = {
modelId: "mushroom_king" as const,
...BIG_BOSS_SCALE
...BIG_BOSS_SCALE,
};
super(
game,
Expand All @@ -61,12 +61,18 @@ export class BigBossEntity extends PlayerEntity {
);
model.offset[1] = this.footOffset;

this.animator = new Animator({
hit: new Animation([
{ model: [{...BIG_BOSS_SCALE, modelId: `big_boss_hit1`}], duration: 3 },
{ model: [{...BIG_BOSS_SCALE, modelId: `big_boss_hit2`}], duration: 3 },
], 2),
}, [model]);
this.animator = new Animator(
{
hit: new Animation(
[
{ model: [{ ...BIG_BOSS_SCALE, modelId: `big_boss_hit1` }], duration: 3 },
{ model: [{ ...BIG_BOSS_SCALE, modelId: `big_boss_hit2` }], duration: 3 },
],
2,
),
},
[model],
);

this.previousAttackTick = this.game.getCurrentTick();
this.previousShootTick = this.game.getCurrentTick();
Expand All @@ -78,7 +84,7 @@ export class BigBossEntity extends PlayerEntity {
super.handleLanding(fallHeight);
this.game.shakeFromSource(this.getFootPos(), fallHeight / 20, 10, this);
}

attack(): Action<Attack> | null {
if (this.game.getCurrentTick() - this.previousAttackTick < BOSS_ATTACK_COOLDOWN) {
return super.attack();
Expand Down Expand Up @@ -120,7 +126,7 @@ export class BigBossEntity extends PlayerEntity {
entity.body.applyImpulse(
new Vec3(this.lookDir.x * 300, Math.abs(this.lookDir.y) * 150 + 50, this.lookDir.z * 300),
);
this.game.playSound("hit", entity.getPos());
this.game.playSound("bossMelee", entity.getPos());
} else if (entity instanceof InteractableEntity) {
entity.hit(this);
}
Expand Down Expand Up @@ -150,6 +156,7 @@ export class BigBossEntity extends PlayerEntity {
let betterDirection = this.body.position.vadd(dir);

this.game.shootArrow(betterDirection, dir.scale(10), 1, [{ modelId: "mushroom" }]);
this.game.playSound("bossRange", this.getPos());
//console.log(dir, betterDirection, betterDirection.unit(), this.body.position.vadd(betterDirection.unit()), this.getPos());
}
//this.animator.play("pee");
Expand Down
2 changes: 2 additions & 0 deletions server/entities/PlayerEntity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,7 @@ export abstract class PlayerEntity extends Entity {
);
//this.animator.play("punch");
this.#previousAttackTime = Date.now();
this.game.playSound("arrow", this.getPos());
},
};
}
Expand Down Expand Up @@ -450,6 +451,7 @@ export abstract class PlayerEntity extends Entity {
}
this.health -= damage;
if (this.health <= 0) {
this.game.playSound("death", this.getPos());
this.health = 0;
// Die
this.game.addToDeleteQueue(this.id);
Expand Down

0 comments on commit 5a07d1b

Please sign in to comment.