Using the Processing platform, write a sketch PixelWalker
that uses a RandomWalker()
class.
RandomWalker
classThe RandomWalker
class tracks the x- and y-coordinates of a walker. It includes
int
parameters x
and y
to establish the walker's initial positiongetX()
and getY()
that return the values of those variablessetX(newX)
and setY(newY)
that modify the values of those variables.move()
method which causes the walker's position to change, usually by one step in the x
or y
directionPixelWalker
classIn Processing, the main program (in this case PixelWalker
) has to be the first, leftmost tab in the project. Click on the down-arrow in the tab to create a new tab for additional classes (in this case RandomWalker
) that should be included in the project.
The main program in the sketch will include the void setup()
method to establish a graphical window and a void draw()
loop that displays the walker and its position as long as the walker hasn't returned to the middle of the screen.
Also, print in the console the coordinates of the walker and the number of steps it has taken.
Note that you don't need to set up an explicit loop for this project: the draw()
method itself repeats.