One interesting bug found...
in
Programming Questions
•
1 years ago
In the code below (just a copy of Windows' Starfield screensaver)
- int num = 4500;
- Star stars[] = new Star[num];
-
- void setup() {
- size(800, 600, P3D);
- smooth();
- for (int i=0; i< num; i++) {
- stars[i] = new Star();
- }
- frameRate(25);
- }
-
- void draw() {
- background(0);
- for (int i=0; i< num; i++) {
- stars[i].display();
- }
- }
-
- class Star {
- float x = random(width);
- float y = random(height);
- float z = random(600);
- int a = 0;
-
- void display() {
- pushMatrix();
- translate(0, 0, z-100);
- stroke(0);
- box(0);
- stroke(255, a);
- line(x, y, z, x, y, z+45);
- popMatrix();
-
- z+=random(10.0, 25.0);
- //change alpha with z position
- a+=z/20;
-
- if (z>600) {
- z=0;
- a=0;
- x = random(width);
- y = random(height);
- }
- }
- }
if you comment out
box(0); (theoretically, it's useless) in the code, the effect will go wrong...
1