Created
January 23, 2017 04:08
-
-
Save jtescher/dfbba1048fae57e4b59a13495f26579b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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