From 914e042cc878860055f91322aa9d35da2b2ac0fe Mon Sep 17 00:00:00 2001 From: vask3 <131193901+vask3@users.noreply.github.com> Date: Sat, 10 Oct 2026 19:49:06 +0300 Subject: [PATCH 1/6] Sprig App - Vasko JS game --- games/Vasko-JS-game.js | 94 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 94 insertions(+) create mode 100644 games/Vasko-JS-game.js diff --git a/games/Vasko-JS-game.js b/games/Vasko-JS-game.js new file mode 100644 index 0000000000..f82e3fd227 --- /dev/null +++ b/games/Vasko-JS-game.js @@ -0,0 +1,94 @@ +// Block Pusher (Sokoban) +const player = "p"; +const block = "b"; +const goal = "g"; +const wall = "w"; + +setLegend( + [player, bitmap` + . . 3 3 . . + . 3 3 3 3 . + . . 3 3 . . + . 3 3 3 3 . + . 3 . . 3 . + `], + [block, bitmap` + 2 2 2 2 2 2 + 2 8 8 8 8 2 + 2 8 2 2 8 2 + 2 8 8 8 8 2 + 2 2 2 2 2 2 + `], + [goal, bitmap` + . . . . . . + . 5 5 5 5 . + . 5 . . 5 . + . 5 5 5 5 . + . . . . . . + `], + [wall, bitmap` + 1 1 1 1 1 1 + 1 1 1 1 1 1 + 1 1 1 1 1 1 + 1 1 1 1 1 1 + `] +); + +const level = map` + wwwwwwwww + w.......w + w..p.b..w + w.....g.w + w.......w + wwwwwwwww +`; + +setMap(level); + +// Set collision and pushing rules +setSolids([player, block, wall]); +setPushables({ + [player]: [block] +}); + +function canMove(sprite, dx, dy) { + const targetX = sprite.x + dx; + const targetY = sprite.y + dy; + + if (targetX < 0 || targetX >= width() || targetY < 0 || targetY >= height()) { + return false; + } + + return true; +} + +onInput("w", () => { + const p = getFirst(player); + if (canMove(p, 0, -1)) p.y -= 1; +}); + +onInput("s", () => { + const p = getFirst(player); + if (canMove(p, 0, 1)) p.y += 1; +}); + +onInput("a", () => { + const p = getFirst(player); + if (canMove(p, -1, 0)) p.x -= 1; +}); + +onInput("d", () => { + const p = getFirst(player); + if (canMove(p, 1, 0)) p.x += 1; +}); + +afterInput(() => { + const b = getFirst(block); + const g = getFirst(goal); + + // Check if the block is on the goal target + if (b.x === g.x && b.y === g.y) { + clearText(); + addText("YOU WIN!", { x: 2, y: 0, color: color`5` }); + } +}); \ No newline at end of file From c4943724404ffdce4bd7a1c18dd668da91543bcf Mon Sep 17 00:00:00 2001 From: vask3 <131193901+vask3@users.noreply.github.com> Date: Sat, 17 Oct 2026 16:39:15 +0300 Subject: [PATCH 2/6] Add metadata comments to Vasko JS Game --- games/Vasko-JS-game.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/games/Vasko-JS-game.js b/games/Vasko-JS-game.js index f82e3fd227..0fa4f36ddb 100644 --- a/games/Vasko-JS-game.js +++ b/games/Vasko-JS-game.js @@ -1,3 +1,9 @@ +// @title: Vasko JS Game +// @author: vask3 +// @description: A puzzle game where you push blocks onto target tiles. +// @tags: ['puzzle', 'maze'] +// @addedOn: 2026-10-17 + // Block Pusher (Sokoban) const player = "p"; const block = "b"; @@ -91,4 +97,4 @@ afterInput(() => { clearText(); addText("YOU WIN!", { x: 2, y: 0, color: color`5` }); } -}); \ No newline at end of file +}); From c9b9dac14af099c20286ceedcd28be07459c7d24 Mon Sep 17 00:00:00 2001 From: vask3 <131193901+vask3@users.noreply.github.com> Date: Sat, 17 Oct 2026 16:41:26 +0300 Subject: [PATCH 3/6] Revise game comments and description format Updated game metadata and description. --- games/Vasko-JS-game.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/games/Vasko-JS-game.js b/games/Vasko-JS-game.js index 0fa4f36ddb..f96b26b4b9 100644 --- a/games/Vasko-JS-game.js +++ b/games/Vasko-JS-game.js @@ -1,8 +1,10 @@ -// @title: Vasko JS Game -// @author: vask3 -// @description: A puzzle game where you push blocks onto target tiles. -// @tags: ['puzzle', 'maze'] -// @addedOn: 2026-10-17 +/* +@title: Vasko JS Game +@author: vask3 +@description: Hello, that is my first JS game. +@tags: ['puzzle'] +@addedOn: 2026-10-17 +*/ // Block Pusher (Sokoban) const player = "p"; From 18f01c7afaa453d6f928036025bdf256473df161 Mon Sep 17 00:00:00 2001 From: vask3 <131193901+vask3@users.noreply.github.com> Date: Sat, 17 Oct 2026 16:48:30 +0300 Subject: [PATCH 4/6] Add initial game setup for Block Pusher --- games/Vasko-JS-game.js | 1 + 1 file changed, 1 insertion(+) diff --git a/games/Vasko-JS-game.js b/games/Vasko-JS-game.js index f96b26b4b9..2efad3defb 100644 --- a/games/Vasko-JS-game.js +++ b/games/Vasko-JS-game.js @@ -6,6 +6,7 @@ @addedOn: 2026-10-17 */ + // Block Pusher (Sokoban) const player = "p"; const block = "b"; From a70523f6e83539a264ab521f51442119c3b20947 Mon Sep 17 00:00:00 2001 From: vask3 <131193901+vask3@users.noreply.github.com> Date: Sun, 18 Oct 2026 18:31:08 +0300 Subject: [PATCH 5/6] Update game date and enhance level mechanics --- games/Vasko-JS-game.js | 176 ++++++++++++++++++++++++++++------------- 1 file changed, 119 insertions(+), 57 deletions(-) diff --git a/games/Vasko-JS-game.js b/games/Vasko-JS-game.js index 2efad3defb..f40acce646 100644 --- a/games/Vasko-JS-game.js +++ b/games/Vasko-JS-game.js @@ -3,59 +3,107 @@ @author: vask3 @description: Hello, that is my first JS game. @tags: ['puzzle'] -@addedOn: 2026-10-17 +@addedOn: 2026-10-18 */ - -// Block Pusher (Sokoban) const player = "p"; const block = "b"; const goal = "g"; const wall = "w"; +const key = "k"; +const door = "d"; + +let levelIndex = 0; +let moves = 0; +let hasKey = false; setLegend( [player, bitmap` - . . 3 3 . . - . 3 3 3 3 . - . . 3 3 . . - . 3 3 3 3 . - . 3 . . 3 . - `], +...33... +..3333.. +...33... +..3333.. +...3.3.. +`], [block, bitmap` - 2 2 2 2 2 2 - 2 8 8 8 8 2 - 2 8 2 2 8 2 - 2 8 8 8 8 2 - 2 2 2 2 2 2 - `], +22222222 +28888882 +28222282 +28888882 +22222222 +`], [goal, bitmap` - . . . . . . - . 5 5 5 5 . - . 5 . . 5 . - . 5 5 5 5 . - . . . . . . - `], +........ +..5555.. +..5..5.. +..5555.. +........ +`], [wall, bitmap` - 1 1 1 1 1 1 - 1 1 1 1 1 1 - 1 1 1 1 1 1 - 1 1 1 1 1 1 - `] +11111111 +11111111 +11111111 +11111111 +`], + [key, bitmap` +........ +..00.... +..00000. +....0.0. +........ +`], + [door, bitmap` +77777777 +7......7 +7..77..7 +77777777 +`] ); -const level = map` - wwwwwwwww - w.......w - w..p.b..w - w.....g.w - w.......w - wwwwwwwww -`; +const levels = [ + map` +wwwwwwwww +w.......w +w..p.b..w +w.....g.w +w.......w +wwwwwwwww`, + + map` +wwwwwwwww +w.p...k.w +w.wwwdwww +w...b...w +w.....g.w +wwwwwwwww`, -setMap(level); + map` +wwwwwwwwwww +w.p...w...w +w.bbb.w.k.w +w.....d...w +w.www.w.g.w +w.........w +wwwwwwwwwww` +]; -// Set collision and pushing rules -setSolids([player, block, wall]); +function loadLevel(idx) { + hasKey = false; + moves = 0; + clearText(); + + if (idx < levels.length) { + setLevel(levels[idx]); + addText(`Level: ${idx + 1}`, { x: 1, y: 0, color: color`3` }); + addText(`Moves: ${moves}`, { x: 7, y: 0, color: color`3` }); + } else { + addText("YOU WIN!", { x: 2, y: 2, color: color`5` }); + } +} + +loadLevel(levelIndex); + +setSolids([player, block, wall, door]); setPushables({ [player]: [block] }); @@ -63,41 +111,55 @@ setPushables({ function canMove(sprite, dx, dy) { const targetX = sprite.x + dx; const targetY = sprite.y + dy; - + if (targetX < 0 || targetX >= width() || targetY < 0 || targetY >= height()) { return false; } - + return true; } -onInput("w", () => { +function movePlayer(dx, dy) { const p = getFirst(player); - if (canMove(p, 0, -1)) p.y -= 1; -}); + if (!p) return; -onInput("s", () => { - const p = getFirst(player); - if (canMove(p, 0, 1)) p.y += 1; -}); + if (canMove(p, dx, dy)) { + p.x += dx; + p.y += dy; + moves++; -onInput("a", () => { - const p = getFirst(player); - if (canMove(p, -1, 0)) p.x -= 1; -}); + const k = getFirst(key); + if (k && p.x === k.x && p.y === k.y) { + k.remove(); + hasKey = true; + const d = getFirst(door); + if (d) d.remove(); + } + } +} -onInput("d", () => { - const p = getFirst(player); - if (canMove(p, 1, 0)) p.x += 1; +onInput("w", () => movePlayer(0, -1)); +onInput("s", () => movePlayer(0, 1)); +onInput("a", () => movePlayer(-1, 0)); +onInput("d", () => movePlayer(1, 0)); + +onInput("r", () => { + loadLevel(levelIndex); }); afterInput(() => { + addText(`Moves: ${moves}`, { x: 7, y: 0, color: color`3` }); + const b = getFirst(block); const g = getFirst(goal); - // Check if the block is on the goal target - if (b.x === g.x && b.y === g.y) { - clearText(); - addText("YOU WIN!", { x: 2, y: 0, color: color`5` }); + if (b && g && b.x === g.x && b.y === g.y) { + levelIndex++; + if (levelIndex < levels.length) { + loadLevel(levelIndex); + } else { + clearText(); + addText("YOU WIN!", { x: 2, y: 2, color: color`5` }); + } } }); From ce8285f0d4f403b12f0fa9ad4e1080fe1a530d09 Mon Sep 17 00:00:00 2001 From: vask3 <131193901+vask3@users.noreply.github.com> Date: Sat, 24 Oct 2026 12:14:03 +0300 Subject: [PATCH 6/6] Define color function to avoid ReferenceError Added a color helper function to prevent ReferenceError. --- games/Vasko-JS-game.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/games/Vasko-JS-game.js b/games/Vasko-JS-game.js index f40acce646..c06d393f9f 100644 --- a/games/Vasko-JS-game.js +++ b/games/Vasko-JS-game.js @@ -13,6 +13,9 @@ const wall = "w"; const key = "k"; const door = "d"; +// Дефиниция на color помощната функция, за да се премахне ReferenceError +const color = (strings, value) => value; + let levelIndex = 0; let moves = 0; let hasKey = false;