-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathChallengeInJava.java
More file actions
49 lines (43 loc) · 995 Bytes
/
Copy pathChallengeInJava.java
File metadata and controls
49 lines (43 loc) · 995 Bytes
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
import processing.core.PApplet;
class Ball{
private final PApplet p;
int y;
int speed;
Ball(PApplet p, int num1, int i){
this.p = p;
this.y = num1;
this.speed = i;
}
void method(int x){
x = x*speed;
p.ellipse(x,y, 20,20);
}
}
public class ChallengeInJava extends PApplet {
public static final int WIDTH = 640;
public static final int HEIGHT = 480;
Ball b1, b2, b3, b4;
int x;
public static void main(String[] args) {
PApplet.main("ChallengeInJava", args);
}
@Override
public void settings() {
size(WIDTH, 510);
}
@Override
public void setup() {
b1 = new Ball(this, HEIGHT/4, 1);
b2 = new Ball(this,HEIGHT/2,2);
b3 = new Ball(this,3*HEIGHT/4,3);
b4 = new Ball(this,HEIGHT,4);
}
@Override
public void draw() {
x++;
b1.method(x);
b2.method(x);
b3.method(x);
b4.method(x);
}
}