Midterm Project

P5js Link: https://editor.p5js.org/meeraa/full/umLuxqZZ5

YouTube Game Demo:

Concept:

For my midterm project, I came up with the game called Star Catcher. This idea came to mind from this Nyota Pop Mart figurine that I own (check 2nd link in Resources section), which sparked the idea of making a game that catches stars. I started brainstorming the story and came up with the story that this girl was stuck on the moon and the only way to go back is to regain her power using the stars. It will ask the user to help her by moving left and right on the arrow keys to “catch” 30 of the falling stars from space. With every caught star, the star power increases by 1. However, there are also meteors/rocks falling that the user has to watch out for or they will lose 2 points. There is also a 45 second countdown for the game to add more pressure and make it fun.

Design:

For the title screen, I initially was just going to add text for the title but since drawing became a major part of the code, it only felt right and consistent to draw it out.

For the instructions screen, I added text to describe the story of the game and also how to play, win, and what to avoid. I also remembered the Week 4 creative reading by Norman and made sure to specify how the game works (using LEFT and RIGHT arrow keys) as signifiers for the user to know how to actually play. I drew the moon in the bottom right corner and the planet in the top left corner but smaller

to show that the user is stuck in the moon and trying to get back to home.

For the game, I traced the girl on my iPad because I wanted a drawing rather than an image. I think it looks better and more game-friendly. It was also a fun, creative process that I think adds a more personal touch to this project.

I initially also drew the background but after loading it in, I did not like how it looked like just because I drew it as a square almost, so it stretched out. I also felt like the quality would be better if I just coded the gradient background.

The moon part in the bottom is quite easy with just a bunch of ellipses.

I also redrew the stars because I did not like how it looked before. They play a sparkle sound when hit as a signifier that the user caught it.

I drew and added meteors/rocks in the game as the obstacle.
They also play a rock thud sound when hit as a signifier that the user hit it.

For the winning ending screen, I edited it from last time and added a background to the girl as if the star is shining bright against the galaxy sky. I did the same for the losing ending screen but made it more dark and drew vignette to add a sad, disappointing feel for losing/ not being able to make it back to home, planet ST4R-17.

Highlighted Code:

class Star {
  constructor(x, y, speed) {
    this.x = x;
    this.y = y;
    this.speed = speed; // falling speed
  }

  // this is what makes the star fall down
  move() {
    this.y = this.y + this.speed;

    // once it reaches the bottom it goes back up, had to add this because the stars stopped appearing
if (this.y > height) {
  this.y = 0;
  this.x = random(width - 100);
    }
  }

  // displays the star
  show() {
    image(star, this.x, this.y, 80, 80);
  }

  // checks if girl caught star
  checkCatch() {
    if (
      this.x > girlX && // left
      this.x < girlX + 120 && // right
      this.y +100> height-275 && // reached girl's hands
      this.y < height-280 // but not too far down
    ) {
      // adds to starCount so the displayed text updates & plays the sparkle sound
      starCount = starCount + 1;
      sparkleSound.play();

      // send it to the top randomly so it seems like the star disappeared
      this.y = random(-300, 0);
      this.x = random(width);
    }
  }
}

I am proud of this code because it is the main interaction of my game. I used OOP to make my Star class and that it what makes the stars fall. Then, show() is what displays the star at a size of 80×80 and checkCatch() uses an if statement to see if the star is within the girl’s parameter and if it is it adds the starCount so the user knows they caught it as well as by the sparkle sound that plays right after. This took me a while to figure out just because the girl’s image is slightly bigger than where she actually is, so I could not just plug in the image’s x, y, and height. I explain more in depth in the Problems section below. Then the stars go back up to this.y= a random number between -300 and 0 so they do not all fall back down at the same time. It was so fun writing these codes because I initially did not have that last line so the stars never appeared again but when I realized what I could do–with the help of Gemini–and fixed the issue, it was really satisfying to see it work out. I was not going to add the rocks/meteor obstacles in the game but because I had this code ready and working, I figured why not! It is basically a copy except I named the collision checkHit() instead of checkCatch() and made the starCount decrease by 2 and the rock sound play.

How This Was Made?

Space background: As I mentioned in the previous blog post, I had a different code for the gradient at first—like the one I used in my Bubbles project—but it caused the stars and girl to infinitely draw, creating a trail for some reason. I figured it was because I put it in setup but putting it in draw caused the same problem so I just searched for a new reference instead (P5js example gradient background in Resources section).

Character movement: This was done using the keyIsDown(LEFT_ARROW) and and keyIsDown(RIGHT_ARROW) to move her horizontally across the bottom screen. I changed girlX by 16 points to control her speed because it initially was around 8 maybe and it worked fine, but when I played in fullscreen, it was so slow.

Falling stars and meteors: This part was done using OOP to create the Star and Rock classes. 15 stars fall in the title screen and 7 stars in the game and 5 rocks in the game as well and that is done using the for loops in lines 66-78 of my code. This was similar to the code we did in class for week 3.1 and similar to my Bubble assignment 3. I stored all the objects in arrays using push() then another for loop (in lines 144-154 + 216) goes through each object in the array and does move() to make it fall, checkHit or checkCatch depending if it is a star or rock and if it is true, if it is within the girl’s parameters, the starCount increases by 1/decreases by 2 and the corresponding sound effect plays. Then the star/rock goes back to the top randomly between -300 and 0 to make it seem like it disappeared. Then show() to actually display it.

