Mercurial > hg > Members > e105711
view webGL/src/keybord.js @ 5:a730b51d59eb draft
6th:use stat.js,divide render and update,change a way of updating game.
author | e105711 <yomitan.ie.u-ryukyu.ac.jp> |
---|---|
date | Fri, 04 May 2012 05:22:57 +0900 |
parents | a22ff379000f |
children | 8c25fd3f9866 |
line wrap: on
line source
SPressed = false; DPressed = false; FPressed = false; JPressed = false; KPressed = false; QPressed = false; APressed = false; SpacePressed = false; PlayingBGM = false; AUTO = false; function keyMain(key){ switch(key){ case "S": if(!SPressed){ SPressed = true; if(HCloseCnt%2==0){ audioStop(audioHClose2); audioHClose.play(); } else{ audioStop(audioHClose); audioHClose2.play(); } HCloseCnt++; } break; case "D": if(!DPressed){ DPressed = true; if(SnareCnt%2==0){ audioStop(audioSnare2); audioSnare.play(); } else{ audioStop(audioSnare); audioSnare2.play(); } SnareCnt++; } break; case "F": if(!FPressed){ FPressed = true; if(KickCnt%2==0){ audioStop(audioKick2); audioKick.play(); } else{ audioStop(audioKick); audioKick2.play(); } KickCnt++; } break; case "J": if(!JPressed){ JPressed = true; if(FtomCnt%2==0){ audioStop(audioFtom2); audioFtom.play(); } else{ audioStop(audioFtom); audioFtom2.play(); } FtomCnt++; } break; case "K": if(!KPressed){ KPressed = true; if(CymbalCnt%2==0){ audioStop(audioCymbal2); audioCymbal.play(); } else{ audioStop(audioCymbal); audioCymbal2.play(); } CymbalCnt++; } break; case " ": if(!SpacePressed){ SpacePressed = true; PlayingBGM = true; pl = function(){audioBGM.play()/*; setInterval(asdf,500);*/}; // asdf = function(){console.log(audioBGM.currentTime)}; var setTime = Interval*105.0*100.0/testBPM; setTimeout(pl,setTime); MODE = PLAY; } break; default: break; } } function keyPlay(key){ switch(key){ case "S": if(!SPressed){ SPressed = true; if(HCloseCnt%2==0){ audioStop(audioHClose2); audioHClose.play(); } else{ audioStop(audioHClose); audioHClose2.play(); } HCloseCnt++; } break; case "D": if(!DPressed){ DPressed = true; if(SnareCnt%2==0){ audioStop(audioSnare2); audioSnare.play(); } else{ audioStop(audioSnare); audioSnare2.play(); } SnareCnt++; } break; case "F": if(!FPressed){ FPressed = true; if(KickCnt%2==0){ audioStop(audioKick2); audioKick.play(); } else{ audioStop(audioKick); audioKick2.play(); } KickCnt++; } break; case "J": if(!JPressed){ JPressed = true; if(FtomCnt%2==0){ audioStop(audioFtom2); audioFtom.play(); } else{ audioStop(audioFtom); audioFtom2.play(); } FtomCnt++; } break; case "K": if(!KPressed){ KPressed = true; if(CymbalCnt%2==0){ audioStop(audioCymbal2); audioCymbal.play(); } else{ audioStop(audioCymbal); audioCymbal2.play(); } CymbalCnt++; } break; case " ": if(!SpacePressed){ SpacePressed = true; audioStop(audioBGM); PlayingBGM = false; MODE = MAIN; } break; default: break; } } function keyTitle(key){ switch(key){ case " ": if(!SpacePressed){ SpacePressed = true; MODE = MAIN; } break; default: break; } } function keybordDown() { var keyChar = String.fromCharCode(event.keyCode); switch(MODE){ case TITLE: keyTitle(keyChar); break; case MAIN: keyMain(keyChar); break; case PLAY: // keyPlay(keyChar); break; } console.log("Key: Pushed '"+keyChar+"'"); } function keybordPress(){} function keybordUp() { var keyChar = String.fromCharCode(event.keyCode); if(keyChar == "S"){ SPressed = false; } if(keyChar == "D"){ DPressed = false; } if(keyChar == "F"){ FPressed = false; } if(keyChar == "J"){ JPressed = false; } if(keyChar == "K"){ KPressed = false; } if(keyChar == "Q"){ JPressed = false; } if(keyChar == "A"){ KPressed = false; } if(keyChar == " "){ SpacePressed = false; } }