I’ve never used Processing before, but I’ve found I like it so far with the first assignment and the things we’ve begun to do in class. Learning how to create the sketches and then making one based on a drawing was a little fussy and tedious, but I’m happy with the results!
I sketched out a cute little robot on paper for my design before moving to Processing.
He came out pretty good! I primarily used CENTER mode for the ellipses and rectangles that I drew, first getting the shape and color correct and then moving it into position, which worked out well!
I’ll continue to update this blog post with the iterations I make on this for the next assignment. I had a lot of fun in class today playing with variables and colors, so I’ll try to work in the various “challenges” in some interesting ways!
Quick update, here’s my first new iteration on the robot – now with dynamic colors and moving eyes! Try clicking on him, too!
Edit 2: Here’s another iteration, working on completing the challenges all within this sketch.
In addition to dynamic eyes and colors based on mouse location, and eyebrow movement based on mousepress, you can use the keys R,O,Y,G,B,I and V to change the color of the robot’s square front panel!
Here’s what I’ve done so far for each of the challenges:
Challenge 1: I’ve been using variables instead of hard-coding values into the sketch. This came in useful when centering the design, where I was able to use ‘width/2’ and ‘height/2’ instead of the numerical pixel values of the locations I wanted. Additionally, for the movement of the eyes, I used an if statement and looked for the location of the mouse based on thirds; if the mouse is in the left third of the screen, the eyes look left; in the center third, the eyes are centered; finally, in the right third, the eyes are drawn looking right! This is also how the up and down movements of the eyes were coded.
Challenge 2: I declared my own variables to create the key-press activated color changing for the robot’s square panel. I declared rColor, bColor, and gColor at the beginning of the sketch with initial values of 255 (when you start the sketch you can see the panel is white.) Then, I used if-statements to figure out which key was being pressed, and assigned new values to rColor, bColor and gColor depending on which letter was pressed so that when the rectangle is drawn, it changes color and stays changed, not just changing when the specific key is pressed.
Challenge 3: The eyes and colors of the robot are dependent on the mouseX and mouseY, the eyebrows are dynamic with mouse presses, and the square panel is dynamic depending on specific key presses.
Challenge 4: All of the above use logic, including IF, AND, OR, ELSE, and ELSE IF.
I’ll continue to work on playing with the sketch to work in more logic to get more familiar with the different conditional logic concepts soon!