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

New Game #1304

Merged
merged 9 commits into from
Dec 22, 2023
Merged
Changes from 2 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
159 changes: 159 additions & 0 deletions games/move_the_rocks.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
const player = "p";
const wall = "w";
const gold = "g";


setLegend(
[ player, bitmap`
................
................
.......000......
.......000......
.......000......
.......000......
........0...0...
........0...0...
....000000000...
....0..000......
....0..000......
.......000......
.......0.0......
.......0.0......
.....000.000....
................` ],
[ wall, bitmap`
................
.....LLLL.......
...LL...LLLLL...
..L..L..L...LL..
..L..L..LLLLLL..
..L..L......LL..
..L..LL.LL..LL..
..L...LLLL.LLL..
..LL..L..LLLLL..
...LL....LLLL...
....LLLLLL......
................
................
................
................
................` ],
[ gold, bitmap`
................
................
................
................
..9C7C7CCCCC7...
..CCC6C6C696C...
..7C9CCC796CC...
..6CCC79C7CC6...
..9C6C6C6C96C...
..7CCC7C7C799...
..6C6C6C6CCC6...
..9CCC9C9C9CC...
................
................
................
................` ]
)

setSolids([player,wall])

let level = 0
const levels = [
map`
w.
gw
w.
p.`,
map`
w.w
wg.
.ww
p..`,
map`
g..w
.w.w
www.
.pw.`,
map`
p.ww
wwg.
.w.w
..ww`,
map`
.g.w
w.ww
.ww.
.pw.`,
map`
w.g.
www.
..w.
.wpw`,
map`
w.wp
gw.w
.ww.
w...`,
map`
....g
wwww.
..w.w
w.ww.
pw...`,
map`
.w.wg
w.ww.
.wpw.
.ww..
.....`,
map`
.ww.g
w..w.
.w.ww
w.w..
.wpww`
]

setMap(levels[level])

setPushables({
[ player ]: [wall]
})

onInput("s", () => {
getFirst(player).y += 1
})
onInput("w", () => {
getFirst(player).y -= 1
})
onInput("d", () => {
getFirst(player).x += 1
})
onInput("a", () => {
getFirst(player).x -= 1
})
onInput("k", () => {
setMap(levels[level])
})

afterInput(() => {
if (level === 0){
addText("Get the Treasure!", {y: 11, color: color`6` });
addText("Press k to Restart", {y: 13, color: color`6` });
}
const targetNumber = tilesWith(gold).length;
const numberCovered = tilesWith(player, gold).length;
if (numberCovered === targetNumber) {
level = level + 1;
clearText()
const currentLevel = levels[level];
if (currentLevel !== undefined) {
setMap(currentLevel);
} else {
addText("You Win!", {y: 5, color: color`H` });
}
}

})
Loading