From 76e993c475424b5aa00d88ab4cb8fcedf9a192d3 Mon Sep 17 00:00:00 2001 From: wvminecraftkid <139291007+wvminecraftkid@users.noreply.github.com> Date: Wed, 30 Oct 2024 13:43:06 -0400 Subject: [PATCH] Apple_Drop (#2508) * Add files via upload * Add files via upload * fix metadata --------- Co-authored-by: Mare Cosmin <147330889+Cosmin-Mare@users.noreply.github.com> --- games/Apple_Drop.js | 302 +++++++++++++++++++++++++++++++++++++++ games/img/Apple_Drop.png | Bin 0 -> 3184 bytes 2 files changed, 302 insertions(+) create mode 100644 games/Apple_Drop.js create mode 100644 games/img/Apple_Drop.png diff --git a/games/Apple_Drop.js b/games/Apple_Drop.js new file mode 100644 index 0000000000..db9b9b8de6 --- /dev/null +++ b/games/Apple_Drop.js @@ -0,0 +1,302 @@ +/* +First time? Check out the tutorial game: +https://sprig.hackclub.com/gallery/getting_started + +@title: Apple_Drop +@author: wvminecraftkid +@tags: [] +@addedOn: 2024-10-30 +*/ + +const player = "p" +const apple = "a" +const background = "b" +const song = tune` +297.029702970297: G4/297.029702970297, +297.029702970297, +297.029702970297: C5/297.029702970297, +297.029702970297, +297.029702970297: C5/297.029702970297, +297.029702970297: D5/297.029702970297, +297.029702970297: E5/297.029702970297, +297.029702970297: D5/297.029702970297, +297.029702970297: C5/297.029702970297, +297.029702970297: A4/297.029702970297, +297.029702970297: G4/297.029702970297, +297.029702970297, +297.029702970297: C5/297.029702970297, +297.029702970297: B4/297.029702970297, +297.029702970297: C5/297.029702970297, +594.059405940594, +297.029702970297: G4/297.029702970297, +297.029702970297: C5/297.029702970297, +297.029702970297, +297.029702970297: C5/297.029702970297, +297.029702970297: D5/297.029702970297, +297.029702970297: E5/297.029702970297, +297.029702970297: D5/297.029702970297, +297.029702970297: C5/297.029702970297, +297.029702970297: A5/297.029702970297, +297.029702970297: G5/297.029702970297, +1485.148514851485` +const ding = tune` +150, +150: B4-150, +150: G5-150, +4350` +const death = tune` +333.3333333333333, +333.3333333333333: E4/333.3333333333333 + C5/333.3333333333333, +333.3333333333333, +333.3333333333333: G4/333.3333333333333 + C4/333.3333333333333, +333.3333333333333, +333.3333333333333: G4/333.3333333333333 + E4/333.3333333333333, +333.3333333333333, +333.3333333333333: F4/333.3333333333333 + A4/333.3333333333333, +333.3333333333333: F4/333.3333333333333 + B4/333.3333333333333, +333.3333333333333: F4/333.3333333333333 + A4/333.3333333333333, +333.3333333333333: F4/333.3333333333333 + G4/333.3333333333333, +333.3333333333333: F4/333.3333333333333 + A4/333.3333333333333, +333.3333333333333: G4/333.3333333333333 + F4/333.3333333333333, +333.3333333333333: E4/333.3333333333333 + G4/333.3333333333333, +333.3333333333333: E4/333.3333333333333 + G4/333.3333333333333, +333.3333333333333: E4/333.3333333333333 + G4/333.3333333333333, +333.3333333333333: G4/333.3333333333333 + E4/333.3333333333333, +5000` + + +const playback = playTune(song, Infinity) +const black = "d" + +let gameOver = false; + + +function setup(callback) { + callback() +} + +function forever(callback) { + setInterval(callback, 10000 / 65); +} + +setLegend( + [ player, bitmap` +.0............0. +.000........000. +..L0000000000L.. +..L..........L.. +..L..LLLLLL..L.. +..L..L0LL0L..L.. +..L.1L0LL0L1.L.. +..L.1LLLLLL1.L.. +..L..LL00LL..L.. +..LLLLLLLLLLLL.. +...LLLLLLLLLL... +.....LLLLLL..... +.....LLLLLL..... +.....LLLLLL..... +.....L....L..... +....LLL..LLL....` ], + [ background, bitmap ` +CL666666666666LC +C66666666666666C +C66666666666666C +C66666666666666C +C66666666666666C +C66666666666666C +C66666666666666C +C66666666666666C +C66666666666666C +C66666666666666C +C66666666666666C +C66666666666666C +C66666666666666C +C66666666666666C +C66666666666666C +CL666666666666LC`], + [ apple, bitmap` +........DD...... +........D....... +.....33FD33..... +...333FDD3333... +...333FD33933... +..33333D333933.. +..333333333933.. +..333333333333.. +..333333333333.. +..3C3333333333.. +..3C3333333333.. +...3C33333333... +...33CC333333... +.....333333..... +................ +................` + ], + [ black, bitmap` +0000000000000000 +0000000000000000 +0000000000000000 +0000000000000000 +0000000000000000 +0000000000000000 +0000000000000000 +0000000000000000 +0000000000000000 +0000000000000000 +0000000000000000 +0000000000000000 +0000000000000000 +0000000000000000 +0000000000000000 +0000000000000000`] + +) + +setSolids([]) + +setBackground("b") +let level = 0 +const levels = [ + map` +d..a..d +d.....d +d.....d +d.....d +d.....d +d..p..d` +] + +setMap(levels[level]) + +setPushables({ + [ player ]: [] +}) +setSolids([ player, black ]) + +setup(() => { + let playerPoints = 0; + let appleExists = true; + + addText("A", {x:2, y:3, color: color`3`}); + addText("P", {x:2, y:4, color: color`4`}); + addText("P", {x:2, y:5, color: color`3`}); + addText("L", {x:2, y:6, color: color`4`}); + addText("E", {x:2, y:7, color: color`3`}); + + addText("D", {x:2, y:9, color: color`4`}); + addText("R", {x:2, y:10, color: color`3`}); + addText("O", {x:2, y:11, color: color`4`}); + addText("P", {x:2, y:12, color: color`3`}); + + addText("P", {x:17, y:1, color: color`2`}); + addText("o", {x:17, y:2, color: color`2`}); + addText("i", {x:17, y:3, color: color`2`}); + addText("n", {x:17, y:4, color: color`2`}); + addText("t", {x:17, y:5, color: color`2`}); + addText("s", {x:17, y:6, color: color`2`}); + + addText("0", {x:17, y:8, color: color`H`}); + + forever(() => { + const playerSprite = getFirst(player); + const appleSprite = getFirst(apple); + + if (!appleExists && !appleSprite) { + const newX = Math.floor((Math.random() * 5)+1); + const newY = 0; + addSprite(newX, newY, apple); + appleExists = true; + } + + if (playerSprite && appleSprite) { + if (appleSprite.y === playerSprite.y - 1 && appleSprite.x === playerSprite.x) { + playerPoints++; + playTune(ding) + clearText(); + addText("A", {x:2, y:3, color: color`3`}); + addText("P", {x:2, y:4, color: color`4`}); + addText("P", {x:2, y:5, color: color`3`}); + addText("L", {x:2, y:6, color: color`4`}); + addText("E", {x:2, y:7, color: color`3`}); + + addText("D", {x:2, y:9, color: color`4`}); + addText("R", {x:2, y:10, color: color`3`}); + addText("O", {x:2, y:11, color: color`4`}); + addText("P", {x:2, y:12, color: color`3`}); + + addText("P", {x:17, y:1, color: color`2`}); + addText("o", {x:17, y:2, color: color`2`}); + addText("i", {x:17, y:3, color: color`2`}); + addText("n", {x:17, y:4, color: color`2`}); + addText("t", {x:17, y:5, color: color`2`}); + addText("s", {x:17, y:6, color: color`2`}); + + addText(`${playerPoints}`, { x: 17, y: 8, color: color`H` }); + appleSprite.remove(); + appleExists = false; + } + } + + if (appleExists && appleSprite) { + if (appleSprite.y < height() - 1) { + clearTile(appleSprite.x, appleSprite.y); + appleSprite.y++; + addSprite(appleSprite.x, appleSprite.y, apple); + } else { + // Game over when apple reaches the bottom + if (!gameOver) { + playback.end() + playTune(death) + clearText(); + addText("P", {x:17, y:1, color: color`2`}); + addText("o", {x:17, y:2, color: color`2`}); + addText("i", {x:17, y:3, color: color`2`}); + addText("n", {x:17, y:4, color: color`2`}); + addText("t", {x:17, y:5, color: color`2`}); + addText("s", {x:17, y:6, color: color`2`}); + + addText(`${playerPoints}`, { x: 17, y: 8, color: color`H` }); + + addText("G", { x: 2, y: 3, color: color`3`, size: 4 }); + addText("A", { x: 2, y: 4, color: color`3`, size: 4 }); + addText("M", { x: 2, y: 5, color: color`3`, size: 4 }); + addText("E", { x: 2, y: 6, color: color`3`, size: 4 }); + addText("O", { x: 2, y: 8, color: color`3`, size: 4 }); + addText("V", { x: 2, y: 9, color: color`3`, size: 4 }); + addText("E", { x: 2, y: 10, color: color`3`, size: 4 }); + addText("R", { x: 2, y: 11, color: color`3`, size: 4 }); + + gameOver = true; + // Additional game over logic can be added here + }} + } + }); +}); + +onInput("a", () => { + const playerSprite = getFirst(player); + playerSprite.x -= 1; + playerSprite.bitmap = bitmap` + .00..........00. + ..0..........0.. + ..00........00.. + ...0000000000... + ....L......L.... + ....L.0L0L.L.... + ....L.0L0L.L.... + ....L.LLLL.L.... + .....LL0LLL..... + ......LLLL...... + ......LLLL...... + ......LLLL...... + ......LLLL...... + ......L..L...... + ......L..L...... + .....LL.LL......`; +}); + + +onInput("d", () => { + const playerSprite = getFirst(player); + playerSprite.x += 1; +}); diff --git a/games/img/Apple_Drop.png b/games/img/Apple_Drop.png new file mode 100644 index 0000000000000000000000000000000000000000..147cfa71ae0bedfa9cf1fa387136d169fbc7a761 GIT binary patch literal 3184 zcmai1dpMK*8-L6xh83c#hA8#&A|1(Ik`Bs>Ey`hlAj3ODf<+ORR{hsN0qSx>6$F5!1v+we*WO72Wdj}}VY4!8QkYV)Ds|v^Cv;shkc;I96P?u+9+5byoPCb?2#qCI zXJCPCC;LxC<=JX~{qQ5udw-^5)iTVIoJ>=I+{U`o()gY~e50VtyyZyr!gqkdpGyC$ z5+^i}w7O*X?gwLyDkD&lSfK5+v(kKa4O}m8^7r!Rp}RWzxK%yw33H@}5Hyk7z1NG` zRoW%`+%!DMIGMI8oYQ|DRpKiU_8(TLBoempd$C1Q>uTGoeoo=Cg~5>&jwt{7#`0Te zw~bIacgLn_e62DA^F}MBz$Yly`4fVYgf-!cALlZMP{f{TTBcmLD;9-x$Qzq*i%JI8 zQe!lx+8>vC^>h-BzLh3g9((Mz4s#01R@XJsbEom_9XjAmRay0nG0$5f!mwJ$ODUi> z7unn3!@nY>0loX-rx;1ny}kVFaB1Bi$p? zz`ssFM@)kT0q~X-U|&V82XVT%(zy@VyyINj0!qFFq-?3F!hTuvgJ+# zH)lHxqO?mSXIw}#T6I){xtWQ?OSo-M3Gs7sWYa_Ye3)IK3B9N|{e}S{?s?~VuPMT8 zst=ihDe2o|gcknAb#!IeC4n@ZZon9{6vq4E1XQzTBO1g6-6b+Uc14C2;B=T@U72Ky ztAn!KAunXcx?QG4%}Wgw1c6U^Aww?hAYa2emzCg!Cff;0+!mpRS7VnjxD@SzEG;zqq~Hc`oJVB z|FjxuEd;4vi*kTs70u{~(gLm=_hk+~0`IFU@a{KYT3is>Mxz#dUpW1=vvTxC6}Kdy zb;sD=tMONdVJwS^rDD6;%TsgWWwMj3bv}xdrb`yzT$x%`^91E^qb%jMYwqjx=a#cSB!Ir^ZUUv`J(arL78vBa;(e$ z#t&%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