From b5e4a91ee031a33a4e5c526378ff0ab0400f2cde Mon Sep 17 00:00:00 2001 From: Cookiesgobrr <90541179+Cookiesgobrr@users.noreply.github.com> Date: Fri, 20 Dec 2024 22:04:07 +0400 Subject: [PATCH] Sprig App - save the goat!!! --- games/save-the-goat!!!.js | 122 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 122 insertions(+) create mode 100644 games/save-the-goat!!!.js diff --git a/games/save-the-goat!!!.js b/games/save-the-goat!!!.js new file mode 100644 index 0000000000..36cb108ba9 --- /dev/null +++ b/games/save-the-goat!!!.js @@ -0,0 +1,122 @@ +const player = "p"; +const hammerhead = "o"; +const mapa = "m"; +setLegend( + [hammerhead, bitmap` +................ +................ +................ +................ +................ +1111111111111111 +LLLLLLLLLLLLLLLL +0000000000000000 +0000000000000000 +....000000000000 +.....000000..... +.....000000..... +.....000000..... +...00000000..... +..000000000000.. +.0000000000000..`], + [player, bitmap` +................ +.......FFFFFFFFF +.......FFFF2020F +.......FFFF2222F +.......FFFF2022F +.......FF.F2000F +.......FF.FFFFFF +..........FF.... +FFFFFFFFFFFF.... +F.FFFFFFFFFF.... +F.FFFFFFFFFF.... +F.FFFFFFFFFF.... +F.FFF...FFFF.... +..FFF...FFFF.... +..FFF...FFFF.... +..FFF...FFFF....`], + [mapa, bitmap ` +1111111111111111 +1111111111111111 +1111111111111111 +1111111111111111 +1111111111111111 +1111111111111111 +1111111111111111 +1111111111111111 +1111111111111111 +1111111111111111 +1111111111111111 +1111111111111111 +1111111111111111 +1111111111111111 +1111111111111111 +1111111111111111`] +) +setMap(map` +mmmmmmmm +mmmmmmmm +mmmmmmmm +mmmmmmmm +mmmmmmmm +mmmmmmmm +mmmmmmmm +..p.....`) +var gameRunning = true; +onInput("a", () => { + if (gameRunning) { + getFirst(player).x -= 1; + } +}); +onInput("d", function() { + getFirst(player).x += 1; +}); +function spawnhammerhead() { + let x = Math.floor(Math.random() * 8); + let y = 0; + addSprite(x, y, hammerhead); +} + +function movehammerheads() { + let hammerheads = getAll(hammerhead); + + for (let i = 0; i < hammerheads.length; i++) { + hammerheads[i].y += 1; + } +} +function despawnhammerheads() { + let hammerheads = getAll(hammerhead); + + for (let i = 0; i < hammerheads.length; i++) { + if (hammerheads[i].y == 8) { + hammerheads[i].remove(); + } + } +} +function checkHit() { + let hammerheads = getAll(hammerhead); + let p = getFirst(player); + + for (let i = 0; i < hammerheads.length; i++) { + if (hammerheads[i].x == p.x && hammerheads[i].y == p.y) { + return true; + } + } + return false; +} +var gameLoop = setInterval(() => { + despawnhammerheads(); + movehammerheads(); + spawnhammerhead(); + if (checkHit()) { + clearInterval(gameLoop); + gameRunning = false; + addText("YOU DIED BRUH!", { + x: 5, + y: 6, + color: color`5` + }); + } +}, 750); +