changeset 22:df7f7eef72ef draft

put canvas to center
author e105711 <yomitan.ie.u-ryukyu.ac.jp>
date Sun, 15 Jul 2012 00:45:56 +0900
parents 5da2afa45e41
children 30c23f93cbc0
files webGL/DrumSimulator.html webGL/src/const.js webGL/src/f4notes.js webGL/src/f4xml.js webGL/src/mainfunc.js webGL/src/sound.js
diffstat 6 files changed, 25 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/webGL/DrumSimulator.html	Mon Jul 09 00:15:08 2012 +0900
+++ b/webGL/DrumSimulator.html	Sun Jul 15 00:45:56 2012 +0900
@@ -144,9 +144,11 @@
     }
   </style> 
   <body onload="main()" onkeydown="keybordDown()" onkeypress="keybordPress()" onkeyup="keybordUp()" style='overflow:scroll'>
+    <div align="center">
     <canvas id="example"> 
       There is supposed to be an example drawing here, but it's not important.
     </canvas> 
+    </div>
     <canvas id="textCanvas" style="display:none;">
     </canvas>
     <div id="console"></div> 
--- a/webGL/src/const.js	Mon Jul 09 00:15:08 2012 +0900
+++ b/webGL/src/const.js	Sun Jul 15 00:45:56 2012 +0900
@@ -11,7 +11,7 @@
 const HEIGHT = 600;
 const FPS = 60;
 const Interval = 1000/FPS;
-const ALPHA = 5; // influence speed of notes
+const ALPHA = 6; // influence speed of notes
 
 // Key code
 const keyA = 65;
@@ -26,7 +26,7 @@
 const keySpace = 32;
 
 // judges (s)
-const PERFECT = 0.03;
-const GREAT = 0.06;
-const GOOD = 0.09;
-const BAD = 0.12;
+const PERFECT = 0.025;
+const GREAT = 0.04;
+const GOOD = 0.06;
+const BAD = 0.1;
--- a/webGL/src/f4notes.js	Mon Jul 09 00:15:08 2012 +0900
+++ b/webGL/src/f4notes.js	Sun Jul 15 00:45:56 2012 +0900
@@ -33,7 +33,6 @@
 	PutSpriteF(ctx,58.984375+11.71875*6,60,1,ctx.obj["beam"]);
     if(SemicolonPressed)
 	PutSpriteF(ctx,58.984375+11.71875*7,60,1,ctx.obj["beam"]);
