Why does it get stuck 'up'

Trying to make a SUPER rudamentary Geometry dash. When I jump though, it stays up. i don’t know why.

float playerY;
float truePY;
boolean playerJump;
boolean cube;
boolean ship;

void setup() {
fullScreen();
playerY = height11/15;
truePY = (height
11/15)+height/17;
cube = true;
ship = false;
playerJump = false;

// COPY EVERYWHERE:

background(65, 45, 250);
stroke(54, 40, 188);
strokeWeight(width/100);
fill(39, 28, 152);
rectMode(CORNER);
rect(-width/50, height4/5, width+width/50, height+height/50);
line(width/7, height
4/5, width/7, height);
line(width/7, (height4/5)+width/15, width/3, (height4/5)+width/15);
line(width/3, height4/5, width/3, height);
line(width/3+width/13, height
4/5, width/3+width/13, height);
line(width/3+width/6.5, height4/5, width/3+width/6.5, height);
line(width/2+width/7, height
4/5, width/2+width/7, height);
line(width/2+width/7, (height4/5)+width/15, width/2+width/3, (height4/5)+width/15);
line(width/2+width/3, height4/5, width/2+width/3, height);
line(width/2+width/3+width/13, height
4/5, width/2+width/3+width/13, height);
line(width/2+width/3+width/6.5, height*4/5, width/2+width/3+width/6.5, height);
rectMode(CENTER);
fill(246, 255, 3);
stroke(3, 255, 21);
strokeWeight(5);
square(width/6, playerY, width/16);

}
void draw() {

// COPY EVERYWHERE!!!

background(65, 45, 250);
stroke(54, 40, 188);
strokeWeight(width/100);
fill(39, 28, 152);
rectMode(CORNER);
rect(-width/50, height4/5, width+width/50, height+height/50);
line(width/7, height
4/5, width/7, height);
line(width/7, (height4/5)+width/15, width/3, (height4/5)+width/15);
line(width/3, height4/5, width/3, height);
line(width/3+width/13, height
4/5, width/3+width/13, height);
line(width/3+width/6.5, height4/5, width/3+width/6.5, height);
line(width/2+width/7, height
4/5, width/2+width/7, height);
line(width/2+width/7, (height4/5)+width/15, width/2+width/3, (height4/5)+width/15);
line(width/2+width/3, height4/5, width/2+width/3, height);
line(width/2+width/3+width/13, height
4/5, width/2+width/3+width/13, height);
line(width/2+width/3+width/6.5, height*4/5, width/2+width/3+width/6.5, height);
rectMode(CENTER);
fill(246, 255, 3);
stroke(3, 255, 21);
strokeWeight(5);
square(width/6, playerY, width/16);
line(width, truePY, 0, truePY);

if (keyPressed); {
if(keyCode == 32 || keyCode == 38 || keyCode == 40) {
if (cube == true) {
playerJump = true;
}
}
}

if (playerY <= truePY - width/6 && playerJump == true) {
playerJump = false;
}

if (playerJump == true) {
playerY = playerY - width/100;
} else {
playerY = playerY + width/100;
}

if (playerY >= truePY - width/32) {
playerY = truePY - width/32;
}
}

Ignore the “// COPY EVERYWHERE”

if (keyPressed); { should not have a ; in the middle of it.

I tried removing it, but when I did nothing moved at all

Wait nevermind the spacebar just didnt work when i removed it. Thank you!

1 Like