private void tickPerPlane(int i) { double theta = thePlanes[i].theta += thePlanes[i].speed; thePlanes[i].z = -9 + 4 * Math.cos(theta); thePlanes[i].x = 4 * Math.sin(2 * theta); thePlanes[i].y = Math.sin(theta / 3.4) * 3; thePlanes[i].angle = ((Math.atan(2.0) + PI_2) * Math.sin(theta) - PI_2) * 180 / PI; if (thePlanes[i].speed < 0.0) thePlanes[i].angle += 180; }
private void addPlane() { int i; for (i = 0; i < MAX_PLANES; i++) if (thePlanes[i].speed == 0) { switch (Math.abs(random.nextInt() % 6)) { case 0: thePlanes[i].red = 1.0; thePlanes[i].green = 0.0; thePlanes[i].blue = 0.0; // red break; case 1: thePlanes[i].red = 1.0; thePlanes[i].green = 1.0; thePlanes[i].blue = 1.0; // white break; case 2: thePlanes[i].red = 0.0; thePlanes[i].green = 1.0; thePlanes[i].blue = 0.0; // green break; case 3: thePlanes[i].red = 1.0; thePlanes[i].green = 0.0; thePlanes[i].blue = 1.0; // magenta break; case 4: thePlanes[i].red = 1.0; thePlanes[i].green = 1.0; thePlanes[i].blue = 0.0; // yellow break; case 5: thePlanes[i].red = 0.0; thePlanes[i].green = 1.0; thePlanes[i].blue = 1.0; // cyan break; } thePlanes[i].speed = (Math.abs(random.nextInt() % 20)) * 0.001 + 0.02; if ((random.nextInt() & 0x1) != 0) thePlanes[i].speed *= -1; thePlanes[i].theta = ((float) (Math.abs(random.nextInt() % 257))) * 0.1111; tickPerPlane(i); if (!moving) display(); return; } }