In processing I have recently been experimenting with directions. In this example I created a triangle and assigned 1 coordinate of each point a variable. I then incremented each point so that the left and right points of the triangle move up vertically and the centre point of the triangle moves down.
The problem that I’m having which I am yet to solve is how to change the direction of the triangle so that when it exceeds the height of the page it goes the opposite direction. I have tried a series of different methods to try and solve this problem including assigning a Boolean variable so if the direction is true the point moves one direction and the other when false. However my lack of knowledge of programming is postponing my progression.
Here is an example of my problem, I have created an if statement assigned to the variable ‘b’. The if statement says that if ‘b’ is greater than height then decrement by 1. The resulting output does nothing however and the triangle doesn’t move.
If I do b= b-20 the point does move but doesn’t want to go the other direction, instead it just moves the point back twenty pixels and moves down again until it reaches the height of the canvas, and does this indefinitely.
I’m also having a similar problem with some other code I’ve been messing around with. In this example I’ve created 4 squares which grow in size until they reach the height and width of the canvas. What I want to do is make each square grow towards the centre instead of all to the bottom right of the canvas. I have not worked out how to do this yet.