-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTITLE.JS
More file actions
106 lines (91 loc) · 2.75 KB
/
Copy pathTITLE.JS
File metadata and controls
106 lines (91 loc) · 2.75 KB
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
// =============================================================================
// Name: Radroach Races
// Author: Theeohn Megistus
// License: MIT
// Repository: https://github.com/Theeohn/Radroach-Races
// =============================================================================
// File: TITLE.JS (scene)
// Description: Draws the title screen using the full-screen TITLEIMG.JSON
// bitmap as the backdrop, with a single map selector box on top. Knob1 and
// knob2 both scroll through Random Map + Maps 1-16, wrapping in both
// directions, and a press on either knob launches a race on the selected
// map.
// =============================================================================
(function(app) {
let selected = 0; // 0 = Random Map, 1-16 = Map 1-16
/**
* @returns {void}
*/
function drawSelector() {
h.setColor(0)
.fillRect(130, 238, 350, 270)
.setColor(3)
.drawRect(132, 240, 348, 268);
h.setFont('Monofonto18')
.setFontAlign(-1, 0)
.drawString('<', 144, 254)
.setFontAlign(1, 0)
.drawString('>', 336, 254)
.setFont('Monofonto23')
.setFontAlign(0, 0)
.drawString(
selected === 0
? 'Random Map'
: 'Map ' + (selected < 10 ? '0' + selected : selected),
240,
255,
);
}
/**
* @param dir
* @returns {void}
*/
function onKnob(dir) {
if (dir === 0) {
Pip.audioStart('HOLO/RADROACH_RACES/BUGLE.WAV');
app.go(app.scenes.RACE, { mapId: selected });
return;
}
selected = (selected + dir + 17) % 17;
Pip.audioStart('HOLO/RADROACH_RACES/FLAP.WAV');
drawSelector();
h.flip();
Pip.lastFlip = getTime();
}
Pip.audioStart('HOLO/RADROACH_RACES/FLAP.WAV');
let file = E.openFile('HOLO/RADROACH_RACES/TITLEIMG.BIN', 'r');
let target = new Uint8Array(h.buffer);
let offset = target.length;
let chunk = file.read(256);
while (chunk) {
offset -= chunk.length;
target.set(chunk, offset);
chunk = file.read(256);
}
file.close();
h.flip();
h.setFont('Monofonto14')
.setFontAlign(-1, 0)
.setColor(1)
.drawString('Art by', 10, 283)
.drawString('The Nuka Lounge', 12, 298);
h.setFont('Monofonto14')
.setFontAlign(0, -1)
.setColor(2)
.drawString('v2.2.1', 444, 20);
drawSelector();
h.setFont('Monofonto14')
.setFontAlign(0, -1)
.setColor(3)
.drawString('SELECT A MAP, PRESS LEFT WHEEL TO RACE!', 243, 290);
h.flip();
Pip.lastFlip = getTime();
Pip.onExclusive('knob1', onKnob);
Pip.onExclusive('knob2', onKnob);
return {
remove: function() {
Pip.removeListener('knob1', onKnob);
Pip.removeListener('knob2', onKnob);
},
};
});