Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {
- PjApplication cyApp = new PjApplication();
- cyApp.setLayout(null);
- int alpha = (int) (Math.random() * 10) + 5;
- PjShape[] cyShapes = new PjShape[alpha];
- for(int i = 0; i < alpha; i++){
- PjOval cyOval = new PjOval();
- cyOval.setBackground(Color.white);
- cyShapes[i] = cyOval;
- }
- cyApp.setVisible(true);
- for(int i = 0; i < alpha; i++){
- int x = (int)
- (Math.random() * (cyApp.getWidth()
- - cyShapes[i].getWidth()));
- int y = (int)
- (Math.random() * (cyApp.getHeight()
- - cyShapes[i].getHeight()));
- cyShapes[i].setLocation(x, y);
- cyApp.setVisible(true);
- if (i == 0){
- cyApp.add(cyShapes[i]);
- cyShapes[i].setVisible(true); }
- if (i > 0){
- for(int c = 1; c <= i; c++){
- if (PjUtils.intersects(cyShapes[i -c], cyShapes[i])){
- cyShapes[i].setVisible(false);
- i = i -1;
- }
- else{
- cyApp.add(cyShapes[i]);
- cyShapes[i].setVisible(true);
- }
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment