/* built with Studio Sketchpad:
* https://sketchpad.cc
*
* observe the evolution of this sketch:
* https://bard117f12.sketchpad.cc/sp/pad/view/ro.FtGLIH2klDJ/rev.11
*
* authors:
* Diana Ruggiero
* license (unless otherwise specified):
* creative commons attribution-share alike 3.0 license.
* https://creativecommons.org/licenses/by-sa/3.0/
*/
// This sketch builds on a prior work, "Untitled Sketch", created by Diana Ruggiero
// http://bard117f12.sketchpad.cc/sp/pad/view/ro.6n2lM5boFRTrIr/rev.5
/*Diana Ruggiero-September 23 [email protected]
This program makes the cool kid in the party hat fly to the top
of the screen when you press a key. When they get to the top, they
come back down and stop at the bottom. The eyes also follow the mouse.
In addiion, the arms move when the key is pressed.
*/
/* This self-portrait is very different from my designblocks projcet,
as this one is dynamic (whereas my designblocks was static). Also, this sketch
contains color. I found the process of programming this sketch much less frustrating
when compared to designblocks, which felt clunky in comparison.*/
float headY = 330;
float bodyY = 405;
float mouthY = 400;
float armsY1 = 420;
float armsY2 = 490;
float armbendX1= 180;
float armbendX2= 450;
float legsY1 = 550;
float legsY2= 600;
float eyesY= 350;
float hatX=300;
//movement variables
float movement=0;
float armMovement=0;
void setup(){
size (600,600);
smooth();
strokeWeight(4);
}
void keyPressed(){
movement = 2;
armMovement=1.1;
}
void draw(){
background (255);
//body
fill(19, 147, 41);
rect (238, bodyY, 130, 145);
//head
fill(247,199,95);
ellipse (300, headY, 200, 200);
//eyes
fill(255);
ellipse (250, eyesY, 40, 40);
ellipse (345, eyesY, 40, 40);
//pupils
strokeWeight(6);
fill(57,40,4);
ellipse (constrain(mouseX, 244, 257), constrain(mouseY, eyesY-6, eyesY+6), 20, 20);
ellipse (constrain (mouseX, 338, 352), constrain(mouseY, eyesY-6, eyesY+6), 20, 20);
strokeWeight(4);
//mouth
noFill();
curve(260, mouthY-50, 260, mouthY, 340, mouthY, 340, mouthY-50);
//legs
noFill();
curve(260, legsY1, 260, legsY1, 260, legsY2, 260, legsY2);
curve(340, legsY1, 340, legsY1, 340, legsY2, 340, legsY2);
//arms
curve (238, armsY1, 238, armsY1, 215, armsY2, armbendX1, armsY2);
curve (368, armsY1, 368, armsY1, 390, armsY2, armbendX2, armsY2);
//hat
fill(255, 50, 50);
triangle(180, hatX, 420, hatX, 300, hatX-190);
fill(0);
textSize(10);
text("nosecose/party hat", 250, hatX-70);
//instructions
textSize(30);
text("Move your mouse to move my eyes!", 55, 520);
text("Press a key to make me fly!", 130, 50);
//stuff that happens when key is pressed
headY= headY-movement;
bodyY= bodyY-movement;
armsY1= armsY1-movement;
armsY2= armsY2-movement;
legsY1= legsY1-movement;
legsY2= legsY2-movement;
mouthY= mouthY-movement;
eyesY= eyesY-movement;
hatX= hatX-movement;
armbendX1= armbendX1+armMovement;
armbendX2= armbendX2-armMovement;
//when it goes up top
if(headY==-300){
movement=-2;
armMovement=-1.1;
}
//when it hits the bottom again
if(legsY2==600){
movement=0;
armMovement=0;
}
}