Skip to content

Commit

Permalink
Updated tnoc walker 3
Browse files Browse the repository at this point in the history
  • Loading branch information
Nick B committed Aug 19, 2024
1 parent 6f0bb87 commit 7883ba3
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
10 changes: 8 additions & 2 deletions z_sol/tnoc_walker_03/Walker.pde
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ class Walker {
y = height / 2;
}

void setXY ( int _x, int _y)
{
x = _x;
y = _y;
}

void display () {
stroke (0);
point (x, y);
Expand All @@ -17,9 +23,9 @@ class Walker {
float r = random(1);

if ( r < 0.4) {
x++;
} else if (r < 0.6) {
x--;
} else if (r < 0.6) {
x++;
} else if (r < 0.8) {
y++;
} else {
Expand Down
12 changes: 12 additions & 0 deletions z_sol/tnoc_walker_03/tnoc_walker_03.pde
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,16 @@ void setup () {
void draw () {
w.step();
w.display();

}

void keyPressed() {
if (key == 'r') {
reset();
}
}

void reset() {
background ( 255);
w.setXY(width / 2, height / 2);
}

0 comments on commit 7883ba3

Please sign in to comment.