/*PCS halloween scene base code - Fall 2015 - ZJ Wood */ void draw() { background(128); /* TODO add as many pumpkins, bats, witches, or stars */ /* you can control where they are in {x, y} by changing the numbers */ /* for example to draw a pumpkin at {200, 200) */ drawPumpkin(200, 200); drawBat(400, 200); /* You can add more, by writing the function with different locations */ drawStar(400, 350); drawStar(200, 350); /* For any one object you want to move, use moveX, move Y - like this*/ drawWitch(moveX, moveY); /*You can also draw any shapes you want here */ /* try drawing a ghost */ /* DO NOT EDIT THESE */ moveX = moveX + 1; moveY = moveY -1; } /**** example loop: for(int i=0; i < 5; i++) { drawPumpkin(random(0, width), random(500, 800)); } ******/ float moveX, moveY; void setup() { size(800, 800); moveX = 0; moveY = height; } void mousePressed() { moveX = 0; moveY = height; } void drawStar(float sx, float sy) { float radi; fill(250, 150, 0); beginShape(); for (int i =0; i < 360; i+=35) { if (i%2 == 0) { radi = 20; } else { radi = 40; } vertex(sx + radi*cos(radians(i)), sy+radi*sin(radians(i))); } endShape(CLOSE); } void drawBat(float posX, float posY) { fill(0); triangle(posX, posY, posX+8, posY-30, posX+16, posY); triangle(posX, posY, posX-8, posY-30, posX-16, posY); ellipse(posX, posY, 40, 40); triangle(posX, posY, posX+70, posY-30, posX+130, posY); triangle(posX, posY, posX-130, posY, posX-70, posY-30); fill(255); ellipse(posX-5, posY-5, 10, 10); ellipse(posX+5, posY-5, 10, 10); fill(0); ellipse(posX-5, posY-5, 2, 2); ellipse(posX+5, posY-5, 2, 2); } void drawPumpkin(float tx, float ty) { fill(219, 146, 35); ellipse(tx, ty, 60, 50); fill(36, 118, 12); rect(tx-5, ty-40, 10, 20); } //function to draw the witch void drawWitch(float wx, float wy) { pushMatrix(); translate(wx, wy); scale(2); fill(0); //the body ellipse(0, 0, 10, 20); ellipse(0, -15, 10, 10); //legs ellipse(9, 7, 11, 4); ellipse(12, 12, 4, 11); //the hat triangle(-10, -20, 0, -35, 10, -20); //the broom strokeWeight(6); line(25, -20, -10, 20); quad(-18, 30, -11, 18, -7, 21, -12, 34); popMatrix(); strokeWeight(1); }