-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwin.ts
94 lines (78 loc) · 2.68 KB
/
win.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
namespace Win {
let _title: Sprite
let _totals: Sprite
let restingPlayer1: Sprite
let restingPlayer2: Sprite
let restingPlayer1Animation: Image[] = assets.animation`Pirate Rest`
let restingPlayer2Animation: Image[] = Utils.flipAnimation(Utils.swapAnimationColors(assets.animation`Pirate Rest`, 14, 4))
let coinPile: Sprite
let island: Sprite
let waves: Sprite[] = []
const waveAnimation: Image[] = Utils.swapAnimationColors(assets.animation`wave`, 9, 6)
export function init() {
music.stopAllSounds()
scene.setBackgroundColor(9)
music.play(music.createSong(assets.song`Treasure Island Theme`), music.PlaybackMode.LoopingInBackground)
island = sprites.create(assets.image`Treasarr Island`)
island.x = 80
island.y = 60
island.z = 1
coinPile = sprites.create(assets.image`Coin Pile`)
coinPile.x = 52
coinPile.y = 70
coinPile.z = 2
restingPlayer1 = sprites.create(restingPlayer1Animation[0])
restingPlayer2 = sprites.create(restingPlayer2Animation[0])
restingPlayer1.x = 86
restingPlayer1.y = 62
restingPlayer1.z = 3
restingPlayer2.x = 104
restingPlayer2.y = 67
restingPlayer2.z = 3
animation.runImageAnimation(
restingPlayer1,
restingPlayer1Animation,
500,
true
)
pause(100)
animation.runImageAnimation(
restingPlayer2,
restingPlayer2Animation,
500,
true
)
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)
})
_title = textsprite.create('Arrgh! Ye be pirates!', 1, 15)
_title.x = 80
_title.y = 100
_title.z = 120
_totals = textsprite.create(TreasureStats.getTotal() + ' coin!')
_totals.x = 80
_totals.y = 90
_totals.z = 120
controller.player1.A.addEventListener(ControllerButtonEvent.Pressed, game.reset)
}
export function destroy() {
_title.destroy()
_totals.destroy()
island.destroy()
waves.forEach(wave => wave.destroy())
restingPlayer1.destroy()
restingPlayer2.destroy()
coinPile.destroy()
controller.player1.A.removeEventListener(ControllerButtonEvent.Pressed, game.reset)
}
}