Answer the question
In order to leave comments, you need to log in
How do I fix the "Mixing "active" and "static" modes" error in my code in Processing?
Tell me how to fix the error?
Here is the code:
int size = 10;
void setup () {
fullScreen();
background(255);
}
int w = width / size;
int h = height / size;
Cell[][] world;
int[] random_genome () {
int[] result = new int[64];
for (int i = 0; i < 64; i++) {
result[i] = int(random(64));
}
return result;
}
int[] empty_genome () {
int[] result = new int[64];
for (int i = 0; i < 64; i++) {
result[i] = 63;
}
return result;
}
class Cell {
int[] genome;
int energy;
boolean isCell;
int[] rgb;
Cell (int[] arg_genome, int arg_energy, boolean arg_isCell, int[] arg_rgb) {
genome = arg_genome;
energy = arg_energy;
isCell = arg_isCell;
rgb = arg_rgb;
}
}
void createWorld () {
for (int x = 0; x < w; x++) {
for (int y = 0; y < h; y++) {
if (random(100) < 10) {
world[x][y] = new Cell(random_genome(), 500, true, new int[] {127, 127, 127});
} else {
world[x][y] = new Cell(empty_genome(), 0, false, new int[] {255, 255, 255});
}
}
}
}
void drawWorld () {
for (int x = 0; x < w; x++) {
for (int y = 0; y < h; y++) {
stroke(world[x][y].rgb[0], world[x][y].rgb[1], world[x][y].rgb[2]);
point(x * size, y * size);
}
}
}
createWorld();
drawWorld();
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question