# Processing Dino Game

**URL:** <https://discourse.processing.org/t/processing-dino-game/114>\
**Category:** Coding Questions\
**Created:** [May 18, 2018, 6:01pm UTC](https://discourse.processing.org/t/processing-dino-game/114 "2018-05-18T18:01:42Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![TfGuy44](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/tfguy44/32/41_2.png) [@TfGuy44](https://discourse.processing.org/u/TfGuy44)\
**Post date:** [May 19, 2018, 3:48am UTC](https://discourse.processing.org/t/processing-dino-game/114/2 "2018-05-19T03:48:14Z")

</div>

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.

```auto
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();
  }
}

```

---

_[View the full topic](https://discourse.processing.org/t/processing-dino-game/114)._
