NOC – Week3: Vectors – Skye Gao

Link for assignment 3:  https://editor.p5js.org/Skye/present/pOTCz1Dow

For this assignment, I first played around with vectors.sub(), vector.normalize() and vector. must(). Based on the class example which measures the vector length, I tried to make a click-shooting effect.  For this part, I first tried to draw a moving ellipse simply by adding an If (mouseIsPressed) function and attached the vector of line to the ellipse. However, I can make the shooting happened only when mouse is pressed. I also tried to use the function mouseClicked(), but I cannot transfer the value from one function to another. To modify that I further added a object class to separate the balls, which made the effect happen successfully.

From the shooting effect, I then tried to make a Buzzle Bobble style interaction, thus I added another class to create several rectangles as obstacles moving above the gun. However, I got stuck again when trying to compare the exposition of each ellipse and rectangle. I did not figure it out till the end so I just kept the sketch as what it was, and hopefully I will figure this out soon.

NOC – Week 3: Vectors – Yang Gao

For the Vector Assignment, I used vector and object to create a birth of the duck Sally. 

Link🔗: https://editor.p5js.org/yg1273@nyu.edu/full/rZ2isohcj

The difficulty I faced this time was I did not have much inspiration. It’s a bit hard to combine what we learned into visuals. I guess this will be improved when we learn more about nature of code. After finishing this homework, I also decided to observe our life more to get some inspiration.

NOC – Week 3: Vectors – Katie Pellegrino

Assignment 3

UPDATED ASSIGNMENT 🙂

Link to Assignment

For assignment 3, I tried experimenting with classes and vectors. However, much of the code I couldn’t quite get to work. I think I’m still confused of the best approach between when it’s important to define a method within a class, when to define a new function, or when to simply write a few lines within the draw function. So using the best tactics in coding still confuses me a bit, but practice should help!

For this I defined a particle class made up of square objects. Each object is assigned position, velocity, and acceleration as vectors along with assigned size, rotation speed, scale factor, and color. The program initially creates an object every frame until it reaches 100. At first the objects are simply drawn and rotate in place wherever they are randomly generated. Then, after a mouseClick(), the objects update by adding velocity to their position. After the next mouseClick(), the objects update with acceleration added to the velocity. However, as we did in class, the acceleration must be recent each iteration so it’s not continuously increasing. Finally, after another mouseClick(), I remove acceleration and the objects begin to fluctuate size. 

Throughout, the edges are checked with a simple bounce() method, however, I also wanted to do something fun with color here. So, initially, the objects are assigned random colors in the blue spectrum (setting b value of rgb to 255 and ther est to random). But when they hit a wall, the objects update with a new color in the red spectrum (setting r value to 255, rest to random).

Additionally, I tried adding a rift. So that when the mouseY matches that of the object, the object expands. Additionally, I wanted to add a second class of circle objects that appear after the third click. Finally, I still wanted to try and connect the objects with lines if their distance was close enough to each other. But I still need to practice the distance function more to fully understand it.  

Overall, I have a much better understanding of vectors and they significantly simplify the logic of creating visuals.

UPDATE

The updated program adds an additional 4th update function that first reduces the particles to a uniform size before applying acceleration towards the direction of the mouse.

NOC – Week 3: Vectors (Wentao)

This is the initial setting of the project. This is a simulated spring. When you move your cursor onto the gray part of the rectangle, it will turn bright and you can move it up an down.

After you press the spring with your mouse, then you can release your mouse. The spring will bounce up and down while colorful rectangles will fly out of the spring. 

The rectangles will fall on to the floor due to gravity. And disappear after a while.