Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class CircleAnimation implements Animation {
- int radius;
- int framesPerRotation;
- private CircleAnimation(int radius, int framesPerRotation) {
- this.radius = radius;
- this.framesPerRotation = framesPerRotation;
- }
- public void animate(int frame) {
- double angle = 2 * Math.PI / framesPerRotation;
- Figure.this.setX(Figure.this.getX() + (int) (Math.cos((frame * angle) * radius) * 10));
- Figure.this.setY(Figure.this.getY() + (int) (Math.sin((frame * angle) * radius) * 10));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement