This exercise is to exchange self-portrait code and share a meaningful memory or dream with our partner, then create an interactive sketch that illustrates the memory or dream within the self-portrait. I'm exchanging the self-portrait with my friend Leyla:) This image was originally created by Leyla herself. After listening to her story of studying away in Madrid and being inspired by the moon she put as decoration, I animated the picture.
I divided her memory into night and daytime. During the night, the moon is rising and Leyla's eyes are closed. If you click the mouse, she would only say "bye" in Spanish because she's asleep. During the daytime, the sun is rising instead and Leyla would say "Good morning" with eyes open haha. (hope I didn't get the word wrong)
The feedback I gained from Leyla regarding my work was that she really likes the details. The rising moon and sun make a lot of sense. The eyes opening and the Spanish part are very interesting.
To make the moon and sun move, I utilized what we learned in class:
Basic steps for using variables: create, assign a value; update; use.
Using conditionals to achieve the effect that the sun and the moon start going down after reaching the highest point.
Putting the speed of the movement as a variable as well, otherwise, it will get stuck at the point I want it to change directions because the conditions keep changing.
I encountered some difficulties because I wanted the turning point to be in the middle which means I have to use x to measure the positions that also affect y. Jiapei and I looked into the problem together and finally altered it back on the right track.
let moonx = 0;
let moony = 180;
let smoonx = 0.8;
let smoony = -0.5;
let sunx = 0;
let suny = 160;
let ssunx = 0.8;
let ssuny = -0.5;
...
moonx = moonx + smoonx
if (moonx > 200) {
moony = moony - smoony
} else {
moony = moony + smoony
}
...
if (moonx>400){
fill(250, 167, 32)
circle(sunx + 10, suny, 60)
sunx = sunx+ssunx
if (sunx > 200) {
suny = suny - ssuny
} else {
suny = suny + ssuny
}
...
It's very useful and common to have conditionals inside conditionals. I put "bye" under the condition of night while "good morning" under the condition of daytime.
Besides the two conditions divided by the sun and the moon, I also added "mouseIsPressed" as a boolean to control the occurrence of the conversation bubble.
text(), textSize().
I noticed that the position of the text will be affected by the utilization of the display of mouse position.
if (mouseIsPressed == true){
fill(255);
noStroke();
ellipse(310, 100, 130, 90);
fill(255);
noStroke();
ellipse(295, 150, 30, 18);
fill(255);
noStroke();
ellipse(270,160, 15, 10);
fill(0);
textSize(25);
text(' Adiós~ ', 260,110);
}
...
if (mouseIsPressed == true){
fill(255);
noStroke();
ellipse(310, 100, 130, 90);
fill(255);
noStroke();
ellipse(295, 150, 30, 18);
fill(255);
noStroke();
ellipse(270,160, 15, 10);
fill(0);
textSize(25);
text('¡Buenas! ', 260,110);
}
This is also simply done by putting different images of eyes under different conditions: day and night.
I used arc() to demonstrate closed eyes.
if (moonx>400){
...
noStroke()
fill(255); // white of the eyes
ellipse(170, 180, 30, 20); // left eye
ellipse(230, 180, 30, 20); // right eye
fill(0); // pupils
ellipse(170, 180, 18, 20); // left pupil
ellipse(230, 180, 18, 20); // right pupil
fill(255); //eye dimension
ellipse(174, 174, 8, 8); //left eye shine
ellipse(235, 175, 8, 8); //right eye shine
//left eyelashes
stroke(0);
line(157, 175, 153, 172)
line(160, 172, 158, 169)
line(165, 170, 164, 168)
//right eyelashes
stroke(0)
line(244, 176, 248, 172)
line(240, 173, 242, 170)
line(236, 171, 237, 169)
...
After we started to learn variables, conditionals, booleans, etc., the logic of codes became a lot more essential and obvious. For me, it felt very helpful to go through the process in the order that the computer would conduct. It often takes a lot of patience and a "light bulb" moment but the logic is always very persuasive and always understandable. So I really like it.
I like how we are able to create interactions through the keyboard and mouse after learning conditionals. I tried it in the last recitation and it became clearer now after the systematic explanations towards the language of the keyboard and the mouse (keycode, etc).
Regarding the difficulty I encountered while trying to change the motion of the object, I realized that the conditions can change all the time and that might cause the object to jump between two instructions all the time. This is what I need to consider when making two related conditionals.
Instead of a lesson, it remains a question that I hope I'll be able to solve in the future: I don't like how the shape "bounces" back from the top which isn't the smooth motion I want.
Another concern is that without instructions, I believe it's hard for viewers to realize that they can make interactions through the mouse. But I didn't choose to add any instructions language wise because I prefer to leave the space for explorations haha.