Project 11- Landscape

sketch
var peakvalue = [];
var noiseParam = 0;
var noiseStep = 0.005;
var x = [];
var y = [];
var dx = [];
var dx1 = 0;
var c = [];
var seacoralshape = 0.002;
var seacoralspeed = 0.005


function preload(){
  cloud = loadImage("https://i.imgur.com/ZtLcxL9.png");
}



function setup() {
  createCanvas(400, 400);
  for (var i = 0; i <=width/5; i++) {
    var n = noise(noiseParam);
    var value = map(n, 0, 1, 300, height);
    peakvalue.push(value);
    noiseParam += noiseStep;
  }

   for (var i=0; i<50; i++){
      x[i]= random(10, width-10);
      y[i] = random(250, 400);
      dx[i] = random(-5,-1);
      c[i] = color(random(255),255,240);
    }
}

function draw() {

  background(251, 164, 153);
  fill(246, 189, 192);
  ellipse(200,200,320,320);
  fill(241, 149, 155);
  ellipse(200,200,290,290);
  fill(240, 116, 112);
  ellipse(200,200, 260);
  fill(234, 76, 70);
  ellipse(200,200,230,230);
  fill(220, 28, 19);
  ellipse(200,200, 200,200);
  seacoral();
  cloud.resize(70,0);
  tint(255,127);
  image(cloud, -250 + dx1, 40);
  image(cloud, -100 +dx1, 100);
  image(cloud, 180 + dx1, 40);
  image(cloud, 20 + dx1, 30);
  image(cloud, 100 + dx1, 100);
  image(cloud, 300 + dx1, 100);
  dx1 += 0.5;
  peakvalue.shift();
  var n2 = noise(noiseParam);
    var value = map(n2, 0, 1, 0, height*1.5);
    peakvalue.push(value);
    noiseParam += noiseStep;

  beginShape();
  vertex(0, height);
  for (var i = 0; i <= width/5; i++) {
    fill(102, 179, 255);
  noStroke();
    vertex(i*5, peakvalue[i]);
    
  }
  vertex(width, height);
   endShape(); 

    for (i = 0; i<50; i++){
      if(x[i] < -30){
        x[i] = 450
      }
      fish(x[i], y[i], dx[i],c[i]);
      x[i] += dx[i]
  }
  frameRate(10);

}


function fish(x,y, dx,c){
  fill(c);
  ellipse(x,y,20,10);
  if(dx >= 0){
    triangle(x - 10, y, x -15, y - 5, x - 15, y + 5);
  }else if(dx < 0){
    triangle(x+10,y, x + 15, y - 5, x + 15, y + 5);
  }
}

function seacoral(){
  noStroke();
  fill(119, 158, 203);
  beginShape();

  for(var i = 0; i < width; i ++){
    var x = (i * seacoralshape) + (millis() * seacoralspeed);
    var y = map(noise(x), 0, 1.2, 200, 250);
    vertex(i, y);
  }

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


For this week’s project, I wanted to create a landscape that shows the ocean drifting and many fish swimming.

Leave a Reply