Skip to content

Commit

Permalink
Sprig App - save the goat!!!
Browse files Browse the repository at this point in the history
  • Loading branch information
Cookiesgobrr committed Dec 20, 2024
1 parent 201a99e commit b5e4a91
Showing 1 changed file with 122 additions and 0 deletions.
122 changes: 122 additions & 0 deletions games/save-the-goat!!!.js
Original file line number Diff line number Diff line change
@@ -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);

0 comments on commit b5e4a91

Please sign in to comment.