You made me noticed i had to declare the color variable as global within the class. Solved!, Thanks a lot.
I also noticed i should check out āthisā. Wil it make my life easier not using local variables with different names related to the original global variables?. Here goes the example.
//Class tab
class Walker {
float x;
float y;
color colC;
Walker (int tempX, int tempY, color colC) {
fill(colC);
noStroke();
x = tempX;
y = tempY;
}
void render () {
ellipseMode (CENTER);
ellipse (x,y,25,25);
}
void step () {
float chance = random (1);
if (chance < 0.4){
x++;
} else if (chance > 0.4 && chance < 0.6) {
x--;
} else if (chance > 0.6 && chance < 0.8) {
y++;
} else if (chance < 0.8 && chance < 0.9) {
y--;
}
constrain (x,0,width-1);
constrain (y,0,height-1);
}
}
// Main Tab
Walker [] w = new Walker [3];
void setup () {
size (1280,600);
for (int i = 0; i < w.length; i++){
w [i] = new Walker (width/2,height/2,color (i*50,i*50,i*50,100));
}
}
void draw () {
background (0,51,93);
for (int i = 0; i < w.length; i++) {
w[i].render();
w[i].step();
}
And as we are on it, after you solved my initial issue, i tried to multiply the RGB values by the index, and the three ellipses will run with the same color. Shouldnāt it goes like this:
[i] = goes from 0 to 2.
every RGB value in setup is noted as i*50 , shouldn it then give back this:
when [i] = 0 --> i*50 = 0.
when [i] = 1 --> i*50 = 50.
when [i] = 2 --> i*50 = 100.
(i already did the whole processing tutorial by dan in YouTube, now i started in Nature of Code and am trying to add some math logic to basic examples so i can embelish more complex ones i already have made myself, and keep getting stuck with some declarations)