Code Play character (assignment 01)

Screen shot 2013-02-05 at 1.37.33 PM

//x, y position of the creature
float cx, cy;

void setup(){
size(700,700);
background(100);
smooth();

cx = width/2;
cy = height/2;
}

void draw(){

noStroke();
fill(25);
ellipse(cx, cy, 400, 400);

//eyes
fill(225);
ellipse(cx-150, cy-150, 125, 125);
ellipse(cx+150, cy-150, 125, 125);

fill(25);
ellipse(cx-150, cy-150, 75, 75);
ellipse(cx+150, cy-150, 75, 75);

fill(255);
ellipse(cx-175, cy-175, 50, 50);
ellipse(cx+175, cy-175, 50, 50);

//limbs
fill(25);
pushMatrix();
translate(cx, cy+175);
triangle(-50, 0, 0, 125, 50, 0);
popMatrix();

pushMatrix();
translate(cx+100, cy+125);
rotate(radians(-45));
triangle(-50, 0, 0, 125, 50, 0);
popMatrix();

pushMatrix();
translate(cx-100, cy+125);
rotate(radians(45));
triangle(-50, 0, 0, 125, 50, 0);
popMatrix();

//face
fill(175);
ellipse(cx, cy+50, 250, 250);

//mouth
fill(0);
pushMatrix();
translate(cx, cy+125);
ellipse(0,0,50,50);
popMatrix();

//eyes
fill(0);
pushMatrix();
translate(cx-85, cy);
rotate(radians(45));
rect(0, 0, 100, 25);
rotate(radians(-45));
translate(-20, 70);
rotate(radians(-45));
rect(0, 0, 100, 25);
popMatrix();

pushMatrix();
translate(cx+35, cy);
rotate(radians(45));
rect(0, 0, 100, 25);
rotate(radians(-45));
translate(-20, 70);
rotate(radians(-45));
rect(0, 0, 100, 25);
popMatrix();

}

Advertisements

Your thoughts

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s