Mercurial > hg > Members > e105711
changeset 11:502bc41e0c59 draft
FPS:50->60 notesArray:[](all notes in)->[lane][note](prepared eight array for notes.)
author | e105711 <yomitan.ie.u-ryukyu.ac.jp> |
---|---|
date | Fri, 18 May 2012 02:13:31 +0900 |
parents | 98a90bc478b3 |
children | c358bb5a031b |
files | webGL/DrumSimulator.html webGL/src/const.js webGL/src/f4notes.js |
diffstat | 3 files changed, 95 insertions(+), 86 deletions(-) [+] |
line wrap: on
line diff
--- a/webGL/DrumSimulator.html Thu May 17 16:04:02 2012 +0900 +++ b/webGL/DrumSimulator.html Fri May 18 02:13:31 2012 +0900 @@ -64,8 +64,8 @@ var MODE = TITLE; var AUTO = true; -notesArray = []; -objsArray = []; +var notesArray = [[],[],[],[],[],[],[],[]]; +var objsArray = []; /* these variables are defined at const.js */ // var WIDTH = 1024;
--- a/webGL/src/const.js Thu May 17 16:04:02 2012 +0900 +++ b/webGL/src/const.js Fri May 18 02:13:31 2012 +0900 @@ -8,7 +8,7 @@ // Constituents of game const WIDTH = 960; const HEIGHT = 600; -const FPS = 50; +const FPS = 60; const Interval = 1000/FPS; const ALPHA = 5; // influence speed of notes @@ -25,7 +25,7 @@ const keySpace = 32; // judges (s) -const PERFECT = 0.15; -const GREAT = 0.03; -const GOOD = 0.06; -const BAD = 0.08; \ No newline at end of file +const PERFECT = 0.025; +const GREAT = 0.05; +const GOOD = 0.075; +const BAD = 0.1; \ No newline at end of file
--- a/webGL/src/f4notes.js Thu May 17 16:04:02 2012 +0900 +++ b/webGL/src/f4notes.js Fri May 18 02:13:31 2012 +0900 @@ -2,80 +2,83 @@ function drawNote(ctx){ for(i=0;i<notesArray.length;i++){ - var note = notesArray[i]; - if(note.getLocate()<0) //note isn't in the screen. - return; - - PutSpriteF(ctx,58.984375+(note.getLane()-1)*11.71875,note.getLocate(),1,imgs[5-(note.getLane()%2)]); - - } -} - -function updateNote(){ - for(i=0;i<notesArray.length;i++){ - var note = notesArray[i]; - if(!note.isAlive()){ - notesArray.splice(i,1); - continue; - } - note.updateLocate(testBPM,1.0); - - if(note.getLocate() >= 105 && note.isAlive() && AUTO){//105:line's locate - note.autoSound(); - note.kill(); - notesArray.splice(i,1); - continue; - } - // judge:POOR - if(note.isAlive() && note.getTime() + BAD < audioBGM.currentTime){ - note.kill(); - notesArray.splice(i,1); - console.log("poor"); + for(j=0;j<notesArray[i].length;j++){ + var note = notesArray[i][j]; + if(note.getLocate()<0) //note isn't in the screen. + break; + PutSpriteF(ctx,58.984375+(note.getLane()-1)*11.71875,note.getLocate(),1,imgs[5-(note.getLane()%2)]); } } } +/* + updateNote() + Update a note's locate and dead or alive. +*/ +function updateNote(){ + for(i=0;i<notesArray.length;i++){ + for(j=0;j<notesArray[i].length;j++){ + var note = notesArray[i][j]; + + if(!note.isAlive()){ + notesArray[i].splice(j,1); + continue; + } + note.updateLocate(testBPM,1.0); + + if(note.getLocate() >= 105 && note.isAlive() && AUTO){ // 105:line's locate + note.autoSound(); + note.kill(); + notesArray[i].splice(j,1); + continue; + } + // judge:POOR + + if(note.isAlive() && note.getTime() + BAD < audioBGM.currentTime){ + note.kill(); + notesArray[i].splice(j,1); + console.log("poor"); + } + + } + } +} + + +/* + judge() + Judge a player's input. + */ function judge(lane,hitTime){ var note1,note2; // The passage of time : note1 -> note2 var diff1,diff2; note1=note2=null; diff1=diff2=0; - var i,j; - for(i=0;i<notesArray.length;i++){ - var note = notesArray[i]; - if(note.getLane()!=lane) - continue; + var i; + for(i=0;i<notesArray[lane-1].length;i++){ + var note = notesArray[lane-1][i]; if(hitTime < note.getTime()-BAD || note.getTime()+BAD < hitTime) break; - note1 = notesArray[i]; - for(j=i+1;j<notesArray.length;j++){ - note = notesArray[j]; - if(note.getLane()!=lane) - continue; - if(hitTime < note.getTime()-BAD) - break; - note2 = notesArray[j]; - break; - } + note1 = notesArray[lane-1][i]; + if(i+1<notesArray[lane-1].length) + note2 = notesArray[lane-1][i+1]; break; } if(note1==null){ // This input doesn't need judgement. -// console.log("through the judgement"); + console.log("through the judgement"); return; } diff1 = Math.abs(hitTime-note1.getTime()); diff2 = (note2==null)? 100 : Math.abs(hitTime-note2.getTime()); if(diff1<diff2){ // Input for note1. solveDiff(diff1,hitTime); - console.log("di1"); note1.kill(); - notesArray.splice(i,1); + notesArray[lane-1].splice(i,1); }else{ // Input for note2. solveDiff(diff2,hitTime); - console.log("di2"); note2.kill(); - notesArray.splice(j,1); + notesArray[lane-1].splice(i+1,1); } } @@ -96,41 +99,47 @@ function loadNotes(){ - notesArray.push(new Note(0.0,3,testBPM)); - notesArray.push(new Note(1.75,3,testBPM)); + noteAdd(0.0,3,testBPM); + noteAdd(1.75,3,testBPM); - notesArray.push(new Note(2.0,3,testBPM)); - notesArray.push(new Note(3.75,3,testBPM)); + noteAdd(2.0,3,testBPM); + noteAdd(3.75,3,testBPM); + + noteAdd(4.0,3,testBPM); + noteAdd(4.25,3,testBPM); + noteAdd(5.625,3,testBPM); + noteAdd(5.875,3,testBPM); - notesArray.push(new Note(4.0,3,testBPM)); - notesArray.push(new Note(4.25,3,testBPM)); - notesArray.push(new Note(5.625,3,testBPM)); - notesArray.push(new Note(5.875,3,testBPM)); + noteAdd(6.0,3,testBPM); + noteAdd(7.0,3,testBPM); + noteAdd(7.375,3,testBPM); + noteAdd(7.75,3,testBPM); - notesArray.push(new Note(6.0,3,testBPM)); - notesArray.push(new Note(7.0,3,testBPM)); - notesArray.push(new Note(7.375,3,testBPM)); - notesArray.push(new Note(7.75,3,testBPM)); + noteAdd(8.0,3,testBPM); + noteAdd(9.75,3,testBPM); - notesArray.push(new Note(8.0,3,testBPM)); - notesArray.push(new Note(9.75,3,testBPM)); + noteAdd(10.0,3,testBPM); + noteAdd(11.75,3,testBPM); - notesArray.push(new Note(10.0,3,testBPM)); - notesArray.push(new Note(11.75,3,testBPM)); - - notesArray.push(new Note(12.0,3,testBPM)); - notesArray.push(new Note(12.25,3,testBPM)); - notesArray.push(new Note(13.625,3,testBPM)); - notesArray.push(new Note(13.875,3,testBPM)); + noteAdd(12.0,3,testBPM); + noteAdd(12.25,3,testBPM); + noteAdd(13.625,3,testBPM); + noteAdd(13.875,3,testBPM); - notesArray.push(new Note(14.0,3,testBPM)); - notesArray.push(new Note(15.0,3,testBPM)); - notesArray.push(new Note(15.375,3,testBPM)); - notesArray.push(new Note(15.75,3,testBPM)); - notesArray.push(new Note(15.0,1,testBPM)); - notesArray.push(new Note(15.375,1,testBPM)); - notesArray.push(new Note(15.75,1,testBPM)); + noteAdd(14.0,3,testBPM); + noteAdd(15.0,3,testBPM); + noteAdd(15.375,3,testBPM); + noteAdd(15.75,3,testBPM); + noteAdd(15.0,1,testBPM); + noteAdd(15.375,1,testBPM); + noteAdd(15.75,1,testBPM); - notesArray.push(new Note(16.0,3,testBPM)); - notesArray.push(new Note(16.0,8,testBPM)); + noteAdd(16.0,3,testBPM); + noteAdd(16.0,8,testBPM); + +} + + +function noteAdd(time,lane,BPM){ + notesArray[lane-1].push(new Note(time,lane,testBPM)); } \ No newline at end of file