diff options
author | sanine <sanine.not@pm.me> | 2024-07-07 18:29:38 -0500 |
---|---|---|
committer | sanine <sanine.not@pm.me> | 2024-07-07 18:29:38 -0500 |
commit | 95ee8172ae99c00efbfb1c8c105112f82711ae01 (patch) | |
tree | 318befb7568b6624b74f5d975dc8d4ea4b20155a | |
parent | a4d923659f49ccd44e1d6bd09804ba658ca34ac4 (diff) |
add level intro messages
-rw-r--r-- | level.js | 9 | ||||
-rw-r--r-- | levelSelect.js | 20 |
2 files changed, 22 insertions, 7 deletions
@@ -2,7 +2,7 @@ import { setupLevelSelectUi } from './levelSelect.js'; import { render } from './render.js'; -const X_START = '0'; +const X_START = 't'; const Y_START = 't'; const PATH_LEN = 20; @@ -12,10 +12,11 @@ const SLOW_RAMP = 1; const FAST_RAMP = 0.01; -export function setupLevel(resources, home) { +export function setupLevel(resources, home, intro) { const level = { resources: resources.map(position => ({ position, collected: false })), home, + intro: intro || null, running: false, completed: false, index: 0, @@ -149,6 +150,10 @@ export function setupLevelUi(level, root, sfx) { appearSound(); }, 500); + if (level.intro) { + setTimeout(() => showAlert(ui, level.intro), 600); + } + return ui; } diff --git a/levelSelect.js b/levelSelect.js index 04c65a6..997bbb2 100644 --- a/levelSelect.js +++ b/levelSelect.js @@ -1,22 +1,28 @@ import{ setupLevel, setupLevelUi } from './level.js'; -function buildLevel(x, y, t) { +function buildLevel(x, y, t, intro) { const ts = t.slice(0, -1); const tf = t[t.length-1]; - return setupLevel(ts.map(T => [ x(T), y(T) ]), [ x(tf), y(tf) ]); + return setupLevel(ts.map(T => [ x(T), y(T) ]), [ x(tf), y(tf) ], intro); } const levels = { - 'initial jump': [ [], setupLevel([], [8, 0]) ], - 'monopole harvesting': [ ['initial jump'], setupLevel([[3, 3]], [8,8]) ], + 'initial jump': [ [], setupLevel([], [8, 8], 'please launch the platform into the AMH processor.') ], + 'monopole harvesting 0': [ ['initial jump'], setupLevel([[3, 3]], [8,8], 'please ensure that all monopoles are collected before proceeding to the processor.') ], + 'monopole harvesting 1': [ ['initial jump'], setupLevel([[4, 2]], [8,4], 'the automated navigation system seems to have overshot on the Y axis. please correct.') ], + 'monopole harvesting 2': [ ['initial jump'], setupLevel([[1, 2]], [5,4], 'the automated navigation system seems to have missed the offset on the X axis. please correct.') ], 'inverted': [ ['initial jump'], setupLevel([[-3, -3]], [-8,-8]) ], 'double inverted': [ ['initial jump'], setupLevel([[-8, -8]], [-3,-3]) ], 'parabolic 0': [ ['monopole harvesting'], - buildLevel(t => t, t => t**2, [...Array(4).keys()].map(x => x)), + buildLevel( + t => t, + t => t**2, + [...Array(4).keys()].map(x => x), + ), ], 'parabolic 1': [ ['monopole harvesting'], @@ -78,6 +84,10 @@ export function setupLevelSelectUi(root, sfx) { sfx.buttonClickAudio.currentTime = 0; sfx.buttonClickAudio.play(); root.innerText = ''; + const header = document.createElement('h1'); + header.classList.add('centered'); + header.innerText = name; + root.appendChild(header); setupLevelUi(level, root, sfx); } const li = document.createElement('li'); |