Guest User

Untitled

a guest
Jan 24th, 2018
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. {
  2. PjApplication cyApp = new PjApplication();
  3. cyApp.setLayout(null);
  4. int alpha = (int) (Math.random() * 10) + 5;
  5. PjShape[] cyShapes = new PjShape[alpha];
  6. for(int i = 0; i < alpha; i++){
  7. PjOval cyOval = new PjOval();
  8. cyOval.setBackground(Color.white);
  9. cyShapes[i] = cyOval;
  10. }
  11. cyApp.setVisible(true);
  12. for(int i = 0; i < alpha; i++){
  13. int x = (int)
  14. (Math.random() * (cyApp.getWidth()
  15. - cyShapes[i].getWidth()));
  16. int y = (int)
  17. (Math.random() * (cyApp.getHeight()
  18. - cyShapes[i].getHeight()));
  19. cyShapes[i].setLocation(x, y);
  20. cyApp.setVisible(true);
  21. if (i == 0){
  22. cyApp.add(cyShapes[i]);
  23. cyShapes[i].setVisible(true); }
  24. if (i > 0){
  25. for(int c = 1; c <= i; c++){
  26. if (PjUtils.intersects(cyShapes[i -c], cyShapes[i])){
  27. cyShapes[i].setVisible(false);
  28. i = i -1;
  29. }
  30. else{
  31. cyApp.add(cyShapes[i]);
  32. cyShapes[i].setVisible(true);
  33. }
  34. }
  35. }
  36. }
  37. }
Add Comment
Please, Sign In to add comment