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

Change Sprig Device to just sprig on main website #2579

Open
wants to merge 16 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
136 changes: 129 additions & 7 deletions games/racing_game.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ pgggr
gorod
gggrr`,
map`
pgogd
pgord
..gor
gorgr`,
map`
Expand All @@ -156,14 +156,25 @@ g.gg.gg..
......oo.
..ooooo..
..od.....
ggggggggg`,
map`
pgggggggg
oooooooog
ogggggggg
ogggggggg
oooooooog
gggoggdog
gogggggog
gooooooog
ggggggggg`

];

let destinationPosition = null;

const setLevel = (lvl) => {
setMap(levels[lvl]);
destinationPosition = getFirst(destination); // Save the destination position
destinationPosition = getFirst(destination);
}

setLevel(level);
Expand All @@ -188,13 +199,114 @@ const checkDestination = () => {
if (playerTile) {
const targetTile = getTile(playerTile.x, playerTile.y);
if (targetTile.some(tile => tile.type === destination)) {
if (getAll(grass).length === 0) { // Check if all grass is collected
if (getAll(grass).length === 0) {
setTimeout(() => {
level++;
if (level < levels.length) {
if (level < levels.length - 1) {
level++;
setLevel(level);
} else {
addText("You win!", { y: 6, color: color`3` });
clearText();
addText("You win!", { y: 6, color: color`3`, duration: 2000 });
playTune(tune`
204.08163265306123: C4~204.08163265306123 + G4/204.08163265306123,
204.08163265306123: C4~204.08163265306123 + D4~204.08163265306123 + A4/204.08163265306123,
204.08163265306123: D4~204.08163265306123 + A4/204.08163265306123,
204.08163265306123: D4~204.08163265306123 + E4~204.08163265306123 + A4/204.08163265306123 + B4/204.08163265306123,
204.08163265306123: E4~204.08163265306123 + B4/204.08163265306123,
204.08163265306123: E4~204.08163265306123 + F4~204.08163265306123 + B4/204.08163265306123,
204.08163265306123: F4~204.08163265306123 + G4~204.08163265306123 + C5/204.08163265306123,
204.08163265306123: G4~204.08163265306123 + D5/204.08163265306123,
204.08163265306123: A4~204.08163265306123 + D5/204.08163265306123 + E5/204.08163265306123,
204.08163265306123: A4~204.08163265306123 + E5/204.08163265306123,
204.08163265306123: B4~204.08163265306123 + E5/204.08163265306123 + F5/204.08163265306123,
204.08163265306123: B4~204.08163265306123 + C5~204.08163265306123 + F5/204.08163265306123,
204.08163265306123: C5~204.08163265306123 + F5/204.08163265306123 + G5/204.08163265306123,
204.08163265306123: C5~204.08163265306123 + D5~204.08163265306123 + G5/204.08163265306123,
204.08163265306123: D5~204.08163265306123 + A5/204.08163265306123,
204.08163265306123: E5~204.08163265306123 + A5/204.08163265306123,
204.08163265306123: E5~204.08163265306123 + F5~204.08163265306123 + A5/204.08163265306123 + B5/204.08163265306123,
204.08163265306123: F5~204.08163265306123 + G5~204.08163265306123 + B5/204.08163265306123,
204.08163265306123: G5~204.08163265306123,
204.08163265306123: A5~204.08163265306123,
204.08163265306123: A5~204.08163265306123 + B5~204.08163265306123,
204.08163265306123: B5~204.08163265306123,
204.08163265306123: B5^204.08163265306123 + A5^204.08163265306123 + F5-204.08163265306123 + E5-204.08163265306123,
204.08163265306123: G5^204.08163265306123 + F5^204.08163265306123 + B5^204.08163265306123 + E5-204.08163265306123 + D5-204.08163265306123,
204.08163265306123: F5~204.08163265306123 + C5-204.08163265306123,
204.08163265306123: D5^204.08163265306123 + B5~204.08163265306123 + F5~204.08163265306123 + C5-204.08163265306123 + B4-204.08163265306123,
204.08163265306123: B4^204.08163265306123 + G5^204.08163265306123 + B5~204.08163265306123 + A5~204.08163265306123 + A4-204.08163265306123,
204.08163265306123: B4^204.08163265306123 + A4^204.08163265306123 + A5~204.08163265306123 + G5~204.08163265306123 + G4-204.08163265306123,
204.08163265306123: A4^204.08163265306123 + G4^204.08163265306123 + F4^204.08163265306123 + E4^204.08163265306123 + D4^204.08163265306123,
204.08163265306123: D4^204.08163265306123 + C4^204.08163265306123 + E5~204.08163265306123 + D5~204.08163265306123 + G4-204.08163265306123,
204.08163265306123: C4^204.08163265306123 + F4-204.08163265306123,
204.08163265306123: C4-204.08163265306123 + E4-204.08163265306123 + D4-204.08163265306123`);
playTune(tune`
123.45679012345678: C4~123.45679012345678 + G4/123.45679012345678,
123.45679012345678: C4~123.45679012345678 + D4~123.45679012345678 + A4/123.45679012345678,
123.45679012345678: D4~123.45679012345678 + A4/123.45679012345678,
123.45679012345678: D4~123.45679012345678 + E4~123.45679012345678 + A4/123.45679012345678 + B4/123.45679012345678,
123.45679012345678: E4~123.45679012345678 + B4/123.45679012345678,
123.45679012345678: E4~123.45679012345678 + F4~123.45679012345678 + B4/123.45679012345678,
123.45679012345678: F4~123.45679012345678 + G4~123.45679012345678 + C5/123.45679012345678,
123.45679012345678: G4~123.45679012345678 + D5/123.45679012345678,
123.45679012345678: A4~123.45679012345678 + D5/123.45679012345678 + E5/123.45679012345678,
123.45679012345678: A4~123.45679012345678 + E5/123.45679012345678,
123.45679012345678: B4~123.45679012345678 + E5/123.45679012345678 + F5/123.45679012345678,
123.45679012345678: B4~123.45679012345678 + C5~123.45679012345678 + F5/123.45679012345678,
123.45679012345678: C5~123.45679012345678 + F5/123.45679012345678 + G5/123.45679012345678,
123.45679012345678: C5~123.45679012345678 + D5~123.45679012345678 + G5/123.45679012345678,
123.45679012345678: D5~123.45679012345678 + A5/123.45679012345678,
123.45679012345678: E5~123.45679012345678 + A5/123.45679012345678,
123.45679012345678: E5~123.45679012345678 + F5~123.45679012345678 + A5/123.45679012345678 + B5/123.45679012345678,
123.45679012345678: F5~123.45679012345678 + G5~123.45679012345678 + B5/123.45679012345678,
123.45679012345678: G5~123.45679012345678,
123.45679012345678: A5~123.45679012345678,
123.45679012345678: A5~123.45679012345678 + B5~123.45679012345678,
123.45679012345678: B5~123.45679012345678,
123.45679012345678: B5^123.45679012345678 + A5^123.45679012345678 + F5-123.45679012345678 + E5-123.45679012345678,
123.45679012345678: G5^123.45679012345678 + F5^123.45679012345678 + B5^123.45679012345678 + E5-123.45679012345678 + D5-123.45679012345678,
123.45679012345678: F5~123.45679012345678 + C5-123.45679012345678,
123.45679012345678: D5^123.45679012345678 + B5~123.45679012345678 + F5~123.45679012345678 + C5-123.45679012345678 + B4-123.45679012345678,
123.45679012345678: B4^123.45679012345678 + G5^123.45679012345678 + B5~123.45679012345678 + A5~123.45679012345678 + A4-123.45679012345678,
123.45679012345678: B4^123.45679012345678 + A4^123.45679012345678 + A5~123.45679012345678 + G5~123.45679012345678 + G4-123.45679012345678,
123.45679012345678: A4^123.45679012345678 + G4^123.45679012345678 + F4^123.45679012345678 + E4^123.45679012345678 + D4^123.45679012345678,
123.45679012345678: D4^123.45679012345678 + C4^123.45679012345678 + E5~123.45679012345678 + D5~123.45679012345678 + G4-123.45679012345678,
123.45679012345678: C4^123.45679012345678 + F4-123.45679012345678,
123.45679012345678: C4-123.45679012345678 + E4-123.45679012345678 + D4-123.45679012345678`);
playTune(tune`
80: C4~80 + G4/80,
80: C4~80 + D4~80 + A4/80,
80: D4~80 + A4/80,
80: D4~80 + E4~80 + A4/80 + B4/80,
80: E4~80 + B4/80,
80: E4~80 + F4~80 + B4/80,
80: F4~80 + G4~80 + C5/80,
80: G4~80 + D5/80,
80: A4~80 + D5/80 + E5/80,
80: A4~80 + E5/80,
80: B4~80 + E5/80 + F5/80,
80: B4~80 + C5~80 + F5/80,
80: C5~80 + F5/80 + G5/80,
80: C5~80 + D5~80 + G5/80,
80: D5~80 + A5/80,
80: E5~80 + A5/80,
80: E5~80 + F5~80 + A5/80 + B5/80,
80: F5~80 + G5~80 + B5/80,
80: G5~80,
80: A5~80,
80: A5~80 + B5~80,
80: B5~80,
80: B5^80 + A5^80 + F5-80 + E5-80,
80: G5^80 + F5^80 + B5^80 + E5-80 + D5-80,
80: F5~80 + C5-80,
80: D5^80 + B5~80 + F5~80 + C5-80 + B4-80,
80: B4^80 + G5^80 + B5~80 + A5~80 + A4-80,
80: B4^80 + A4^80 + A5~80 + G5~80 + G4-80,
80: A4^80 + G4^80 + F4^80 + E4^80 + D4^80,
80: D4^80 + C4^80 + E5~80 + D5~80 + G4-80,
80: C4^80 + F4-80,
80: C4-80 + E4-80 + D4-80`);

}
}, 200);
} else {
Expand All @@ -206,11 +318,21 @@ const checkDestination = () => {
}
};


onInput('a', () => pushPlayer(-1, 0));
onInput('d', () => pushPlayer(1, 0));
onInput('w', () => pushPlayer(0, -1));
onInput('s', () => pushPlayer(0, 1));
onInput('j', () => setLevel(level)); // Reset the current level when 'j' is pressed
onInput('j', () => {
clearText();
for (let x = 0; x < width(); x++) {
for (let y = 0; y < height(); y++) {
clearTile(x, y);
}
}
setLevel(level);
});


afterInput(() => {
checkDestination();
Expand Down
2 changes: 1 addition & 1 deletion src/pages/index.astro
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ if (session && session.session.full) {
</div>
<div class='text'>
<h1>Every player is a creator.</h1>
<p>Explore 430+ games built by other teenagers, <br />or make your own and we'll send you a console!</p>
<p>Explore 800+ games built by other teenagers, <br />or make your own and we'll send you a console!</p>
<div>
<button class='btn active top' onclick="makeGameRedirect()">
Make a game &raquo;
Expand Down
Loading