Skip to content

Commit

Permalink
End game is awesome
Browse files Browse the repository at this point in the history
  • Loading branch information
Kikketer committed Jul 18, 2024
1 parent d52e61a commit b0696a3
Showing 1 changed file with 37 additions and 12 deletions.
49 changes: 37 additions & 12 deletions win.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down

0 comments on commit b0696a3

Please sign in to comment.