Advertisement
Guest User

Untitled

a guest
Dec 12th, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.35 KB | None | 0 0
  1. package world;
  2.  
  3. import de.ur.mi.geom.Point;
  4. import de.ur.mi.util.RandomGenerator;
  5.  
  6. import java.util.Random;
  7.  
  8. public class Sky {
  9.  
  10.  
  11.     public RandomGenerator randomgenerator;
  12.     public Random random;
  13.     public Stars star;
  14.  
  15.     public void setup() {
  16.         setupApplication();
  17.         createStars();
  18.     }
  19.     public void setupApplication() {
  20.         random = RandomGenerator.getInstance();
  21.     }
  22.     public void draw(){
  23.         drawStars();
  24.     }
  25.     public void drawStars() {
  26.         for (int i = 0; i < Constant.MAX_STARS; i++) {
  27.             if (i%2==0) {
  28.                 star.draw();
  29.             }
  30.         }
  31.     }
  32.     public void createStars() {
  33.  
  34.         star = new Stars(Constant.OBJECT_SIZE, Constant.OBJECT_SIZE, Constant.OBJECT_SIZE, Constant.OBJECT_SIZE, Constant.STAR_PATH,Constant.STAR_DISTANCE);
  35.  
  36.     }
  37.     public int getNextDiameter() {
  38.         return randomgenerator.nextInt(Constant.MIN_CIRCLE_WIDTH, Constant.MAX_CIRCLE_WIDTH);
  39.     }
  40.  
  41.     public Point getNextPoint(int diameter) {
  42.         int lowerX = diameter / 2;
  43.         int upperX = Constant.WIDTH - (diameter / 2);
  44.         int lowerY = diameter / 2;
  45.         int upperY = Constant.HEIGHT - (diameter / 2);
  46.  
  47.         int x = randomgenerator.nextInt(lowerX, upperX);
  48.         int y = randomgenerator.nextInt(lowerY, upperY);
  49.         return new Point(x, y);
  50.     }
  51.  
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement