I’m trying to learn Processing . Again. Properly this time honest. I am coding a bit every day to get better. Covering old things I know nad things I thought I knew. As part of this learning I am also trying to communicate the code in pseudo -code. Hopefully this will make my methodology clear to everyone and help me to think in a sequential fashion to solve my coding problems.
I’m currently using boolean TRUE/FALSE functions. Below is the pseudo-code and the link to the processing Sketch.
https://www.openprocessing.org/sketch/901734
I found this very logical to code. The feeling I get from watching the sketch in action is oddly satisfying. It was the same for coding it.
It uses a truth table. There are main variables the X co-ordinate position and the Y co-ordinate position.
The square has to move in 4 directions. :
1 Left to Right;
2 Top to Bottom:
3 Right to Left;
4 Bottom to Top;
Let’s say the width is 200 and the height is 200. In the code the TOP RIGHT corner is (0,0) so X = 0 and Y = 0.
1.(X,Y) is at (0,0) to move LEFT to RIGHT
X is 0. Y is 0. X needs to increase from 0 to 200.
While the Y co-ordinate (height) remains at 0.
2. (X,Y) = (200,0) to move TOP to BOTTOM
X is now 200. Y is 0. Y needs to increase from 0 to 200.
While X remains at 200.
3. (X,Y) = (200,200) to move RIGHT to LEFT
X is 200. Y is 200. X needs to decrease from 200 to 0.
While Y remains at 200.
4.(X,Y) = (0,200) to move BOTTOM to TO.
X is 0. Y is 200. Y needs to decrease from 200 to 0.
While X remains at 0.
5. Go To 1.
.