Score and countdown: The variable starCount, as I mentioned is what tracks the amount of stars caught or rocks hit and that is what is displayed in the text on the top left of the game so the player knows how much is needed to win. For the countdown, I used millis() to calculate how much time has passed since the game started (startTime) and divided it by 1000 to turn it into seconds, which is also subtracted by 45 because that is the intended duration of the game I wanted to set. I asked Gemini to explain the class example we talked about and how I could apply it to mine since my circumstances were different with the screens. It responded with “Since your game has multiple screens, you should start the timer only when the player clicks the START GAME button, rather than when the sketch first opens. You can use startTime = millis() inside mousePressed() to record when gameplay begins.” So, I proceeded to do that and put it under the if statement for screen === instructions in mousePressed() in line305. It worked and I understood the logic behind it!

Buttons: For the buttons, I made them before we learned about the button code in class so what I did instead was just have a basic rect() and utilized mousePressed() and the mouseX and mouseY to check if the user clicked within the parameters of the button. For all the buttons, I did it by taking and checking with mouseX the rectangle’s x position for the left boundary and the opposite sign of that number because all the rectangles are set at width/2 for the right boundary. To check mouseY if it is within the rectangle’s top and bottom boundary, I did the same by taking the y value of the rectangle and plus its height.

Also, for the button colors, I used Image Color Picker website and uploaded the picture of the girl to select the colors the colors in it and have it match and be consistent with the overall color scheme of the background since the end screen shares the same button regarding the outcome (line 422). I recommend everyone to use it! It is so helpful when it comes to styling the code.

Problems

While coding, the part I was unsure about was the collision detection part—when the game knows that girl “caught” the star—just because it kept confusing me as to which numbers would work best. At first, it was very sensitive and rather kind because it was pretty easy to catch the star from afar or after it had passed the girl’s reaching hands, which looked wrong. I had to keep changing the numbers to make sure it is fair and actually within the girl’s parameter. The same situation happened with the rocks/meteors but it was easier because I already had the parameters closest to it from the Star class.

Another issue I had was the background images of the winning and losing screen where it would fill the entire screen but it would be cut off because it is not the same size of the screen. I did not know how to fix this issue so I asked Gemini what to do and it told me about the max() code. That code chooses the largest size to cover the entire screen.

Another error I had was that the audio was not playing but when I removed the .loop and put .play instead, it worked for some reason.

Reflection

Overall, I am really happy with how my game turned out, especially since my vision came to life. I am most proud of the game section of my code and all the visual elements I drew. Although it was a long process, it was definitely worth it. I initially was not going to draw but after I drew the girl from the first draft, I felt like it was only right and consistent to keep going with that style so the game feels like a whole and not in parts. I also really love all the music/effects I chose because I feel like they are the perfect sounds for the game vibe I was going for.

Some improvements of the game I thought of was add a limit for how many meteors the user can hit. So, if starCount reaches like -14, the game ends rather than waiting till the 45 seconds are up. I could also add levels with maybe more rocks falling or less stars or less time to make it harder. Another thing I wish I did was draw at the same size of a usual desktop size for the background because that is what caused the background to stretch and me using AI to fix it. It also caused it to slightly zoom in more for that reason.

Resources:

ibis Paint X: app used to draw

Pop Mart’s Nyota “Dream”: character reference https://www.popmart.com/us/pop-now/set/122

P5js example gradient background: https://editor.p5js.org/adriennecassel3/sketches/b7FTa6sF_

Class: https://editor.p5js.org/Aya_Riad/sketches/Wky6-ythQ

Key movement: https://editor.p5js.org/Aya_Riad/sketches/XtHkp-A7N

https://editor.p5js.org/Aya_Riad/sketches/vgp-dlvea

millis() https://editor.p5js.org/Aya_Riad/sketches/qZsp9Qete

Title/Cursive Font: https://fonts.google.com/specimen/Twinkle+Star?preview.script=Latn

Main font:  https://fonts.google.com/specimen/Sour+Gummy?preview.script=Latn

Sparkle sound: https://pixabay.com/sound-effects/film-special-effects-sparkle-355937/

Lose sound https://pixabay.com/sound-effects/film-special-effects-marimba-game-over-250960/

Win sound https://pixabay.com/sound-effects/musical-fairy-dust-magical-chime-576279/

Game sound https://pixabay.com/music/fantasy-dreamy-childrens-magical-storytime-389087/

Main sound https://pixabay.com/music/fantasy-dreamy-childrens-magical-sparkling-orchestral-music-192725/

Image Color Picker: https://imagecolorpicker.com/

Google Gemini for errors unable to resolve as mentioned in blog post

Assignment 5: Midterm Draft

Concept:

For my midterm project, I came up with the game called Star Catcher. This idea came to mind from this Nyota figurine that I own (see image on the right), which sparked the idea of making a game that catches stars. I started brainstorming the story and came up with the idea that this girl was stuck on the moon after a failed round-trip and the only way to go back to her planet is to regain her power using the stars. It will ask the user to help her by moving left and right on the arrow keys to “catch” the falling stars from space. With every caught star, the star power increases by 1 and a sparkle sound plays.

