-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstargenesis.pde
74 lines (61 loc) · 1.21 KB
/
stargenesis.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
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
import processing.opengl.*;
import javax.media.opengl.GL;
ArrayList nuclei = new ArrayList();
PGraphicsOpenGL pgl;
GL gl;
void setup() {
smooth();
noStroke();
size(1000,800,OPENGL);
colorMode(HSB, 1000);
frameRate(60);
/*fixes crazy flickering*/
pgl = (PGraphicsOpenGL)g;
gl = pgl.beginGL();
gl.setSwapInterval(1);
pgl.endGL();
int nNuclei = 500;
for(int i=0; i<nNuclei; i++)
{
nuclei.add(new Nucleus(int(random(width)), int(random(height)), 1,0));
}
}
void draw() {
int nNuclei = nuclei.size();
Nucleus n;
for(int i=0; i<nNuclei; i++)
{
n = (Nucleus)nuclei.get(i);
int outcome = n.collide(nuclei, i);
if(outcome != 0)
{
if(outcome>0)
{
Nucleus other = (Nucleus)nuclei.get(outcome-1);
n.merge(other);
nuclei.remove(outcome-1);
}
if(n.type==7)
{
// Be8 -> He4 + He4
nuclei.add(n.divide(2,2));
}
if(n.type==8)
{
// He3 + He3 -> He4 + H1 + H1
nuclei.add(n.divide(1,0));
nuclei.add(n.divide(1,0));
}
return;
}
n.move();
}
background(0);
for(int i=0; i<nNuclei; i++)
{
n = (Nucleus)nuclei.get(i);
n.draw();
}
}
/**
*/