Pseudocode
Pseudocode
BEGIN
This is mostly just a pseudocode description of how
Define a ‘position’ record as
all Processing programs work – when they start
int x,y;
they define any global variables, run the setup()
Initialise ‘positions’ as an array of 50 position records
procedure, then they keep running the draw()
procedure as a loop until the program is stopped.
setup()
WHILE true
Notice the definition of the position record data
draw()
structure and the array of 50 positions before
END WHILE
setup
END
BEGIN setup()
Set the screen size to 500, 500
FOR i=0 to positions.length-1 STEP 1
positions(i) = new position();
positions(i).x = 0 This FOR loop iterates through all of the items in the positions array
positions(i).y = 0 and sets their initial values to 0
NEXT i
END setup
BEGIN mouseMoved()
Set the background colour to 0
FOR i=0 to positions.length-2 STEP 1
Set the ith position’s x value to the (i+1)th position’s x value
A FOR loop to shuffle the
Set the ith position’s y value to the (i+1)th position’s y value
values in the array along by 1
Set the fill colour to i
Draw an ellipse at the ith position’s x & y values
NEXT i
positions[positions.length-1].x=mouseX; Store the current mouse position
positions[positions.length-1].y=mouseY; in the last record of the array.
END mouseMoved