velocity-angle.js 253 B

123456789101112131415
  1. var stage = new mtm.Stage('c'),
  2. ball = new Ball(50, 100),
  3. angle = 45,
  4. speed = 3;
  5. stage.shapes.push(ball);
  6. stage.play(function() {
  7. var vx = Math.cos(angle) * speed,
  8. vy = Math.sin(angle) * speed;
  9. ball.x += vx;
  10. ball.y += vy;
  11. });