-
Notifications
You must be signed in to change notification settings - Fork 0
/
Charge.pde
34 lines (23 loc) · 811 Bytes
/
Charge.pde
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
class charge{
float strength;
float mass;
PVector pos;
PVector acc;
PVector vel;
PVector force;
int[] chargeColor = new int[3];
public charge(float strength, PVector pos){
this.mass = 1;
this.pos = pos;
this.strength = strength;
if (this.strength < 0) {this.chargeColor[0] = 255; this.chargeColor[1] = 0; this.chargeColor[2] = 0;}
else if (this.strength == 0) {this.chargeColor[0] = 0; this.chargeColor[1] = 255; this.chargeColor[2] = 0;}
else {this.chargeColor[0] = 0; this.chargeColor[1] = 0; this.chargeColor[2] = 255;}
}
public void show(){
ellipseMode(CENTER);
noStroke();
fill(this.chargeColor[0], this.chargeColor[1], this.chargeColor[2]);
ellipse(this.pos.x, this.pos.y, this.mass, this.mass);
}
}