<script src="http://spelprogrammering.nu/simple.js">
function start()
{
  pend = {l: 2,
          theta0: pi/4,
          theta: 0,
          phi: pi/2};

  world = {g: 9.8,
           t: 0};

  pend.omega = sqrt(world.g / pend.l);
}

function update()
{
  clearScreen();
  pend.theta = pend.theta0 * sin(pend.omega * world.t + pend.phi);

  math.polarLine(0, 0, pend.theta + 3*pi/2, pend.l, "black");
  math.polarPoint(pend.theta + 3*pi/2, pend.l, 20, "black");

  world.t += 0.03;
}
</script>
        
Gå tillbaka