Mercurial > hg > Members > e105711
changeset 4:a22ff379000f draft
5th,commit test
author | e105711 <yomitan.ie.u-ryukyu.ac.jp> |
---|---|
date | Fri, 04 May 2012 01:18:13 +0900 |
parents | 4bcac064db6c |
children | a730b51d59eb |
files | webGL/DrumSimulator.html webGL/src/Note.js webGL/src/f4notes.js webGL/src/keybord.js webGL/src/mainfunc.js webGL/src/sound.js webGL/test2.html |
diffstat | 7 files changed, 44 insertions(+), 161 deletions(-) [+] |
line wrap: on
line diff
--- a/webGL/DrumSimulator.html Thu May 03 15:42:45 2012 +0900 +++ b/webGL/DrumSimulator.html Fri May 04 01:18:13 2012 +0900 @@ -72,9 +72,13 @@ l = function(){loop(ctx)}; loadNotes(); loadSounds(); + ptime=0; +// gameStart(); } function gameStart(){ + d1 = new Date(); + time1 = d1.getMilliseconds(); setInterval(l,Interval); } @@ -89,8 +93,14 @@ } function loop(ctx){ //main loop - framerate.snapshot(); - gameRender(ctx,MODE); + d2 = new Date(); + framerate.snapshot(); + gameRender(ctx,MODE); + ptime = d2.getMilliseconds()-time1; + if(ptime<0) + ptime+=1000; + console.log("time is "+ptime); + time1 = d2.getMilliseconds(); } width = -1; @@ -113,7 +123,7 @@ border: 2px solid black; } </style> - <body onload="main()" onkeydown="keybordDown()" onkeypress="keybordPress()" onkeyup="keybordUp()" style='overflow:scroll'> + <body onload="main()" onkeydown="keybordDown()" onkeypress="keybordPress()" onkeyup="keybordUp()" style='overflow:hidden'> <font size="4"> TITLE) SPACE:Go to MAIN MODE<br> MAIN MODE)S:High-hat D:Snare F:Kick J:Tom K:Cymbal SPACE:Play/Stop <!--A:AUTO PLAY<br>-->
--- a/webGL/src/Note.js Thu May 03 15:42:45 2012 +0900 +++ b/webGL/src/Note.js Fri May 04 01:18:13 2012 +0900 @@ -21,7 +21,6 @@ Note.prototype.updLocate = function(BPM,sp){ //sp:HI-SPEED,BPM:Music's BPM - console.log(this.locate); this.locate += BPM*0.01*sp; }; @@ -31,6 +30,7 @@ Note.prototype.kill = function(){ this.alive = false; + console.log(this.time+","+audioBGM.currentTime); switch(this.lane){ case 1: break;
--- a/webGL/src/f4notes.js Thu May 03 15:42:45 2012 +0900 +++ b/webGL/src/f4notes.js Fri May 04 01:18:13 2012 +0900 @@ -1,9 +1,12 @@ +testBPM = 121; + function drawNote(ctx,note){ if(note.getLocate() > 105 && note.isAlive())//105:line's locate note.kill(); if(!note.isAlive()) return; - note.updLocate(121,1.0); + note.updLocate(testBPM,1.0); + if(note.getLane()%2!=0){ PutSpriteF(ctx,58.984375+(note.getLane()-1)*11.71875,note.getLocate(),1,imgs[4]); } @@ -13,6 +16,16 @@ } function loadNotes(){ +/* notesArray.push(new Note(0,4,testBPM)); + notesArray.push(new Note(0.25,4,testBPM)); + notesArray.push(new Note(0.5,4,testBPM)); + notesArray.push(new Note(0.75,4,testBPM)); + notesArray.push(new Note(1.0,4,testBPM)); + notesArray.push(new Note(1.25,4,testBPM)); + notesArray.push(new Note(1.5,4,testBPM)); + notesArray.push(new Note(1.75,4,testBPM)); +*/ + notesArray.push(new Note(0,4,121)); notesArray.push(new Note(1.736,4,121));
--- a/webGL/src/keybord.js Thu May 03 15:42:45 2012 +0900 +++ b/webGL/src/keybord.js Fri May 04 01:18:13 2012 +0900 @@ -85,8 +85,9 @@ if(!SpacePressed){ SpacePressed = true; PlayingBGM = true; - pl = function(){audioBGM.play()}; - var setTime = Interval*105.0*100.0/121.0; + 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; }
--- a/webGL/src/mainfunc.js Thu May 03 15:42:45 2012 +0900 +++ b/webGL/src/mainfunc.js Fri May 04 01:18:13 2012 +0900 @@ -39,7 +39,6 @@ PutSpriteF(ctx,100,7.8125,1,imgs[2]); PutSpriteF(ctx,100,105,1,imgs[3]); //y == 480 for(i=0;i<notesArray.length;i++){ -// notesArray[i].updLocate(150,1.0); drawNote(ctx,notesArray[i]); } PutSpriteF(ctx,100,70,1,imgs[6]);
--- a/webGL/src/sound.js Thu May 03 15:42:45 2012 +0900 +++ b/webGL/src/sound.js Fri May 04 01:18:13 2012 +0900 @@ -6,38 +6,22 @@ var FtomCnt = 0; var KickCnt = 0; var SnareCnt = 0; -/* - -var audioHClose; -var audioHClose2; -var audioHOpen; -var audioHOpen2; -var audioFtom; -var audioFtom2; -var audioCymbal; -var audioCymbal2; -var audioKick; -var audioKick2; -var audioSnare; -var audioSnare2; -var audioBGM; -*/ function loadSounds(){ - audioHClose = loadAudio("sound/hclose.ogg"); - audioHClose2 = loadAudio("sound/hclose.ogg"); - audioHOpen = loadAudio("sound/hopen.ogg"); - audioHOpen2 = loadAudio("sound/hopen.ogg"); - audioFtom = loadAudio("sound/ftom.ogg"); - audioFtom2 = loadAudio("sound/ftom.ogg"); - audioCymbal = loadAudio("sound/cymbal.ogg"); - audioCymbal2 = loadAudio("sound/cymbal.ogg"); - audioKick = loadAudio("sound/kick.ogg"); - audioKick2 = loadAudio("sound/kick.ogg"); - audioSnare = loadAudio("sound/snare.ogg"); - audioSnare2= loadAudio("sound/snare.ogg"); - audioBGM = loadAudio("sound/BGM.ogg"); + audioHClose = loadAudio("sound/hclose.wav"); + audioHClose2 = loadAudio("sound/hclose.wav"); + audioHOpen = loadAudio("sound/hopen.wav"); + audioHOpen2 = loadAudio("sound/hopen.wav"); + audioFtom = loadAudio("sound/ftom.wav"); + audioFtom2 = loadAudio("sound/ftom.wav"); + audioCymbal = loadAudio("sound/cymbal.wav"); + audioCymbal2 = loadAudio("sound/cymbal.wav"); + audioKick = loadAudio("sound/kick.wav"); + audioKick2 = loadAudio("sound/kick.wav"); + audioSnare = loadAudio("sound/snare.wav"); + audioSnare2= loadAudio("sound/snare.wav"); + audioBGM = loadAudio("sound/BGM.wav"); }
--- a/webGL/test2.html Thu May 03 15:42:45 2012 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,124 +0,0 @@ -<!DOCTYPE html> - -<html> - <head> - <meta http-equiv="Content-Type" content="text/html;charset=UTF-8"> - <title>WebGL test2</title> - <script src="src/keybord.js"></script> - <script src="src/sound.js"></script> - <script src="src/J3DI.js"></script> - <script src="src/J3DIMath.js"></script> - <script src="src/f4xml.js"></script> - <script src="src/const.js"></script> - <script src="src/mainfunc.js"></script> - <script src="src/jkl-parsexml.js"></script> - </head> - <script id="vshader" type="x-shader/x-vertex"> - uniform mat4 u_modelViewProjMatrix; - uniform mat4 u_normalMatrix; - uniform vec3 lightDir; - - attribute vec3 vNormal; - attribute vec4 vTexCoord; - attribute vec4 vPosition; - - varying float v_Dot; - varying vec2 v_texCoord; - - void main() - { - gl_Position = u_modelViewProjMatrix * vPosition; - v_texCoord = vTexCoord.st; - vec4 transNormal = u_normalMatrix * vec4(vNormal,1); - v_Dot = max(dot(transNormal.xyz, lightDir), 0.0); - } - </script> - - <script id="fshader" type="x-shader/x-fragment"> - #ifdef GL_ES - precision mediump float; - #endif - - uniform sampler2D sampler2d; - - varying float v_Dot; - varying vec2 v_texCoord; - - void main() - { - vec4 color = texture2D(sampler2d,v_texCoord); - color += vec4(0.1,0.1,0.1,1); - // if(color.a == 1.0)color=vec4(1,0,0,1); - // else color=vec4(0,1,1,1); - gl_FragColor = vec4(color.xyz * v_Dot, color.a); - // gl_FragColor = vec4(color.xyz * v_Dot, 0.5); - } - </script> - <script> - - var WIDTH = 1024; - var HEIGHT = 640; - var MODE = TITLE; - function start(){ - var c = document.getElementById("example"); - c.width = WIDTH; - c.height = HEIGHT; - var ctx = init(); - l = function(){loop(ctx)}; - setInterval(l,10); - } - - function init(){ - var gl = initWebGL("example","vshader","fshader",["vNormal","vTexCoord","vPosition"],[0,0,0,1],10000); - gl.uniform3f(gl.getUniformLocation(gl.program,"lightDir"),0,0,1); - gl.uniform1i(gl.getUniformLocation(gl.program,"sampler2d"),0); - gl.enable(gl.TEXTURE_2D); - parseXml(gl); - - return gl; - } - - function loop(ctx){ //main loop - gameRender(ctx,MODE); - if(MODE==MAIN){ - console.log(getBGMTime()); - } - } - - width = -1; - height = -1; - - function reshape(ctx) - { - var canvas = document.getElementById('example'); - if (canvas.width == width && canvas.width == height) - return; - - width = canvas.width; - height = canvas.height; - - ctx.viewport(0, 0, width, height); - - ctx.perspectiveMatrix = new J3DIMatrix4(); - ctx.perspectiveMatrix.ortho(0, -200, 0, -140, 0, 10000); - } - - </script> - <style type="text/css"> - canvas { - border: 2px solid black; - } - </style> - <body onload="start()" onkeydown="keybordDown()" onkeypress="keybordPress()" onkeyup="keybordUp()" style='overflow:scroll'> - <font size="4"> - TITLE) SPACE:Go to MAIN MODE<br> - MAIN MODE)S:High-hat D:Snare F:Kick J:Tom K:Cymbal SPACE:Play/Stop <!--A:AUTO PLAY<br>--> - <!-- AUTO PLAY)Q:Quit(Back to MAIN MODE)--> - </font> - <canvas id="example"> - There is supposed to be an example drawing here, but it's not important. - </canvas> - <div id="framerate"></div> - <div id="console"></div> - </body> -</html>