Nina Yoo – Project 10 – Landscape

sketch

 /* Nina Lee Yoo
Section E
nyoo@andrew.cmu.edu
Project- 10:Landscape*/
var terrainSpeed = 0.0005;
var terrainDetail = 0.005;
var terrainDetailB = 0.0015;
var person = [];




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

  }
 
function draw() {
    background("pink");
   	
   	noStroke();
    push();
    beginShape();
    fill(176, 196, 222);
    vertex(0,height);



    for (var x = 0; x < width; x++) { // creating background of the first landscape
        var t = (x * terrainDetail) + (millis() * terrainSpeed);
        var y = map(noise(t), 0,1, 0, height);
        vertex(x, y+10); 
    }
    vertex(width,height);
    endShape();
    pop();

    push();
    beginShape();
    fill(250,250,205);
    vertex(0,height);
    for(var x = 0; x<width; x ++){ // creating backfround for the yellow landscape
    	var t = (.5*x*terrainDetailB)+ (millis()*terrainSpeed);
    	var y = map(noise(t),0,1,0,height);
    	vertex(x,y+200);

    }
    vertex(width,height);
    endShape();
    pop();

    //people
  
    push()
    updateP();
    removeP();
    addNewP(); 
    pop()
}


function updateP(){
    for (var i = 0; i < person.length; i++){
        person[i].move();
        person[i].display();
    }
}


function removeP(){

    var personToKeep = [];
    for (var i = 0; i < person.length; i++){
        if (person[i].x + person[i].breadth > 0) {
            personToKeep.push(person[i]);
        }
    }
    persons = personToKeep; 
}

function addNewP(){
   
    var newPerson = 0.01; 
    if (random(0,1) < newPerson) {
        person.push(makePerson(width));
    }
}


function personMove() {
    this.x += this.speed;
}
    

function personDisplay() {
	push()
    var personHeight = 20;
    var pHeight = this.nPersons * personHeight; 
    fill(255); 
    noStroke(); 
    push();
    translate(this.x, height - 40);
    ellipse(0, -pHeight, this.breadth, pHeight); // drawing the body
    fill(0);
    ellipse(-15, -pHeight - 20, 5, 5); // drawing eyes 
    ellipse(15, -pHeight - 20, 5, 5);

    stroke(200); 
    
    pop()
    }

 



function makePerson(birthLocationX) {
    var personn = {x: birthLocationX,
                breadth: 50,
                speed: -1.0,
                nPersons: round(random(2,8)),
                move: personMove,
                display: personDisplay}
    return personn;
}














I got inspired by this show I watched a long time ago with my brother. It was this weird cartoon blobs with little beady eyes that would just move from place to place in swarms, creating trouble along the way. It was fun to create the moving setting for the little guys and see the different little white marshmellow blobs come out.

Leave a Reply