generated from robo-technical-group/javascript-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.ts
50 lines (44 loc) · 918 Bytes
/
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
/**
* My JavaScript Game
* Built on
* MakeCode Arcade JavaScript Template v. 4.2.2
* Template last update: 11 Jun 2023 ak
*/
/**
* Constants
*/
const HARDWARE: boolean = control.ramSize() < (1024 * 1024)
/**
* Global variables
*/
let g_state: GameState = new GameState()
/**
* Game loops
*/
game.onUpdate(function () {
switch (g_state.Mode) {
case GameMode.Attract:
Attract.update()
break
case GameMode.Main:
break
} // switch (g_state.Mode)
}) // game.onUpdate()
/**
* Other functions
*/
function startGame(): void {
g_state.Mode = GameMode.NotReady
Attract.splashScreen.release()
scene.setBackgroundImage(assets.image`bg`)
g_state.Mode = GameMode.Main
} // startGame()
/**
* Main() a.k.a. game.onStart()
*/
game.stats = true
if (settings.exists(Tests.TESTING_KEY)) {
Tests.run()
} else {
Attract.start()
}