• fullscreen
  • Background.pde
  • Cloud.pde
  • Lightning.pde
  • Rain.pde
  • Snow.pde
  • Sun.pde
  • Sun_project.pde
  • Tornado.pde
  • class Background {
    
      float x, y;
      float nx, ny;
    
      Background(float nx, float ny) {
        x = nx;
        y = ny;
      }
    
      void display() {
        fill(0, y*.6);
        rect(-width, -height, width*2, height*2);
    
        // Ground
        fill(60, 180, 100);
        noStroke();
        rect(0, height-100, width, 100);
    
        //Sound filters beased off of sun coords
        float passBand = map(y, 0, width, 100, 2000);
        bpf.setFreq(passBand);
        float bandWidth = map(x, 0, height, 50, 500);
        bpf.setBandWidth(bandWidth);
        //bpf.printCoeff();
      }
    }
    
    
    class Cloud {
    
      float x, y;
      float nx, ny;
    
      Cloud(float nx, float ny) {
        x = nx;
        y = ny;
      }
    
      void display() {
        image(img, x-80, y-40);
      }
    }
    
    
    class Lightning {
    
      float x, y;
      float nx, ny;
    
      Lightning(float nx, float ny) {
        x = nx;
        y = ny;
      }
    
      void display() {
        stroke(255);
        strokeWeight(2);
    
        line(x, y, x + 10, y + 80);
        line(x + 10, y + 80, x - 10, y + 100);
        line(x + 6, y + 50, x + 20, y + 55);
    
        line(x - 20, y, x - 25, y + 70);
        line(x - 22, y + 55, x - 10, y + 60);
        line(x - 22, y + 35, x - 30, y + 40);
      }
    }
    
    
    class Rain {
    
      float x, y;
      float nx, ny;
    
      Rain() {
        x = random(playerX-50, playerX+50);
        y = random(playerY, height);
      }
    
      void move() {
        x += 1;
        y += 2;
    
        if (y > height) {
          y = playerY;
        }
        if (x > playerX+50) {
          x = playerX-50;
        }
      }
    
      void display() {
        fill(0, 0, 255);
        noStroke();
        ellipse(x, y, 5, 5);
      }
    }
    
    
    class Snow {
    
      float x, y;
      float nx, ny;
    
      Snow() {
        x = random(playerX-50,playerX+50);
        y = random(playerY, height);
      }
    
      void move() {
        x += 1;
        y += 2;
        x += random(-5, 1);
    
        if (y > height) {
          y = playerY;
        }
        if (x < playerX-50) {
          x = playerX+50;
        }
      }
    
      void display() {
        fill(255);
        ellipse(x, y, 5, 5);
      }
    }
    
    
    class Sun {
    
      float x, y;
    
      Sun(float nx, float ny) {
        x = nx;
        y = ny;
      }
    
      void move() {
        x = cos(sunRotation)*width/2+width/2;
        y = sin(sunRotation)*width/2+height/2;
        sunRotation -= sunSpeed;
        // xs=x*=-1;
        // ys=y*=-1;
        if ( mousePressed) {
          sunSpeed = sunSpeed * -1;
        }
      }
    
      void display() {
        fill(239, 240, 12); //yellow sun
        stroke(0); //black outline
        strokeWeight(5); //thick outline
    
        pushMatrix();
        translate(x, y); //sets center of the scetch to X,Y (0,0)
    
        //sun spikes
        for (float theta = 0.0; theta < TWO_PI; theta += PI/8) {
          pushMatrix();
          rotate(theta);
          float sunRayLength = sin(a)*100;
          //sunRayLength+=100;
          a+= .6;
    
          line(sunRayLength, 0, 0, 0);
          popMatrix();
        }
    
        ellipse(0, 0, 100, 100); //sun body
        fill(mouseX/2); //eyes color black
    
        ellipse(-20, -20, 15, 15); //left eye
        ellipse(+20, -20, 15, 15); //right eye
        fill(0); //eyes color black
    
        noFill();
        arc(0, 10, 60, 20, 0, PI); //mouth
        fill(0); //nose & mouth
        line(-28, 5, -35, 12); //side of mouth
        line(0, -10, 0, 0); //top half of nose
        line(0, 0, 5, 0); //bottom half of nose
        popMatrix();
    
        pushMatrix();
        translate (0, y);
        for (x=20; x<400; x+=30) {
          stroke(50, 100, 50);
          line (x, height, x, y+250);
          noStroke();
          //petals 
          fill(#FF48E7);
    
          ellipse(x-3, y+246, 7, 7);
          ellipse( x-3, y+253, 7, 7);
          ellipse( x+3, y+246, 7, 7);
          ellipse (x+3, y+253, 7, 7);  
          //center of circle
          fill (252, 215, 23);
          ellipse( x, y+250, 5, 5);
    
          fill(50, 100, 50);
          ellipse( x-2, y+275, 5, 7);
        }
        popMatrix();
      }
    }
    
    
    // IDEA - Josh Moody (Mr.Sun Project)
    // ANIMATE - Paul Way
    // INTERACTION - Henry Oman
    // Iteration -alexzandra 
    // Sound and Stuff - Wyatt Tarabochia
    
    //sound imports
    import ddf.minim.*;
    import ddf.minim.effects.*;
    PImage img;
    
    Cloud cloud;
    Sun sun;
    Background backlayer;
    Rain[] rain;
    Snow[] snow;
    Lightning lightning;
    Tornado tornado;
    
    Minim minim;
    AudioPlayer groove;
    BandPass bpf;
    float sunSpeed = .009;
    float a;
    float sunRotation;
    float plants;
    //float xs, ys;
    float x, y;
    float cX, cY;
    float playerX, playerY;
    
    void setup() {
      size(400, 400);
      smooth();
      //sound setup
      minim = new Minim(this);
      groove = minim.loadFile("1-09 Badlands.mp3");
      groove.loop();
      bpf = new BandPass(440, 20, groove.sampleRate());
      groove.addEffect(bpf);
      img = loadImage("cloud.png");
      playerX = width/2;
      playerY = height/2;
    
      backlayer = new Background(0, 0);
      sun = new Sun(0, 0);
      cloud = new Cloud(playerX, playerY);
      lightning = new Lightning(playerX, playerY);
      tornado = new Tornado(playerX, playerY);
    
      rain = new Rain[200];
      for (int i = 0; i < 200; i++) {
        rain[i] = new Rain();
      }
      snow = new Snow[200];
      for (int i = 0; i < 200; i++) {
        snow[i] = new Snow();
      }
    }
    
    void draw() {
      background(43, 105, 234);
      fill(0, sun.y*.6);
      rect(-width, -height, width*2, height*2);
      sun.display();
      sun.move();
    
      for (int i = 0; i < 200; i++) {
        if (rain[i].x > playerX-50 || rain[i].x < playerX+50) {
          if (rain[i].y > playerY || rain[i].y < height) {
            if (keyPressed) {
              if (key == 'k') {
                rain[i].move();
                rain[i].display();
                if (millis() % 25 == 0) {
                  lightning.display();
                }
              }
            }
          }
        }
      }
      for (int i = 0; i < 200; i++) {
        if (snow[i].x > playerX-50 || snow[i].x < playerX+50) {
          if (snow[i].y > playerY || snow[i].y < height) {
            if (keyPressed) {
              if (key == 'j') {
                snow[i].move();
                snow[i].display();
              }
            }
          }
        }
      }
      if (keyPressed) {
        if (key == 'l') {
          tornado.move();
          tornado.display();
        }
      }
      cloud.display();
      backlayer.display();
    }
    
    void stop() {
      // always close Minim audio classes when you finish with them
      groove.close();
      // always stop Minim before exiting
      minim.stop();
      super.stop();
    }
    
    
    class Tornado {
    
      float x, y;
      float x2, y2;
      float x3, y3;
      float x4, y4;
      float xt, yt;
      float nx, ny;
      float centerX, centerY;
      int radius = 80;
      float ang = TWO_PI-PI/2;
      float ang2 = PI;
      float ang3 = PI/2;
      float ang4 = 0;
      float speed;
    
      Tornado(float nx, float ny) {
        x = nx;
        y = ny;
        x2 = nx;
        y2 = ny;
        x3 = nx;
        y3 = ny;
        x4 = nx;
        y4 = ny;
        xt = nx;
        yt = ny + 60;
        centerX = x;
        centerY = y;
        speed = 1;
      }
    
      void move() {
        if (keyPressed) {
          if (key == 'a') {
            xt -= 1;
          }
          if (key == 'd') {
            xt += 1;
          }
        }
        x = cos(ang)*radius/2+centerX;
        y = sin(ang)*radius/4+centerY;
        ang = ang + speed;
        x2 = cos(ang2)*radius/2+centerX;
        y2 = sin(ang2)*radius/4+centerY;
        ang2 = ang2 + speed;
        x3 = cos(ang3)*radius/2+centerX;
        y3 = sin(ang3)*radius/4+centerY;
        ang3 = ang3 + speed;
        x4 = cos(ang4)*radius/2+centerX;
        y4 = sin(ang4)*radius/4+centerY;
        ang4 = ang4 + speed;
      }
    
      void display() {
        stroke(100);
        line(xt, yt+100, x, y);
        line(xt, yt+100, x2, y2);
        line(xt, yt+100, x3, y3);
        line(xt, yt+100, x4, y4);
      }
    }
    
    

    code

    tweaks (0)

    about this sketch

    This sketch is running as Java applet, exported from Processing.

    license

    advertisement

    Joshua Moody

    Badlands

    Add to Faves Me Likey@!
    You must login/register to add this sketch to your favorites.

    Click Mouse: changes suns direction
    Press J: Snow
    Press K: Rain
    Press L: Tornado

    Thank You: Paul Way, Henry Oman, Alexzandra Morris & Wyatt Tarabochia

    Music: Badlands by Bruce Springsteen

    Note: *If the program lags a lot copy the source code and play through processing.

    You need to login/register to comment.