Halloween Witch

edited November 2014 in Share Your Work
float skyX=0;
float skyY=0;
float skyW=600;
float skyH=150;
float sunX=500;
float sunY=50;
float sunW=75;
float sunH=75;
float dx=1;
float moonX=250;
float moonY=70;
float moonW=75;
float moonH=75;
float witchx=590;
float witchy=50;
float witchw=60;
float witchh=20;
int broomX =80;
int spacing =12;
int broomLen =40;

boolean click = false;


void setup() {
  size(600, 500);
}


void draw() {
  background(3, 255, 80);
  clicked();
  // stageNight(skyX, skyY, skyW, skyH);
}

///////// Day ///////////

void stageDay(float skyX, float skyY, float skyW, float skyH) {

  // sky color and layout
  fill(192, 221, 250);  // Set fill to Light blue
  noStroke();
  rect(skyX, skyY, skyW, skyH);

  //sun body
  strokeWeight(1);
  stroke(0);
  ellipseMode(CENTER);  // Set ellipseMode to CENTER
  fill(255, 243, 3);  // Set fill to yellow
  ellipse(sunX, sunY, sunW, sunH);  // Draw ellipse using CENTER mode
}

///////// night ///////////

void stageNight(float skyX, float skyY, float skyW, float skyH) {
  // sky color and layout
  fill(3, 185, 255);  // Set fill to Light blue
  noStroke();
  rect(skyX, skyY, skyW, skyH);

  //moon body
  strokeWeight(1);
  stroke(0);
  ellipseMode(CENTER);  // Set ellipseMode to CENTER
  fill(245, 220, 237);  // Set fill to yellow
  ellipse(moonX, moonY, moonW, moonH);  // Draw ellipse using CENTER mode

  witch(witchx, witchy, witchw, witchh);
  moveWitch();
}

///////// witch body///////////

void witch(float witchx, float witchy, 
float witchw, float witchh) {
  //head
  strokeWeight(1);
  stroke(0);
  fill(255, 0, 0);
  ellipseMode(CENTER);  // Set ellipseMode to CENTER
  ellipse(witchx-48, witchy+20, witchw-20, witchh+20);  // Draw ellipse using CENTER mode

  //hat
  fill(0);  // Set to black
  noStroke();
  triangle( witchx-35, witchy, witchx+10-witchw, witchy-witchh-5, witchx-witchw, witchy-18+witchh);
  rect(witchx-80, witchy, 70, 10);  // Draw rect

  //leg2
  stroke(70, 191, 19);  // Set to d green
  strokeWeight(10);
  line(witchx-40, witchy+100, witchx-70, witchy+175); 

  //body
  fill(252, 185, 48);  // Set to brown
  noStroke();
  rect(witchx-85, witchy+41, 70, 90);  // Draw rect

  //broom
  stroke(185, 131, 13);  // Set to d green
  strokeWeight(10);
  line(witchx-125, witchy+135, witchx+40, witchy+135);
  line(witchx+40, witchy+100, witchx+40, witchy+170);

  //broom lines for loop
  for (int broomY=150; broomY<=225; broomY+=spacing) {
    strokeWeight(3);  
    line(witchx+40, broomY, witchx+40+broomLen, broomY);
  }

  //leg1
  stroke(70, 191, 19);  // Set to d green
  strokeWeight(10);
  line(witchx-40, witchy+120, witchx-40, witchy+200);
}

///////// move witch ///////////


void moveWitch() {
  // normal movement of the Witch From right to left
  if (witchx>width) witchx=0;
  {
    witchx = witchx-dx;//take dx and -1 untill 0 then run the next if
  }
  if (witchx <= -100) {
    witchx=600;// sets this back to 600 so witch can fly from the right
  }
}

///////// click witch ///////////


void mouseClicked () {
  if ( (mouseX > witchx-125) && (mouseX < witchx + 225 ) && 
    (mouseY > witchy) && (mouseY < witchy + 200) ) {
    click = !click;
  }
  // clicked ();
}

void clicked () {
  if (click) {
    stageDay(skyX, skyY, skyW, skyH);
  }
  else {
    stageNight(skyX, skyY, skyW, skyH);
  }
}

//

Comments

Sign In or Register to comment.