class User {
  constructor() {
    this.y = 400;
    this.x = 100;      // all needed variables

    this.gravity = 0.75;
    this.lift = -14;           // gravity variables
    this.velocity = 0;
  }

  show() {
    fill(0, 100, 0);
    rect(this.x, this.y, 50, 50);       // colour and size
  }

  up() {
    this.velocity += this.lift;      // jump
  }

  left() {
    this.x -= 10;       //left
  }

  right() {
    this.x += 10;     //right
  }

  update() {
    this.velocity += this.gravity;       //    jumping physics
    this.y += this.velocity;

    if (this.y > 475) {
      this.y = 475;              //stops when hits roof
      this.velocity = 0;
    }

    if (this.y < 0) {       
      this.y = 0;
      this.velocity = 0;       // stops when hits floor
    }

    if (this.x > 700) {        //stops when hits right wall
      this.x = 700;

    }
    if (this.x < 0) {        //stops when hits left wall
      this.x = 0;
    }
  }
}