Going deeper into processing.js we learnt the fundamentaals of integrating Physics into the program, and make objects move accordingly. By incrementing the speed of the variable that controls the object’s speed, we were able to make it move across the windows in whichever direction we liked.
The next challenge was to reverse it’s direction on hitting the edge of the window. In order to accomplish his task, we used if statements in the draw loop which changed the changed the speed of the object from positive to negative, hence resulting in it moving in the opposite direction.