Every player is a creator.
-Explore 430+ games built by other teenagers,
or make your own and we'll send you a console!
Explore 800+ games built by other teenagers,
or make your own and we'll send you a console!
diff --git a/games/racing_game.js b/games/racing_game.js index 2e87c0c17f..dbf8305ad2 100644 --- a/games/racing_game.js +++ b/games/racing_game.js @@ -132,7 +132,7 @@ pgggr gorod gggrr`, map` -pgogd +pgord ..gor gorgr`, map` @@ -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); @@ -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 { @@ -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(); diff --git a/src/pages/index.astro b/src/pages/index.astro index 55b489056b..51efbfdaa8 100644 --- a/src/pages/index.astro +++ b/src/pages/index.astro @@ -64,7 +64,7 @@ if (session && session.session.full) {
Explore 430+ games built by other teenagers,
or make your own and we'll send you a console!
Explore 800+ games built by other teenagers,
or make your own and we'll send you a console!