-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdisk_planet.js
More file actions
37 lines (32 loc) · 1.41 KB
/
Copy pathdisk_planet.js
File metadata and controls
37 lines (32 loc) · 1.41 KB
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
// A planet with some disks around it:
function DiskPlanet(x, y, r, red, green, blue, distance, velocity) {
this.r = r;
this.distance = distance;
this.random_shift = floor(random(180));
this.position = createVector(x + this.distance, y);
this.radians = 0 + this.random_shift;
this.velocity = velocity;
this.red = red;
this.green = green;
this.blue = blue;
// SHOWS the object:
this.show = function() {
noStroke();
fill(this.red-30, this.green-50, this.blue); // First Ring (outer)
ellipse(this.position.x, this.position.y, this.r*2+30, this.r*2+30);
fill(51); // First Gap (outer)
ellipse(this.position.x, this.position.y, this.r*2+20, this.r*2+20);
fill(this.red-30, this.green-50, this.blue); // Second Ring (middle)
ellipse(this.position.x, this.position.y, this.r*2+16, this.r*2+16);
fill(51); // Second Gap (middle)
ellipse(this.position.x, this.position.y, this.r*2+10, this.r*2+10);
fill(this.red, this.green, this.blue); // The actual planet
ellipse(this.position.x, this.position.y, this.r*2, this.r*2);
}
// UPDATES position:
this.checkPosition = function(parent) {
this.radians -= this.velocity;
this.position.x = parent.x + Math.cos(this.radians) * this.distance;
this.position.y = parent.y + Math.sin(this.radians) * this.distance;
}
}