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

[Sprig App] Legally Distinct Yellow Creature Collects Bananas #2796

Merged
merged 3 commits into from
Jan 22, 2025
Merged
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
359 changes: 359 additions & 0 deletions games/Legally-Distinct-Yellow-Creature-Collects-Bananas.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,359 @@
/*
@title: Legally Distinct Yellow Creature Collects Bananas
@author: DogeJr
@tags: []
@addedOn: 2025-01-22
*/

//Starting the game

const player = "p"
const banana = "w"
const wall = "i"


const health4 = "9"
const health35 = "8"
const health3 = "7"
const health25 = "6"
const health2 = "5"
const health15 = "4"
const health1 = "3"
const health05 = "2"
const health0 = "1"



//Making da map
setLegend(
[player, bitmap`
.......666......
.....666666.....
...666611666....
...6661661666...
...0016006100...
...0016006100...
...6661661666...
...6666116666...
...6666666666...
...5666666665...
..665666666566..
.66.55555555.66.
.66.55555555.66.
.66.55555555.66.
....55555555....
....00....00....`],
[banana, bitmap`
............000.
...........00C0.
...........0CC00
...........06660
...........06660
..........006660
.........0066600
.........066660.
.......00066660.
......006666600.
....0006666600..
0000066666600...
066666666000....
0066666000......
.0000000........
................`],
[wall, bitmap`
................
................
................
................
................
................
................
................
................
................
................
................
................
................
................
................`],
[health4, bitmap`
.00.00...00.00..
0330330.0330330.
0333330.0333330.
0333330.0333330.
.03330...03330..
..030.....030...
...0.......0....
................
................
.00.00...00.00..
0330330.0330330.
0333330.0333330.
0333330.0333330.
.03330...03330..
..030.....030...
...0.......0....`],
[health35, bitmap `
.00.00...00.00..
0330330.0330..0.
0333330.0333..0.
0333330.0333..0.
.03330...03..0..
..030.....0.0...
...0.......0....
................
................
.00.00...00.00..
0330330.0330330.
0333330.0333330.
0333330.0333330.
.03330...03330..
..030.....030...
...0.......0....`],
[health3, bitmap `
.00.00...00.00..
0330330.0..0..0.
0333330.0.....0.
0333330.0.....0.
.03330...0...0..
..030.....0.0...
...0.......0....
................
................
.00.00...00.00..
0330330.0330330.
0333330.0333330.
0333330.0333330.
.03330...03330..
..030.....030...
...0.......0....`],
[health25, bitmap `
.00.00...00.00..
0330..0.0..0..0.
0333..0.0.....0.
0333..0.0.....0.
.03..0...0...0..
..0.0.....0.0...
...0.......0....
................
................
.00.00...00.00..
0330330.0330330.
0333330.0333330.
0333330.0333330.
.03330...03330..
..030.....030...
...0.......0....`],
[health2, bitmap `
.00.00...00.00..
0..0..0.0..0..0.
0.....0.0.....0.
0.....0.0.....0.
.0...0...0...0..
..0.0.....0.0...
...0.......0....
................
................
.00.00...00.00..
0330330.0330330.
0333330.0333330.
0333330.0333330.
.03330...03330..
..030.....030...
...0.......0....`],
[health15, bitmap `
.00.00...00.00..
0..0..0.0..0..0.
0.....0.0.....0.
0.....0.0.....0.
.0...0...0...0..
..0.0.....0.0...
...0.......0....
................
................
.00.00...00.00..
0330330.0330..0.
0333330.0333..0.
0333330.0333..0.
.03330...03..0..
..030.....0.0...
...0.......0....`],
[health1, bitmap `
.00.00...00.00..
0..0..0.0..0..0.
0.....0.0.....0.
0.....0.0.....0.
.0...0...0...0..
..0.0.....0.0...
...0.......0....
................
................
.00.00...00.00..
0330330.0..0..0.
0333330.0.....0.
0333330.0.....0.
.03330...0...0..
..030.....0.0...
...0.......0....`],
[health05, bitmap `
.00.00...00.00..
0..0..0.0..0..0.
0.....0.0.....0.
0.....0.0.....0.
.0...0...0...0..
..0.0.....0.0...
...0.......0....
................
................
.00.00...00.00..
0330..0.0..0..0.
0333..0.0.....0.
0333..0.0.....0.
.03..0...0...0..
..0.0.....0.0...
...0.......0....`],
[health0, bitmap `
.00.00...00.00..
0..0..0.0..0..0.
0.....0.0.....0.
0.....0.0.....0.
.0...0...0...0..
..0.0.....0.0...
...0.......0....
................
................
.00.00...00.00..
0..0..0.0..0..0.
0.....0.0.....0.
0.....0.0.....0.
.0...0...0...0..
..0.0.....0.0...
...0.......0....`],
)
setSolids([player, wall,])
let level = 0
const levels = [
map`
iiiiiiii
.p...w..
........
........`,
map `
........
........
........
........`,
]


setMap(levels[level])
setPushables({
[player]: []
})

const ding = tune`
101.69491525423729: B4/101.69491525423729,
101.69491525423729: C5/101.69491525423729,
3050.8474576271187`

//Set points to 0
var Points = 0
var health = 9
var difficulty = 800
var hLoop = 0;

function placeRandomSprite(spriteType) {
const emptyTiles = [];
const mapWidth = width();
const mapHeight = height();
for (let x = 0; x < mapWidth; x++) {
for (let y = 0; y < mapHeight; y++) {
if (getTile(x, y).length === 0) {
emptyTiles.push({ x, y });
}
}
}
if (emptyTiles.length === 0) {
console.log("no empty tiles")
return;
}
const randomTile = emptyTiles[Math.floor(Math.random() * emptyTiles.length)];
addSprite(randomTile.x, randomTile.y, spriteType);
}

function updatePoints() {
clearText()
addText("Bananas: " + Points, {
x: 8,
y: 4,
color: color`4`,
})
}

function updateHealth() {
if (health > 0) {
clearTile(0, 0)
addSprite(0, 0, health)}
addSprite(0, 0, wall)}




function healthLoop() {
if (health > 0) {
setTimeout(function(){
health--
updateHealth();
difficulty = difficulty - 5
if (hLoop < 9999999) {
healthLoop();
}
}, difficulty)
}
else {
setMap(levels[1])
clearText()
addText("you dided!11!1!", {
x: 3,
y: 7,
color: color`0`,})
};
}


//inputs
onInput("w", () => {
getFirst(player).y -= 1;
});
onInput("a", () => {
getFirst(player).x -= 1;
});
onInput("s", () => {
getFirst(player).y += 1;
});
onInput("d", () => {
getFirst(player).x += 1;
});

afterInput(() => {
if (tilesWith(banana, player, ).length >= 1) {
getFirst(banana).remove();
Points = Points + 1
if (health > 0) {
if ((health + 2) > 9) {
health = health + (9 - health)
} else {
health = health + 2}
updatePoints()
updateHealth()
placeRandomSprite(banana)
playTune(ding)}
}
})

setMap(levels[0])
updatePoints()
updateHealth()
healthLoop()
console.log("startup initiated")
Loading