//Introducing Dr. Zoidberg, the Cross Dressing Robot! //Let Him/Her bounce around your window! //Code written by Zachary Semcken, assisted by BAM. void setup() { //Initializes Sketch. size(750,750); //Sets size of window. smooth(); //Keeps the annimation smooth. } boolean SEX; //Sets boolean variable to change sex. float sX= 650; //Sets X position of the Sun float sDX= -2; //Sets horizontal velocity of the Sun. float mX=0, mY=0, mDX=5, mDY=3; //Sets X and Y position and velocity of Dr. Zoidberg. float bX, bY; //Sets position of Bomb. float bV=0; //Sets velocity of Bomb float bA=9.81 / 30; //Sets acceleration of Bomb. void drawScene() { //Creates the drawScene variable. background(0,175,255); //Creates the sky. text("Press X to transform Dr. Zoidberg!",10,35); //Change the sex of Dr. Zoidberg. smooth(); //Keeps the annimation smooth. rectMode(CORNER); //Sets rectangle mode. fill(0,255,100); //Sets fill color for grass. stroke(0); //Sets outline color for grass. rect(0,height-height/10,width,height); //Draws the grass. sX += sDX; //Time to move the sun. if (sX<100 || sX>width-100) sDX= -sDX; //Sets Sun's borders for bounces. ellipseMode(CENTER); //Sets Ellipse mode to Center. fill(255,255,0); //Sets fill color for the Sun. stroke(255,150,0); //Sets outline color for the Sun ellipse(sX,100,80,80); //Draws the Sun. } void mousePressed() { //Alters the location and sex of Dr. Zoidberg. SEX= false; //Changes boolean value of SEX variable. mX= mouseX; //Moves Dr. Zoidberg to mouse's horizontal position. mY= mouseY; //Moves Dr. Zoidberg to mouse's vertical position. } void keyPressed() { //Use of specific keys to alter the scene. SEX= false; //Changes boolean value of SEX variable. if (key == 'x') SEX=!SEX; //Changes sex of Dr. Zoidberg. if (key == 'b') {bY=0;bV=0;} //Resets bomb coordinates. } void dropBomb() { //Creates dropBomb method to .. DROP A BOMB!?! fill(0,0,255); //Sets the internal color of the bomb. bX= mouseX; //Makes the bomb follow the mouse in the horizontal. ellipse(bX,bY,30,50); //Draws the ellipse with variables. bY += bV; //Sets the bomb in motion. bV += bA; //Gives the bomb acceleration. } void moveZoidberg() { //Time to move Dr. Zoidberg! mX -= mDX; //Sets horizontal function for movement. if (mX<0 || mX>width) { //Sets parameters for horizontal motion to stop at the window's edge. mDX= -mDX; //Negates the velocity (Reverses it). SEX= !SEX; //Changes the sex of Dr. Zoidberg upon "impact". } mY -= mDY; //Sets vertical function for movement. if (mY<0 || mY>width-150) { //Sets parameters for vertical motion to stop at the window's edge. mDY= -mDY; //Negates the velocity (Reverses it). SEX= !SEX; //Changes the sex of Dr. Zoidberg upon "impact". } } void drawMrs() { ellipseMode(CENTER); //Sets ellipse mode. fill(150,150,255); //Sets fill color for the head. stroke(0); //Sets outline color for the head. ellipse(mX,mY,50,50); //Draws the head. fill(0); //Sets eye color. stroke(0); //Sets eye liner. ellipse(mX-10,mY-10,10,10); //Draws left eye. ellipse(mX+10,mY-10,10,10); //Draws right eye. arc(mX,mY+15,30,30,PI,2*PI); //Draws Mrs. Zoidberg's frown. fill(255,0,255); //Sets fill color for the body. stroke(0); //Sets outline color for the body. triangle(mX,mY+25,mX-25,mY+125,mX+25,mY+125); //Draws the body. stroke(0); //Sets arm and leg color. line(mX-8,mY+50,mX-50,mY+100); //Mrs. Zoidberg's Left Arm. line(mX+8,mY+50,mX+50,mY+100); //Mrs. Zoidberg's Right Arm. line(mX-14,mY+125,mX-25,mY+150); //Mrs. Zoidberg's Left Leg. line(mX+13,mY+125,mX+25,mY+150); //Mrs. Zoidberg's Right Leg. fill(255); //Puts Mrs. Zoidberg's title in white. text("Mrs. Zoidberg",mX-40,mY-35); //Draw's Mrs. Zoidberg's title. } void drawMr() { ellipseMode(CENTER); //Sets ellipse mode. fill(255); //Sets fill color for the head. stroke(0); //Sets outline color for the head. ellipse(mX,mY,50,50); //Draws the head. fill(255,0,100); //Sets eye color. stroke(255,0,100); //Sets eye liner. ellipse(mX-10,mY-10,10,10); //Draws left eye. ellipse(mX+10,mY-10,10,10); //Draws right eye. arc(mX,mY+5,30,30,0,PI); //Draws Mr. Zoidberg's smile. rectMode(CENTER); //Sets body to the center. fill(255,0,0); //Sets fill color for the body. stroke(0); //Sets outline color for the body. rect(mX,mY+75,30,80); //Draws the body. stroke(0); //Sets arm and leg color. line(mX-15,mY+50,mX-30,mY+100); //Mr. Zoidberg's Left Arm. line(mX+15,mY+50,mX+30,mY+100); //Mr. Zoidberg's Right Arm. line(mX-15,mY+115,mX-25,mY+140); //Mr. Zoidberg's Left Leg. line(mX+15,mY+115,mX+25,mY+140); //Mr. Zoidberg's Right Leg. fill(255); //Puts Mr. Zoidberg's title in white. text("Mr. Zoidberg",mX-35,mY-35); //Draw's Mr. Zoidberg's title. } void draw() { //Time to actually draw the sketch! drawScene(); //Sets the scenery. moveZoidberg(); //Calls the moveZoidberg method. if (key == 'b') dropBomb(); //Calls the dropBomb method when the key, "b" is pressed. if (SEX) drawMr(); //Initializes drawMr() method. else drawMrs(); //Defers drawMr() method to drawMrs() method. }