Project-03-sjahania

sketch

var skyColor = 150;
var sunY = 50;
var lightsOn = false;
var starsX = 100
var starsY = 320


function setup() {
    createCanvas(640, 480);
    background(0, skyColor,255);
}

function draw() {

	//sky color
	strokeWeight(1);
	var skyColor = mouseX/(640/225);
	background(0, 225 - skyColor, 225);
	
	//sun
	fill(255,228,0);
	ellipse(2*mouseX, sunY + (.2*mouseX), 80, 80);

	//moon
	fill(219,220,226);
	var moonY = 2*(-mouseX+480)
	if (moonY < 80) {
		moonY = 80;
	}
	arc(width/2, moonY, 80, 80, HALF_PI, PI + HALF_PI, CHORD);

	//stars
	fill(219,220,226);
	strokeWeight(10);
	if (mouseX > 400) {
		starsX = random(0,640);
		starsY = random(0,100);
		point(starsX,starsY);
	}


	//grass
	strokeWeight(1);
	var grassColor = mouseX/(640/177);
	noStroke();
	fill(0, 177 - grassColor, 0);
	rect(0, 420, 640, 60);


	//house
		//house part
	fill(165, 0, 0);
	rect(400, 270, 175, 180);

		//roof part
	fill(0);
	triangle(350,270,487,200,625,270);

		//door
	fill(0);
	arc(487,450,40,150,PI, TWO_PI)

		//door handle
	fill(255,228,0);
	ellipse(500,430,10,10);

		//window color
	if (lightsOn == true) {
		fill(255,228,0);
	} else {
		fill(0);
	}

		//windows
	ellipse(487,300,30,30);
	rect(430,320,40,40);
	rect(505,320,40,40);
	stroke(0);
	line(525,320,525,360);
	line(450,320,450,360);
	line(505,340,545,340);
	line(430,340,470,340);



}

function mousePressed() {
	if (lightsOn == true) {
		lightsOn = false;
	} else {
		lightsOn = true;
	}
}

I had trouble coming up with an idea, so I settled for something easy because I’m artistically challenged. The sun and moon set and rise respectively when the mouse goes left to right, the colors change, the house lights turn on with a mouse click, and the stars come out when it’s dark.

Leave a Reply