diff --git a/assets/jewels.png b/assets/jewels.png index d913801..ab5c2b6 100644 Binary files a/assets/jewels.png and b/assets/jewels.png differ diff --git a/assets/jewels.psd b/assets/jewels.psd index 778017d..91f2f4a 100644 Binary files a/assets/jewels.psd and b/assets/jewels.psd differ diff --git a/assets/surfer-a1.mp3 b/assets/surfer-a1.mp3 new file mode 100644 index 0000000..8e1012a Binary files /dev/null and b/assets/surfer-a1.mp3 differ diff --git a/assets/surfer-a2.mp3 b/assets/surfer-a2.mp3 new file mode 100644 index 0000000..fedd49e Binary files /dev/null and b/assets/surfer-a2.mp3 differ diff --git a/assets/surfer-a3.mp3 b/assets/surfer-a3.mp3 new file mode 100644 index 0000000..a07ff7b Binary files /dev/null and b/assets/surfer-a3.mp3 differ diff --git a/assets/surfer-b.mp3 b/assets/surfer-b.mp3 new file mode 100644 index 0000000..a8e9d84 Binary files /dev/null and b/assets/surfer-b.mp3 differ diff --git a/assets/surfer-background.mp4 b/assets/surfer-background.mp4 new file mode 100644 index 0000000..f85dd92 Binary files /dev/null and b/assets/surfer-background.mp4 differ diff --git a/assets/surfer-c.mp3 b/assets/surfer-c.mp3 new file mode 100644 index 0000000..6ea8c5f Binary files /dev/null and b/assets/surfer-c.mp3 differ diff --git a/assets/surfer-excited.mp4 b/assets/surfer-excited.mp4 new file mode 100644 index 0000000..3fa4714 Binary files /dev/null and b/assets/surfer-excited.mp4 differ diff --git a/assets/surfer-intro.mp3 b/assets/surfer-intro.mp3 new file mode 100644 index 0000000..48e947d Binary files /dev/null and b/assets/surfer-intro.mp3 differ diff --git a/assets/surfer-match.mp4 b/assets/surfer-match.mp4 new file mode 100644 index 0000000..19b048a Binary files /dev/null and b/assets/surfer-match.mp4 differ diff --git a/assets/surfer-music.mp3 b/assets/surfer-music.mp3 new file mode 100644 index 0000000..50906fe Binary files /dev/null and b/assets/surfer-music.mp3 differ diff --git a/assets/surfer-music2.mp3 b/assets/surfer-music2.mp3 new file mode 100644 index 0000000..b737ecc Binary files /dev/null and b/assets/surfer-music2.mp3 differ diff --git a/assets/surfer-outro.mp3 b/assets/surfer-outro.mp3 new file mode 100644 index 0000000..2e750cf Binary files /dev/null and b/assets/surfer-outro.mp3 differ diff --git a/assets/surfer-pleased.mp4 b/assets/surfer-pleased.mp4 new file mode 100644 index 0000000..1807fb9 Binary files /dev/null and b/assets/surfer-pleased.mp4 differ diff --git a/assets/surfer-resting.mp4 b/assets/surfer-resting.mp4 new file mode 100644 index 0000000..d1dd324 Binary files /dev/null and b/assets/surfer-resting.mp4 differ diff --git a/assets/surferDude.png b/assets/surferDude.png new file mode 100644 index 0000000..7215d45 Binary files /dev/null and b/assets/surferDude.png differ diff --git a/src/GameScene.js b/src/GameScene.js index 6c037ce..0bc468d 100644 --- a/src/GameScene.js +++ b/src/GameScene.js @@ -20,7 +20,7 @@ export class GameScene extends Phaser.Scene { this.matchesNeeded = 8; this.score = 0; this.ally = 'goblin'; - this.gameStatus = true; + this.spritePlus = 0; // Status Indication this.isDropping = false; @@ -29,6 +29,7 @@ export class GameScene extends Phaser.Scene { this.isMovingUp = false; this.isPlayingVideo = false; this.isPlayingAudio = false; + this.gameStatus = true; // Add selectedJewel property this.selectedJewel = null; @@ -53,8 +54,6 @@ export class GameScene extends Phaser.Scene { 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'); @@ -63,20 +62,21 @@ export class GameScene extends Phaser.Scene { this.load.audio('alarm', 'assets/alarm.mp3'); // Ally Assets - const allys = ['goblin']; + const allys = ['goblin', 'surfer']; allys.forEach((ally) => { - this.load.video(`${ally}-resting`, 'assets/goblin-resting.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.video(`${ally}-resting`, `assets/${ally}-resting.mp4`); + this.load.video(`${ally}-excited`, `assets/${ally}-excited.mp4`); + this.load.video(`${ally}-pleased`, `assets/${ally}-pleased.mp4`); + this.load.video(`${ally}-match`, `assets/${ally}-match.mp4`); this.load.video(`${ally}-background`, `assets/${ally}-background.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'); + this.load.audio(`${ally}-a1`, `assets/${ally}-a1.mp3`); + this.load.audio(`${ally}-a2`, `assets/${ally}-a2.mp3`); + this.load.audio(`${ally}-a3`, `assets/${ally}-a3.mp3`); + this.load.audio(`${ally}-b`, `assets/${ally}-b.mp3`); + this.load.audio(`${ally}-c`, `assets/${ally}-c.mp3`); + this.load.audio(`${ally}-intro`, `assets/${ally}-intro.mp3`); + this.load.audio(`${ally}-outro`, `assets/${ally}-outro.mp3`); + this.load.audio(`${ally}-music`, `assets/${ally}-music.mp3`); }); } @@ -229,7 +229,7 @@ export class GameScene extends Phaser.Scene { col * this.gridConfig.jewelWidth + this.gridConfig.leftPadding, row * this.gridConfig.jewelHeight, 'jewels', - type + type + this.spritePlus ); jewel.setOrigin(0.5); jewel.setDisplaySize(this.gridConfig.jewelWidth, this.gridConfig.jewelHeight); @@ -544,53 +544,6 @@ export class GameScene extends Phaser.Scene { this.matchesText.setText(`Matches Needed: ${this.matchesNeeded}`); } - levelUp() { - this.level ++; - const newLevel = LEVEL_CONFIG[this.level]; - this.numberOfJewels = newLevel.numberOfJewels; - 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}`, { - fontFamily: 'code, arial', - fontSize: '100px', - fill: '#ea00ffff', - padding: { - left: 10, - right: 10, - top: 5, - bottom: 5 - } - }).setOrigin(0.5); - - // Add cool eye-catching effect - this.tweens.add({ - targets: newLevelText, - scale: { from: 0.5, to: 1.5 }, - alpha: { from: 0, to: 1 }, - duration: 1000, - ease: 'Back.easeOut', - yoyo: true - }); - - // Fade out and destroy after 500ms - this.time.delayedCall(1200, () => { - this.tweens.add({ - targets: newLevelText, - angle: 360, - scale: 0, - alpha: 0, - duration: 500, - onComplete: () => { - newLevelText.destroy(); - } - }); - }); - } - // Function to check for matches and destroy them checkMatches() { const matchedJewels = new Set(); @@ -1006,6 +959,108 @@ export class GameScene extends Phaser.Scene { } } + refreshJewelSprites() { + // Iterate through all jewels and update their sprite frames + this.jewels.children.iterate((jewel) => { + if (jewel && jewel.jewelType !== undefined) { + // Update the jewel's frame to reflect the new spritePlus value + jewel.setFrame(jewel.jewelType + this.spritePlus); + } + }); + } + + refreshScene(originalAlly) { + // Stop the current music + this.bgMusic.stop(); + + // Play the new ally's music + this.bgMusic = this.sound.add(`${this.ally}-music`, { volume: 0.2 }); + this.bgMusic.loop = true; + this.bgMusic.play(); + + // Refresh the ally video with the new ally + if (this.allyVideo) { + console.log('update-vid ',this.ally); + // Destroy the existing video + this.allyVideo.destroy(); + + // Create a new video with the updated ally + this.allyVideo = this.add.video(350, 610, `${this.ally}-resting`).setOrigin(0.5); + this.allyVideo.play(true); + this.allyVideo.postFX.addGlow(); + } + + // Refresh the background video with the new ally + if (this.bgVideo) { + // Destroy the existing background video + this.bgVideo.destroy(); + + // Create a new background video with the updated ally + this.bgVideo = this.add.video(0, 0, `${this.ally}-background`).setOrigin(0); + this.bgVideo.scaleX = this.scale.width / 848; + this.bgVideo.scaleY = this.scale.height / 480; + this.bgVideo.play(true).setDepth(-1); + } + } + + levelUp() { + this.level ++; + const newLevel = LEVEL_CONFIG[this.level]; + this.numberOfJewels = newLevel.numberOfJewels; + this.matchesNeeded = newLevel.matchesNeeded; + this.moveInterval = newLevel.moveInterval; + this.LevelText.setText(`Level: ${this.level}`); + this.sound.play('level-up'); + + if (this.ally !== newLevel.ally) { + this.sound.play(`${this.ally}-outro`); + this.time.delayedCall(1000, () => { + const originalAlly = this.ally; + this.ally = newLevel.ally; + this.refreshScene(originalAlly); + this.spritePlus = newLevel.spritePlus; + this.refreshJewelSprites(); + }); + } + + // Create the New Level text + const newLevelText = this.add.text(1150, 250, `Level ${this.level}`, { + fontFamily: 'code, arial', + fontSize: '100px', + fill: '#ea00ffff', + padding: { + left: 10, + right: 10, + top: 5, + bottom: 5 + } + }).setOrigin(0.5); + + // Add cool eye-catching effect + this.tweens.add({ + targets: newLevelText, + scale: { from: 0.5, to: 1.5 }, + alpha: { from: 0, to: 1 }, + duration: 1000, + ease: 'Back.easeOut', + yoyo: true + }); + + // Fade out and destroy after 500ms + this.time.delayedCall(1200, () => { + this.tweens.add({ + targets: newLevelText, + angle: 360, + scale: 0, + alpha: 0, + duration: 500, + onComplete: () => { + newLevelText.destroy(); + } + }); + }); + } + // Game over function gameOver() { console.log('Game Over!'); diff --git a/src/config.js b/src/config.js index 1d696de..507223c 100644 --- a/src/config.js +++ b/src/config.js @@ -3,48 +3,56 @@ export const LEVEL_CONFIG = { numberOfJewels: 4, matchesNeeded: 8, moveInterval: 12000, - ally: 'goblin' + ally: 'goblin', + spritePlus: 0 }, 2: { numberOfJewels: 5, matchesNeeded: 8, moveInterval: 12000, - ally: 'goblin' + ally: 'goblin', + spritePlus: 0 }, 3: { numberOfJewels: 5, matchesNeeded: 9, moveInterval: 11000, - ally: 'goblin' + ally: 'goblin', + spritePlus: 0 }, 4: { numberOfJewels: 5, matchesNeeded: 10, moveInterval: 10000, - ally: 'goblin' + ally: 'goblin', + spritePlus: 0 }, 5: { numberOfJewels: 5, - matchesNeeded: 12, - moveInterval: 9000, - ally: 'goblin' + matchesNeeded: 10, + moveInterval: 10000, + ally: 'surfer', + spritePlus: 10 }, 6: { - numberOfJewels: 5, - matchesNeeded: 12, - moveInterval: 8000, - ally: 'goblin' + numberOfJewels: 6, + matchesNeeded: 10, + moveInterval: 10000, + ally: 'surfer', + spritePlus: 10 }, 7: { - numberOfJewels: 5, - matchesNeeded: 12, - moveInterval: 7000, - ally: 'goblin' + numberOfJewels: 6, + matchesNeeded: 10, + moveInterval: 9000, + ally: 'surfer', + spritePlus: 10 }, 8: { - numberOfJewels: 5, - matchesNeeded: 12, - moveInterval: 6000, - ally: 'goblin' + numberOfJewels: 6, + matchesNeeded: 10, + moveInterval: 8000, + ally: 'surfer', + spritePlus: 10 } };