-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
216 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,216 @@ | ||
/* | ||
First time? Check out the tutorial game: | ||
https://sprig.hackclub.com/gallery/getting_started | ||
@title: Maze Ball | ||
@author: doggo_742 | ||
@tags: [] | ||
@addedOn: 2024-00-00 | ||
Roll through the labyrinth! New levels every day! | ||
*/ | ||
|
||
const player = "p" | ||
const wall = "w" | ||
const goal = "g" | ||
setLegend( | ||
[player, bitmap` | ||
................ | ||
................ | ||
.....555555..... | ||
...5555555555... | ||
...5555555555... | ||
..555555555555.. | ||
..555555555555.. | ||
..555555555555.. | ||
..555555555555.. | ||
..555555555555.. | ||
..555555555555.. | ||
...5555555555... | ||
...5555555555... | ||
.....555555..... | ||
................ | ||
................`], | ||
[wall, bitmap` | ||
LLLLLLLLLLLLLLLL | ||
LLLLLLLLLLLLLLLL | ||
LLLLLLLLLLLLLLLL | ||
LLLLLLLLLLLLLLLL | ||
LLLLLLLLLLLLLLLL | ||
LLLLLLLLLLLLLLLL | ||
LLLLLLLLLLLLLLLL | ||
LLLLLLLLLLLLLLLL | ||
LLLLLLLLLLLLLLLL | ||
LLLLLLLLLLLLLLLL | ||
LLLLLLLLLLLLLLLL | ||
LLLLLLLLLLLLLLLL | ||
LLLLLLLLLLLLLLLL | ||
LLLLLLLLLLLLLLLL | ||
LLLLLLLLLLLLLLLL | ||
LLLLLLLLLLLLLLLL`], | ||
[goal, bitmap` | ||
................ | ||
................ | ||
.....DDDDDD..... | ||
...DDDDDDDDDD... | ||
...DD......DD... | ||
..DD........DD.. | ||
..DD........DD.. | ||
..DD........DD.. | ||
..DD........DD.. | ||
..DD........DD.. | ||
..DD........DD.. | ||
...DD......DD... | ||
...DDDDDDDDDD... | ||
.....DDDDDD..... | ||
................ | ||
................`], | ||
) | ||
// Make sure each sprite definition is enclosed in square brackets within the setLegend function call. | ||
setSolids([wall, player]) | ||
|
||
// Add this code inside the afterInput block to check for reaching the goal | ||
afterInput(() => { | ||
const playerSprite = getFirst(player) | ||
const goalTile = getTile(playerSprite.x, playerSprite.y).find(sprite => sprite.type === goal) | ||
|
||
if (goalTile) { | ||
level++ | ||
clearTile(playerSprite.x, playerSprite.y) | ||
if (levels[level]) { | ||
setMap(levels[level]) | ||
} else { | ||
console.log("You have completed all levels!") | ||
} | ||
} | ||
}) | ||
let level = 0 | ||
const levels = [ | ||
map` | ||
wwwwwwwwwww | ||
w.........w | ||
w.wwwww.w.w | ||
w.w...w.www | ||
w.w.www...w | ||
w...wp..w.w | ||
www.wwwwwww | ||
w......w.gw | ||
w.www.ww.ww | ||
w...w.....w | ||
wwwwwwwwwww`, | ||
map` | ||
wwwwwwwwwww | ||
w...w.....w | ||
w.w.wwwww.w | ||
w.w.......w | ||
w.wwwwwww.w | ||
w.wpwg..w.w | ||
w.w.www.w.w | ||
w.w.w...w.w | ||
w.w.w.www.w | ||
w...w.....w | ||
wwwwwwwwwww`, | ||
map` | ||
wwwwwwwwwww | ||
w........pw | ||
w.wwwwwwwww | ||
w.w...w.w.w | ||
w.www.w.w.w | ||
w...w.w...w | ||
w.w.w.w.www | ||
w.w.......w | ||
www.wwwww.w | ||
w.....wg..w | ||
wwwwwwwwwww`, | ||
map` | ||
wwwwwwwwwww | ||
wp....wgw.w | ||
www.www.w.w | ||
w.w.w.w.w.w | ||
w.w.w.w.w.w | ||
w.w...w...w | ||
w.w.w.www.w | ||
w.w.w.w...w | ||
w.www.w.www | ||
w.........w | ||
wwwwwwwwwww`, | ||
map` | ||
wwwwwwwwwww | ||
wp....w...w | ||
w.wwwwwww.w | ||
w...w.....w | ||
www.w.w.www | ||
w.....w.w.w | ||
w.wwwwwww.w | ||
w.........w | ||
www.wwwww.w | ||
w...wg....w | ||
wwwwwwwwwww`, | ||
map` | ||
wwwwwwwwwww | ||
wp....w...w | ||
w.w.w.w.w.w | ||
w.w.w.w.w.w | ||
www.www.www | ||
w.........w | ||
w.www.w.w.w | ||
w...w.w.w.w | ||
wwwwwww.w.w | ||
wg......w.w | ||
wwwwwwwwwww`, | ||
map` | ||
wwwwwwwwwww | ||
w.....w...w | ||
www.w.www.w | ||
w...wpw.w.w | ||
www.www.w.w | ||
wgw.......w | ||
w.wwwww.w.w | ||
w.w...w.w.w | ||
w.www.www.w | ||
w.........w | ||
wwwwwwwwwww`, | ||
map` | ||
wwwwwwwwwww | ||
w..pw...wgw | ||
w.www.www.w | ||
w.....w...w | ||
w.wwwwwww.w | ||
w...w.w...w | ||
www.w.w.www | ||
w.w.w.w...w | ||
w.w.w.www.w | ||
w.........w | ||
wwwwwwwwwww`, | ||
map` | ||
wwwwwwwwwww | ||
wpwg......w | ||
w.wwwwwww.w | ||
w.w.w...w.w | ||
w.w.www.w.w | ||
w.......w.w | ||
w.w.www.w.w | ||
w.w.w...w.w | ||
w.wwwww.w.w | ||
w...w.....w | ||
wwwwwwwwwww` | ||
|
||
] | ||
|
||
setMap(levels[level]) | ||
|
||
setPushables({ | ||
[player]: [] | ||
}) | ||
|
||
onInput("s", () => { | ||
getFirst(player).y += 1 | ||
}) | ||
onInput("w", () => { | ||
getFirst(player).y -= 1 | ||
}) | ||
onInput("d", () => { | ||
getFirst(player).x += 1 | ||
}) | ||
onInput("a", () => { | ||
getFirst(player).x -= 1 | ||
}) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.