Romi Jin – Project-10-Landscape

sketch

/*
Romi Jin
Section B
rsjin@andrew.cmu.edu
Project-10
*/

var terrainSpeed1 = 0.0005;
var terrainDetail1 = 0.015;
var terrainSpeed2 = 0.0005;
var terrainDetail2 = 0.005;
var frames = []; 

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

    imageMode(CENTER);
    frameRate(11); //speed of doggos
} 

function preload(){
    var filenames = [];
      filenames[0] = "https://i.imgur.com/ejRANDS.png";
      filenames[1] = "https://i.imgur.com/coVxjO1.png";
      filenames[2] = "https://i.imgur.com/qJKozUu.png";
      filenames[3] = "https://i.imgur.com/ukTPJk3.png";
      filenames[4] = "https://i.imgur.com/KlTBTOl.png";
      filenames[5] = "https://i.imgur.com/Yei5uel.png";
      filenames[6] = "https://i.imgur.com/srcpeKV.png";
      filenames[7] = "https://i.imgur.com/3mbE69u.png";
      filenames[8] = "https://i.imgur.com/EKPZJMw.png";
      filenames[9] = "https://i.imgur.com/L6GOIGZ.png";

    for (var i = 0; i < filenames.length; i++) {
        frames.push(loadImage(filenames[i]));
    } 

}

function draw() {
    background('black');
    mountain1();
    mountain2();
    push();
    doggos();
    pop();

    //ground
    fill(255, 174, 76);
    rect(0, 375, width, 105);
}


function mountain1(){
  noStroke();
  fill(139, 64, 0); 
  beginShape(); 
  for (var x = 0; x < width; x++) {
    var t = (x * terrainDetail1) + (millis() * terrainSpeed1);
    var y = map(noise(t), 0, 2, height/8, height);
    vertex(x, y); 
  }
  vertex(width, height);
  vertex(0, height);
  endShape();
}

function mountain2(){
  fill(217, 119, 0); 
    noStroke();
    beginShape(); 
      for (var x = 0; x < width; x++) {
            var t = (x * terrainDetail2) + (millis() * terrainSpeed2);
            var y = map(noise(t), 0, 1.75, height/2, height);
            vertex(x, y); 
      }
      vertex(width, height);
      vertex(0, height);
    endShape();
}


function doggos(){

    //dooggos scaled down and translated to center
    translate(width/2,360);
    scale(.2,.2);
    image(frames[frameCount % 10], 0, 0);

}

I decided to do a Halloween themed project! Using a gif I found online and editing it on Photoshop (editing out the background and creating separate png files), the two dressed-up dogs are walking along the horizon against an black background and orange mountains.

Leave a Reply