Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
278 changes: 278 additions & 0 deletions games/Frog-Maze-Game.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,278 @@
/*
@title: Frog Maze game
@author: Froggy1018
@description: Solve the maze
@tags: [Maze]
@addedOn: 2025-10-22
*/



const player="p"
const fly = "y"
const worm="e"
const wall= "w"
const wall2= "v"
const key = "k"
const door = "d"
const key2="f"


setLegend(
[ player, bitmap`
................
................
..DD...DD.......
.D44D.D44D......
.4024D4024D.....
.400444004D.....
..4444444D......
..433334D.......
..444444DD......
...DDDDDD4D.....
...D44D4444D....
...D44D4444D....
...D44D44DD.....
................
................
................` ],

[ fly, bitmap`
................
................
................
................
................
....LLL..LLL....
...LL1L..L1LL...
...L11000011L...
...LLL0000LLL...
......3003......
......0000......
................
................
................
................
................` ],

[ worm, bitmap`
................
................
................
................
............CC..
............CC..
.....CCCC...CC..
....CCCCCC..CC..
....CC..CC..CC..
...CCC..CCCCCC..
..CCC....CCCC...
................
................
................
................
................` ],

[ wall, bitmap`
DD.DD...4.D...4.
D.4.D..4..DD.44.
D.44D.44...D.4..
D..4D.4....D.4..
DD..D.44..DD.44.
.D.DD..4..DD..44
.D.D.4..4..D...4
.D.D44...4.D..44
D4.D4....4.D.44.
D44.DD...4.D.4..
DD4..D..4.DD.4..
.DD..D..4.DD..4.
..D..D..4..D..44
.D...D.4...DD..4
.D..DD.4....D.44
.D.DD..4....D.4.` ],

[ wall2, bitmap`
4DD..44D.C.DDD..
.DD.D44..4DDD...
4DD4344D..DDD.4C
.DD.D44.3..DDD44
4DD...44D...DDD.
.DD4..D44...DDDD
.DD4...44....DDD
4DD....44D....DD
.DD4.3.44...3.DD
.DD..D444....DDD
4DD...44....DDD.
.DD4...44...DD..
4DD....44D..4DD.
.DD....44..44DD.
.DD4...D44..44DD
4DD.....44D...DD` ],

[ key, bitmap`
................
.....66666F.....
....6666666F....
....66FFF66F....
....66FFF66F....
....6666666F....
.....66666F.....
......666F......
......6666F.....
......66FFF.....
......6666F.....
......66FF......
......6666F.....
......6666F.....
......66FF......
......66F.......` ],

[ door, bitmap`
......6666......
.....66CC66.....
....66CCCC66....
....6CCCCCC6....
...66CCCCCC66...
...6CCCCCCCC6...
...6CCCCCCCC6...
...6CC6CC6CC6...
...6CC6CC6CC6...
...6CC6CC6CC6...
...6CCCCCCCC6...
...6CCCCCCCC6...
...6CCCCCCCC6...
...6CCCCCCCC6...
.LL6666666666LL.
.LLLLLLLLLLLLLL.` ],

[ key2, bitmap`
................
.....66666C.....
....6666666C....
....66CCC66C....
....66CCC66C....
....6666666C....
.....66666C.....
......666C......
......6666C.....
......66CCC.....
......6666C.....
......66CC......
......6666C.....
......6666C.....
......66CC......
......66C.......` ]
)

setSolids([player, wall, wall2, door])

let level = 0
const levels = [
map`
wwwwwwwww
w.......w
w.wwwww.w
w.w..ew.w
w.w.www.w
w.w.....w
wpwwwwwww`,

map`
wwwwewwww
wwww.wwww
wwww.wwww
e...p...y
wwww.wwww
wwww.wwww
wwwwywwww`,

map`
wpwwwwwwwww
w.w...wywew
w.w.www.www
w...w.....w
w.www.ww.ww
w.wy...w.ww
w.wwww.w.ww
w...w..w.ww
www.w.ww.ww
wy....w...e
wwwwwwwwwww`,

map`
wpwwwwwwwwwwwwwwwww
w.v..............fw
w.w.wvw.w.wvwvwvwvw
w...v...v.........w
w.wvw.wvwvwvwvw.w.w
w.vf..v.......vfv.w
w.wvwvw.wvwvw.wvw.w
w...v.......v.v...w
wvw.w.wvwvw.w.w.w.w
wf..v.v...v.v.v.v.w
wvw.w.w.w.w.w.w.w.w
w...v...v.vfv...vfw
w.wvwvwvw.wvwvwvwvw
w.......v.v.......w
wvwvw.w.w.w.wvwvw.w
w..kv.v.v...v...v.w
w.wvw.w.wvwvw.w.w.w
w.....v.......v.vde
wwwwwwwwwwwwwwwwwww`
]

setMap(levels[level])

setPushables({
[ player ]: []
})

onInput("w", () => {
getFirst(player).y -= 1
})

onInput("s", () => {
getFirst(player).y += 1
})

onInput("a", () => {
getFirst(player).x -= 1
})

onInput("d", () => {
getFirst(player).x += 1
})

onInput("j", () => {
level = 0; // Reset the level to the first level
setMap(levels[level]); // Set the map to the first level
});

let hasKey = false;

afterInput(() => {
const playerSprite = getFirst(player);

const wormTiles = tilesWith(player, worm);
if (wormTiles.length > 0) {
level++;
if (level < levels.length) {
setMap(levels[level]);
hasKey = false; // Reset key state for new level
} else {
addText("you win!", { y: 4, color: color`0` });
}
return; // Exit early since we changed level
}

const keyTiles = tilesWith(player, key);
if (keyTiles.length > 0) {
hasKey = true;
clearTile(17,17)
}

const doorTiles = tilesWith(player, door);
if (doorTiles.length > 0 && hasKey) {

}
});