From 47f9821eefded62fc00e1c5694a1c405dc8c6936 Mon Sep 17 00:00:00 2001 From: playfun24 <121130096+playfun24@users.noreply.github.com> Date: Sat, 16 Dec 2023 17:43:59 -0500 Subject: [PATCH 1/7] Add files via upload --- games/Move the Rocks.js | 159 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 159 insertions(+) create mode 100644 games/Move the Rocks.js diff --git a/games/Move the Rocks.js b/games/Move the Rocks.js new file mode 100644 index 0000000000..8b2f213c3b --- /dev/null +++ b/games/Move the Rocks.js @@ -0,0 +1,159 @@ +const player = "p"; +const wall = "w"; +const gold = "g"; + + +setLegend( + [ player, bitmap` +................ +................ +.......000...... +.......000...... +.......000...... +.......000...... +........0...0... +........0...0... +....000000000... +....0..000...... +....0..000...... +.......000...... +.......0.0...... +.......0.0...... +.....000.000.... +................` ], + [ wall, bitmap` +................ +.....LLLL....... +...LL...LLLLL... +..L..L..L...LL.. +..L..L..LLLLLL.. +..L..L......LL.. +..L..LL.LL..LL.. +..L...LLLL.LLL.. +..LL..L..LLLLL.. +...LL....LLLL... +....LLLLLL...... +................ +................ +................ +................ +................` ], + [ gold, bitmap` +................ +................ +................ +................ +..9C7C7CCCCC7... +..CCC6C6C696C... +..7C9CCC796CC... +..6CCC79C7CC6... +..9C6C6C6C96C... +..7CCC7C7C799... +..6C6C6C6CCC6... +..9CCC9C9C9CC... +................ +................ +................ +................` ] +) + +setSolids([player,wall]) + +let level = 0 +const levels = [ + map` +w. +gw +w. +p.`, + map` +w.w +wg. +.ww +p..`, + map` +g..w +.w.w +www. +.pw.`, + map` +p.ww +wwg. +.w.w +..ww`, + map` +.g.w +w.ww +.ww. +.pw.`, + map` +w.g. +www. +..w. +.wpw`, + map` +w.wp +gw.w +.ww. +w...`, + map` +....g +wwww. +..w.w +w.ww. +pw...`, + map` +.w.wg +w.ww. +.wpw. +.ww.. +.....`, + map` +.ww.g +w..w. +.w.ww +w.w.. +.wpww` +] + +setMap(levels[level]) + +setPushables({ + [ player ]: [wall] +}) + +onInput("s", () => { + getFirst(player).y += 1 +}) +onInput("w", () => { + getFirst(player).y -= 1 +}) +onInput("d", () => { + getFirst(player).x += 1 +}) +onInput("a", () => { + getFirst(player).x -= 1 +}) +onInput("k", () => { + setMap(levels[level]) +}) + +afterInput(() => { + if (level === 0){ + addText("Get the Treasure!", {y: 11, color: color`6` }); + addText("Press k to Restart", {y: 13, color: color`6` }); + } + const targetNumber = tilesWith(gold).length; + const numberCovered = tilesWith(player, gold).length; + if (numberCovered === targetNumber) { + level = level + 1; + clearText() + const currentLevel = levels[level]; + if (currentLevel !== undefined) { + setMap(currentLevel); + } else { + addText("You Win!", {y: 5, color: color`H` }); + } + } + +}) \ No newline at end of file From 2a47c637d128c8460f43970c859b3746c8ba025f Mon Sep 17 00:00:00 2001 From: playfun24 <121130096+playfun24@users.noreply.github.com> Date: Sun, 17 Dec 2023 08:31:56 -0500 Subject: [PATCH 2/7] Rename Move the Rocks.js to move_the_rocks.js --- games/{Move the Rocks.js => move_the_rocks.js} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename games/{Move the Rocks.js => move_the_rocks.js} (99%) diff --git a/games/Move the Rocks.js b/games/move_the_rocks.js similarity index 99% rename from games/Move the Rocks.js rename to games/move_the_rocks.js index 8b2f213c3b..932b3274cc 100644 --- a/games/Move the Rocks.js +++ b/games/move_the_rocks.js @@ -156,4 +156,4 @@ afterInput(() => { } } -}) \ No newline at end of file +}) From fc2b2208fb09c6c99b67b5ee7fca5ce252ce28e9 Mon Sep 17 00:00:00 2001 From: playfun24 <121130096+playfun24@users.noreply.github.com> Date: Mon, 18 Dec 2023 20:38:23 -0500 Subject: [PATCH 3/7] Update move_the_rocks.js --- games/move_the_rocks.js | 43 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 41 insertions(+), 2 deletions(-) diff --git a/games/move_the_rocks.js b/games/move_the_rocks.js index 932b3274cc..8b8a5d8c57 100644 --- a/games/move_the_rocks.js +++ b/games/move_the_rocks.js @@ -2,7 +2,6 @@ const player = "p"; const wall = "w"; const gold = "g"; - setLegend( [ player, bitmap` ................ @@ -58,7 +57,42 @@ setLegend( ) setSolids([player,wall]) - +const walk = tune` +370.3703703703704: B4-370.3703703703704, +11481.481481481482` +const win = tune` +147.05882352941177: B4~147.05882352941177, +147.05882352941177: G4~147.05882352941177, +147.05882352941177: A4~147.05882352941177, +147.05882352941177: C5~147.05882352941177, +147.05882352941177: B4~147.05882352941177, +147.05882352941177: C5~147.05882352941177, +147.05882352941177: B4~147.05882352941177, +147.05882352941177: C5~147.05882352941177, +147.05882352941177: D5~147.05882352941177, +147.05882352941177: E5~147.05882352941177, +147.05882352941177: D5~147.05882352941177, +147.05882352941177: C5~147.05882352941177, +147.05882352941177: D5~147.05882352941177, +147.05882352941177: E5~147.05882352941177, +147.05882352941177: D5~147.05882352941177, +147.05882352941177: A4~147.05882352941177, +147.05882352941177: C5~147.05882352941177, +147.05882352941177: E5~147.05882352941177, +147.05882352941177: G5~147.05882352941177, +147.05882352941177: E5~147.05882352941177, +147.05882352941177: C5~147.05882352941177, +147.05882352941177: A4~147.05882352941177, +147.05882352941177: D5~147.05882352941177, +147.05882352941177, +147.05882352941177: E5~147.05882352941177, +147.05882352941177: G5~147.05882352941177, +147.05882352941177: D5~147.05882352941177, +147.05882352941177: B4~147.05882352941177, +147.05882352941177: D5~147.05882352941177, +147.05882352941177: C5~147.05882352941177, +147.05882352941177: F5~147.05882352941177, +147.05882352941177: A4~147.05882352941177` let level = 0 const levels = [ map` @@ -124,15 +158,19 @@ setPushables({ onInput("s", () => { getFirst(player).y += 1 + playTune(walk) }) onInput("w", () => { getFirst(player).y -= 1 + playTune(walk) }) onInput("d", () => { getFirst(player).x += 1 + playTune(walk) }) onInput("a", () => { getFirst(player).x -= 1 + playTune(walk) }) onInput("k", () => { setMap(levels[level]) @@ -153,6 +191,7 @@ afterInput(() => { setMap(currentLevel); } else { addText("You Win!", {y: 5, color: color`H` }); + playTune(win, Infinity) } } From 9b75265ba3eb292e9e7c408b67188e5ee77f8d31 Mon Sep 17 00:00:00 2001 From: playfun24 <121130096+playfun24@users.noreply.github.com> Date: Wed, 20 Dec 2023 14:55:44 -0500 Subject: [PATCH 4/7] Update move_the_rocks.js I want the trap to disappear if the user types j next to a tile with a trap. How do I code that? --- games/move_the_rocks.js | 106 ++++++++++++++++++++++++++-------------- 1 file changed, 70 insertions(+), 36 deletions(-) diff --git a/games/move_the_rocks.js b/games/move_the_rocks.js index 8b8a5d8c57..f1237553a4 100644 --- a/games/move_the_rocks.js +++ b/games/move_the_rocks.js @@ -1,7 +1,7 @@ const player = "p"; const wall = "w"; const gold = "g"; - +const trap = "t"; setLegend( [ player, bitmap` ................ @@ -53,9 +53,27 @@ setLegend( ................ ................ ................ -................` ] +................` ], + [trap,bitmap` +................ +................ +................ +....DDDDDDD..... +...D4444444D.... +..D44DDDDD44D... +..D4D44444D4D... +..D4D4DDD4D4D... +..D4D4DDD4D4D... +..D4D44444D4D... +..D44DDDDD44D... +...D4444444D.... +....DDDDDDD..... +................ +................ +................`] ) - +const player_x = player.x +const trap_x = trap.x setSolids([player,wall]) const walk = tune` 370.3703703703704: B4-370.3703703703704, @@ -93,49 +111,54 @@ const win = tune` 147.05882352941177: C5~147.05882352941177, 147.05882352941177: F5~147.05882352941177, 147.05882352941177: A4~147.05882352941177` -let level = 0 +let level = 1; const levels = [ + map` +.... +.... +.... +....`, map` w. gw -w. -p.`, +wt +pt`, map` w.w wg. .ww -p..`, +p.t`, map` -g..w -.w.w -www. +gt.w +twtw +wwwt .pw.`, map` -p.ww -wwg. -.w.w -..ww`, +ptww +wwgt +tw.w +.tww`, map` -.g.w -w.ww -.ww. -.pw.`, +.gtw +wtww +twwt +tpw.`, map` w.g. www. ..w. .wpw`, map` -w.wp -gw.w -.ww. -w...`, +wtwp +gwtw +twwt +w.t.`, map` -....g -wwww. -..w.w -w.ww. -pw...`, +..ttg +wwwwt +ttwtw +w.wwt +pwtt.`, map` .w.wg w.ww. @@ -144,9 +167,9 @@ w.ww. .....`, map` .ww.g -w..w. -.w.ww -w.w.. +wt.wt +twtww +wtwtt .wpww` ] @@ -175,15 +198,19 @@ onInput("a", () => { onInput("k", () => { setMap(levels[level]) }) - +const traps = tilesWith(trap) +onInput("j", () => { + //If the player is next to a tile with a trap + getFirst(trap).remove(); +}) afterInput(() => { - if (level === 0){ + if (level === 1){ addText("Get the Treasure!", {y: 11, color: color`6` }); addText("Press k to Restart", {y: 13, color: color`6` }); } - const targetNumber = tilesWith(gold).length; - const numberCovered = tilesWith(player, gold).length; - if (numberCovered === targetNumber) { + const goldnum = tilesWith(gold).length; + const playergold = tilesWith(player, gold).length; + if (goldnum === playergold) { level = level + 1; clearText() const currentLevel = levels[level]; @@ -194,5 +221,12 @@ afterInput(() => { playTune(win, Infinity) } } - + const playertrap = tilesWith(player, trap).length; + if (playertrap> 0) { + setMap(levels[0]); + clearText() + addText("You lose!", {y: 5, color: color`H` }); + addText("Destroy the traps!", {y: 8, color: color`H` }) + level = 1 + } }) From cb0afcf3edc6690418577ffcd082a943a2f3c963 Mon Sep 17 00:00:00 2001 From: playfun24 <121130096+playfun24@users.noreply.github.com> Date: Thu, 21 Dec 2023 14:13:52 -0500 Subject: [PATCH 5/7] Update move_the_rocks.js --- games/move_the_rocks.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/games/move_the_rocks.js b/games/move_the_rocks.js index f1237553a4..44f7ba9b94 100644 --- a/games/move_the_rocks.js +++ b/games/move_the_rocks.js @@ -200,11 +200,13 @@ onInput("k", () => { }) const traps = tilesWith(trap) onInput("j", () => { - //If the player is next to a tile with a trap + //If the player is ne getFirst(trap).remove(); }) +let restart = 0 afterInput(() => { - if (level === 1){ + clearText() + if (restart === 0){ addText("Get the Treasure!", {y: 11, color: color`6` }); addText("Press k to Restart", {y: 13, color: color`6` }); } @@ -228,5 +230,6 @@ afterInput(() => { addText("You lose!", {y: 5, color: color`H` }); addText("Destroy the traps!", {y: 8, color: color`H` }) level = 1 + restart = 1 } }) From 55a601185af5186100bd5d9e997d49b3ba37ef68 Mon Sep 17 00:00:00 2001 From: playfun24 <121130096+playfun24@users.noreply.github.com> Date: Thu, 21 Dec 2023 19:30:00 -0500 Subject: [PATCH 6/7] Update move_the_rocks.js --- games/move_the_rocks.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/games/move_the_rocks.js b/games/move_the_rocks.js index 44f7ba9b94..bcc8c9cf98 100644 --- a/games/move_the_rocks.js +++ b/games/move_the_rocks.js @@ -200,8 +200,9 @@ onInput("k", () => { }) const traps = tilesWith(trap) onInput("j", () => { - //If the player is ne - getFirst(trap).remove(); + if (getFirst(trap).x === getFirst(player).x + 1 ||getFirst(trap).x === getFirst(player).x - 1 || getFirst(trap).x === getFirst(player).y - 1 || getFirst(trap).y === getFirst(player).y + 1 ){ + getFirst(trap).remove(); + } }) let restart = 0 afterInput(() => { From 2f7d81ee082a93d0559e64681624ea6379a028d7 Mon Sep 17 00:00:00 2001 From: playfun24 <121130096+playfun24@users.noreply.github.com> Date: Thu, 21 Dec 2023 19:38:36 -0500 Subject: [PATCH 7/7] Update move_the_rocks.js --- games/move_the_rocks.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/games/move_the_rocks.js b/games/move_the_rocks.js index bcc8c9cf98..eaafa6db47 100644 --- a/games/move_the_rocks.js +++ b/games/move_the_rocks.js @@ -200,9 +200,8 @@ onInput("k", () => { }) const traps = tilesWith(trap) onInput("j", () => { - if (getFirst(trap).x === getFirst(player).x + 1 ||getFirst(trap).x === getFirst(player).x - 1 || getFirst(trap).x === getFirst(player).y - 1 || getFirst(trap).y === getFirst(player).y + 1 ){ - getFirst(trap).remove(); - } + getFirst(trap).remove(); + }) let restart = 0 afterInput(() => {