generated from robo-technical-group/javascript-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
attract.ts
52 lines (48 loc) · 1.48 KB
/
attract.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
/**
* Attract mode
*/
namespace Attract {
export const TEXT_HEADLINES: string[][] = [
['My Game is', '(C) 20XX'],
['Programmed in', 'MakeCode Arcade'],
['by', 'Me']
]
const TEXT_ACTIONS: string[][] = [[
'Left/Right = Action',
'Up = Action',
'Down = Action',
'A = Action',
'B = Action'
]]
const TEXT_LOAD_GAME: string = 'Press B to load game'
export const TEXT_TITLES: string[] = ['My Game', 'in JavaScript']
/**
* Global variables
*/
export let splashScreen: SplashScreens = null
export function build(): void {
if (GameState.savesExist()) {
let newActions: string[][] = []
newActions.push(TEXT_ACTIONS[0].concat([TEXT_LOAD_GAME,]))
splashScreen = new SplashScreens(
TEXT_TITLES, Color.Yellow,
TEXT_HEADLINES, Color.Brown,
newActions, Color.LightBlue)
} else {
splashScreen = new SplashScreens(
TEXT_TITLES, Color.Yellow,
TEXT_HEADLINES, Color.Brown,
TEXT_ACTIONS, Color.LightBlue)
}
}
export function start(): void {
build()
splashScreen.build()
g_state.Mode = GameMode.Attract
} // start()
export function update(): void {
if (game.runtime() >= Attract.splashScreen.nextTime) {
Attract.splashScreen.rotate()
} // if (game.runtime() >= splash.nextTime)
}
}