Design:

I traced the figurine on my iPad because I wanted a drawing rather than an image. I think it looks better and more game-friendly. It was also a fun, creative process that I think adds a more personal touch to this project.

I drew the girl for the ending screen where she will be holding the star to show the user that they have won but I have yet to use it because I did not work on the screens yet.

I also drew the stars to keep the style consistent.

I initially also drew the background but after loading it in, I did not like how it looked like just because I drew it as a square almost, so it stretched out. I also felt like the quality would be better if I just coded the gradient background and the moon part is quite easy with just a bunch of ellipses. I am happy I made that decision and it definitely helped me learn something new, as I found a p5js example for the gradient. I had a different code for the gradient at first—like the one I used in my Bubbles project—but it caused the stars and girl to infinitely draw, creating a trail for some reason. I figured it was because I put it in setup but putting it in draw caused the same problem so I just searched for a new reference instead (P5js example gradient background in Resources section).

This is the structure I have in mind:

  1. Starting screen (title/intro) + play button
  2. Story / Instruction (explains the game + how to play) + play button
  3. Game
  4. Ending screen (win/lose) + play again button

Uncertainties:

I think the most uncertain part as of right now is the rest of the concept, which is the goal of the game. I am not sure how to go about this game, as I have multiple ideas. One idea is to have rocks falling from space as well and if the user hits it, the Star Power decreases, and it needs to reach a certain number in a limited time in order for the user to win. Another idea was having the stars continuously falling with no drawbacks, but if a star falls without being caught, then the game ends and to make it easier I would have a special star fall to temporarily speed up the girl’s movement.

While coding, the part I was unsure about was the collision detection part—when the game knows that girl “caught” the star—just because it kept confusing me as to which numbers would work best. At first, it was very sensitive and rather kind because it was pretty easy to catch the star from afar or after it had passed the girl’s reaching hands, which looked wrong. I had to keep changing the numbers to make sure it is fair and actually within the girl’s parameter.

In the beginning, the girl was also able to go beyond the canvas but that was because I did not restrict thekeyIsDown if statement. I added if (girlX > -20) and     if (girlX < width – 120) to fix that.

For now, I want to work on figuring out the goal of the game. After that, I want to do all the different screens. In the end, I want to finalize with background sounds or effects.

Resources:

Sparkle sound: https://pixabay.com/sound-effects/film-special-effects-sparkle-355937/

Font (Gemini helped me pick this font): https://fonts.google.com/specimen/Twinkle+Star?preview.script=Latn

P5js example gradient background: https://editor.p5js.org/adriennecassel3/sketches/b7FTa6sF_

Class: https://editor.p5js.org/Aya_Riad/sketches/Wky6-ythQ

Key movement: https://editor.p5js.org/Aya_Riad/sketches/XtHkp-A7N

WK5 Creative Reading

Before this reading, I thought that computer vision was complicated and I was not sure how it worked at all. After reading, I was surprised to learn the techniques used to help the computer see and track what we are interested in have a simple explanation. The reading mentioned multiple techniques like frame differencing, background subtraction, and object tracking. The one I found most intriguing though was the brightness thresholding, which can differentiate things based on how dark or light it is. LimboTime was an example of that, where two people extend their arms towards each other and the computer makes a line. The third person then tries to limbo under that line and if they go over it the computer rings the alarm. At first glance, the photo examples of the game looked complicated but after learning it was because they placed a white background, which allowed the computer to detect any darker pixels as players, it sounded much simpler. It reminded me of the way green screen works and how the computer uses that to easily separate the person or object from the background.

Thus, computer vision differs completely from human vision because computers just see pixels and because of that cannot always differentiate between things. We can easily see something even if the background is messy, but a computer would struggle because it needs its techniques like brightness thresholding and contrast. This explains why the remove background feature in the editing website I use sometimes is not always accurate to how I want it. One thing though, is the computer can be more precise with movement and detection if the technique is perfected. For example, in the dark we cannot see, but the computer could with infrared lighting, which is why security cameras are so common with their ability to detect movement like the Ring camera.

To answer the final question, I think computer vision’s capacity for tracking and surveillance is quite interesting and interactive but also uncomfortable. The example of Videoplace looked really fun and interactive to have the participant BE the art with their silhouette and movement. It funnily reminded me of Just Dance. The reason why I say uncomfortable is because of the multiple examples shared in the reading, but especially the Cheese installation. Because the participant knows they are being tracked, they feel more self-conscious. It does not feel like they are participating in the art like Videoplace, but being controlled to act a certain way or in this specific example, to keep smiling. Overall, this reading taught me that computers are able of making art with the help of human interaction, pixel movement and detection, and lighting.

Assignment 4: Unknown Texts

Concept:

For this assignment, I initially thought of doing the Super Mario lucky block and have it display random text like “+3 Coins!” everytime it was clicked, but I could not brainstorm anything more after that and I felt stuck. I also thought of doing something with a Marvel characters dataset I found on Kaggle like pick 4 superheroes, display their logos, and showcase their information on the side from the data when the user clicks it, but I felt that it was too simple and I also could not visualize it. Ultimately I was stuck at this point, so I went back to our classwork to see if that could spark something, and it did! I was playing around with the generative poem and it reminded me of the New Phone, Who Dis? card game because the responses are always random and sometimes funny. The way the game works is you have an inbox card or prompt and the players compete by placing the funniest reply card to it.

I used that same concept but instead of players choosing the card, the system randomly generates the prompt, reply, response, and ending from the CSV file I created. I wrote down 9 points for each of the 4 categories that are random yet still work together seamlessly so each combination is unexpected and funny, but not confusing either. That was the one thing I did not like about the classwork we did, so I made sure all the points worked with each other but still provided funny outcomes that could mean multiple different things and stories. 9 to the power of 4 is 6,561, so that is how many different combinations of conversations there are!

hello???,who is this?????,you know what you did,i’m going back to sleep
are you awake,why are you texting me?,i thought you knew,i regret texting back
don't panic but,leave me alone bruh,your mom knows..,see you in court stalker
we need to talk,i don’t care.,LET ME EXPLAIN,goodbye forever!!!
i’ve got bad news…,can you send me 50dhs?,that's not important,i'll deal with this tomorrow
DID YOU HEAR?,oh-oh are you mad at me?,please stay calm,DON’T TELL ANYONE.
you owe me 1000dhs btw,WHATTTT?!!,i’m outside,this conversation never happened
you forgot my birthday,i’m scared…,it’s over.,abcdefg i have to go
WHERE ARE YOU? YOU’RE LATE,i will block you btw,you’re in biggg trouble,one sec i just need to block you

The interaction works when the user clicks the screen and then it generates a different conversation combination. It is supposed to look like the actual Messages app just like the cards in the game. I put the contact information up top, including the service bars and battery percentage that is usually seen there. Below that is the actual message chain with grey as the recipient and blue as the sender. I also made sure to include the text box and send button so that it is more realistic.

Highlighted Code:

let INBOX = 0;
let REPLY = 1;
let RESPONSE = 2;
let END = 3;


function draw() {
  background(245);

  let singleRow = [];

  // random first grey text
  singleRow = splitTokens(strings[int(random(strings.length))], ",");
  let greeting = singleRow[INBOX];

  // random first blue reply
  singleRow = splitTokens(strings[int(random(strings.length))], ",");
  let reply = singleRow[REPLY];

  // random second grey response
  singleRow = splitTokens(strings[int(random(strings.length))], ",");
  let response = singleRow[RESPONSE];

  // random second blue end
  singleRow = splitTokens(strings[int(random(strings.length))], ",");
  let ending = singleRow[END];

I am proud of this code that creates the different text conversation combinations because I understood the work we did in class and was able to implement it easily because of that. It was a satisfying feeling. I first assigned INBOX, REPLY, RESPONSE, and END the right column indexes because in each line in the CSV file, it is separated by first a prompt/inbox then a reply then a response to that and finally an ending. Then, I have the empty array, singleRow, that temporarily holds the strings. These strings are chosen by random(strings.length) that picks a random row from the file by making sure to put int so that it is not a float number or else it would not work. Then it takes those strings in that row and using splitTokens, it splits the row into separate strings from the comma and places them all in singleRow. Then, for example, singleRow[INBOX] would be assigned to greeting, where it would be the first string since we previously said that we assigned them each the column index they would be in. This process is repeated 3 more times for the 3 other texts. These are the core codes that make the whole project work.

How This Was Made?

The majority of the code was made using what we learned in class. I relied on the Week 4 Generative Poem example whenever I needed to go back and check if I used splitTokens correctly.

I came up with the phrases for each message and put them in a CSV file. I had to ask ChatGPT for help with this because Google Sheets was not functioning for me. It told me to open up TextEdit, format it to plain text, paste my messages, and save/name the file messages.csv.

As for the basic layout, I searched up “New Phone, Who Dis?” on Google and used the image of the cards as a reference to try to imitate. For example, I included the service bars, which are just small rectangles, and a text that says “WDYM” like the cards right next to it. I also did the same for the battery on the top right side.

For the contact icon, I went into my phone’s Messages app and copied the design of the icon which is simply one big grey circle for the background, one small white circle for the head, and finally an ellipse for the body that blended with the background even though it is outside of the circumference of the big grey circle.

The text messages and text boxes are just rounded rectangles by 15. I also put tiny ellipses in the bottom corner to copy that text bubble look. The text box initially said “iMessage” just like how it actually is on Messages, but after reading this week’s creative reading, I changed it to “ Click for new messages” because the author was highlighting how interactive elements should clearly show what actions can be done, where, and how. By indicating exactly how to make the code function without sacrificing the visual appearance, it makes the project well-designed and avoids user error due to bad design.

One issue I had was the fact that sometimes some messages would be much longer than others, so it would go out of the canvas. I had to keep playing around with it to make sure each text was contained within the message box, and I would widen the rectangle and reposition the text until it fit all the possible inputs.

For final touches, I wanted to make the ending look as close as a real text message chain, so I searched for the font that Apple uses for messages, which is SF Pro, but I could not find it. So, I searched Google what the closest font is to SF pro and Reddit recommended Inter, which I found on Google Fonts and installed in my assignment using the Week 4 example as a guide. I also searched for a text messages color palette to get the blues and greys as close as possible to the real thing.

Reflection:

Overall, I am pretty happy with how it turned out because I think that I achieved what I had in mind. I really like how the visual design ended up looking like because it is so similar to how the actual Messages app does, so I am proud of that. The small details like the rounded text bubbles, the typing box, the contact, the service bars, and battery all made it look more like the actual interface.

In the future, I could make the text bubbles size change based on the random message length selected just because some of the text messages had big gaps. If I had more time I would definitely have added an if statement that checks the length of each string and in accordance gives the text bubble the right width. Another thing I could have done was add more messages to the CSV so that there are more fun combinations. I also thought of having the message notification sound effect play every time the user clicks so it feels like the user is actually texting. I am excited to learn how to do that next week!

References:

Card game reference images: https://corners.ge/eng/product/new-phone-who-dis/

WK4 Generative text class example: https://editor.p5js.org/Aya_Riad/sketches/fIy61R_jf

WK4 Font class example: https://editor.p5js.org/Aya_Riad/sketches/Y28fO79o4

“Inter” font: https://fonts.google.com/specimen/Inter?query=inter + Reddit post: https://www.reddit.com/r/AfterEffects/comments/12mz22f/commercial_usable_font_that_looks_like_apples_sf/

Text messages color palette: https://www.color-hex.com/color-palette/13071

WK4 Creative Reading

The reading talks about how everyday objects can be confusing and frustrating due to bad design rather than user issues. Don Norman notes after the swinging door example that “the relevant components must be visible, and they must communicate the correct message: What actions are possible?; Where and how should they be done?” This made me realize that for my last assignment, where the bubbles are added through key presses and popped by a mouse click, a new user would not know because I have not indicated anything. This is an error on my part because I did not take into account new students possibly browsing ideas for this class in the future or the professor when grading. Therefore, after reading that sentence, I immediately went back to my code for this week’s assignment—where the text messages change every mouse click—and added a text that says “Click for new messages.” The change made much more sense now and checks of the “discoverability” and “signifier” boxes that Norman mentions. It is also how I was able to apply some of the author’s principles of design to my interactive media assignments. In the future I could also consider the other 5 fundamental psychological concepts: affordances, constraints, mappings, feedback, and conceptual models. Mapping could be useful for the second part of Interactive Media when we are building our project to make sure that if I create something that requires a sensor or button to be pressed, then it should make sense and match what actually happens. A quick yet not obnoxious beep could play immediately after to show the user that it has worked, which is the feedback Norman was talking about. Lastly, the conceptual model, I think, is the most important because when the user looks at my p5.js project or my final IM project, they should have a mental picture of how it works without having to look at the code or figure it out.

On a more relatable note, this reading was extremely satisfying to me; having someone understand the frustration when it comes to design errors felt so validating. Something, though, that drives me crazy and was not mentioned in the way I wanted to is public washroom sinks. There is not just one that was memorable (in a bad way), but many. This specific one I remember was in a mall in Dubai, and from afar the washroom looks really clean, new, and functional. However, when I came to use the sink, I could not find the soap! The cleaner had to point it out to me that it was under the mirror. That is when I noticed the barely noticeable icons for the soap, tissues, and dryer. It does not stop here because when I put my hand under the soap icon directly, the soap was dispensing a little more to the right, so some of it ended up falling on the tabletop. On top of that, there was no light or sound to indicate that soap was currently being dispensed, or if there was, it was not loud enough for a crowded public Dubai mall washroom. For it to be improved, they should not sacrifice the easy functionality for the clean look, or if they really want to, then the icons need to be in a different color than the color scheme of the washroom or have it placed in a bordered box so that it is more visible against the mirror. To fix the issue of the indication that soap is being dispensed, they could first have a light shining right next to where it gets dispensed so they know where to place their hand and second have the light blink lightly when the sensor detects a hand so that the user does not move while the soap is being dispensed. Overall, this was a very fun read and an even more enjoyable analysis that will definitely make me think twice on my future projects to ensure no bad design and avoidable user error.

Assignment 3: Nostalgia in Bubbles

Concept:

For this artwork, I wanted to capture the childhood memory and experience of when we would go outside to play with bubbles. My aim is to be able to relay that nostalgic, hazy, dreamy feeling using soft colors and a gradient background of the sky and grass but in a blur just like the memories. I did not want it to be too complex but simple, carefree, and fun instead because that is how life was, where popping bubbles was the highlight of our day and running out of the bubble soap was our low.

If you press a key, bubbles spawn. If you mouse click, a bubble pops. I intentionally did it this way because the press of a key reminded me of when we would press on a bubble machine to blow out more bubbles, and the click of the mouse reminded me of how we would run, jump, and reach out with our hands to pop the bubbles as fast as we can before it flies too high or pops on its own.

Highlighted Code:

// "pops" the bubble
function mousePressed(){
  for (let i = bubbles.length - 1; i >= 0; i--){
    let distance = dist(mouseX, mouseY, bubbles[i].x, bubbles[i].y);
    if (distance < bubbles[i].size / 2){
      bubbles.splice(i, 1);
    }
  }
}

I am proud of this function because it creates the main interactive feature: popping the bubbles. I had to do some research in order to figure out how to get it to pop but also used previous dist() knowledge from Week 2 to calculate the distance between the mouse and the center of the bubble. The code splice() was used to remove the bubble from the array when clicked. I think I am most proud of it because it wasthe code that had the most trial and error, which I explain more in depth in the “How This Was Made?” section.

How This Was Made?

The majority of the code was made using what we learned in class. In the Bubble class, I added this.size in order to produce many different sizes of bubbles to match realistically how it is. To add to that, I also created an array of different colors that picks between them randomly  using this.color for that very same reason. I searched for a bubble color palette on Google and scrolled till I found the one that matched the vision in my head and used those colors.

For the bubbles it is just one perfect ellipse based on this.size, which is a random number between 50 and 150. The two small reflection spots are also ellipses but multiplied by + or – 0.1-0.3 to make it smaller. Though small, this is what adds dimensions and makes the bubble look like a bubble.

I let keyPressed() create a new bubble instead and mousePressed() to pop it. For keyPressed() I ran into an issue where the bubbles would almost disappear because they would go out of the canvas, so I had to subtract the radius (this.size / 2) from the width and height in order for it to bounce off immediately as it touches the canvas borders.

For the bubble popping part, I knew I needed dist() as wherever mouseX, mouseY, and the x and y values of the certain bubble[i] in the array is, but I was unsure how to have it “pop” because when I actually used bubbles.pop() it deleted the last bubble that was made regardless of where I clicked. I noticed that the previous student’s example used splice(), but she also had other variables and codes that made it confusing to understand. So, a simpler way was just searching up “bubbles popping p5.js” on google. I ended up finding an example made by someone and noticed they used splice() as well. I asked Gemini to explain how their code works and then I implemented it on my own. Their code had the distance in a separate function, so I just combined it in the same mousePressed() function because it felt unnecessary and simpler.

I did the gradient background last because initially I was just going to leave it as a plain light blue; however, I did not think it encapsulated the nostalgic, hazy, childhood memory feeling, so I thought a gradient from light blue to green would be better. It matched my bubble reference image where you see the sky above then the greenery below it. I searched for “gradient background p5.js” and found a simple example. I recognized lerpColor from a classmate’s palleteLerp() code but wanted to know more about how map works, so I looked for the reference. It learned that it converts the coordinates to numbers between 0-1 as a the percent lerpColor needs to blend c1 and c2.

Reflection:

Overall, I am pretty happy with how it turned out because I think that I achieved that nostalgic, childhood feeling I was going for. I feel like this assignment definitely helped me understand classes more and allowed me to explore new things that we have not learned. In the future, I could maybe do more with the background like having the gradient flow and move around from top to bottom like an actual hazy memory. For improvements, I also found a p5.js example where they actually installed a bubble pop sound that plays when the user “pops” a bubble, which I thought could have been a fun interaction and addition to complete the experience.

References:

Bubble reference image: https://www.pinterest.com/pin/112027111108718506/

WK13 Bouncing ball example: https://editor.p5js.org/Aya_Riad/sketches/Wky6-ythQ

Previous student example: https://editor.p5js.org/AyshaSalma/sketches/09cZh8SDk

Bubble pop example: https://editor.p5js.org/haydencarey/sketches/4Jksy0Odg

map(): https://www.geeksforgeeks.org/javascript/p5-js-map-function/

Gradient background example: https://editor.p5js.org/evebdn/sketches/O9G35ueZv

Bubble color palette: https://www.schemecolor.com/colors-of-a-soap-bubble.php

WK3 Creative Reading

In the reading by Chris Crawford, they define interaction as “a cyclic process in which two actors alternatively listen, think, and speak.” He emphasizes that there are two actors, not one, and that is the only way to define something as interactive, but I disagree with his definition. I feel like there does not have to be a back and forth and an interaction can just be something simple like the user just clicking something and something appears. For example, in my Assignment 3, I had an interaction where if the user presses a key, a bubble appears, and if you click on the bubble, it disappears. To me, that is interaction even though the p5.js system is not necessarily thinking or speaking. I would describe it as what he thinks is low interactivity.

With that, I think characteristics of a strong interactive system is, first of all and most important of all, the system responding to the user. This means that the user should have input and be able to affect the outcome. Now, what makes a strong interactive system I think should be having multiple different outcomes, so multiple user inputs. In the section about “Thinking” he was talking about communication and how when you talk with someone who is a slow thinker, the conversation is meaningless and how “Good thinking can make a conversation sparkle.” Therefore, another strong interactive system has to feel engaging, so the user feels like whatever it is they are controlling in the system matters and is worth their time.

Finally, after reading and analyzing the text, some ideas I have for improving the degree of user interaction in my p5 sketch is maybe having the bubbles make a pop sound when the user clicks it. I could also have the user decide what size and color they want so they could personalize it. I also thought of having the background move as a gradient to the direction of where the mouse hovers.

Assignment 2: Disco Dance Floor

Concept:

For this second assignment we were instructed to code an artwork using the concepts we have learned in class this second week. Initially, my concept was inspired by the atmosphere of a disco dance party where the grid of squares represent a disco ball.

 

However, when I added the diamond shape to appear based on the mouse position to represent the sparkles when light reflects off it, it reminded me of a different idea. Seeing the grid of squares, the colors changing, and an object moving using my mouse gave me a sense of deja vu and reminded me of when I used to play Club Penguin. Specifically, the night club dance floor. So, I pulled up a reference image to help me tweak a few things like changing the color scheme to match it and changing the diamond shape to appear into the closest penguin I could code that looked like a Club Penguin.

I liked this idea and direction because it allows my project to be interpreted in multiple ways and combines both my initial idea and my current one. When the mouse is not in use, it can still be portrayed as anything within the realm of dance, parties, and disco based on the perception of the viewer. This is why I kept the sizes of the square to be random even though it is static in the club penguin dance floor, I felt like it made it visually dynamic and added energy like how a real, lively dance floor is and also how disco ball patterns rapidly change as though it is spinning fast and reflecting the different colorful lights of the vibrant environment usually in parties.

Highlighted Code:

// random color + size 4 the rect/tiles
  let color = random(7);
  let size = random(35, 40);
      
      if (color < 1) {
        fill("#ffffff");
      } else if (color < 2) {
        fill("#d970ff");
      } else if (color < 3) {
        fill("#ff2e1f");
      } else if (color < 4) {
        fill("#3ef226");
      } else if (color < 5) {
        fill("#f4f830");
      } else if (color < 6) {
        fill("#3ef9ca");
      } else {
        fill("#ee9f5d");
      }

      rect(x, y, size, size);

This code assigns color a random number between 0-7 and size a random number between 35-40 and based on that it fills the rect() a certain color and width/height. I am particularly proud of it because I had previously known about the random generator code I just had to see how it worked in p5js as my knowledge was from python. Knowing now that I can set up random() to be in between a certain amount of numbers by setting the maximum amount within the parameter made it pretty easy to code the rest with simple if/elseif/else statements. So, if the random() let color to be 2 then the rect() would be filled with the color red because (color < 3) would be finally true. I liked that I was independently applying something I had learned from before rather than just following an example and seeing my vision come to life.

How This Was Made?

To create the grid of squares I used the help of Week 2.2’s classwork example for the nested loop and I just played around with the x and y values to get the squares as close as I want them to be. Then before the rect() executes, I had the random size and color if/else statements that I explained in the Highlighted Code section to fill it a random color and give it a random width and height. For the penguin part, in order to make it appear based on mouse position and within a certain part of the canvas, I used Week 2.1’s example of the && logical operators. The mouseX and mouseY part makes sure that the mouse is within the boundaries of each grid square and I used the same number (42) that I used in the nested loop in order to have matching spacing. This is what makes the penguin appear right above each tile that the mouse is hovering over. For the penguin part, It was just multiple ellipses stretched out in different widths and heights based on the body part. It took a bit as I had to keep going back and forth checking with the mouse then adjusting the x, y values but it worked out in the end.

Overall, I used the Club Penguin reference image, the random() p5js reference, Week 2.1 examples, and Week 2.2 examples.

Reflection:

I am happy with how my artwork turned out because the whole development was fun to work with. I started with a disco ball-inspired art then ended up with a mix of both that and a Club Penguin dance floor. My previous work was SpongeBob SquarePants and I really enjoy the assignments when I make them more personalized to my likings, yet still abiding by the instructions. The final artwork is more than just a visual idea, but a nostalgic memory to I am sure many people.

For future developments, I have a couple of suggestions for myself if I had more time and that would be maybe to add multiple penguins in the dance floor. I could have them placed on a certain grid when the mouse is pressed and have them change colors like how the real Club Penguin actually is. I could also have the tiles change colors when the penguin is hovering over them kind of like the penguin (user) is activating the dance floor. It would make the final piece more interactive and playful for the user, yet still preserving the main concept of the artwork.

WK2 Creative Reading

Before watching the video, I did not like the idea of disorder or randomness, as I felt like it meant going out of routine. I feel more comfortable with the expected rather than the unexpected. After hearing Casey Reas’s thoughts about how it can be used as a tool to create something that the artist may not have expected, I am more open to it and think that it can create unique outputs. It also made me realize that if I were not open to it, then I would not have been able to code my second assignment. My second assignment used the random() code to generate the different colors of the dance floor. In [27:03] he talks about Lia’s random 4×4 generative design and how the increase in deviations of pixels transitioned the design from order to chaos. This made me realize that I answered the first question, which is that I have already implemented that chaos part in my second assignment, where I have the tiles/rect() randomly change between 35 and 40, which made it visually dynamic and added energy like how a real, lively dance floor would. For the second question, I think that a balance between randomness and complete control is the best because there should be structure, but having randomness makes the final design look more unique and interesting. So, for my Assignment 2 example, if the frameRate() was high, then the dance floor tiles would be too chaotic to the point that they would not have even looked like a dance floor. Thus, having a good balance between chaos and control is best as long as the meaning of what you are trying to depict is still understood.

Assignment 1: Portrait of SpongeBob SquarePants

Concept:

For this first assignment we were instructed to code a self-portrait. Instead, I thought it would be more interesting to code a childhood favorite character: SpongeBob SquarePants. For some reason, he was the first character that came to mind when we were told that we were allowed to code anything, not necessarily ourselves. When I googled SpongeBob to use as a reference image while I coded, I was able to analyze it and think of all the different shapes I could use for each part. I broke every part down into little pieces so I could visualize the shapes it needs, which helped me code it much more efficiently.

Highlighted Code:

// 4a. eyes + lashes
  // left eye
  fill('#2f2f2d'); // eyelashes
  stroke('#2f2f2d')
  strokeWeight(1.5)
  rect(141, 102, 5, 20)
  
  fill('#2f2f2d');
  stroke('#2f2f2d')
  strokeWeight(1.5)
  rect(156.5, 100, 5, 20)

  fill('#2f2f2d');
  stroke('#2f2f2d')
  strokeWeight(1.5)
  rect(172, 102, 5, 20)
  
  fill('#ffffff'); // eyeball
  stroke('#2f2f2d')
  strokeWeight(1.5)
  ellipse(162, 147, 70, 72)

  fill('#26B9C8'); // iris
  stroke('#2f2f2d')
  strokeWeight(1.5)
  circle(165, 147, 30)

  fill('#2f2f2d'); // pupil
  stroke('#2f2f2d')
  strokeWeight(1.5)
  circle(165, 147, 15)

  fill('#ffffff'); // "reflection"
  noStroke()
  circle(163, 140, 6)

  fill('#ffffff');
  noStroke()
  circle(170, 153, 3)

  // right eye
  fill('#2f2f2d'); // eyelashes
  stroke('#2f2f2d')
  strokeWeight(1.5)
  rect(216, 102, 5, 20)
  
  fill('#2f2f2d');
  stroke('#2f2f2d')
  strokeWeight(1.5)
  rect(230.5, 100, 5, 20)

  fill('#2f2f2d');
  stroke('#2f2f2d')
  strokeWeight(1.5)
  rect(245, 102, 5, 20)
  
  fill('#ffffff'); // eyeball
  stroke('#2f2f2d')
  strokeWeight(1.5)
  ellipse(233, 147, 70, 72)

  fill('#26B9C8'); // iris
  stroke('#2f2f2d')
  strokeWeight(1.5)
  circle(230, 147, 30)

  fill('#2f2f2d'); // pupil
  stroke('#2f2f2d')
  strokeWeight(1.5)
  circle(230, 147, 15)

  fill('#ffffff'); // "reflection"
  noStroke()
  circle(228, 140, 6)

  fill('#ffffff');
  noStroke()
  circle(235, 153, 3)

This is the code I wrote for the eyes. I am most proud of it because it looks almost identical to the actual SpongeBob character. It is the first thing that stands out when I look at the code. Also, the placement of the eyes is well-positioned for the face as well as the iris, pupils, and reflection spots. On top of that, both eyes are identical with the same structure and dimension. I also really like that I added the two small white circles that serve as reflection spots. I initially was not going to do it because I did not feel like it, honestly, but I am so glad I did. Those four little white circles made all the difference, as they made it seem like it was animated and lively. It really was the cherry on top.

I think an honorable mention would be the outline of SpongeBob’s face, as anyone could have easily just done a square, but I think the curves, though it took long to code, is what made it really look like SpongeBob after the eyes.

How This Was Made?

When I started the code, I just had a yellow rectangle (almost square) and a thin white rectangle under for the shirt and a thin brown rectangle under that for the pants. After I pulled up a reference image of SpongeBob to help me code, I realized that the shape of the head was not ideal, as it is more of a square cloud with the curves. For that, I used ellipses to create different circular shapes for the natural, uneven curved face. A mistake I noticed after reaching the bottom is that due to the face code being at the start, the shirt overlapped it, so I had to rearrange the code throughout the entire process in order of the correct layering.  This happened with the lashes too, so I had to have that first before the whole eye. It also happened with the shirt, where I had to have the code for the arms first as well.

For the eyes, I used an ellipse for the eyeball because it did not look like a perfect circle based on my reference image. The iris, pupil, and reflection spots were all circles. Then for the mouth, nose, and cheeks, I used PI and TWO_PI to create the half circles. The lashes, teeth, and black belt all just needed the rectangle shape but in different positions. For the collar, I used triangles and quads for the tie, as it starts with an upside-down trapezoid and then a sharp diamond. Finally, I just used a mix of circles and ellipses as the sponge marks SpongeBob has on his face to make it more identical with the animation.

This all wouldn’t have been done without the code that prints the mouse’s X and Y because that made positioning everything much easier and took less time.

The only source I used to help me code was the p5js reference site to remind myself of the parameters of each shape, especially for the arc. It is what made me realize that I could set PI as the starting point and have it end at TWO_PI to make an upside down half-circle for the cheeks and nose. I also used the website Color Hex Color Codes and SchemeColor to get the most accurate color palette of SpongeBob SquarePants.

Reflection:

Overall, I am super proud of how my code turned out. It was better than I had expected even though I had my doubts throughout the whole process. It was a really satisfying process seeing the image come to life as I code, edit, and make changes. It was also enjoyable, as I knew what to do to achieve the results I wanted but just needed the time and patience and trust in the process.

For improvements, I would definitely have to say the smile. SpongeBob actually has a much bigger smile with a deeper and taller curved smile that reaches all the way to his cheeks. Unfortunately, I was not sure on how to do that, and that is what made the final product slightly inaccurate. I tried having the half-circle shape as the mouth and two triangles on the side of each to pull them and make them more curved, but it did not work out due to the strokes. It also looked rigid and not smooth. If I wanted to add anything in the future, it would definitely be a SpongeBob-related background with all the fun colors and shapes.