# Project 10 Landscape- Sara Frankel

``````// Sara Frankel
// sfrankel
// Project 10
// Section A

var speed = 0.00025;
var detail = 0.001;
var sheeps = new Array(480);
var numNoDraw = 0;
var clouds = new Array(480);
var numNoDrawC = 0;
var cloudY = new Array(12);
var cloudCount2 = 0;
var sheepcolors = new Array(12);
var colorCount = 0;
var herderURL;
var sheepStatus;

}

function setup() {
createCanvas(480, 400);
frameRate(10);
}

function draw() {
background('lightblue');
//____________________________________________

if(sheeps) {
shiftLeft(sheepcolors);//inserts random colors from array and shifts it over so that the value is not the same everytime
//(makes sure the x point of the object moves with the point)
colorCount--;
}
shiftLeft(sheeps);//
if(numNoDraw === 0) {
sheeps = (random(0, 1) <= 0.05);//using a random 5% chance the sheep will be on the point
} else {
sheeps = false;//there will be no sheep directly after
numNoDraw--;
}
if(sheeps) {
sheepcolors[colorCount] = random(0, 255); //each sheep will have a different random grey scale color
if (colorCount === 11) {
} else {
colorCount++;
}
numNoDraw = 40;//there will be no sheeps every 40 pixels
}
//____________________________________________

if(clouds) {
shiftLeft(cloudY); //shifts cloud to the left so that the object moves with the x point change
cloudCount2--;
}

shiftLeft(clouds);
clouds = false;//shift left and ensures last is set to default value (false)
if(numNoDrawC === 0) {
clouds = random(0,1) <= 0.01; //probility of if the cloud will be on the sreen in a specific point
} else {
numNoDrawC--;
}
if(clouds) {
numNoDrawC = 40;
cloudY[cloudCount2] = random(150,250); //randomly positions clouds between y points 150-250
if(cloudCount2 === 12){ //there cannot be more than 12 clouds (each cloud must be spaced at least 40 pixels from the last)
} else {
cloudCount2++;//increases number of clouds
}
}

//______________________________________________

noFill();
beginShape();
var cloudCount = 0;
var sheepCount = 0;
for (var i = 0; i < width; i++) {
var j = (i * speed) + (millis() * speed);
var y = map(noise(j), 0, 1, height/2, height);//utilizes noise function
vertex(i, y);
stroke('green');
line(i, y, i, height);

if(sheeps[i]) {
sheep(i,y - 5, sheepcolors[sheepCount]);//places sheep on positions of the noise
sheepCount++; //increases sheep count
}

if(clouds[i]) {
cloud(i, y - cloudY[cloudCount]);//places clouds in position relative to noise
cloudCount++;//increase cloud count
}

image(herderURL, 350, y + 30, 60, 60);//puts sheep herder on screen
}
endShape();
}

//draws sheep at given x, y coordinate and given face color
function sheep(x, y, col) {
beginShape();
stroke(255);
fill(255);
ellipse(x, y, 10, 10);
ellipse(x + 5, y + 5, 10, 10);
ellipse(x + 10, y + 5, 10, 10);
ellipse(x + 15, y, 10, 10);
ellipse(x + 10, y - 5, 10, 10);
ellipse(x + 5, y - 5, 10, 10);
fill(col);
ellipse(x - 5, y, 10, 10);
fill(255);
endShape();
}

//draws clouds at given cx and cy
function cloud(cx, cy) {
beginShape();
stroke(255);
fill(255);
ellipse(cx, cy, 20, 20);
ellipse(cx + 10, cy + 9, 20, 20);
ellipse(cx + 20, cy + 9, 20, 20);
ellipse(cx + 30, cy, 20, 20);
ellipse(cx + 20, cy - 9, 20, 20);
ellipse(cx + 10, cy - 9, 20, 20);
endShape();
}

//uses for loop to help shift an array over so that you never reach the "end" of it
function shiftLeft(array){
for(var r = 0; r < array.length - 1; r++) {
try {
array[r] = array[r+1];
} catch(e) {
}
}
}``````

For my project, I decided that Shepard and their sheep was quite fitting. At first I was uncertain on how I will execute this project. I found that using an image for the Shepard and a cute little drawn image of the sheep would be quite fitting. Nothing would also be fluffier than white random clouds that go with it. Especially with the pain of this previous week, I felt that something calmer like “counting sheep” would be best. ^ Image of my original sketch