view webGL/src/Note.js @ 7:c5455ae6cd70 draft

8th,change a way of update to notes,support ogg and wav sound
author e105711 <yomitan.ie.u-ryukyu.ac.jp>
date Sat, 05 May 2012 23:57:18 +0900
parents 8c25fd3f9866
children 040c922bd7ff
line wrap: on
line source

var Note = function(time,lane,BPM){

    this.time = time + (60/BPM*4); //60/BPM*4 = Time of a bar
    this.lane = lane;

//    this.locate = - (this.time*BPM/(Interval*0.1));
    this.locate = 105.0 - ((this.time-audioBGM.currentTime)*BPM*ALPHA/Interval);

    this.alive = true;
};

Note.prototype.getTime = function(){
    return this.time;
};

Note.prototype.getLane = function(){
    return this.lane;
};

Note.prototype.getLocate = function(){
    return this.locate;
};

Note.prototype.updLocate = function(BPM,sp){
    //sp:HI-SPEED,BPM:Music's BPM
//    this.locate += BPM*0.01*sp;
    this.locate = 105.0 - ((this.time-audioBGM.currentTime)*BPM*ALPHA/Interval);
};

Note.prototype.isAlive = function(){
    return this.alive;
};

Note.prototype.kill = function(){
    console.log(this.time+","+audioBGM.currentTime);
    switch(this.lane){
    case 1:
	break;
    case 2:
	audioHClose = audioPlay(audioHClose);
	break;
    case 3:
	audioSnare = audioPlay(audioSnare);
	break;
    case 4:
	audioKick = audioPlay(audioKick);
	break;
    case 5:
	audioFtom = audioPlay(audioFtom);
	break;
    case 6:
	audioCymbal = audioPlay(audioCymbal);
	break;
    case 7:
	break;
    case 8:
	break;
    }
    this.alive = false;
};