Created
January 23, 2017 05:06
-
-
Save venetucci/8fc31dc43b2819e9bcc8db23ce024343 to your computer and use it in GitHub Desktop.
This file contains hidden or 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