<script src="http://spelprogrammering.nu/simple.js">
function start()
{
  s  = 0;
  s0 = totalHeight / 2;
  g  = -9.8;
  v0 = 50;
  t  = 0;
}

function update()
{
  t += 0.2;
  s = v0*t + (g*t*t) / 2;
  y = totalHeight - (s + s0);
  clearScreen();
  circle(200, y, 50, "red");

  if (y > totalHeight - 50)
  {
    v  = -(v0 + g*t);
    t  = 0;
    v0 = v * 0.8;
    s0 = 50;
  }
}
</script>
        
Gå tillbaka