-
 }
 
 /*
@@ -63,14 +62,14 @@
 		note.kill();
 		notesArray[i].splice(j,1);
 		poorCount++;
-		console.log("poor");
+		drawText(ctx,"judge","poor",35,"purple","center");
 	    }
 
 	}
     }
 }
 
-function resetResult(){
+function resetResult(ctx){
     perfectCount=0;
     greatCount=0;
     goodCount=0;
@@ -79,16 +78,20 @@
 }
 
 function showResult(){
+    var resultScore = (perfectCount + greatCount + goodCount + badCount + poorCount)*5; // calculate MAX score.
+    resultScore = Math.round((perfectCount*5 + greatCount*3 + goodCount*1)/resultScore*10000)/100;
     objsArray.push(new Obj(100,30,1,"perfect_count"));
     objsArray.push(new Obj(100,40,1,"great_count"));
     objsArray.push(new Obj(100,50,1,"good_count"));
     objsArray.push(new Obj(100,60,1,"bad_count"));
     objsArray.push(new Obj(100,70,1,"poor_count"));
+    objsArray.push(new Obj(100,85,1,"result"));
     drawText(ctx,"perfect_count","PERFECT    "+perfectCount,40,"white","left",450,50);
     drawText(ctx,"great_count"  ,"GREAT      "+greatCount,40,"white","left",450,50);
     drawText(ctx,"good_count"   ,"GOOD       "+goodCount,40,"white","left",450,50);
     drawText(ctx,"bad_count"    ,"BAD        "+badCount,40,"white","left",450,50);
     drawText(ctx,"poor_count"   ,"POOR       "+poorCount,40,"white","left",450,50);
+    drawText(ctx,"result"       ,"Your score is "+resultScore,40,"white","left",450,50);
     resetResult();
 }
 
@@ -133,16 +136,16 @@
 function solveDiff(diff,hitTime){
     if(diff<=PERFECT){
 	perfectCount++;
-	console.log("perfect");
+	drawText(ctx,"judge","perfect",35,"yellow","center");
     }else if(diff<=GREAT){
 	greatCount++;
-	console.log("great");
+	drawText(ctx,"judge","great",35,"green","center");
     }else if(diff<=GOOD){
 	goodCount++;
-	console.log("good");
+	drawText(ctx,"judge","good",35,"blue","center");
     }else if(diff<=BAD){
 	badCount++;
-	console.log("bad");
+	drawText(ctx,"judge","bad",35,"red","center");
     }else{
 	console.log("judge error: hit:"+hitTime+" diff:"+diff);
     }
--- a/webGL/src/f4xml.js	Mon Jul 09 00:15:08 2012 +0900
+++ b/webGL/src/f4xml.js	Sun Jul 15 00:45:56 2012 +0900
@@ -15,6 +15,8 @@
     drawText(gl,"good_count","",40,"white","center",450,50);
     drawText(gl,"bad_count","",40,"white","center",450,50);
     drawText(gl,"poor_count","",40,"white","center",450,50);
+    drawText(gl,"result","",40,"white","center",450,50);
+    drawText(gl,"judge","",35,"white","center",0,0);
 }
 
 function loadObjXml(gl,url)
--- a/webGL/src/mainfunc.js	Mon Jul 09 00:15:08 2012 +0900
+++ b/webGL/src/mainfunc.js	Sun Jul 15 00:45:56 2012 +0900
@@ -14,6 +14,7 @@
 
 function toTitle(){
     MODE = TITLE;
+    resetResult();
     objsArray.length = 0;
     objsArray.push(new Obj(100,30,1,"title"));
     objsArray.push(new Obj(100,90,1,"press"));
@@ -21,6 +22,7 @@
 
 function toMenu(){
     MODE = MENU;
+    resetResult();
     objsArray.length = 0;
     objsArray.push(new Obj(100,7.8125,1,"select_music"));
     loadMusicTitle(cursor.getIndex());
@@ -29,6 +31,7 @@
 
 function toMain(){
     MODE = MAIN;
+    resetResult();
     objsArray.length = 0;
     objsArray.push(new Obj(100,7.8125,1,"main_mode"));
     objsArray.push(new Obj(100,105,1,"line"));
@@ -36,8 +39,11 @@
 
 function toPlay(){
     MODE = PLAY;
+    resetResult(ctx);
     objsArray.length = 0;
     objsArray.push(new Obj(100,7.8125,1,"main_mode"));
+    objsArray.push(new Obj(100,40,1,"judge"));
+    dummyPlay();
     loadMusics(musicsArray[cursor.getIndex()]);
 }
 
@@ -50,7 +56,6 @@
 
 function drawObj(ctx){
     reshape(ctx);
-    ctx.clearColor(0,0,0,1);
     ctx.clear(ctx.COLOR_BUFFER_BIT | ctx.DEPTH_BUFFER_BIT);
     for(var i=0;i < objsArray.length;i++){
 	var obj = objsArray[i];
--- a/webGL/src/sound.js	Mon Jul 09 00:15:08 2012 +0900
+++ b/webGL/src/sound.js	Sun Jul 15 00:45:56 2012 +0900
@@ -10,7 +10,6 @@
     else
 	alert("your browser does not support wav and ogg File.");
     audioHClose = loadAudio("sound/hclose"+ext);
-//    audioHOpen = loadAudio("sound/hopen"+ext);
     audioSnare = loadAudio("sound/snare"+ext);
     audioKick = loadAudio("sound/kick"+ext);
     audioTomA = loadAudio("sound/toma"+ext);