Monday, June 29, 2009
Anenomes
float z = 0, dx = 0, dy = 0, r = 0;
int count = 0;
int fcount = 0;
int spawnpoint;
float[] start_x, start_y;
int fColour = 120;
float[] objX = new float[300];
float[] objY = new float[300];
float[] objDir = new float[300];
void setup()
{
start_x = new float[5];
start_y = new float[5];
start_x[0] = 100;
start_x[1] = 100;
start_x[2] = 500;
start_x[3] = 900;
start_x[4] = 600;
start_y[0] = 400;
start_y[1] = 500;
start_y[2] = 150;
start_y[3] = 300;
start_y[4] = 400;
size(600, 600);
for (int i = 0; i < objX.length; i++) {
objX[i] = -1000;
objY[i] = -1000;
}
spawn();
noStroke();
}
void spawn()
{
float direction = 1;
for (int i = count; i < count+10; i++) {
if (i == objX.length) {
count = 0;
break;
}
if(spawnpoint % 2 == 0) {
direction = 1;
} else {
direction = -1;
}
objX[i] = start_x[spawnpoint];
objY[i] = start_y[spawnpoint];
objDir[i] = direction;
spawnpoint++;
if(spawnpoint > 4) {
spawnpoint = 0;
}
}
count += 10;
}
void draw()
{
float theta;
fill(0, 50);
rect(0, 0, width, height);
fill(fColour, 255 - fColour, 600);
fColour += random(0, 2);
if(fColour > 255) {
fColour = 0;
}
z += 0.1;
for (int i = 0; i < objX.length; i++) {
ellipse(objX[i], objY[i], 10, 10);
theta = i;
theta = (theta % 6) + (theta / (30 * objDir[i]));
objX[i] += sin(theta) * 2;
objY[i] += cos(theta) * 2;
}
fcount++;
if (fcount == 5) {
spawn();
fcount = 0;
}
}
int count = 0;
int fcount = 0;
int spawnpoint;
float[] start_x, start_y;
int fColour = 120;
float[] objX = new float[300];
float[] objY = new float[300];
float[] objDir = new float[300];
void setup()
{
start_x = new float[5];
start_y = new float[5];
start_x[0] = 100;
start_x[1] = 100;
start_x[2] = 500;
start_x[3] = 900;
start_x[4] = 600;
start_y[0] = 400;
start_y[1] = 500;
start_y[2] = 150;
start_y[3] = 300;
start_y[4] = 400;
size(600, 600);
for (int i = 0; i < objX.length; i++) {
objX[i] = -1000;
objY[i] = -1000;
}
spawn();
noStroke();
}
void spawn()
{
float direction = 1;
for (int i = count; i < count+10; i++) {
if (i == objX.length) {
count = 0;
break;
}
if(spawnpoint % 2 == 0) {
direction = 1;
} else {
direction = -1;
}
objX[i] = start_x[spawnpoint];
objY[i] = start_y[spawnpoint];
objDir[i] = direction;
spawnpoint++;
if(spawnpoint > 4) {
spawnpoint = 0;
}
}
count += 10;
}
void draw()
{
float theta;
fill(0, 50);
rect(0, 0, width, height);
fill(fColour, 255 - fColour, 600);
fColour += random(0, 2);
if(fColour > 255) {
fColour = 0;
}
z += 0.1;
for (int i = 0; i < objX.length; i++) {
ellipse(objX[i], objY[i], 10, 10);
theta = i;
theta = (theta % 6) + (theta / (30 * objDir[i]));
objX[i] += sin(theta) * 2;
objY[i] += cos(theta) * 2;
}
fcount++;
if (fcount == 5) {
spawn();
fcount = 0;
}
}
comments
loading...
Add a comment: