Intro to Computational Media 9/13/22

Link to week 2 homework in the p5 web editor.


Who Nose?

I knew going into this assignment that it'd be difficult to devote the same continuous chunk of time to it that I did with the first week's homework–it was my birthday this weekend, and on top of that I gave myself a lot of little errands and tasks around the house to take care of.

Still, since I had already made a variation on my first screen drawing that uses mouseX and mouse Y to control the color of the astronaut, I wanted to push myself to instead fulfill the homework's three elements with something new.

  • One element controlled by the mouse.
  • One element that changes over time, independently of the mouse.
  • One element that is different every time you run the sketch.

After a bit of thinking, I settled on wanting my independently changing element to be something that flies around the screen, and a while later I settled on the idea of making a WarioWare-esque minigame. It'd use a relatively simple mouse control, just a single click, but I thought that the accompanying logic even to get a simple minigame working correctly would be a nice challenge. I think I was more right than I knew?

A video of 2003's WarioWare Inc. for the Game Boy Advance.

Apart from the two semesters I took in undergrad, the other time I've really dealt with programming was in a short, two week summer class on games offered at DigiPen around 2010. I remember that I avoided adding a timer to my final project for that class even though it definitely would've been nice to have some time pressure in that game. Most of WarioWare's minigames are so simple that the timing element really becomes the driving factor of the experience, so I knew that getting the timer working properly, complete with a fail state, had to be a priority.

The first day I worked on this, I sat down and wrote out what I wanted to accomplish before opening p5, an exercise that I found very, very helpful.

A photo of what I wrote in my ICM notebook before I started writing code for week 2.
My notes before programming.

About an hour later, I almost had what I wanted. The face shape and color were randomized, the nose was bouncing left and right across the screen (with a semi-random speed), and the detection for pinning the nose to the face worked as intended. The timer and win/loss conditions were basically entirely broken and in need of debugging, however.

I had a guess that I had run into trouble by not correctly handling my win/loss logic across the draw() and mousePressed() functions, and that one quirk in particular (the timer refusing to stop counting down, running left past its origin and off the screen) might be down to some shoddy if/else formatting. But again, I decided to start on paper first.

A page of debugging information in my ICM notebook.
My notes once I was in the thick of things.

Once again, I found this was the right move for me. After articulating what was going wrong and how, then thinking through the program flow, it was pretty clear to me how I should go about fixing the bugs to get the timer working properly. I easily could've spent an hour or more on this if I was trying to tweak different variables or bits of syntax without a clear idea of what I had to do. Lesson learned.

The last of my ICM notebook debugging for this assignment.
Once I had this, it only took about 15 minutes to get the game working as intended.

With that sorted out, I moved on to adding something that I thought would be a "nice to have" feature in this assignment: making the character's eyes follow the position of the nose as it moved left and right. There's definitely a ton more that could be done to enhance how expressive that movement is, but I was pleasantly surprised to see that my idea of using map() with my variable for the nose's position got me to the basic cat clock feeling I wanted the eyes to have.

Visually, it'd be nice to have more randomized elements for the game's character–I think after next week it'd be nice to set up a for loop to create some squiggly hairs on top of the character's head. I also have some ideas about how I might add an intro screen and a reset ability to the game, but I also wanted to try going to bed at a reasonable time as a gift to my 30-year-old self.-9/20/22