Project – 06

sketch
//Shaun Murray, Section B

var x
var y
var cDisPos = 0
var cDisNeg = 0


function setup() {
    createCanvas(480, 480);
}

function draw() {
	background(0, 200 , 255);

	//ground
	push();
	noStroke();
	fill(0, 150, 50);
	rect(x, y + 145, width, 180);
	fill('Brown');
	rect(x, y + 150, width, 180);
	pop();

	x = width/2
	y = height/2

	//cloud
	push();
    translate(cDisPos, y - 100);
    cloud(0, );
    cDisPos += 1
    if (cDisPos > width + 50) {
    	cDisPos = -50
    }
    pop();

    push();
    translate(cDisNeg, y);
    cloud(0, 0);
    cDisNeg -= 1
    if (cDisNeg < -width) {
    	cDisNeg = width
    }
    pop();

	//pipes
	pipe(x , y + 45);
	pipe(x - 150, y + 45);
	pipe(x + 150, y + 45);

    //stars
	push();
    translate(width * 0.813, height * .15 + second() * 6.8); //6.8 is the scale for seconds on the Y axis of 'pipe'
    rotate(frameCount / 50);
    star(0, 0, 13, 26, 5);

    //eyes
    rotate(radians(50));
    fill(1);
    ellipse(-5, 0, 3, 10);
    ellipse(5, 0, 3, 10);
    pop();

    push();
    translate(width * 0.5, height * .15 + minute() * 6.8);//6.8 is the scale for minutes on the Y axis of 'pipe'
    rotate(frameCount / 50);
    star(0, 0, 13, 26, 5);

    //eyes
    fill(1);
    rotate(radians(50));
    ellipse(-5, 0, 3, 10);
    ellipse(5, 0, 3, 10);
    pop();

    push();
    translate(width * 0.19, height * .15 + hour() * 17);//17 is the scale for hours on the Y axis of 'pipe'
    rotate(frameCount / 50);
    star(0, 0, 13, 26, 5);

    //eyes
    rotate(radians(50));
    fill(1);
    ellipse(-5, 0, 3, 10);
    ellipse(5, 0, 3, 10);
    pop();


    
}


function pipe(x, y) {
	
	rectMode(CENTER);
	push();
	translate(x, y);
	fill(0, 255, 50);
	rect(0, 0, 75, height);
	fill('Green');
	rect(0, 0, 50, height);
    fill(0, 200, 50);
    stroke(1);
    rect(0, -250, 90, 30);
    fill(0, 200, 150);
    noStroke();
    rect(-25, -250, 20, 28);
	pop();
}

function star(x, y, rad1, rad2, points) {
  let angle = TWO_PI / points;
  let halfAngle = angle / 2;
  beginShape();
  fill(255, 255, 0);
  for (let a = 0; a < TWO_PI; a += angle) {
    let sx = x + cos(a) * rad2;
    let sy = y + sin(a) * rad2;
    vertex(sx, sy);
    sx = x + cos(a + halfAngle) * rad1;
    sy = y + sin(a + halfAngle) * rad1;
    vertex(sx, sy);

  }
  endShape(CLOSE);
}


function cloud(x, y) {
	push();
    translate(x, y);

    //cloud 
	noStroke();
	fill(255);
	ellipse(-5, -17, 43, 43);
	fill(245);
	ellipse(-3, -15, 40, 40);
	//eyes
	fill(1);
	ellipse(-10, -25, 3, 10);
	ellipse(0, -25, 3, 10);

	fill(255);
	ellipse(18, -12, 30, 30);
	fill(245);
	ellipse(20, -10, 27, 27);

	fill(255);
    ellipse(-20, -9, 25, 23);
    fill(245);
    ellipse(-17, -6, 23, 20);

	fill(255);
	ellipse(0, 0, 80, 10);
	fill(245);
    ellipse(5, 1, 75, 8);

    pop();

}

Super Clock World. The pipes represent hour, minute, and second.

Leave a Reply