Skip to content

Instantly share code, notes, and snippets.

@jtescher
Created January 23, 2017 04:08
Show Gist options
  • Save jtescher/dfbba1048fae57e4b59a13495f26579b to your computer and use it in GitHub Desktop.
Save jtescher/dfbba1048fae57e4b59a13495f26579b to your computer and use it in GitHub Desktop.
class Walker {
int x;
int y;
Walker () {
x = width / 2;
y = height / 2;
}
void display() {
stroke(30);
point(x,y);
}
void step() {
int choice = int(random(4));
int stepAmount = 4;
if (choice == 0) {
x += stepAmount;
} else if (choice == 1) {
x -= stepAmount;
} else if (choice == 2) {
y += stepAmount;
} else {
y -= stepAmount;
}
}
}
Walker w;
void setup() {
size(640,360);
w = new Walker();
background(255,255,255);
}
void draw() {
w.step();
w.display();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment