ICM Week 6

This week I set out to make a Halloween themed game. While it still needs a lot of work, I’m happy with my use of classes and am excited to build upon that. It is a very simple smash the pumpkin game, where there is a particle system creating an array of pumpkins. They are randomized and generate from the bottom of the screen upwards. The cursor is turned into a hammer, and when you smash a pumpkin the image updates to a smashed pumpkin. Also once you hit 50 smashed pumpkins, they shrink to half the size. I need to find a way to update my distance function for when the shrinking happens. I was having trouble getting it to update without throwing the program into some kind of infinite loop.

Here are some photos of the game in addition to the main source code.

https://editor.p5js.org/wpolitan/sketches/rO3QkvRB4

Phys Comp Week 6

This week we demonstrated different types of serial communication from P5.JS to the Arduino IDE. I decided to have a potentiometer determine a couple of the color values in my sketch from last week for ICM. This was my take on the 10print challenge where the computer draws lines at different angles horizontally. Below is a video of it working, along with snapshots of the code in Arduino and P5.

ICM Week 5

This week we talked about defining our own functions, and tidying our code. While I slightly changed the look of my project from last week I made a lot of changes within the code to expand on what I was trying to do. I originally set out to make an interesting 10print example using triangles instead of diagonal lines. This week I implemented a for-loop instead of an if statement for the actual 10print horizontal printing functionality. I then wanted to further randomize things with some sort of user input. I thought using an object I call “color” would be a fun way to change things up. That way while it is printing different triangular shapes I used the mousePressed function to change the colors being printing. As I continue to expand on these ideas I will be making it more user interactive and intuitive how to change the shapes and the amount times it runs.

I also added a new argument to my printing functions called “times” which dictates how many times each function will run. This became interesting when I realized that if I call two functions in draw at the same time, the spacing would actually be different because they are being drawn together. This created crazier patterns and is an interesting idea to try and expand on in the future. Below are some examples of the resulting images and new code.

ICM Week 4

This week I wanted to focus on creating a simple algorithmic design that iterates, and changes over time. I was really inspired by the 10print example. Instead of using diagonal lines I wanted to incorporate more colors, so I used triangles with fill. I loved watching the program move in rows and grow. I also wanted it to keep changing once it hits the bottom. I began experimenting with different colors and transparencies. Below are some examples of the iterations I went through and the final code.

https://editor.p5js.org/wpolitan/sketches/iAmFy4oRB

P Comp Week 4

This week we began experimenting with assigning tones to a speaker. We were also introduced to a pitches.h library designed by Brett Hagman. I used the examples on the Arduino site to help create this simple melody. I also added an if statement so instead of just initializing the song when the program starts, you can trigger it with the touch sensitive resistor in the loop function. Below I figured out a simple melody for the song Old Town Road by Lil Nas X.

After figuring out the melody I wanted, I input the notes into the Arduino IDE. The code is below.

https://create.arduino.cc/projecthub/wpolitan/p-comp-week-4-bb8fb4

#include "pitches.h"

// notes in the melody:
int melody[] = {
  NOTE_E4, NOTE_E4, NOTE_E4, NOTE_D4, NOTE_C4, NOTE_A3, NOTE_A3, NOTE_E4, NOTE_D4, NOTE_C4,0,NOTE_A3,NOTE_G3,NOTE_D4, NOTE_D4, NOTE_E4, NOTE_C4, NOTE_A3, NOTE_A3,
  
};

// note durations: 4 = quarter note, 8 = eighth note, etc.:
int noteDurations[] = {
  8, 8, 4, 4, 4, 8, 8, 8, 4,8,8,8,8,2,4,4,8,4,4
};
void setup() {
 Serial.begin(9600);

}

 
 void loop() {

   
   // get a sensor reading:
   int sensorReading = analogRead(A0);
   int frequency= map(sensorReading, 0, 1023, 100,880);
   if(sensorReading>600){
       // iterate over the notes of the melody:
  for (int thisNote = 0; thisNote < 19; thisNote++) {

    // to calculate the note duration, take one second divided by the note type.
    //e.g. quarter note = 1000 / 4, eighth note = 1000/8, etc.
    int noteDuration = 1000 / noteDurations[thisNote];
    tone(9, melody[thisNote], noteDuration);

    // to distinguish the notes, set a minimum time between them.
    // the note's duration + 30% seems to work well:
    int pauseBetweenNotes = noteDuration * 1.30;
    delay(pauseBetweenNotes);
    // stop the tone playing:
    noTone(9);
    
    Serial.println("pressed");
    }
   }
    else {
      Serial.println("not pressed");
      }
   


 }

Below is the final application in use.

Next week I hope to expand on the use of triggering different sounds and LED’s. Eventually I want to create musical applications and hardware, that can interface with the computer in a more intuitive way.

ICM Week 3

For this week’s project Neta and I attempted to make a breathing exercise. We start on the home screen, where we see a prompt that asks how you are feeling. There are two black circles to choose from. When you hover over either circle another prompt appears. “Are you anxious?” or “Feeling good?” If you choose feeling good, it takes you to our exit function. If you choose, anxious it take you to the breathing exercise. This is what the graphics look like.

We originally wanted the circle to inflate while the cursor is hovering, and then stop itself after four seconds. This is where we ran into some issues. We couldn’t get the circle to stop without ending the If conditional. When we did set it to start deflating, it would get caught in a feedback loop at its maximum size. I think by controlling the circle with different variables it could’ve helped us achieve what we wanted. I think a “for loop” could’ve helped too but it is not something we have figured out yet. We did get a slider on the exercise page to turn the background from yellow to pure white.

We then added a smiley face instead of the cursor on the exit function for aesthetics.

Below is the code for the home screen.

We also built on the game state changing in my last project to change when options are clicked.

Here is a link to the final project.

https://editor.p5js.org/wpolitan/sketches/pQPpAOTp0

P-Comp Week 3

This week for my observation assignment I decided to look at the Whole Foods automated register lanes. At the 365 whole Foods by Atlantic Avenue, there is always a backup around peak hours. There are three dedicated lanes that flash a new register once it becomes open. If I were designing these lanes I would try my best to incorporate the fact that everyone is extremely frustrated while checking out of the grocery store. They have kids at home, work to finish and places to be. This means everyone just wants to get out of there.

I tend to think of the status bar as an inspiration to make this system better. Why is it so satisfying to watch our data upload with a bar? Imagine uploading and downloading without it! These lanes seem to choose which of the three at random (with a preference to the express lane). How do they code the split? And what data caused the way they divvy up the lanes? This could cause more frustration for the other lanes but does provide a speedier experience for those not getting as much. All of these questions run through the minds of the people in the lanes. They also have screens displaying cooking videos, which do help I think to keep people distracted but also has the feeling of trying to sell you more product.

One way I think I would make this experience better is by using the status bar idea. Create a whole foods app (use the existing prime now app they make you download for discounts, where they are probably just selling more of your data/preferences). Instead, use the app to show the average wait time of both lanes in real time. This could be made using cameras and machine learning. That way, people know the wait time and can plan their expectations accordingly. Also, I would use this data to inform an algorithm that would disperse the express lane-regular lane ratio accordingly.