annotate webGL/src/mainfunc.js @ 16:b322a8557f93 draft

draw text
author e105711 <yomitan.ie.u-ryukyu.ac.jp>
date Tue, 03 Jul 2012 23:20:21 +0900
parents 80789d11de5c
children 1e8fa3c370ab
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7
c5455ae6cd70 8th,change a way of update to notes,support ogg and wav sound
e105711 <yomitan.ie.u-ryukyu.ac.jp>
parents: 6
diff changeset
1 function gameRender(ctx){
c5455ae6cd70 8th,change a way of update to notes,support ogg and wav sound
e105711 <yomitan.ie.u-ryukyu.ac.jp>
parents: 6
diff changeset
2 drawObj(ctx);
0
9285dae61395 1st commit,just play sounds.
e105711 <yomitan.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3 }
9285dae61395 1st commit,just play sounds.
e105711 <yomitan.ie.u-ryukyu.ac.jp>
parents:
diff changeset
4
7
c5455ae6cd70 8th,change a way of update to notes,support ogg and wav sound
e105711 <yomitan.ie.u-ryukyu.ac.jp>
parents: 6
diff changeset
5 function gameUpdate(){
5
a730b51d59eb 6th:use stat.js,divide render and update,change a way of updating game.
e105711 <yomitan.ie.u-ryukyu.ac.jp>
parents: 4
diff changeset
6 switch(MODE){
a730b51d59eb 6th:use stat.js,divide render and update,change a way of updating game.
e105711 <yomitan.ie.u-ryukyu.ac.jp>
parents: 4
diff changeset
7 case PLAY:
a730b51d59eb 6th:use stat.js,divide render and update,change a way of updating game.
e105711 <yomitan.ie.u-ryukyu.ac.jp>
parents: 4
diff changeset
8 playUpdate();
15
80789d11de5c add function for text draw
e105711 <yomitan.ie.u-ryukyu.ac.jp>
parents: 13
diff changeset
9 break;
16
b322a8557f93 draw text
e105711 <yomitan.ie.u-ryukyu.ac.jp>
parents: 15
diff changeset
10 default:
15
80789d11de5c add function for text draw
e105711 <yomitan.ie.u-ryukyu.ac.jp>
parents: 13
diff changeset
11 break;
5
a730b51d59eb 6th:use stat.js,divide render and update,change a way of updating game.
e105711 <yomitan.ie.u-ryukyu.ac.jp>
parents: 4
diff changeset
12 }
a730b51d59eb 6th:use stat.js,divide render and update,change a way of updating game.
e105711 <yomitan.ie.u-ryukyu.ac.jp>
parents: 4
diff changeset
13 }
a730b51d59eb 6th:use stat.js,divide render and update,change a way of updating game.
e105711 <yomitan.ie.u-ryukyu.ac.jp>
parents: 4
diff changeset
14
7
c5455ae6cd70 8th,change a way of update to notes,support ogg and wav sound
e105711 <yomitan.ie.u-ryukyu.ac.jp>
parents: 6
diff changeset
15 function toTitle(){
c5455ae6cd70 8th,change a way of update to notes,support ogg and wav sound
e105711 <yomitan.ie.u-ryukyu.ac.jp>
parents: 6
diff changeset
16 MODE = TITLE;
c5455ae6cd70 8th,change a way of update to notes,support ogg and wav sound
e105711 <yomitan.ie.u-ryukyu.ac.jp>
parents: 6
diff changeset
17 objsArray.length = 0;
16
b322a8557f93 draw text
e105711 <yomitan.ie.u-ryukyu.ac.jp>
parents: 15
diff changeset
18 objsArray.push(new Obj(100,30,1,"title"));
b322a8557f93 draw text
e105711 <yomitan.ie.u-ryukyu.ac.jp>
parents: 15
diff changeset
19 objsArray.push(new Obj(100,90,1,"press"));
0
9285dae61395 1st commit,just play sounds.
e105711 <yomitan.ie.u-ryukyu.ac.jp>
parents:
diff changeset
20 }
9285dae61395 1st commit,just play sounds.
e105711 <yomitan.ie.u-ryukyu.ac.jp>
parents:
diff changeset
21
13
74dc1d5f2e47 can select music
e105711 <yomitan.ie.u-ryukyu.ac.jp>
parents: 10
diff changeset
22 function toMenu(){
74dc1d5f2e47 can select music
e105711 <yomitan.ie.u-ryukyu.ac.jp>
parents: 10
diff changeset
23 MODE = MENU;
74dc1d5f2e47 can select music
e105711 <yomitan.ie.u-ryukyu.ac.jp>
parents: 10
diff changeset
24 objsArray.length = 0;
16
b322a8557f93 draw text
e105711 <yomitan.ie.u-ryukyu.ac.jp>
parents: 15
diff changeset
25 objsArray.push(new Obj(100,7.8125,1,"select_music"));
b322a8557f93 draw text
e105711 <yomitan.ie.u-ryukyu.ac.jp>
parents: 15
diff changeset
26 // loadMusicTitle(cursor.getIndex());
b322a8557f93 draw text
e105711 <yomitan.ie.u-ryukyu.ac.jp>
parents: 15
diff changeset
27 // drawText(ctx,"music_title",musicsArray(cursor.getIndex()).getTitle(),60,"white","center",432,86);
b322a8557f93 draw text
e105711 <yomitan.ie.u-ryukyu.ac.jp>
parents: 15
diff changeset
28 objsArray.push(new Obj(100,40,1,"music_title"));
13
74dc1d5f2e47 can select music
e105711 <yomitan.ie.u-ryukyu.ac.jp>
parents: 10
diff changeset
29 }
74dc1d5f2e47 can select music
e105711 <yomitan.ie.u-ryukyu.ac.jp>
parents: 10
diff changeset
30
7
c5455ae6cd70 8th,change a way of update to notes,support ogg and wav sound
e105711 <yomitan.ie.u-ryukyu.ac.jp>
parents: 6
diff changeset
31 function toMain(){
c5455ae6cd70 8th,change a way of update to notes,support ogg and wav sound
e105711 <yomitan.ie.u-ryukyu.ac.jp>
parents: 6
diff changeset
32 MODE = MAIN;
c5455ae6cd70 8th,change a way of update to notes,support ogg and wav sound
e105711 <yomitan.ie.u-ryukyu.ac.jp>
parents: 6
diff changeset
33 objsArray.length = 0;
16
b322a8557f93 draw text
e105711 <yomitan.ie.u-ryukyu.ac.jp>
parents: 15
diff changeset
34 objsArray.push(new Obj(100,7.8125,1,"main_mode")); // main mode
b322a8557f93 draw text
e105711 <yomitan.ie.u-ryukyu.ac.jp>
parents: 15
diff changeset
35 objsArray.push(new Obj(100,105,1,"line"));
7
c5455ae6cd70 8th,change a way of update to notes,support ogg and wav sound
e105711 <yomitan.ie.u-ryukyu.ac.jp>
parents: 6
diff changeset
36 }
c5455ae6cd70 8th,change a way of update to notes,support ogg and wav sound
e105711 <yomitan.ie.u-ryukyu.ac.jp>
parents: 6
diff changeset
37
c5455ae6cd70 8th,change a way of update to notes,support ogg and wav sound
e105711 <yomitan.ie.u-ryukyu.ac.jp>
parents: 6
diff changeset
38 function toPlay(){
c5455ae6cd70 8th,change a way of update to notes,support ogg and wav sound
e105711 <yomitan.ie.u-ryukyu.ac.jp>
parents: 6
diff changeset
39 MODE = PLAY;
c5455ae6cd70 8th,change a way of update to notes,support ogg and wav sound
e105711 <yomitan.ie.u-ryukyu.ac.jp>
parents: 6
diff changeset
40 objsArray.length = 0;
16
b322a8557f93 draw text
e105711 <yomitan.ie.u-ryukyu.ac.jp>
parents: 15
diff changeset
41 objsArray.push(new Obj(100,7.8125,1,"main_mode")); // main mode
13
74dc1d5f2e47 can select music
e105711 <yomitan.ie.u-ryukyu.ac.jp>
parents: 10
diff changeset
42 loadMusics(musicsArray[cursor.getIndex()]);
7
c5455ae6cd70 8th,change a way of update to notes,support ogg and wav sound
e105711 <yomitan.ie.u-ryukyu.ac.jp>
parents: 6
diff changeset
43 }
c5455ae6cd70 8th,change a way of update to notes,support ogg and wav sound
e105711 <yomitan.ie.u-ryukyu.ac.jp>
parents: 6
diff changeset
44
15
80789d11de5c add function for text draw
e105711 <yomitan.ie.u-ryukyu.ac.jp>
parents: 13
diff changeset
45 function toResult(){
80789d11de5c add function for text draw
e105711 <yomitan.ie.u-ryukyu.ac.jp>
parents: 13
diff changeset
46 MODE = RESULT;
80789d11de5c add function for text draw
e105711 <yomitan.ie.u-ryukyu.ac.jp>
parents: 13
diff changeset
47 showResult();
80789d11de5c add function for text draw
e105711 <yomitan.ie.u-ryukyu.ac.jp>
parents: 13
diff changeset
48 }
7
c5455ae6cd70 8th,change a way of update to notes,support ogg and wav sound
e105711 <yomitan.ie.u-ryukyu.ac.jp>
parents: 6
diff changeset
49
c5455ae6cd70 8th,change a way of update to notes,support ogg and wav sound
e105711 <yomitan.ie.u-ryukyu.ac.jp>
parents: 6
diff changeset
50 function drawObj(ctx){
2
55702e139f69 3rd,show Notes and set Timing, but it is not completely.
e105711 <yomitan.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
51 reshape(ctx);
6
8c25fd3f9866 7th,change a way of sounds play
e105711 <yomitan.ie.u-ryukyu.ac.jp>
parents: 5
diff changeset
52 ctx.clearColor(0,0,0,1);
0
9285dae61395 1st commit,just play sounds.
e105711 <yomitan.ie.u-ryukyu.ac.jp>
parents:
diff changeset
53 ctx.clear(ctx.COLOR_BUFFER_BIT | ctx.DEPTH_BUFFER_BIT);
7
c5455ae6cd70 8th,change a way of update to notes,support ogg and wav sound
e105711 <yomitan.ie.u-ryukyu.ac.jp>
parents: 6
diff changeset
54 for(var i=0;i < objsArray.length;i++){
c5455ae6cd70 8th,change a way of update to notes,support ogg and wav sound
e105711 <yomitan.ie.u-ryukyu.ac.jp>
parents: 6
diff changeset
55 var obj = objsArray[i];
16
b322a8557f93 draw text
e105711 <yomitan.ie.u-ryukyu.ac.jp>
parents: 15
diff changeset
56 PutSpriteF(ctx,obj.x,obj.y,obj.scale,ctx.obj[obj.imgName]);
2
55702e139f69 3rd,show Notes and set Timing, but it is not completely.
e105711 <yomitan.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
57 }
7
c5455ae6cd70 8th,change a way of update to notes,support ogg and wav sound
e105711 <yomitan.ie.u-ryukyu.ac.jp>
parents: 6
diff changeset
58 if(MODE==PLAY){
c5455ae6cd70 8th,change a way of update to notes,support ogg and wav sound
e105711 <yomitan.ie.u-ryukyu.ac.jp>
parents: 6
diff changeset
59 drawNote(ctx);
16
b322a8557f93 draw text
e105711 <yomitan.ie.u-ryukyu.ac.jp>
parents: 15
diff changeset
60 PutSpriteF(ctx,100,105,1,ctx.obj["line"]); // line
7
c5455ae6cd70 8th,change a way of update to notes,support ogg and wav sound
e105711 <yomitan.ie.u-ryukyu.ac.jp>
parents: 6
diff changeset
61 }
16
b322a8557f93 draw text
e105711 <yomitan.ie.u-ryukyu.ac.jp>
parents: 15
diff changeset
62 PutSpriteF(ctx,100,70,1,ctx.obj["back"]); // background
0
9285dae61395 1st commit,just play sounds.
e105711 <yomitan.ie.u-ryukyu.ac.jp>
parents:
diff changeset
63 ctx.flush();
5
a730b51d59eb 6th:use stat.js,divide render and update,change a way of updating game.
e105711 <yomitan.ie.u-ryukyu.ac.jp>
parents: 4
diff changeset
64 }
a730b51d59eb 6th:use stat.js,divide render and update,change a way of updating game.
e105711 <yomitan.ie.u-ryukyu.ac.jp>
parents: 4
diff changeset
65
a730b51d59eb 6th:use stat.js,divide render and update,change a way of updating game.
e105711 <yomitan.ie.u-ryukyu.ac.jp>
parents: 4
diff changeset
66 function playUpdate(){
10
98a90bc478b3 Change function name.upd->update
e105711 <yomitan.ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
67 updateNote();
15
80789d11de5c add function for text draw
e105711 <yomitan.ie.u-ryukyu.ac.jp>
parents: 13
diff changeset
68 if(BGMEndCheck()){
80789d11de5c add function for text draw
e105711 <yomitan.ie.u-ryukyu.ac.jp>
parents: 13
diff changeset
69 toResult();
80789d11de5c add function for text draw
e105711 <yomitan.ie.u-ryukyu.ac.jp>
parents: 13
diff changeset
70 }
13
74dc1d5f2e47 can select music
e105711 <yomitan.ie.u-ryukyu.ac.jp>
parents: 10
diff changeset
71 }
74dc1d5f2e47 can select music
e105711 <yomitan.ie.u-ryukyu.ac.jp>
parents: 10
diff changeset
72