-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.ts
351 lines (351 loc) · 13.4 KB
/
main.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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
//Create sprites
let safetonSprite = sprites.create(assets.image`safetonBase`, SpriteKind.Player)
let jokestarSprite = sprites.create(assets.image`jokestarBase`, SpriteKind.Enemy)
let bassSprite = sprites.create(assets.image`bassBase`, SpriteKind.Enemy)
let jazzySprite = sprites.create(assets.image`jazzyBase`, SpriteKind.Enemy)
let headCollectable = sprites.create(assets.image`headCollectable`, SpriteKind.Food)
let torsoCollectable = sprites.create(assets.image`torsoCollectable`, SpriteKind.Food)
let armLeftCollectable = sprites.create(assets.image`armLeftCollectable`, SpriteKind.Food)
let armRightCollectable = sprites.create(assets.image`armRightCollectable`, SpriteKind.Food)
let legLeftCollectable = sprites.create(assets.image`legLeftCollectable`, SpriteKind.Food)
let legRightCollectable = sprites.create(assets.image`legRightCollectable`, SpriteKind.Food)
//Set level
tiles.setCurrentTilemap(tilemap`level`)
//Make spawn points
tiles.placeOnTile(safetonSprite, tiles.getTileLocation(1, 66))
tiles.placeOnTile(jokestarSprite, tiles.getTileLocation(15, 22))
tiles.placeOnTile(bassSprite, tiles.getTileLocation(38, 64))
tiles.placeOnTile(jazzySprite, tiles.getTileLocation(55, 28))
tiles.placeOnTile(headCollectable, tiles.getTileLocation(98, 58))
tiles.placeOnTile(torsoCollectable, tiles.getTileLocation(101, 40))
tiles.placeOnTile(armLeftCollectable, tiles.getTileLocation(55, 28))
tiles.placeOnTile(armRightCollectable, tiles.getTileLocation(14, 5))
tiles.placeOnTile(legLeftCollectable, tiles.getTileLocation(4, 86))
tiles.placeOnTile(legRightCollectable, tiles.getTileLocation(23, 90))
//Text
safetonSprite.sayText("I need to find the exit... (6 parts left)", 3500, false)
//Make camera follow player
scene.cameraFollowSprite(safetonSprite)
//Allow player to use wasd and arrow keys to move
controller.moveSprite(safetonSprite)
//Allow player to interact with items by space and q
controller.A.onEvent(ControllerButtonEvent.Pressed, function() {
if (safetonSprite.overlapsWith(headCollectable)) {
sprites.destroy(headCollectable)
info.changeScoreBy(1)
} else if (safetonSprite.overlapsWith(armLeftCollectable)) {
sprites.destroy(armLeftCollectable)
info.changeScoreBy(1)
} else if (safetonSprite.overlapsWith(armRightCollectable)) {
sprites.destroy(armRightCollectable)
info.changeScoreBy(1)
} else if (safetonSprite.overlapsWith(torsoCollectable)) {
sprites.destroy(torsoCollectable)
info.changeScoreBy(1)
} else if (safetonSprite.overlapsWith(legLeftCollectable)) {
sprites.destroy(legLeftCollectable)
info.changeScoreBy(1)
} else if (safetonSprite.overlapsWith(legRightCollectable)) {
sprites.destroy(legRightCollectable)
info.changeScoreBy(1)
}
})
//Text when item picked up
info.onScore(1, function() {
safetonSprite.sayText("This seems old... (5 parts left)", 3500, false)
})
info.onScore(2, function () {
safetonSprite.sayText("This suit looks strong... (4 parts left)", 3500, false)
})
info.onScore(3, function () {
safetonSprite.sayText("I could probably use this to escape... (3 parts left)", 3500, false)
})
info.onScore(4, function () {
safetonSprite.sayText("I just need 2 more to fix the suit... (2 parts left)", 3500, false)
})
info.onScore(5, function () {
safetonSprite.sayText("Where's the last piece? (1 part left)", 3500, false)
})
//Allow jumpscares
forever(function () {
if (safetonSprite.overlapsWith(jokestarSprite)) {
story.startCutscene(function () {
tiles.setCurrentTilemap(tilemap`cutScene`)
scene.cameraFollowSprite(secretSprite)
animation.runImageAnimation(secretSprite, assets.animation`jokestarScene`, 50, false)
music.play(music.createSong(assets.song`jumpscareSound`), music.PlaybackMode.UntilDone)
})
pause(1000)
game.reset()
} else if (safetonSprite.overlapsWith(jazzySprite)) {
story.startCutscene(function () {
tiles.setCurrentTilemap(tilemap`cutScene`)
scene.cameraFollowSprite(secretSprite)
animation.runImageAnimation(secretSprite, assets.animation`jazzyScene`, 50, false)
music.play(music.createSong(assets.song`jumpscareSound`), music.PlaybackMode.UntilDone)
})
pause(1000)
game.reset()
} else if (safetonSprite.overlapsWith(bassSprite)) {
story.startCutscene(function () {
tiles.setCurrentTilemap(tilemap`cutScene`)
scene.cameraFollowSprite(secretSprite)
animation.runImageAnimation(secretSprite, assets.animation`bassScene`, 50, false)
music.play(music.createSong(assets.song`jumpscareSound`), music.PlaybackMode.UntilDone)
})
pause(1000)
game.reset()
}
})
//Set enemy paths
//Jokestar path
let jokestarDirection = 0
game.onUpdateInterval(1000, function () {
if (jokestarDirection == 0) {
jokestarSprite.vx = 50
jokestarSprite.vy = 0
jokestarDirection = 1
} else if (jokestarDirection == 1) {
jokestarSprite.vx = 0
jokestarSprite.vy = 50
jokestarDirection = 2
} else if (jokestarDirection == 2) {
jokestarSprite.vx = -50
jokestarSprite.vy = 0
jokestarDirection = 3
} else if (jokestarDirection == 3) {
jokestarSprite.vx = 0
jokestarSprite.vy = -50
jokestarDirection = 0
}
if (jokestarDirection == 0) {
animation.runImageAnimation(
jokestarSprite,
assets.animation`jokestarWalkRight`,
130,
true
)
} else if (jokestarDirection == 1) {
animation.runImageAnimation(
jokestarSprite,
assets.animation`jokestarWalkRight`,
130,
true
)
} else if (jokestarDirection == 2) {
animation.runImageAnimation(
jokestarSprite,
assets.animation`jokestarWalkLeft`,
130,
true
)
} else if (jokestarDirection == 3) {
animation.runImageAnimation(
jokestarSprite,
assets.animation`jokestarWalkLeft`,
130,
true
)
}
})
//Jazzy path
let jazzyDirection = 0
game.onUpdateInterval(1000, function () {
if (jazzyDirection == 0) {
jazzySprite.vx = 50
jazzySprite.vy = 0
jazzyDirection = 1
} else if (jazzyDirection == 1) {
jazzySprite.vx = 0
jazzySprite.vy = 50
jazzyDirection = 2
} else if (jazzyDirection == 2) {
jazzySprite.vx = -50
jazzySprite.vy = 0
jazzyDirection = 3
} else if (jazzyDirection == 3) {
jazzySprite.vx = 0
jazzySprite.vy = -50
jazzyDirection = 0
}
if (jazzyDirection == 0) {
animation.runImageAnimation(
jazzySprite,
assets.animation`jazzyWalkRight`,
130,
true
)
} else if (jazzyDirection == 1) {
animation.runImageAnimation(
jazzySprite,
assets.animation`jazzyWalkRight`,
130,
true
)
} else if (jazzyDirection == 2) {
animation.runImageAnimation(
jazzySprite,
assets.animation`jazzyWalkLeft`,
130,
true
)
} else if (jazzyDirection == 3) {
animation.runImageAnimation(
jazzySprite,
assets.animation`jazzyWalkLeft`,
130,
true
)
}
})
//Bass path
let bassDirection = 0
game.onUpdateInterval(1000, function () {
if (bassDirection == 0) {
bassSprite.vx = 50
bassSprite.vy = 0
bassDirection = 1
} else if (bassDirection == 1) {
bassSprite.vx = 0
bassSprite.vy = 50
bassDirection = 2
} else if (bassDirection == 2) {
bassSprite.vx = -50
bassSprite.vy = 0
bassDirection = 3
} else if (bassDirection == 3) {
bassSprite.vx = 0
bassSprite.vy = -50
bassDirection = 0
}
if (bassDirection == 0) {
animation.runImageAnimation(
bassSprite,
assets.animation`bassWalkRight`,
130,
true
)
} else if (bassDirection == 1) {
animation.runImageAnimation(
bassSprite,
assets.animation`bassWalkRight`,
130,
true
)
} else if (bassDirection == 2) {
animation.runImageAnimation(
bassSprite,
assets.animation`bassWalkLeft`,
130,
true
)
} else if (bassDirection == 3) {
animation.runImageAnimation(
bassSprite,
assets.animation`bassWalkLeft`,
130,
true
)
}
})
//Set player animations
controller.left.onEvent(ControllerButtonEvent.Pressed, function
() {
animation.runImageAnimation(
safetonSprite,
assets.animation`safetonWalkLeft`,
130,
true
)
})
controller.right.onEvent(ControllerButtonEvent.Pressed, function
() {
animation.runImageAnimation(
safetonSprite,
assets.animation`safetonWalkRight`,
130,
true
)
})
controller.up.onEvent(ControllerButtonEvent.Pressed, function
() {
animation.runImageAnimation(
safetonSprite,
assets.animation`safetonWalkBackward`,
130,
true
)
})
controller.down.onEvent(ControllerButtonEvent.Pressed, function
() {
animation.runImageAnimation(
safetonSprite,
assets.animation`safetonWalkForward`,
130,
true
)
})
controller.left.onEvent(ControllerButtonEvent.Released, function
() {
animation.runImageAnimation(
safetonSprite,
assets.animation`safetonStandLeft`,
180,
true
)
})
controller.right.onEvent(ControllerButtonEvent.Released, function
() {
animation.runImageAnimation(
safetonSprite,
assets.animation`safetonStandRight`,
180,
true
)
})
controller.up.onEvent(ControllerButtonEvent.Released, function
() {
animation.runImageAnimation(
safetonSprite,
assets.animation`safetonStandLeft`,
180,
true
)
})
controller.down.onEvent(ControllerButtonEvent.Released, function
() {
animation.runImageAnimation(
safetonSprite,
assets.animation`safetonStandRight`,
180,
true
)
})
//Start cutscene
info.onScore(6, function () {
sprites.destroy(jokestarSprite)
sprites.destroy(jazzySprite)
sprites.destroy(bassSprite)
story.startCutscene(function () {
tiles.setCurrentTilemap(tilemap`cutScene`)
let sceneSprite = sprites.create(assets.image`safetonBase`, SpriteKind.Player)
scene.cameraFollowSprite(sceneSprite)
animation.runImageAnimation(sceneSprite, assets.animation`endScene`, 200, false)
music.play(music.createSong(assets.song`deathScene`), music.PlaybackMode.UntilDone)
})
pause(9000)
game.reset()
})
//Start secret cutscene
let secretSprite = sprites.create(assets.image`secretBase`, SpriteKind.Player)
tiles.placeOnTile(secretSprite, tiles.getTileLocation(50, 41))
sprites.onOverlap(SpriteKind.Player, SpriteKind.Player, function (sprite: Sprite, otherSprite: Sprite) {
story.startCutscene(function () {
tiles.setCurrentTilemap(tilemap`cutScene`)
scene.cameraFollowSprite(secretSprite)
animation.runImageAnimation(secretSprite, assets.animation`secretScene`, 50, false)
music.play(music.createSong(assets.song`jumpscareSound`), music.PlaybackMode.UntilDone)
})
pause(1000)
game.reset()
})