Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Maze Game #1093

Merged
merged 6 commits into from
Jul 27, 2023
Merged
Changes from 1 commit
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
155 changes: 155 additions & 0 deletions games/maze game.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
/*
First time? Check out the tutorial game:
https://sprig.hackclub.com/gallery/getting_started
*/

const player = "p"
const wall="w"
const end ="e"

setLegend(
[ player, bitmap`
................
................
................
................
.....666666.....
.....666666.....
.....606606.....
.....666666.....
......7777.5....
.....5777755....
.....55777......
......7777......
......5..5......
......5..5......
......5..5......
................` ],
[wall, bitmap`
................
.00000000000000.
.00000000000000.
.00000000000000.
.00000000000000.
.00000000000000.
.00000000000000.
.00000000000000.
.00000000000000.
.00000000000000.
.00000000000000.
.00000000000000.
.00000000000000.
.00000000000000.
.00000000000000.
................`],
[end, bitmap`
................
................
................
................
....C444........
....C44D444.....
....C44D444.....
....C44D444.....
....C44D444.....
....C...444.....
....C...........
....C...........
....C...........
....C...........
................
................`]
)

setSolids([player, wall])

let level = 0
const levels = [
map`
www.w
w...e
w.www
p.w.w
w...w`,
map`
......wew
.ww.w.w.w
.w..ww...
..w.w..ww
w..w.w...
p.w...ww.
w...w....`,
map`
.ww...wwww..
p...w.w.ww.w
..w.w...w.w.
.w....w.w.w.
.wwww.w.....
....w.wwwww.
www.w.w.w.w.
w.......w..e`,
map`
.......w..
.w.ww.w.ww
.w..w.w...
..w.w..ww.
w.w.ww..w.
..w...w...
.wwww.www.
....w.w.w.
www.w.w.w.
p...w...we`,
map`
pw....w..w...w
.w...w.w...w.w
..ww.w..w.w...
.w..w..w.w..w.
.w.w.w.w.w....
..w...e...w.w.
.w...w.w.w..w.
..w.w..w.w....
w..w.w.w..www.
.w......w.....
.w.wwww..wwww.
.......w......`
]

setMap(levels[level])

setPushables({
[ player ]: []
})

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

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

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

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

afterInput(() => {

if (tilesWith(player, end).length==1) {

level = level + 1;

const currentLevel = levels[level];


if (currentLevel !== undefined) {
setMap(currentLevel);
} else {
addText("you win!", { y: 4, color: color`4` });
}
}
});