Background Flashing with Corey and CITD Challege.

3/18/19

Today Corey shared his homework assignment with the class. The question he posted on Slack was: How come the background flashes when the ball bounces off the ends instead of staying a solid color once it reaches the ends? We discussed the importance of Order when it comes to coding.

It is good to remember that code has order and also certain functions also loop. In the code we can see that in Corey’s code the background is set to black on line 18. The draw function loops unlike some of the functions defined by Corey such as move function on line 39 and display function on line 44. That means after all the lines are ran in the code, The program will go back and run through code on lines 18-22. One approach Corey can take is to set the background color code on line 18 into the setup function. This will insure that Corey’s code will set the background to black as the initial color but it will not loop back to it. It will now change colors everytime it bounces and will hold the color until the next bounce.

In class we started a code in the dark challenge. The program introduced being able to attach external images into your code and also to manipulate the built in microphone on the laptop.

We established a global variable for the image on line 41. We than setup the image as a preload on line 46, 48 contains the source of the photo we saved in the asset folder in P5JS. By utilizing the microphone it allows users to interact with functions in a unusual way. This shows that we can input information into code using something other than mouse clicks or keystrokes.

Leave a comment