From b0696a33f5d1014c0eebdb210c83592978b60b84 Mon Sep 17 00:00:00 2001 From: Chris Weed Date: Wed, 17 Jul 2024 23:33:49 -0500 Subject: [PATCH] End game is awesome --- win.ts | 49 +++++++++++++++++++++++++++++++++++++------------ 1 file changed, 37 insertions(+), 12 deletions(-) diff --git a/win.ts b/win.ts index 656066d..d867f91 100644 --- a/win.ts +++ b/win.ts @@ -2,32 +2,57 @@ namespace Win { let _title: Sprite let _totals: Sprite + let island: Sprite + let waves: Sprite[] = [] + + const waveAnimation: Image[] = Utils.swapAnimationColors(assets.animation`wave`, 9, 6) + export function init() { music.stopAllSounds() - scene.setBackgroundColor(6) + scene.setBackgroundColor(9) + + music.play(music.createSong(assets.song`Treasure Island Theme`), music.PlaybackMode.LoopingInBackground) - const totalRiches: number = TreasureStats.currentTreasure.inPocket - + TreasureStats.currentTreasure.onIsland - + TreasureStats.currentTreasure.onBoat + island = sprites.create(assets.image`Treasarr Island`) + island.x = 80 + island.y = 60 + island.z = 1 - _title = textsprite.create('Arrgh! Ye be pirates!') + Utils.getArrayOfLength(10).forEach(() => { + const wave = sprites.create(assets.animation`wave`[0]) + animation.runImageAnimation( + wave, + waveAnimation, + 500, + true + ) + wave.x = Math.randomRange(10, 150) + wave.y = Math.randomRange(10, 60) + wave.z = 0 + waves.push(wave) + }) + + const totalRiches: number = TreasureStats.getTotal() + + _title = textsprite.create('Arrgh! Ye be pirates!', 1, 15) _title.x = 80 - _title.y = 60 + _title.y = 78 + _title.z = 120 _totals = textsprite.create(totalRiches + '') _totals.x = 80 _totals.y = 90 + _totals.z = 120 controller.player1.A.addEventListener(ControllerButtonEvent.Pressed, game.reset) } export function destroy() { - if (_title) { - _title.destroy() - } - if (_totals) { - _totals.destroy() - } + _title.destroy() + _totals.destroy() + + island.destroy() + waves.forEach(wave => wave.destroy()) controller.player1.A.removeEventListener(ControllerButtonEvent.Pressed, game.reset) }