Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
77 lines (64 loc) · 2.32 KB

File metadata and controls

77 lines (64 loc) · 2.32 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
package simpleobjects;
import goo.Goo; // A
import java.awt.Color;
import java.awt.Graphics;
import java.util.Random;
import javax.swing.JOptionPane;
public class CustomGooDrops extends Goo { // B
HorizontalBounceDrop[] horDropArray;
VerticalBounceDrop[] dropArray;
LeftDiagonalBounce[] leftDiagArray;
RightDiagonalBounce[] rightDiagArray;
Random rd;
public CustomGooDrops(int width, int height) { // C
super(width, height);
String no_balls = JOptionPane.showInputDialog("Enter the number of balls?");
int balls = Integer.parseInt(no_balls);
if(balls == 0){
balls = 1;
}
dropArray = new VerticalBounceDrop[balls];
horDropArray = new HorizontalBounceDrop[balls];
leftDiagArray = new LeftDiagonalBounce[balls];
rightDiagArray = new RightDiagonalBounce[balls];
rd = new Random();
for(int i=0; i<dropArray.length; i++)
{
int sizeRan = rd.nextInt(30);
int xposRan = rd.nextInt(width-sizeRan);
int yposRan = rd.nextInt(height-sizeRan);
int xVelRan = rd.nextInt(10);
int yVelRan = rd.nextInt(10);
if(xVelRan == 0) xVelRan++;
if(yVelRan == 0) yVelRan++;
int ranColorR =rd.nextInt(250);
int ranColorG =rd.nextInt(250);
int ranColorB =rd.nextInt(250);
Color color = new Color(ranColorR,ranColorG,ranColorB);
Color color1 = new Color(ranColorR+1,ranColorG+1,ranColorB+1);
Color color2 = new Color(ranColorR+2,ranColorG+2,ranColorB+2);
Color color3 = new Color(ranColorR+3,ranColorG+3,ranColorB+3);
dropArray[i] = new VerticalBounceDrop(xposRan, yposRan, xVelRan, yVelRan, sizeRan,color3);
horDropArray[i] = new HorizontalBounceDrop(xposRan, yposRan, xVelRan, yVelRan, sizeRan,color2);
leftDiagArray[i] = new LeftDiagonalBounce(0,0,xVelRan,yVelRan,sizeRan,color1);
rightDiagArray[i] = new RightDiagonalBounce(width,0,xVelRan,yVelRan,sizeRan,color);
}
}
public void draw(Graphics g) { // D
for(int i=0; i<dropArray.length; i++)
{
int ranHeight = rd.nextInt(900);
int ranWidth = rd.nextInt(1400);
dropArray[i].move(ranWidth, ranHeight);
horDropArray[i].move(ranWidth, ranHeight);
leftDiagArray[i].move(ranWidth, ranHeight);
dropArray[i].draw(g);
horDropArray[i].draw(g);
leftDiagArray[i].draw(g);
rightDiagArray[i].move(ranWidth, ranHeight);
rightDiagArray[i].draw(g);
}
// drop.move(getWidth(), getHeight());
// drop.draw(g);
}
}
Morty Proxy This is a proxified and sanitized view of the page, visit original site.