Advertisement
Guest User

Untitled

a guest
May 19th, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.59 KB | None | 0 0
  1.    public class CircleAnimation implements Animation {
  2.  
  3.         int radius;
  4.         int framesPerRotation;
  5.  
  6.         private CircleAnimation(int radius, int framesPerRotation) {
  7.             this.radius = radius;
  8.             this.framesPerRotation = framesPerRotation;
  9.         }
  10.  
  11.         public void animate(int frame) {
  12.             double angle = 2 * Math.PI / framesPerRotation;
  13.             Figure.this.setX(Figure.this.getX() + (int) (Math.cos((frame * angle) * radius) * 10));
  14.             Figure.this.setY(Figure.this.getY() + (int) (Math.sin((frame * angle) * radius) * 10));
  15.         }
  16.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement