title: jumping and moving in processing
body: <p>I am trying to get a circle to be able to jump and move left and right at the same time, but right now its either only jumping or moving forward at a time. Anyone know how to change my code to solve this? Thanks</p>
  <pre><code>float px,py,vx,vy,ax,ay;
  boolean canJump = false;
  
  void setup(){
    size(600, 400);
    ax = 0;
    ay = .32;
    vx = 0;
    vy = 0;
    px = 300;
    py = 200;
  }
  
  int x = 50;
  int y = 520;
  
  void draw(){
    background(0);
    ellipse(px-15, py-30, 60, 60);
    vx+=ax;
    vy+=ay;
    px+=vx;
    py+=vy;
    if( py &gt; height ){
      py = height;
      vy = 0;
      canJump = true;
    }
    player();
  }
  
  void player(){
    fill(255);
    rect(0, 550, 1000, 50);
  }
  
  void keyPressed(){
    if(keyCode == RIGHT || key == 'd'){
      px += 10;
    }
    
    if(keyCode == LEFT || key == 'a'){
      px -= 10;
    }
    if(keyCode == UP){
      if(canJump) {
        vy = -10;
        canJump = false;
      }
    }
    
  }
  </code></pre>