Week 4

Screen Shot 2021-10-18 at 12.21.15 AM.png

 What I wanted to do:

I wanted to take the color-changing eyeballs of my friend here and use a function to place 10 randomly sized eyes around the canvas. I wanted a green ellipse to show up on them if the mouse hovered over them (like the eye is closing) and to stay there until moused over again. I did not succeed!!

Screen Shot 2021-10-18 at 12.17.58 AM.png

Things went wrong.

I’m really not sure how I broke it, or maybe it was broken all along and some other random line in there was managing to hold it all together before I changed it- but suddenly multiple built-in functions was undefined, even if it was working perfectly fine before.

Error message: 🌸 p5.js says: There's an error due to "colorMode" not being defined in the current scope (on line 53 in sketch.js [/sketch.js:53:5]).

I went back to a new file and copied over line by line until I had something functional. I think I must’ve ended up with improper syntax (improperly placed { } or ( ) that threw everything off because I was able to get it working again, and also left behind a decent amount of extraneous code in the old file.

I haven’t quite gotten the hang of nested for loops yet, but this sketch was good practice. I have auto-refresh on because I like to see how slight adjustments change things in real time. Only issue comes when typing out loops: if you create an infinite loop or something else problematic while in the process of typing it, the program with crash. So I’ll often comment out my loops until I’ve fully typed them and closed them up, to avoid any inadvertent errors that make p5 angry at me. I needed to decrease the x values for value = value + x for this sketch vs. the one with only two eyeballs. For some reason everything moved much more quickly once there were many of them.

Sketch link here.

 
Previous
Previous

Week 3

Next
Next

Week 5