hi, i have made a random walker proggram and my goal is to be able to have a walker appear on the mouse position with every mouse click, but when a new one appears the previous one always stops moving, please help me. sorry if i’m making mistakes i’m new here.
Walker[] Walk = new Walker[200];
int total = 0;
void setup() {
size(800, 600);
background(0);
for (int i = 0; i < Walk.length; i++) {
Walk[i] = new Walker();
}
}
void mousePressed() {
}
void keyPressed() {
total = total - 1;
}
void draw() {
for (int i = 0; i < 1; i++) {
Walk[i].step();
Walk[i].render();
Walk[i].startpo();
}
}
//class
class Walker{
float x;
float y;
int total = 0;
Walker() {
}
void render() {
stroke(102,240,240);
point(x,y);
}
void startpo() {
if (mousePressed){
x = mouseX;
y = mouseY;
total = total + 1;
}
}
void step() {
int choice = int(random(4));
if (choice == 0) {
x++;
} else if (choice == 1) {
x--;
} else if (choice == 2) {
y++;
} else {
y--;
}
}
}