Sheenu-Project 10-Generative Landscape

``````//Sheenu You
//Section E
//sheenuy@andrew.cmu.edu
//Project-10
var tspeed=0.0001
var td=.0005
var signs = [];
var carcar ="https://i.imgur.com/2n8J78A.png";

}
function setup() {
createCanvas(480, 480);
background(248,177,149);
for (var i = 0; i < 10; i++){
signs[i]=makesigns();
}
}
function draw() {
background(248,177,149);
fill(246,114,128);
noStroke();
beginShape();
//Terrain
for (var x = 0; x < width; x++) {
var t = (x * td) + (millis() * tspeed);
var y = map(noise(t), 0,1, 0, height);
vertex(x, y);
vertex(0,250)
vertex(480,250)
}
endShape();
rectMode(CORNERS)
//Ground
fill(246,114,128);
rect(0,250,480,480)
fill(192,108,132)
rect(0,270,480,480)
//Draw Sticks
removesigns();
//Draw Ground again
fill(108,91,123)
rect(0,290,480,480)
fill(53,92,125)
rect(0,320,480,480)
//Car
image(car,130,247,210,75)
}
//Sticks
//Make signs move or grow
for (var i=0;i<signs.length;i++){
signs[i].move();
signs[i].display();
}
}
//Remove signs when they come to the end
function removesigns(){
var signstokeep =[];
for (var i=0;i<signs.length;i++){
signstokeep.push(signs[i]);
}
}
signs=signstokeep;
}
//Generate the signs
var newsignchance=.1;
if(random(0,1)<newsignchance){
signs.push(makesigns(width));
}
}
//Make signs move
function signsmove(){
this.x-=15
}
//Draw one sign
function signdisplay(){
var floorHeight = 20;
var bHeight = this.nFloors * floorHeight;
fill(255);
push();
translate(this.x, height - 40);
fill(108,91,123)
rect(0, -bHeight-200, 7, bHeight);
stroke(200);
pop();
}
//Generate signs at a certain location
function makesigns(birthLocationX) {
var sgn={x: birthLocationX,
speed: -1.0,
nFloors: round(random(2,8)),
move: signsmove,
display: signdisplay}
return sgn;
}
``````

I sometimes think about the times when me and my family go on vacation for a road trip and take a drive on the road. I would always be the one looking through the side window; observing all the cars, the signs, the billboards, and the nature around us. I always found the background around us fascinating and ephemeral moments that zoom past my sight of vision within seconds. This is why I chose to make this a car driving by mountains and sticks on a road. I used a color palette to distinguish depth in the background and also color objects such as mountains, sticks, walls, and the car itself. I used the building generation template and the mountain generation template as a reference.

Preliminary drawing made on MS Paint

Choo choo