/* built with Studio Sketchpad:
* https://sketchpad.cc
*
* observe the evolution of this sketch:
* https://studio.sketchpad.cc/sp/pad/view/ro.0jsmVkoqMr$/rev.214
*
* authors:
* Daewon Lee
* 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, "creature falling", created by Daewon Lee
// http://studio.sketchpad.cc/sp/pad/view/ro.9jutG3fApkwA3/rev.198
// This sketch builds on a prior work, "creature", created by Daewon Lee
// http://studio.sketchpad.cc/sp/pad/view/ro.91is$VPe9teRL/rev.636
float y=320;
float x=100;
float speed=10;
void setup() { // this is run once.
// set the background color
background(255);
// canvas size (Variable aren't evaluated. Integers only, please.)
size(300, 300);
// smooth edges
smooth();
// limit the number of frames per second
frameRate(30);
// set the width of the line.
strokeWeight(3);
}
void draw() { // this is run repeatedly.
//background(255);
ellipseMode(CENTER);
rectMode(CENTER);
//partially erase background
fill(255,255,255,65);
rect(150,150,300,300);
//x = mouseX + 100;
//y = mouseY + 100;
//body
stroke(0);
fill(150);
rect(x,y,20,100);
//head
stroke(0);
fill(255);
ellipse(x,y-30,60,60);
//eyes
fill(0);
ellipse(x-19,y-30,16,32);
ellipse(x+19,y-30,16,32);
//legs
stroke(0);
line(x-10,y+50,x-20,y+60);
line(x+10,y+50,x+20,y+60);
//y = y+speed;
float height=132;
if (y>300 - height / 2)
{
y = 300 - height / 2;
speed = -speed;
}
if (y<0 + height / 2)
{
y = 0 + height / 2;
speed = -speed;
}
y=y+speed;
}
void mousePressed()
{
x=mouseX;
y=mouseY;
}