From b7c9984fc0071012211d017399904935c3aa2ad2 Mon Sep 17 00:00:00 2001 From: ethan-yeoh <107853055+ethan-yeoh@users.noreply.github.com> Date: Thu, 14 Dec 2023 20:28:31 +0800 Subject: [PATCH] Add files via upload --- games/sokoban.js | 169 +++++++++++++++++++++++++---------------------- 1 file changed, 89 insertions(+), 80 deletions(-) diff --git a/games/sokoban.js b/games/sokoban.js index a5ffd333c6..e49943a00c 100644 --- a/games/sokoban.js +++ b/games/sokoban.js @@ -17,100 +17,100 @@ const wall = "w"; setLegend( [ player, bitmap` -................ -................ -................ -.......0........ -.....00.000..... -....0.....00.... -....0.0.0..0.... -....0......0.... -....0......0.... -....00....0..... -......00000..... -......0...0..... -....000...000... -................ -................ +......33........ +.....33333...... +.....C606....... +....CC60666..... +....C666C666.... +....C66CCCC6.... +....CC66666..... +....335353...... +...333535333.... +...633656336.... +....65555566.... +....5555555..... +....555.555..... +....CC...CC..... +...CCC...CCC.... ................`], [ box, bitmap` ................ ................ -................ -...888888888.... -...8...8...8.... -...8...8...8.... -...8...8...8.... -...8...8...8.... -...888888888.... -...8...8...8.... -...8...8...8.... -...888888888.... +...0000000000... +...0966666690... +...0662222660... +...0666662660... +...0666222660... +...0666266660... +...0666666660... +...0666266660... +...0966666690... +...0000000000... ................ ................ ................ ................`], [ goal, bitmap` ................ -................ -................ -....444444...... -...44....44..... -...4......4..... -...4.......4.... -...4.......4.... -...4.......4.... -...44......4.... -....4......4.... -....44....44.... -.....444444..... -................ -................ -................`], +......9999...... +......9999...... +.......11888888. +.......118688688 +.......118666688 +.......118666688 +.......11888888. +.......11....... +.......11....... +.......11....... +.......11....... +.......11....... +......CCCC...... +......CCCC...... +......CCCC......`], [ wall, bitmap` -0000000000000000 -0000000000000000 -0000000000000000 -0000000000000000 -0000000000000000 -0000000000000000 -0000000000000000 -0000000000000000 -0000000000000000 -0000000000000000 -0000000000000000 -0000000000000000 -0000000000000000 -0000000000000000 -0000000000000000 -0000000000000000`] +CCCCCCCLCCCCCCCC +CCCCCCCLCCCCCCCC +CCCCCCCLCCCCCCCC +CCCCCCCLCCCCCCCC +LLLLLLLLLLLLLLLL +CCCLCCCCCCCLCCCC +CCCLCCCCCCCLCCCC +CCCLCCCCCCCLCCCC +CCCLCCCCCCCLCCCC +LLLLLLLLLLLLLLLL +CCCCCCCLCCCCCCCC +CCCCCCCLCCCCCCCC +CCCCCCCLCCCCCCCC +CCCCCCCLCCCCCCCC +LLLLLLLLLLLLLLLL +CCCLCCCCCCCLCCCC`], ); let level = 0; const levels = [ map` -p.w. -.bwg -.... -....`, +pw.. +.wb. +.w.. +.wg.`, map` -....g -.bbww -w.... -g...p`, +wpw. +.w.. +wwww +g.b.`, map` -p.w. -.bwg -.... -..bg`, +pwg.. +w.w.w +w.b.. +w.w.w`, map` -..w -..w -gbg -.b. -.w. -bw. -g.p` +pw.w.ww.bg +wwwwwwwwww +w.w..ww.wg +.bwwwwwww. +...w.w.ww. +.wwwww.b.. +gwwwwwww..` ]; const currentLevel = levels[level]; @@ -132,14 +132,23 @@ onInput("d", () => { getFirst(player).x += 1; }); +onInput("l", () => { + getFirst(player).x += 2; +}); + onInput("j", () => { - const currentLevel = levels[level]; - if (currentLevel !== undefined) { - clearText(); - setMap(currentLevel); - } + getFirst(player).x -= 2; }); +onInput("k", () => { + getFirst(player).y += 2; +}); + +onInput("i", () => { + getFirst(player).y -= 2; +}); + + setSolids([ player, box, wall ]); setPushables({