Quantcast
Channel: Processing Forum
Viewing all articles
Browse latest Browse all 1768

Carried nodes along to music RHYTHM

$
0
0

Hi, I am making the game

that along to the rhythm of music carried rectangulars are coming, remove rectangulars.

 

but I don't know about how to make the carride rectangulars According to the rythm of music...

 

How to solve this problem?

I made just randomly carring rectangulars along to music. 

 

 

void draw() {
  rectMode(CENTER);
  colorMode(HSB, 360, 100, 100);
  println("position : " + song.position()/1000 + "/" + song.length()/1000 + "sec");

  
  
  fft.forward(song.mix);
 
  stroke(255, 0, 0, 128);
  // draw the spectrum as a series of vertical lines
  // I multiple the value of getBand by 4
  // so that we can see the lines better
  for(int i = 0; i < fft.specSize(); i++)
  {
    line(i, height, i, height - fft.getBand(i)*4);
  }

   for(int i = 0; i < song.left.size() - 1; i++)
  {
    line(i, 50 + song.left.get(i)*50, i+1, 50 + song.left.get(i+1)*50);
    line(i, 150 + song.right.get(i)*50, i+1, 150 + song.right.get(i+1)*50);
  }

  stroke(0, 0, 0);
  strokeWeight(3);
  noFill();
  rect(180, 130, 135, 135);
  rect(315, 130, 135, 135);
  rect(450, 130, 135, 135);
  rect(180, 265, 135, 135);
  rect(315, 265, 135, 135);
  rect(450, 265, 135, 135);
  rect(180, 400, 135, 135);
  rect(315, 400, 135, 135);
  rect(450, 400, 135, 135);

  if (start == 1) {
    if (s > 135) {
      // s = 0;
    }
    else {
      stroke(0, 255, 0);
      rect(180, 130, s, s);   
      s++;
    } 
    if (s2 > 135) {
      //s2 = 0;
    }
    else {
      stroke(255, 0, 0);
      rect(315, 400, s2, s2);
      s2+=2;
    }
  }
 
  for (int i = 0; i<flashes.length; i++) {
    flashes[i].update();
    flashes[i].display();
  }
  Time = millis();
  drawRectangle(); 
}


Viewing all articles
Browse latest Browse all 1768

Trending Articles