Music and Sound Effects

This commit is contained in:
Brian Fertig 2025-08-23 22:04:01 -06:00
parent f409413e8d
commit 23940c0dbd
8 changed files with 45 additions and 0 deletions

Binary file not shown.

BIN
assets/beach-music.mp3 Normal file

Binary file not shown.

BIN
assets/clear.mp3 Normal file

Binary file not shown.

BIN
assets/goblin-music.mp3 Normal file

Binary file not shown.

BIN
assets/level-up.mp3 Normal file

Binary file not shown.

BIN
assets/switch.mp3 Normal file

Binary file not shown.

View File

@ -39,13 +39,24 @@ export class GameScene extends Phaser.Scene {
}
preload() {
// Jewels
this.load.spritesheet('jewels', 'assets/jewels.png', {
frameWidth: 100,
frameHeight: 100
});
// Fonts
this.load.font('cruiser', 'assets/NEUROPOL.ttf');
this.load.font('code', 'assets/CodePredators-Regular.otf');
// Music
this.load.audio('goblin-music', 'assets/goblin-music.mp3');
this.load.audio('beach-music', 'assets/beach-music.mp3');
this.load.audio('clear', 'assets/clear.mp3');
this.load.audio('level-up', 'assets/level-up.mp3');
this.load.audio('switch', 'assets/switch.mp3');
// Ally Videos
this.load.video('goblin-resting', 'assets/goblin-resting.mp4');
this.load.video('goblin-excited', 'assets/goblin-excited.mp4');
this.load.video('goblin-pleased', 'assets/goblin-pleased.mp4');
@ -61,6 +72,11 @@ export class GameScene extends Phaser.Scene {
this.physics.add.collider(this.jewels, this.jewels);
this.createStart();
// Background Music
this.bgMusic = this.sound.add('goblin-music', { volume: 0.5 });
this.bgMusic.loop = true;
this.bgMusic.play();
// Create the score text
this.scoreText = this.add.text(20, 50, 'Score: 0', {
fontFamily: 'cruiser, arial',
@ -328,6 +344,7 @@ export class GameScene extends Phaser.Scene {
}
// Set swapping flag to prevent new clicks from being processed
this.isSwapping = true;
this.sound.play('switch');
// Disable all jewel interactivity temporarily
this.jewels.children.iterate((jewel) => {
@ -387,6 +404,7 @@ export class GameScene extends Phaser.Scene {
this.matchesNeeded = newLevel.matchesNeeded;
this.moveInterval = newLevel.moveInterval;
this.LevelText.setText(`Level: ${this.level}`);
this.sound.play('level-up');
// Create the New Level text
const newLevelText = this.add.text(1150, 250, `Level ${this.level}`, {
@ -559,6 +577,8 @@ export class GameScene extends Phaser.Scene {
}
});
this.sound.play('clear');
// Animate destruction
jewelsToDestroy.forEach((jewel) => {
this.tweens.add({

View File

@ -13,5 +13,30 @@ export const LEVEL_CONFIG = {
numberOfJewels: 5,
matchesNeeded: 12,
moveInterval: 11000
},
4: {
numberOfJewels: 5,
matchesNeeded: 12,
moveInterval: 10000
},
5: {
numberOfJewels: 5,
matchesNeeded: 12,
moveInterval: 9000
},
6: {
numberOfJewels: 5,
matchesNeeded: 12,
moveInterval: 8000
},
7: {
numberOfJewels: 5,
matchesNeeded: 12,
moveInterval: 7000
},
8: {
numberOfJewels: 5,
matchesNeeded: 12,
moveInterval: 6000
}
};