Posts

Showing posts from March, 2021

example of classes being used

 https://editor.p5js.org/p5/sketches/Mobile:_Shake_Ball_Bounce   Here is an example that I found that uses classes. The class is used in this code to create one function of "Ball" which is then used to make multiple balls. All of the balls have different movements and sizes even though they are called on in the ball function once which makes the code shorter and easier to read. The balls all look different in terms of shape and motion because the code uses the random function. In the constructor, the code uses different functions that are simplified and separated by what they are doing such as shape, display, and move.  

Partner code with functions

 I turned my partner (Jacquar's) code into functions. https://glitch.com/edit/#!/jacquar?path=script.js%3A29%3A0 original:  https://editor.p5js.org/jacquar.michael/sketches/fTKSkzqTM

Function homework

 https://glitch.com/edit/#!/homework-functions?path=script.js%3A64%3A2   https://editor.p5js.org/kmccloskey2/sketches/TpgL2kZGs Attached are the links to my glitch homework using functions and my original project. For the translation into the functions, I thought that was pretty simple and helpful as I could just copy and paste from my previous work and use the // assignments I had to create a function for what the design was doing. I figured out how to make pepperoni using functions with parameters- but the only thing I have been struggling with is making the pepperoni move with the pizza. This is difficult because the code is not recognizing my assignment for the variable pep to move +.5 each loop through. I tried many things but by keeping it in the parameter function method, I could not find a way to make them move. It is helpful to meet with a person although I had previously assigned and grouped my code together with // on P5 to distinguish what I wanted it to do (which ...

homework #4-loops

 https://editor.p5js.org/kmccloskey2/sketches/TpgL2kZGs   Attached is my project for homework using loops. I attempted to make a pizza oven- conveyer belt. To do this, I used nested loops and set the fill to random to make the look of an electric heater for a pizza oven. I used the random effect so it would appear more as if it was cooking. I used loop for the conveyer belt, to make the appearance of lines. If I would not have used a loop, I would have had to rewrite every rectangle with a different x variable. It is easier to use loops because I only have to write it once. I also used conditionals and variables to make the pizza go continuously in the conveyer belt oven.