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

Space jam sprig game #2313

Open
wants to merge 19 commits into
base: main
Choose a base branch
from
Open

Conversation

Praveenkushinpi
Copy link

@Praveenkushinpi Praveenkushinpi commented Sep 9, 2024

Your checklist for this pull request

Author name

praveenkumar:

About your game

**my game is about a astronaut who has to protect his spaceship from meteors **

You have don't have to colide by the meteor and if you collide with the meteor the game is over them you to score as more as possible by dodging the meteor
https://sprig.hackclub.com/share/6YOxOcUA5PRGcuOWTbWA

How do you play game?
You can play game by using a and d ,
A for left and D for right.

Code

const rocket = "r";
const space = "s";
const meteor = "m";
let gameOver = false;

setLegend(
[ rocket, bitmap ................ .......0........ ......010....... .....01710...... ....0177710..... ...017727710.... ..01772227710... ...222222222.... ...222222222.... ...222202222.... ...202020202.... ...222020222.... ...202002202.... ...202020202.... ...222022222.... ...222222222....] ,
[ space, bitmap 0000000000000000 0020000000000020 0000000000000000 0000002000020000 0000000000000000 0000000000000000 0002000000000200 0000000020000000 0200000000000000 0000000000000000 0000000000000000 0000000000000000 0020000002000200 0000000000000000 0000000000000000 0000000000000000],
[ meteor, bitmap ................ ......000000.... ....001110110... ...01111111110.. ...01101111110.. ...01111011110.. ..011011111110.. ..011111111010.. .0111111011110.. .0111111111110.. ..011101111110.. .011111111010... ..01101111110... ..0111111110.... ...00111010..... .....00000......]
);

setSolids([]);

let score = 0;
let level = 0;

const levels = [
map ........... ........... ........... ........... ........... ........... ........... ........... .....r.....
];
setMap(levels[level]);

setSolids([meteor]);

let gameRunning = true;

function spawnMeteor() {
let x = Math.floor(Math.random() * 10);
let y = 0;
addSprite(x, y, "m");
}

function moveMeteor() {
let meteors = getAll("m");

for (let i = 0; i < meteors.length; i++) {
meteors[i].y += 1;
}
}

function despawnMeteor() {
let meteors = getAll("m");

for (let i = 0; i < meteors.length; i++) {
if (meteors[i].y == 8) {
meteors[i].remove();
}
}
}

function checkHit() {
let meteors = getAll("m");
let r = getFirst("r");

for (let i = 0; i < meteors.length; i++) {
if (meteors[i].x == r.x && meteors[i].y == r.y) {
return true;
}
}

return false;
}

onInput("a", () => {
getFirst("r").x -= 1;
});

onInput("d", () => {
getFirst("r").x += 1;
});

setBackground(space);

var gameLoop = setInterval(() => {
if (checkHit()) {
gameOver = true;
clearInterval(gameLoop);
addText(Game Over! Final Score: ${score}, { x: 4, y: 4, color: color3 });
return;
}

score += 1;
addText(Score: ${score}, { x: 8, y: 1, color: color2 });

despawnMeteor();
moveMeteor();
spawnMeteor();

}, 300);

Image (If an image is used)

  • The image is in the [/games/img directory]Praveenkushinpi@2bcb75c).
  • The name of the image matches the name of your file. 20240909_092950_0000.png

Thanks for your PR!

Copy link

vercel bot commented Sep 9, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
sprig ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 17, 2024 6:21pm

@recursiveforte recursiveforte added submission Game submission initial review performed This Sprig app PR has had initial feedback given, and is in a pending state of review labels Sep 18, 2024
@recursiveforte
Copy link
Member

This is very similar to other games in the gallery- could you add a game mechanic or two to differentiate it?

@Praveenkushinpi
Copy link
Author

Praveenkushinpi commented Sep 18, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
initial review performed This Sprig app PR has had initial feedback given, and is in a pending state of review submission Game submission
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants