<script src="http://spelprogrammering.nu/simple.js">

function start()
{ 
  bigArm = new Arm(100, 100, 150);
  smallArm = new Arm(200, 100, 30);
}

function update()
{ 
  clearScreen();

  bigArm.draw();
  smallArm.draw(); 
  bigArm.rotation += .05;
  smallArm.rotation += .1;
}

function Arm(x, y, size)
{ 
  this.x = x; 
  this.y = y; 
  this.size = size;
  this.rotation = 0;
  
  this.draw = function()
  { 
    save();
    translate(this.x, this.y);
    rotate(40 + 20 * sin(this.rotation));
    rectangle(0, 0, this.size, this.size / 5, "black");
    translate(this.size, this.size / 10);
    rotate(-2 * (40 + 40 * sin(this.rotation)));
    translate(0, - this.size / 10);
    rectangle(0, 0, this.size, this.size / 5, "black");
    translate(this.size, 0);
    circle(0, 0, this.size / 4, "black");
    restore();
  };
}

</script>
        
Gå tillbaka