# Processing Dino Game

Hello everyone,

I just wanted to ask for some help in a small Game I tried to program. I got this bit of code where im basically trying to let a small black rectangle go jump in the air for first. Now, I got the rectangle to go up slowly, stop, and then go down again. But I just dont quite understand why it won’t go up again. So when the Rectangle reaches the “Ground” Line coordinates it stops at it’s normal position, and should be able to go up again if I hit space. But it doesn’t. I don’t even really know how I send my Code in here so just get it here from my GitHub link: https://github.com/Baipyrus/DinoGame

Thanks for help already
~ Baipyrus

I ran your code through the cleaner. You would do well to try to KISS when coding. KISS stands for Keep It Super Simple. Notice that the code now has more functions, but each one only does a very specific thing. Also notice that any “dino” variables are now inside the Dino class.

``````class Dino {
float baseY, px, py, vy, ay, w, h, speed;
boolean canJump, isJumping;
Dino(float lineY) {
baseY = lineY;
px = 100;
py = baseY;
vy = 0;
ay = 0;
h = 100;
w = 50;
speed = 0.001;
canJump = true;
isJumping = false;
}
void draw() {
vy+=ay;
py+=vy;
landed_check();
rect(px, py-h, w, h);
}
void jump(){
if( canJump ){
canJump = false;
isJumping = true;
vy = -10;
ay = 0.32;
}
}
void landed_check(){
if( py >= baseY ){
py = baseY;
vy = 0;
ay = 0;
isJumping = false;
canJump = true;
}
}
}

float lineY;
Dino dino;

void drawGround() {
stroke(0);
fill(0);
rect(0, lineY, width, 5);
}

void setup() {
size(1000, 600);
lineY = 480;
dino = new Dino(lineY);
}

void draw() {
background(255);
drawGround();
dino.draw();
}

void keyPressed(){
if(key == ' '){
dino.jump();
}
}
``````
2 Likes

I was really trying to keep it simple, but it didn’t quite work. So I tried doing it more complicated maybe and searched some stuff on the Internet to do so, but as you can see, it didnt work that well, too.Thanks for help!

~Baipyrus