From baa61834993b5194639c5bca2f9fd574282f07f2 Mon Sep 17 00:00:00 2001 From: icecreaman29 Date: Mon, 19 May 2025 11:31:49 -0700 Subject: [PATCH] Sprig App - Maze 101 --- games/Maze-101.js | 99 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 99 insertions(+) create mode 100644 games/Maze-101.js diff --git a/games/Maze-101.js b/games/Maze-101.js new file mode 100644 index 0000000000..c363026fb3 --- /dev/null +++ b/games/Maze-101.js @@ -0,0 +1,99 @@ +/* +@title: Maze +@author: +@tags: [] +@addedOn: 2025-00-00 +*/ + + +const player = "p" +const wall = "w" +const goal = "g" + +setLegend( + [ player, bitmap` +................ +................ +.......000...... +.......0.0...... +......0..0...... +......0...0.0... +....0003.30.0... +....0.0...000... +....0.05550..... +......0...0..... +.....0....0..... +.....0...0...... +......000....... +......0.0....... +.....00.00...... +................` ], + [ wall, bitmap` +1111111111111111 +1111111111111111 +1111111111111111 +1111111111111111 +1111111111111111 +1111111111111111 +1111111111111111 +1111111111111111 +1111111111111111 +1111111111111111 +1111111111111111 +1111111111111111 +1111111111111111 +1111111111111111 +1111111111111111 +1111111111111111` ], + [ goal, bitmap` +................ +................ +......3333...... +.....3....3..... +....3.3333.3.... +....3.3..3.3.... +....3.3333.3.... +.....3....3..... +......3333...... +................ +................ +................ +................ +................ +................ +................` ] +) + +setSolids([ wall ]) + +let level = 0 +const levels = [ + map` +wwwwwwwwww +wp.....gww +w.wwww..ww +w......www +wwwwwwwwww` +] + +setMap(levels[level]) + +setPushables({ + [ player ]: [] +}) + +// Player controls +onInput("w", () => getFirst(player).y -= 1) +onInput("s", () => getFirst(player).y += 1) +onInput("a", () => getFirst(player).x -= 1) +onInput("d", () => getFirst(player).x += 1) + +afterInput(() => { + const p = getFirst(player) + const g = getFirst(goal) + + // If player touches the goal, restart the level + if (p.x === g.x && p.y === g.y) { + setMap(levels[level]) + } +}) \ No newline at end of file