var canvas = document.getElementById('canvas');
var ctx = canvas.getContext('2d');
var posX = 100.0;
var posY = 176.0;
var velX = 0.0;
var velY = 0.0;
var gravity = 0.5;
var onGround = false;

// window.addEventListener('keypress', function (e) {
//     if (e.keyCode == 13 ) {
//       // enter
//       // model right guess player one
//       startJump(4.0, -12.0);
//       endJump();
//     } else if (e.keyCode == 32) {
//       // spacebar
//       // model wrong guess player one
//       startJump(-5.0, 4.0);
//       endJump();
//     }
// }, false);
loop();
function startJump(vx, vy){
  console.log('starting jump')
  if(onGround){
    velX = vx;
    velY = vy;
    onGround = false;
  }
}
function endJump(){
  if(velY < -6.0){
    velY = -6.0;
  }
}
function loop(){
  update();
  render();
  window.setTimeout(loop, 33 );
}
function update(){
  velY += gravity;
  posY += velY;
  posX += velX;
  if(posY > 175.0){
    posY = 175.0;
    velY = 0.0;
    velX = 0.0;
    onGround = true;
  }
}
function render(){
  ctx.clearRect(0, 0, 500, 500);
  ctx.beginPath();
  ctx.moveTo(0,176);
  ctx.lineTo(500,175);
  ctx.stroke();
  ctx.beginPath();
  ctx.moveTo(posX - 10, posY - 20);
  ctx.lineTo(posX + 10, posY - 20);
  ctx.lineTo(posX + 10, posY);
  ctx.lineTo(posX - 10, posY);
  ctx.closePath();
  ctx.rect(0,175,150,100);
  ctx.rect((500-175),175,150,100);

  ctx.stroke();
}

@@ -188,378 +188,8 @@
 lse;
-%0A%0A// window.addEventListener('keypress', function (e) %7B%0A//     if (e.keyCode == 13 ) %7B%0A//       // enter%0A//       // model right guess player one%0A//       startJump(4.0, -12.0);%0A//       endJump();%0A//     %7D else if (e.keyCode == 32) %7B%0A//       // spacebar%0A//       // model wrong guess player one%0A//       startJump(-5.0, 4.0);%0A//       endJump();%0A//     %7D%0A// %7D, false);
 %0Aloo
@@ -225,39 +225,8 @@
 y)%7B%0A
-  console.log('starting jump')%0A
   if
@@ -371,16 +371,22 @@
 on loop(
+player
 )%7B%0A  upd
@@ -389,16 +389,22 @@
  update(
+player
 );%0A  ren
@@ -460,19 +460,47 @@
  update(
-)%7B%0A
+player)%7B%0A  if (player == 1)%7B%0A  
   velY +
@@ -510,16 +510,18 @@
 ravity;%0A
+  
   posY +
@@ -528,16 +528,18 @@
 = velY;%0A
+  
   posX +
@@ -546,16 +546,18 @@
 = velX;%0A
+  
   if(pos
@@ -568,24 +568,26 @@
 175.0)%7B%0A    
+  
 posY = 175.0
@@ -584,24 +584,26 @@
 sY = 175.0;%0A
+  
     velY = 0
@@ -606,24 +606,26 @@
  = 0.0;%0A    
+  
 velX = 0.0;%0A
@@ -620,24 +620,26 @@
 velX = 0.0;%0A
+  
     onGround
@@ -645,25 +645,222 @@
 d = true;%0A  
-%7D
+  %7D%0A  %7D else if(player == 2)%7B%0A    velY += gravity;%0A    posY += velY;%0A    posX -= velX;%0A    if(posY %3E 175.0)%7B%0A      posY = 175.0;%0A      velY = 0.0;%0A      velX = 0.0;%0A      onGround = true;%0A    %7D%0A  %7D%0A
 %0A%7D%0Afunction 

add player 2 functionality