Untitled
Anonymous
plain_text
02/24/2026 2:34 PM
4.2 KB
17
Indexable
var back = createSprite(200, 200);
back.setAnimation("sky");
var sky = createSprite(200, 200);
sky.setAnimation("sky2");
var player = createSprite(200, 200);
player.setAnimation("fly_bot_1");
var platform = createSprite(69, 69);
platform.setAnimation("platform");
var platform1 = createSprite(200, 260);
platform1.setAnimation("platform1");
var platform2 = createSprite(300, 360);
platform2.setAnimation("platform2");
var platform3 = createSprite(100, 160);
platform3.setAnimation("platform3");
var platform4 = createSprite(300, 160);
platform4.setAnimation("platform4");
var Gover = createSprite(200, 200);
Gover.setAnimation("download (1).png_1");
Gover.visible = false;
//makes backround change when you hit 50 points
back.visible = false;
//sprites were too big so I sized them down
player.scale = 0.3;
platform.scale = 0.6;
platform1.scale = 0.6;
platform2.scale = 0.6;
platform3.scale = 0.6;
platform4.scale = 0.6;
var score = 0;
function draw() {
movePlayer();
falling();
rec();
drawSprites();
fill("white");
text("Score" + score, 330, 25);
}
//moves player to manuver around the platforms
//had to change the movement because the sprites were getting caught on the platforms
//probably a hit box issue but im to lazy to fix it
function movePlayer(){
if (keyDown("up")) {
player.velocityY = -9;
}
//adds score every time you jump
if (keyWentDown("up")) {
score = score + 1;
}
if (keyDown("down")) {
player.y = player.y + 7;
}
if (keyDown("left")) {
player.x = player.x - 7;
}
if (keyDown("right")) {
player.x = player.x + 7;
}
if (player.y >= 400) {
Gover.visible = true;
}
if (player.y <= -6) {
Gover.visible = true;
}
}
//this is the gravity of the player so he doesn't float off into space
//even though when you hit 50 points it puts you into space but this is nothing but semantics
function falling() {
player.velocityY = player.velocityY + 0.7;
}
//makes platforms a moving physical entity
function rec() {
player.collide(platform);
player.collide(platform1);
player.collide(platform2);
player.collide(platform3);
player.collide(platform4);
platform.velocityY = 2;
platform1.velocityY = 2;
platform2.velocityY = 2;
platform3.velocityY = 2;
platform4.velocityY = 2;
//resets the platforms to give them an infinite loop effect
if (platform.y >= 400) {
platform.y = 0;
platform.x = randomNumber(69, 300);
}
if (platform1.y >= 400) {
platform1.y = 0;
platform1.x = randomNumber(69, 300);
}
if ((platform2.y) >= 400) {
platform2.y = 0;
platform2.x = randomNumber(69, 300);
}
if (platform3.y >= 400) {
platform3.y = 0;
platform3.x = randomNumber(69, 300);
}
if (platform4.y >= 400) {
platform4.y = 0;
platform4.x = randomNumber(69, 300);
}
//increases the speed to increase the difficulty
if (score >= 20) {
platform.velocityY = 3;
platform1.velocityY = 3;
platform2.velocityY = 3;
platform3.velocityY = 3;
platform4.velocityY = 3;
}
if (score >= 50) {
platform.velocityY = 4;
platform1.velocityY = 4;
platform2.velocityY = 4;
platform3.velocityY = 4;
platform4.velocityY = 4;
back.visible = true;
}
}
Editor is loading...
Leave a Comment