14 Oct 2015
courses, documentation, icm
For this week's assignment, I reworked our bouncing ball code from week 4 to utilize the DOM. In the earlier example we had manually created a button in the p5 canvas - or, more accurately, the shape of a button that would do something if you clicked inside the rectangle. All of which involved a rather elaborate string of code determining whether or not the mouse was actually inside the rectangle. The createButton function simplifies the process. Now, when you click the button, the bouncing ball will reverse its direciton.