First Ally Complete

This commit is contained in:
Brian Fertig 2025-08-24 07:39:42 -06:00
parent 23940c0dbd
commit fd7e0909e8
9 changed files with 64 additions and 20 deletions

BIN
assets/goblin-a1.mp3 Normal file

Binary file not shown.

BIN
assets/goblin-a2.mp3 Normal file

Binary file not shown.

BIN
assets/goblin-a3.mp3 Normal file

Binary file not shown.

BIN
assets/goblin-b.mp3 Normal file

Binary file not shown.

BIN
assets/goblin-c.mp3 Normal file

Binary file not shown.

BIN
assets/goblin-intro.mp3 Normal file

Binary file not shown.

BIN
assets/goblin-outro.mp3 Normal file

Binary file not shown.

View File

@ -17,7 +17,7 @@ export class GameScene extends Phaser.Scene {
this.numberOfJewels = 4; this.numberOfJewels = 4;
this.startRows = 3; this.startRows = 3;
this.level = 1; this.level = 1;
this.matchesNeeded = 10; this.matchesNeeded = 8;
this.score = 0; this.score = 0;
this.ally = 'goblin'; this.ally = 'goblin';
@ -27,6 +27,7 @@ export class GameScene extends Phaser.Scene {
this.isDestroying = false; this.isDestroying = false;
this.isMovingUp = false; this.isMovingUp = false;
this.isPlayingVideo = false; this.isPlayingVideo = false;
this.isPlayingAudio = false;
// Add selectedJewel property // Add selectedJewel property
this.selectedJewel = null; this.selectedJewel = null;
@ -56,11 +57,21 @@ export class GameScene extends Phaser.Scene {
this.load.audio('level-up', 'assets/level-up.mp3'); this.load.audio('level-up', 'assets/level-up.mp3');
this.load.audio('switch', 'assets/switch.mp3'); this.load.audio('switch', 'assets/switch.mp3');
// Ally Videos // Ally Assets
this.load.video('goblin-resting', 'assets/goblin-resting.mp4'); const allys = ['goblin'];
this.load.video('goblin-excited', 'assets/goblin-excited.mp4'); allys.forEach((ally) => {
this.load.video('goblin-pleased', 'assets/goblin-pleased.mp4'); this.load.video(`${ally}-resting`, 'assets/goblin-resting.mp4');
this.load.video('goblin-match', 'assets/goblin-match.mp4'); this.load.video(`${ally}-excited`, 'assets/goblin-excited.mp4');
this.load.video(`${ally}-pleased`, 'assets/goblin-pleased.mp4');
this.load.video(`${ally}-match`, 'assets/goblin-match.mp4');
this.load.audio(`${ally}-a1`, 'assets/goblin-a1.mp3');
this.load.audio(`${ally}-a2`, 'assets/goblin-a2.mp3');
this.load.audio(`${ally}-a3`, 'assets/goblin-a3.mp3');
this.load.audio(`${ally}-b`, 'assets/goblin-b.mp3');
this.load.audio(`${ally}-c`, 'assets/goblin-c.mp3');
this.load.audio(`${ally}-intro`, 'assets/goblin-intro.mp3');
this.load.audio(`${ally}-outro`, 'assets/goblin-outro.mp3');
});
} }
create() { create() {
@ -73,7 +84,7 @@ export class GameScene extends Phaser.Scene {
this.createStart(); this.createStart();
// Background Music // Background Music
this.bgMusic = this.sound.add('goblin-music', { volume: 0.5 }); this.bgMusic = this.sound.add('goblin-music', { volume: 0.2 });
this.bgMusic.loop = true; this.bgMusic.loop = true;
this.bgMusic.play(); this.bgMusic.play();
@ -131,6 +142,9 @@ export class GameScene extends Phaser.Scene {
this.allyVideo = this.add.video(350, 610, `${this.ally}-resting`).setOrigin(0.5); this.allyVideo = this.add.video(350, 610, `${this.ally}-resting`).setOrigin(0.5);
this.allyVideo.play(true); this.allyVideo.play(true);
this.time.delayedCall(500, () => {
this.sound.play(`${this.ally}-intro`);
});
} }
update(time, delta) { update(time, delta) {
@ -519,6 +533,7 @@ export class GameScene extends Phaser.Scene {
// If we found matches, destroy them and play video // If we found matches, destroy them and play video
if (matchedJewels.size > 0) { if (matchedJewels.size > 0) {
this.playVideo(matchedJewels.size); this.playVideo(matchedJewels.size);
this.playAudio(matchedJewels.size);
const scoreMatches = matchedJewels.size / 3; const scoreMatches = matchedJewels.size / 3;
const scoreAdd = Math.ceil(scoreMatches ** 2) * 10; const scoreAdd = Math.ceil(scoreMatches ** 2) * 10;
this.score += scoreAdd; this.score += scoreAdd;
@ -551,7 +566,28 @@ export class GameScene extends Phaser.Scene {
this.time.delayedCall(5000, () => { this.time.delayedCall(5000, () => {
this.isPlayingVideo = false; this.isPlayingVideo = false;
showVideo.destroy(); showVideo.destroy();
console.log('end video'); });
}
playAudio(amount) {
if (this.isPlayingAudio === true) {
return;
}
this.isPlayingAudio = true;
let audio = null;
if (amount >= 5) {
audio = `${this.ally}-c`;
} else if (amount >= 4) {
audio = `${this.ally}-b`;
} else {
const rand = Phaser.Math.Between(1, 3);
audio = `${this.ally}-a${rand}`;
}
this.sound.play(audio);
this.time.delayedCall(2000, () => {
this.isPlayingAudio = false;
}); });
} }

View File

@ -1,42 +1,50 @@
export const LEVEL_CONFIG = { export const LEVEL_CONFIG = {
1: { 1: {
numberOfJewels: 4, numberOfJewels: 4,
matchesNeeded: 12, matchesNeeded: 8,
moveInterval: 12000 moveInterval: 12000,
ally: 'goblin'
}, },
2: { 2: {
numberOfJewels: 5, numberOfJewels: 5,
matchesNeeded: 12, matchesNeeded: 8,
moveInterval: 12000 moveInterval: 12000,
ally: 'goblin'
}, },
3: { 3: {
numberOfJewels: 5, numberOfJewels: 5,
matchesNeeded: 12, matchesNeeded: 9,
moveInterval: 11000 moveInterval: 11000,
ally: 'goblin'
}, },
4: { 4: {
numberOfJewels: 5, numberOfJewels: 5,
matchesNeeded: 12, matchesNeeded: 10,
moveInterval: 10000 moveInterval: 10000,
ally: 'goblin'
}, },
5: { 5: {
numberOfJewels: 5, numberOfJewels: 5,
matchesNeeded: 12, matchesNeeded: 12,
moveInterval: 9000 moveInterval: 9000,
ally: 'goblin'
}, },
6: { 6: {
numberOfJewels: 5, numberOfJewels: 5,
matchesNeeded: 12, matchesNeeded: 12,
moveInterval: 8000 moveInterval: 8000,
ally: 'goblin'
}, },
7: { 7: {
numberOfJewels: 5, numberOfJewels: 5,
matchesNeeded: 12, matchesNeeded: 12,
moveInterval: 7000 moveInterval: 7000,
ally: 'goblin'
}, },
8: { 8: {
numberOfJewels: 5, numberOfJewels: 5,
matchesNeeded: 12, matchesNeeded: 12,
moveInterval: 6000 moveInterval: 6000,
ally: 'goblin'
} }
}; };