• fullscreen
  • Boy.pde
  • Final222.pde
  • Girl.pde
  • meteor.pde
  • class Boy{
      
      //properties
      float xpos;
      float ypos;
      int width = 50;
      int height = 50;
      float speed;
      
      //setup
      Boy(float x, float y,float s){
          xpos = x;
          ypos = y;
          speed = 5;
        
      }//end of setup
      
      void draw(){
        image(images3[frame],xpos,ypos);
        xpos+=speed;
       
        if(xpos>500){
          reset();
        }
         
      }//end of draw
      
      void reset(){
        
        ypos = random(320,450);
        xpos = random(-10,500); 
      }
    
    }//end of class
    
    import ddf.minim.*;
    import ddf.minim.signals.*;
    import ddf.minim.analysis.*;
    import ddf.minim.effects.*;
    
    //import cc.arduino.*;
    //import processing.serial.*;
    
    
    //Arduino arduino;
    int numFrames = 3;  
    int frame = 0; 
    float mySize = 0;
    float myX;
    float myY;
    int map1=0;
    float mySpeed;
    float speed=2;
    float Ispeed;
    
    PImage[] images = new PImage[numFrames]; 
    PImage[] images2 = new PImage[numFrames];
    PImage[] images3 = new PImage[numFrames];
    PImage[] images4 = new PImage[numFrames];
    PImage townback;
    meteor [] meteorArray = new meteor[14];
    Girl [] GirlArray = new Girl[12];
    Boy [] BoyArray = new Boy[12];
    
    Minim minim;
    AudioPlayer groove;
    AudioPlayer groove2;
    AudioPlayer player;
    
    
    
    void setup() {
      size (500, 500);
     // arduino = new Arduino(this, Arduino.list()[0], 57600);
      smooth();
      townback = loadImage ("town.jpg");
      
      minim = new Minim(this);
      groove = minim.loadFile("Earthquakes 2.wav");
      groove2 = minim.loadFile("UFO.wav");
      player = minim.loadFile("Women scream.aif");
      groove2.loop();
       
      frameRate(20);
     images4[0] = loadImage("townfloor.png");
     images4[1] = loadImage("townfloor3.png");
     images4[2] = loadImage("townfloor4.png");
      
      frameRate(12);
      images2[0] = loadImage("Girl.png");
      images2[1] = loadImage("Girl2.png");
      images2[2] = loadImage("Girl2kkuuteee.png");
    
    
      frameRate(13); 
      images[0] = loadImage("meteorS.png");
      images[1] = loadImage("meteor2.png");
      images[2] = loadImage("meteor2.2S.png");
      
      frameRate(8); 
      images3[0] = loadImage("Boy.png");
      images3[1] = loadImage("Boy2.2.png");
      images3[2] = loadImage("Boy2.png");
      
      
      for (int i=0; i<GirlArray.length;i++) {
        GirlArray[i]= new Girl(random(500,0), random(1,-490), random(0, 5));
      }
       for (int i=0; i<BoyArray.length;i++) {
        BoyArray[i]= new Boy(random(500,0), random(1,-490), random(0, 5));
      }
       for (int i=0; i<meteorArray.length;i++) {
        meteorArray[i] = new meteor(random(0,500), random(-490,1), random(5, 10));
      }
     
    }
    
    
    void draw() {
      background (0);
      mySpeed = map(mouseY, 0, 500, 0, 500);
      //Ispeed=map(arduino.analogRead(1), 0, 510, 0, 500);
       image (townback, 0, 0);
       image (images4[frame],myX,myY,width,height);
          //myX+=Ispeed;
       
     for (int i=0;i<GirlArray.length;i++) {
        GirlArray[i].draw();
        meteorArray[i].draw();
        if (hitTest( meteorArray[i], GirlArray[i])) {
          GirlArray[i].reset();
         meteorArray[i].reset();
        }
      }
      
      for (int i=0;i<BoyArray.length;i++) {
        BoyArray[i].draw();
        meteorArray[i].draw();
        if (hitTest( meteorArray[i], BoyArray[i])) {
          BoyArray[i].reset();
         meteorArray[i].reset();
        }
      }
     frame = (frame+1)%numFrames;
     
    }
    
    void keyPressed()
    {
      if ( key == 'l' ) {
      groove.loop();
      }
       if ( key == 'p' ) {
      player.loop();
      }
       if ( key == 'o' ) {
      player.pause();
      }
    }
    
    void stop()
    {
      groove.close();
      player.close();
      minim.stop();
      super.stop();
    }
    
    
    boolean hitTest(meteor p1, Girl e1) {
      return(p1.xpos<e1.xpos+e1.width && p1.xpos+p1.width>e1.xpos && p1.ypos<e1.ypos+e1.height && p1.ypos+p1.height>e1.ypos);
    }
    boolean hitTest(meteor p1, Boy e1) {
      return(p1.xpos<e1.xpos+e1.width && p1.xpos+p1.width>e1.xpos && p1.ypos<e1.ypos+e1.height && p1.ypos+p1.height>e1.ypos);
    }
    
    class Girl{
      
      //properties
      float xpos;
      float ypos;
      int width = 50;
      int height = 50;
      float speed;
      
      //setup
      Girl(float x, float y,float s){
          xpos = x;
          ypos = y;
          speed = 6;
        
      }//end of setup
      
      void draw(){
        image(images2[frame],xpos,ypos);
       xpos+=speed;
        
        if(xpos>500){
          reset();
        }
         
      }//end of draw
      
      void reset(){
       
         ypos = random(320,450);
         xpos = random(-10,500); 
      }
    
    }//end of class
    
    class meteor {
     
    float xpos;
      float ypos;
      int width = 35;
      int height = 35;
      float yspeed;
     int nummeteor;
      //setup
      meteor(float x, float y,float s){
          xpos = x;
          ypos = y;
          yspeed = 2;
        
      }//end of setup
      
      void draw(){
        image(images[frame],xpos,ypos,width,height);
        ypos= ypos+yspeed;
        
        if(ypos>495){
          reset();
        }
       
         
      }//end of draw
      void reset(){
         ypos = random(-490,0);
         xpos = random(500); 
         
    yspeed =1;
    println(mySpeed);
    if(mySpeed > 420){
    yspeed =1;
    //numMeteor = 1;
    }
    if (mySpeed > 400 && mySpeed <= 424 ){
    yspeed = 5;
    //numMeteor = 20;
    }
    if (mySpeed > 350 && mySpeed <= 399){
    yspeed = 10;
    //numMeteor = 20;
    }
    if (mySpeed > 300 && mySpeed <= 349){
    yspeed = 25;
    //numMeteor = 20;
    }
    if (mySpeed > 250 && mySpeed <= 299){
      yspeed = 50;
     // numMeteor = 1000;
    }
    if (mySpeed > 200 && mySpeed <= 249){
      yspeed = 100;
     // numMeteor = 1000;
    }
    if (mySpeed > 150 && mySpeed <= 199){
      yspeed = 150;
     // numMeteor = 1000;
    }
    if (mySpeed > 100 && mySpeed <= 149){
      yspeed = 200;
     // numMeteor = 1000;
    }
    if (mySpeed <= 99){
      yspeed = 250;
     // numMeteor = 1000;
    }
      }
    }
    

    code

    tweaks (0)

    about this sketch

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

    license

    advertisement

    Yoon Hur

    Meteor

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

    Move mouse at the top - move faster

    Move mouse at the bottom of the window - move slower

    You need to login/register to comment.