Week 3 Assignment – Dina

My Concept:

I won’t lie, I went into the assignment completely blind. This was probably the most challenging assignment for me conceptually. I struggled with understanding the concept of arrays/how they function. After calling four people to come and explain it to me, I got the hang of it.

For my assignment, I was inspired by the idea of popping balloons at a party, and that seemed like something I could replicate through building an array and building a class.

Here is the finished product:

 

The Process:

Honestly, the process of creating the project began way before I opened the p5 website. I still had a lot of confusion about arrays and how they function, especially with the addition of the “i.” I re-read the lesson’s slides to try to grasp the concept to no avail. I then decided to get help from others who managed to successfully explain the topic.

Since I just got the hang of the topic, I decided that I wanted to create something that encapsulates all of what we did in class this week, from arrays, classes, to interactivity.  I first wanted to create a Sudoku game/grid, then a coloring page, but in the end, I decided that the one thing I could do to incorporate the three main things we took in class is through a balloon-popping experience.

I first started by creating a class for my balloons, creating a motion, display, and bouncing function for them. Afterwards, I created an empty array for my balloons and built a for loop to initialize and create my balloons, their parameters, and details. In order to allow my balloons to appear, bounce, and move as intended, I made a for loop within my draw function. Within the same for loop, I made an if statement to allow a text that says “POP!” to appear whenever the user pops a balloon. I incorporated the mousePressed() function as well as mouseX, to boost interactivity and functionality.

Snippet of Code I’m Proud Of:

There isn’t one particular part of my code that I’m proud of. I’m honestly more proud of the entire code in general, because it was a challenge for me to grasp the concepts and integrate them into one idea. For that, I will paste my main sketch’s code:

let balloons = [];
function setup() {
  createCanvas(600, 600);
  for(let i=0; i<9; i++){
    balloons[i]=new Balloon(50*i, random(600), 4+1*i, 4+1*i)
  }

}

function draw() {
  background('pink');
for (let i = 0; i < balloons.length; i++) {
  balloons[i].display();
  balloons[i].move();
  balloons[i].bounce();
  
   if (mouseIsPressed){
     fill('red')
       textSize(100)
    text('POP!', mouseX, mouseY)
  } 
     
}

}
  

  
 function mousePressed(){
  
  balloons.pop(balloons);
   

}

 

Reflections:

I’m satisfied with the end product, however, for future works I would hope to push and challenge myself even more and create specific projects I have in mind like an interactive coloring book that I know could be created using arrays and OOP.

 

Leave a Reply