Hi all! I am new here, specifically signed up to resolve this problem.
I have Processing 3. I am trying to make two “walkers”. I have all this code here but I keep getting the error message that the functions step(), render(), don’t exist. Any ideas why?
> Walker w1;
> Walker w2;
>
> void setup()
> {
> size( 800,600 );
> background ( 255 );
>
> w1 = new Walker();
> w2 = new Walker();
> }
>
> void draw()
> {
> w1.step();
> w1.render();
>
> w2.step();
> w2.render();
> }
>
> class Walker
> {
> float x;
> float y;
> int stepSize;
>
> Walker()
> {
> x = width / 2;
> y = height / 2;
> stepSize = 8;
> }
>
> void step()
> {
> int choice = int( random( 4 ) );
>
> if (choice == 0) // up
> {
> y = y - stepSize;
> }
> else if (choice == 1) // down
> {
> y = y + stepSize;
> }
> else if (choice == 2) // left
> {
> x = x - stepSize;
> }
> else if (choice == 3) // right
> {
> x = x + stepSize;
> }
> }
>
> void render()
> {
> noStroke();
> fill( random(256), random(256), random(256) );
> ellipse(x,y,8,8);
> }
> }
Any insight would be much appreciated. Thank you!