bobbing.js 260 B

12345678910111213
  1. var stage = new mtm.Stage('c'),
  2. ball = new Ball(stage.width/2, stage.height/2),
  3. angle = 0,
  4. range = 100,
  5. speed = .2;
  6. stage.shapes.push(ball);
  7. stage.play(function() {
  8. ball.y = stage.height/2 + Math.sin(angle) * range;
  9. angle += speed;
  10. });