diff webGL/src/mainfunc.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 diff
--- a/webGL/src/mainfunc.js	Sat May 05 01:49:16 2012 +0900
+++ b/webGL/src/mainfunc.js	Sat May 05 23:57:18 2012 +0900
@@ -1,17 +1,8 @@
-function gameRender(ctx,MODE){
-    switch(MODE){
-    case TITLE:
-	titleRender(ctx);
-	break;
-    case MAIN:
-	mainRender(ctx);
-	break;
-    case PLAY:
-	playRender(ctx);
-    }
+function gameRender(ctx){
+    drawObj(ctx);
 }
 
-function gameUpdate(MODE){
+function gameUpdate(){
     switch(MODE){
     case TITLE:
 //	titleUpdate();
@@ -24,37 +15,40 @@
     }    
 }
 
-function titleRender(ctx){
-    reshape(ctx);
-    ctx.clearColor(0,0,0,1);
-    ctx.clear(ctx.COLOR_BUFFER_BIT | ctx.DEPTH_BUFFER_BIT);
-    PutSpriteF(ctx,100,30,1,imgs[0]);
-    PutSpriteF(ctx,100,90,1,imgs[1]);
-    PutSpriteF(ctx,100,70,1,imgs[6]);
-    ctx.flush();
+function toTitle(){
+    MODE = TITLE;
+    objsArray.length = 0;
+    objsArray.push(new Obj(100,30,1,0));
+    objsArray.push(new Obj(100,90,1,1));
 }
 
-function mainRender(ctx){
+function toMain(){
+    MODE = MAIN;
+    objsArray.length = 0;
+    objsArray.push(new Obj(100,7.8125,1,2));
+    objsArray.push(new Obj(100,105,1,3));
+}
+
+function toPlay(){
+    MODE = PLAY;
+    objsArray.length = 0;
+    objsArray.push(new Obj(100,7.8125,1,2));
+    objsArray.push(new Obj(100,105,1,3));
+}
+
+
+function drawObj(ctx){
     reshape(ctx);
     ctx.clearColor(0,0,0,1);
     ctx.clear(ctx.COLOR_BUFFER_BIT | ctx.DEPTH_BUFFER_BIT);
-    PutSpriteF(ctx,100,7.8125,1,imgs[2]);
-    PutSpriteF(ctx,100,105,1,imgs[3]);  //y == 480
-
-    PutSpriteF(ctx,100,70,1,imgs[6]);
-    ctx.flush();
-}
-
-function playRender(ctx){
-    reshape(ctx);
-    ctx.clearColor(0,0,0,1);
-    ctx.clear(ctx.COLOR_BUFFER_BIT | ctx.DEPTH_BUFFER_BIT);
-    PutSpriteF(ctx,100,7.8125,1,imgs[2]);
-    PutSpriteF(ctx,100,105,1,imgs[3]);  //y == 480
-    for(i=0;i<notesArray.length;i++){
-	drawNote(ctx,notesArray[i]);
+    for(var i=0;i < objsArray.length;i++){
+	var obj = objsArray[i];
+	PutSpriteF(ctx,obj.x,obj.y,obj.scale,imgs[obj.imgNo]);
     }
-    PutSpriteF(ctx,100,70,1,imgs[6]);
+    if(MODE==PLAY){
+	drawNote(ctx);
+    }
+    PutSpriteF(ctx,100,70,1,imgs[6]); //background
     ctx.flush();
 }