Ex_00_03_RandomWalker_Lopsidedly

random walker
lopsided

class Walker {
  int x;
  int y;
  
  int w = 1;

  Walker(){
    x = width/4;
    y = height/2;
  }

  void display() {
    stroke(0);
    point(x, y);
  }

  void step() {
    float choice = random(1); // 0.0 to 3.9 // int()
    if (choice < 0.4) {
      x = x+w;
    }
    else if (choice < 0.6) {
      x = x-w;
    }
    else if (choice < 0.8) {
      y = y+w;
    }
    else {
      y = y-w;
    }
  }
}

Walker w; // walker objeect

void setup() {
  size (720, 360);
  w = new Walker();
  background(255);
}

void draw() {
  w.step();
  w.display();
}