Skip to content

Commit

Permalink
death sounds
Browse files Browse the repository at this point in the history
  • Loading branch information
asiaziola committed Jul 24, 2024
1 parent fa99bf7 commit 659ab75
Show file tree
Hide file tree
Showing 13 changed files with 31 additions and 10 deletions.
Binary file added assets/audio/death_headshot_1.mp3
Binary file not shown.
Binary file added assets/audio/death_headshot_2.mp3
Binary file not shown.
Binary file added assets/audio/death_headshot_3.mp3
Binary file not shown.
Binary file added assets/audio/death_slice_1.mp3
Binary file not shown.
Binary file added assets/audio/death_slice_2.mp3
Binary file not shown.
Binary file added assets/audio/death_slice_3.mp3
Binary file not shown.
Binary file added assets/audio/death_tankshot_1.mp3
Binary file not shown.
Binary file added assets/audio/death_tankshot_2.mp3
Binary file not shown.
Binary file added assets/audio/death_tankshot_3.mp3
Binary file not shown.
5 changes: 4 additions & 1 deletion js/Player.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,10 @@ export default class Player extends Phaser.Physics.Arcade.Sprite {
}

deathAnim(killer) {
return this.anims.play(`${this.beaverChoice}_death_${BEAVER_TYPES[killer].kill}`, true);
const kill = BEAVER_TYPES[killer].kill;
const random = Math.floor(Math.random() * (Const.DEATH_SOUND_OPTIONS - 1 + 1) + 1);
this.scene[`${kill}${random}DeathSound`].play();
return this.anims.play(`${this.beaverChoice}_death_${kill}`, true);
}

digAnim() {
Expand Down
3 changes: 3 additions & 0 deletions js/common/const.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ export const MIN_MSG_LENGTH = 2; // Hi

export const MAX_LAST_TXS = 20;

const DEATH_SOUND_OPTIONS = 3;

const Kills = {
headshot: 'headshot',
slice: 'slice',
Expand Down Expand Up @@ -190,4 +192,5 @@ export default {
MED_AP_COST,
HIGH_AP_COST,
Kills,
DEATH_SOUND_OPTIONS,
};
17 changes: 16 additions & 1 deletion js/scenes/MainScene.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,24 @@ export default class MainScene extends Phaser.Scene {
this.load.audio('triple_kill', ['assets/audio/triple_kill.m4a']);
this.load.audio('god_like', ['assets/audio/god_like.m4a']);
this.load.audio('revenge', ['assets/audio/revenge.m4a']);
this.forDeathSounds((k, i) => this.loadDeathSound(k, i, this));
this.load.addFile(new WebFontFile(this.load, 'Press Start 2P'));
}

forDeathSounds(execute) {
for (let i = 1; i < Const.DEATH_SOUND_OPTIONS; i++) {
Object.values(Const.Kills).forEach((k) => execute(k, i));
}
}

loadDeathSound(k, i, self) {
self.load.audio(`death_${k}_${i}`, [`assets/audio/death_${k}_${i}.mp3`]);
}

addDeathSound(k, i) {
this[`${k}${i}DeathSound`] = this.sound.add(`death_${k}_${i}`, { loop: false, volume: 2.0 });
}

loadBeaverAssets(beaver) {
this.load.image(`${beaver}_48`, `assets/images/beavers/${beaver}/${beaver}_48px.png`);
this.loadBeaverAnim(beaver, 'idle');
Expand All @@ -94,7 +109,6 @@ export default class MainScene extends Phaser.Scene {
}

loadBeaverAnim(beaver, asset) {
console.log(`${beaver}_anim_${asset}`);
this.load.atlas(
`${beaver}_anim_${asset}`,
`assets/images/beavers/${beaver}/${beaver}_anim_${asset}.png`,
Expand Down Expand Up @@ -735,6 +749,7 @@ export default class MainScene extends Phaser.Scene {
this.tripleKillSound = this.sound.add('triple_kill', { loop: false, volume: 4.0 });
this.godLikeSound = this.sound.add('god_like', { loop: false, volume: 4.0 });
this.revengeSound = this.sound.add('revenge', { loop: false, volume: 4.0 });
this.forDeathSounds((k, i) => this.addDeathSound(k, i, this));

if (window.warpAO.config.env !== 'local') {
this.backgroundMusic.play();
Expand Down
16 changes: 8 additions & 8 deletions js/scenes/anim/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@ export const ANIM_SETTINGS = {
death_tankshot: {
prefix: 'frame-',
start: 1,
end: 21,
end: 10,
frameRate: 8,
},
death_slice: {
prefix: 'frame-',
start: 1,
end: 21,
end: 17,
frameRate: 8,
},
},
Expand Down Expand Up @@ -83,19 +83,19 @@ export const ANIM_SETTINGS = {
death_headshot: {
prefix: 'frame-',
start: 1,
end: 21,
end: 19,
frameRate: 8,
},
death_tankshot: {
prefix: 'frame-',
start: 1,
end: 21,
end: 18,
frameRate: 8,
},
death_slice: {
prefix: 'frame-',
start: 1,
end: 21,
end: 15,
frameRate: 8,
},
},
Expand Down Expand Up @@ -133,19 +133,19 @@ export const ANIM_SETTINGS = {
death_headshot: {
prefix: 'frame-',
start: 1,
end: 21,
end: 14,
frameRate: 8,
},
death_tankshot: {
prefix: 'frame-',
start: 1,
end: 21,
end: 15,
frameRate: 8,
},
death_slice: {
prefix: 'frame-',
start: 1,
end: 21,
end: 17,
frameRate: 8,
},
},
Expand Down

0 comments on commit 659ab75

Please sign in to comment.