Skip to content

Commit

Permalink
v3 Release
Browse files Browse the repository at this point in the history
- Add remaining treasure counter
- Fix replay blink when it overlaps with the level
- Add a new tutorial level as level 1
- Add a new final level as level 30
- Rework level 28 (formerly level 27)
  • Loading branch information
Zwergesel committed Apr 28, 2024
1 parent dc2d3c3 commit 22e43ce
Show file tree
Hide file tree
Showing 2 changed files with 87 additions and 38 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ You can also play the game in a [simulated _Netronics Connect!_ terminal](https:

![Preview](https://i.imgur.com/S5hFiVc.jpg)

The game contains 28 levels in which you must wander through the maze and collect all diamonds without being eaten by a monster. The monsters move two spaces after each of your moves but they are stupid and only want to move either horizontally or vertically closer to you. If both are possible, they prefer horizontal moves. If neither are possible because there are walls in the way, they don't move at all.
The game contains 30 levels in which you must wander through the maze and collect all diamonds without being eaten by a monster. The monsters move two spaces after each of your moves but they are stupid and only want to move either horizontally or vertically closer to you. If both are possible, they prefer horizontal moves. If neither are possible because there are walls in the way, they don't move at all.

In later levels there are also locked gates which can be opened by the walking onto switches, both by the player and the monsters. Switches can be triggered multiple times and will always close all open gates and open all closed gates simultaneously.

Expand All @@ -32,3 +32,4 @@ Your progress is saved automatically.

- July 27, 2022: Version 1 of Monster Maze is released
- March 7, 2024: Version 2 of Monster Maze is released
- April 29, 2024: Version 3 of Monster Maze is released
122 changes: 85 additions & 37 deletions monstermaze.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ TUTORIAL_Y = 0;
TUTORIAL_WIDTH = 20;
TUTORIAL_HEIGHT = 20;

SAVEGAME_VERSION = 2;
SAVEGAME_VERSION = 4;

SCREEN_GAME = 1;
SCREEN_STATS = 2;
Expand All @@ -20,7 +20,7 @@ PROWL_AT = [10, 4];
HALFSTEP_AT = [7, 1];
SIMULATE_AT = [11, 6];

MOVE_SYMBOLS = "▲▼<>♦";
MOVE_SYMBOLS = "^v<>x";
CRYPT_SYMBOLS = "abcdefghijklmnopqrstuvwxyz012345";

let screen;
Expand All @@ -46,6 +46,25 @@ let messages = [];
let cheatBuffer = "";

const levels = [{
template: [
"#################",
"#P . . . . . . M#",
"### ####### #####",
" #.# #.# ",
" # ##### # ### ",
" #T T T# #. .# ",
" ##### # ### ###",
" #.# #. .#",
" # ##### ###",
" #. . T T T#",
" ######### #",
" I. . .#",
" #######",
],
grades: [14, 16, 18, 20],
solution: "tvs10pigtoei"
},
{
template: [
" ########### ",
" #. . . . .# ",
Expand Down Expand Up @@ -575,26 +594,26 @@ const levels = [{
},
{
template: [
" ################### ",
" #. .G. . .G. . . .# ",
"### #####g######### # ",
"#T .#. B . .#. . B#.# ",
"# # # ##### # ",
"#. .#. . . P .#.#. .# ",
"####### ### #g### ",
" #T .#. B .g. . .G.# ",
" # # ###G# ### ####### ",
" #M .g. .G.#.#.#. .#.#. T# ",
" ######### # # # # # # ",
" #T .#. .#.GB#. .G.#. .# ",
" # # ###g###g# #G### ",
" #. .g. . .#.#B .#B .# ",
" #########g# # #########",
" #. . .G. .G. .g. .I",
" ###################",
" ################# ",
" #. .G. . .G. . .# ",
"### #####g####### ####### ",
"#T .#. B . .#. B#. .#. T# ",
"# # # ##### # # ",
"#. .#. . . . .g. .g.#. .# ",
"####### ### ###G#g### ",
" #T .#. B Pg. . .G. .#. T# ",
" # # ###G# ### # # ",
" #M .g. .G.#.#.#. . .#. .# ",
" ######### # # ### ###G#####",
" #T .#. .#.GB#.#.g. Bg. .#",
" # # ###g# #g# # #",
" #. .g. . .#.#B .#B .#. T#",
" #########g# # #####G###",
" I. . .G. .g. . .# ",
" ################# ",
],
grades: [158, 166, 180, 220],
solution: "ylmumhfojzezippimxlimtduyliglvmip5crc2owrvcldte5eghwrvwnizjvd2thapjiavdznncptvwb0mfi"
grades: [183, 190, 215, 240],
solution: "0lchacenevkrcnwlnmd1jscd0fhemvedispsibicbawlau0bafooslihe30b0fmdemm1a4ysynlpfngojppb0cdibaiqwrq2i"
},
{
template: [
Expand All @@ -618,6 +637,31 @@ const levels = [{
],
grades: [139, 145, 170, 205],
solution: "ildurihbpszbhfdciave3ykdipoemjcmjveyzoegdgiodyov0bwedfhb4wevolwhdvczhfc252w"
},
{
template: [
"######### ######### #########",
"#M . . .# #. . . .# #. T . M#",
"# ### # ##### # ### ##### #",
"#. . .#. . . . .#. .# #. . . .#",
"# ##### ##### ##### ##### ### # #",
"IP . . .# #. . .#M . . . .#.#.#",
"# ### ### ### # ##### # ###",
"#. . . .# #. . . .# #. . . .#",
"### ##### ##### ### ##### ###",
" #.# #.# #.# ",
"### ##### ##### ### ##### ###",
"#. . . .# #. .#.#.# #. .#.#.#",
"# ####### ### # # ##### ### # #",
"#.#. T .# #. . . . . . . . . .#",
"# ### ######### ### ##### ### #",
"#T . .#. . . . . .#.# #. .#T .#",
"### # ##### ### # ### ### #",
"#. . . M# #. . . M# #. . . M#",
"######### ######### #########",
],
grades: [251, 259, 300, 400],
solution: "52moriwehnybfbvwtvdnhvkzekpsrhglzmhbyfcemjghdvoyo4hlrvm0fse5ihxhrpwn5ygrcbidplplepyq05juanel4sc5dmhwavu13rlcolcipap334ktcpidp2kk33x"
}
];

Expand Down Expand Up @@ -762,17 +806,16 @@ function onUpdate()
if (screen == SCREEN_STATS) {
drawBox(brightness.box, 1, 0, 54, 20);
drawText("Level Moves Grade Level Moves Grade", brightness.message, 6, 1);
for (let i=0; i<14; ++i) {
for (let i=0; i<15; ++i) {
drawText(right3(i + 1), brightness.message, 7, 3 + i);
drawText(right3(stats.best[i]), brightness.message, 13, 3 + i);
drawText(grade(stats.best[i], levels[i].grades), brightness.message, 20, 3 + i);
if (i + 14 < levels.length) {
drawText(right3(i + 15), brightness.message, 30, 3 + i);
drawText(right3(stats.best[i + 14]), brightness.message, 36, 3 + i);
drawText(grade(stats.best[i + 14], levels[i + 14].grades), brightness.message, 43, 3 + i);
if (i + 15 < levels.length) {
drawText(right3(i + 16), brightness.message, 30, 3 + i);
drawText(right3(stats.best[i + 15]), brightness.message, 36, 3 + i);
drawText(grade(stats.best[i + 15], levels[i + 15].grades), brightness.message, 43, 3 + i);
}
}
drawText("A: Best known solution, S: Better than lvl author", brightness.message, 3, 18);
return;
}

Expand Down Expand Up @@ -800,6 +843,7 @@ function onUpdate()
drawText("N: Next", stats.currentLevel == stats.maxLevel ? brightness.inactiveMessage : brightness.message, TUTORIAL_X + 11, TUTORIAL_Y + 17)
drawText("X: Replay", stats.best[stats.currentLevel].length ? brightness.message : brightness.inactiveMessage, TUTORIAL_X + 1, TUTORIAL_Y + 18)
drawText("S: Stats", brightness.message, TUTORIAL_X + 11, TUTORIAL_Y + 18)
drawText(glyph.treasure, brightness.treasure, TUTORIAL_X + 11, TUTORIAL_Y + 3)

// Level
for (let y=0; y<level.height; ++y) {
Expand Down Expand Up @@ -910,7 +954,7 @@ function onUpdate()
}

if (simulate && !anyMonsterMoved) {
if (moves[moves.length - 1] == '' && moveDelay == SIMULATE_AT[0] && undoSteps[undoSteps.length - 1][1] == "end") {
if (moves[moves.length - 1] == 'x' && moveDelay == SIMULATE_AT[0] && undoSteps[undoSteps.length - 1][1] == "end") {
// Don't add a move if waiting and no monster moves
undoSteps.pop();
moves = moves.substring(0, moves.length - 1);
Expand Down Expand Up @@ -950,7 +994,7 @@ function onUpdate()
// Replays
if (replay.length) {
drawBox(brightness.box, PLAYAREA_X + PLAYAREA_WIDTH - 3, PLAYAREA_Y, 3, 3);
if (replayBlink) drawText("R", brightness.message, PLAYAREA_X + PLAYAREA_WIDTH - 2, PLAYAREA_Y + 1);
drawText(replayBlink ? "R" : " ", brightness.message, PLAYAREA_X + PLAYAREA_WIDTH - 2, PLAYAREA_Y + 1);
if (--replayDelay <= 0) {
replayDelay = REPLAY_DELAY;
replayBlink = !replayBlink;
Expand All @@ -960,8 +1004,12 @@ function onUpdate()
}

// Info Bar
const title = "Level " + format_level(stats.currentLevel + 1) + " Moves " + left3(moves.length) + " Best " + left3(stats.best[stats.currentLevel]);
const title = "Lvl " + format_level(stats.currentLevel + 1) +
" Move " + left3(moves.length) +
" Best " + left3(stats.best[stats.currentLevel]) +
" " + glyph.treasure + " " + treasures.length;
drawText(title, brightness.title, 0, 0);
drawText(glyph.treasure, brightness.treasure, 32, 0)
}

function onInput(key)
Expand Down Expand Up @@ -1047,20 +1095,20 @@ function onInput(key)
// No control during monster moves or undos
if (moveDelay > 0 || undoCounter > 0) return;

if (key == 17) onPlayerMove(''); // Up
if (key == 18) onPlayerMove(''); // Down
if (key == 17) onPlayerMove('^'); // Up
if (key == 18) onPlayerMove('v'); // Down
if (key == 19) onPlayerMove('<'); // Left
if (key == 20) onPlayerMove('>'); // Right
if (key == 32) onPlayerMove(''); // Space
if (key == 32) onPlayerMove('x'); // Space
}

function onPlayerMove(direction) {
let target = 'Z';

if (direction == '') { // Up
if (direction == '^') { // Up
target = level.data[player.y - 1][player.x];
lastMove.y = -1;
} else if (direction == '') { // Down
} else if (direction == 'v') { // Down
target = level.data[player.y + 1][player.x];
lastMove.y = 1;
} else if (direction == '<') { // Left
Expand All @@ -1081,7 +1129,7 @@ function onPlayerMove(direction) {
lastMove.x = lastMove.y = 0;
}

if (direction == '') { // Space
if (direction == 'x') { // Space
moveDelay = SIMULATE_AT[0] + 1; // Faster monster move on skip
undoSteps.push([moveDelay, "end"]);
moves += direction;
Expand All @@ -1098,7 +1146,7 @@ function onPlayerMove(direction) {
save();
} else {
gameOver = true;
messages = [" You ran away ", " without the treasure! "];
messages = [" You did not collect ", " all the treasure! "];
}
}
}
Expand Down

0 comments on commit 22e43ce

Please sign in to comment.