summaryrefslogtreecommitdiff
path: root/levelSelect.js
diff options
context:
space:
mode:
authorsanine <sanine.not@pm.me>2024-07-06 11:58:58 -0500
committersanine <sanine.not@pm.me>2024-07-06 11:58:58 -0500
commit2f300a221b850ae66a785523436511c06b318a22 (patch)
treefafb251a6fcb63949afe148ddf262ba3d6f7faa4 /levelSelect.js
parent71a61ed1c3929f9d4cb615cf691bb980a8005c9e (diff)
add level select screen
Diffstat (limited to 'levelSelect.js')
-rw-r--r--levelSelect.js28
1 files changed, 28 insertions, 0 deletions
diff --git a/levelSelect.js b/levelSelect.js
new file mode 100644
index 0000000..6c0d995
--- /dev/null
+++ b/levelSelect.js
@@ -0,0 +1,28 @@
+import{ setupLevel, setupLevelUi } from './level.js';
+
+const levels = {
+ 'Initial Jump': [ [], setupLevel([], [8, 0]) ],
+ 'Monopole Mining': [ ['Initial Jump'], setupLevel([[3, 3]], [8,8]) ],
+};
+
+export function setupLevelSelectUi(root, audio) {
+ const levelList = document.createElement('ol');
+ const levelPicker = name => {
+ const [ dependencies, level ] = levels[name];
+ const allDependenciesSatisfied = dependencies.map(x => levels[x][1].completed).reduce((acc, x) => acc && x, true);
+ if (allDependenciesSatisfied) {
+ const button = document.createElement('input');
+ button.type = 'button';
+ button.onclick = () => {
+ root.innerText = '';
+ setupLevelUi(level, root, audio);
+ }
+ const li = document.createElement('li');
+ li.appendChild(button);
+ levelList.appendChild(li);
+ }
+ }
+
+ [...Object.keys(levels)].forEach(levelPicker);
+ root.appendChild(levelList);
+}