9
|
1 function parseXml(gl)
|
|
2 {
|
23
|
3 loadObjXml(gl, "./xml/effect.xml");//gl.objにxmlファイルの中身をいれる
|
13
|
4
|
23
|
5 loadObjXml(gl, "./xml/boss.xml");//gl.bossにxmlファイルの中身を入れる
|
9
|
6
|
23
|
7 loadObjXml(gl, "./xml/titlefont.xml");//gl.objにxmlファイルの中身をいれる
|
|
8 loadObjXml(gl, "./xml/font_pushstart.xml");//gl.objにxmlファイルの中身をいれる
|
|
9 loadObjXml(gl, "./xml/font_superdandy.xml");//gl.objにxmlファイルの中身をいれる
|
|
10 loadObjXml(gl, "./xml/font_0.xml");//gl.objにxmlファイルの中身をいれる
|
|
11 loadObjXml(gl, "./xml/font_1.xml");//gl.objにxmlファイルの中身をいれる
|
|
12 loadObjXml(gl, "./xml/font_2.xml");//gl.objにxmlファイルの中身をいれる
|
|
13 loadObjXml(gl, "./xml/font_3.xml");//gl.objにxmlファイルの中身をいれる
|
|
14 loadObjXml(gl, "./xml/font_4.xml");//gl.objにxmlファイルの中身をいれる
|
|
15 loadObjXml(gl, "./xml/font_5.xml");//gl.objにxmlファイルの中身をいれる
|
|
16 loadObjXml(gl, "./xml/font_6.xml");//gl.objにxmlファイルの中身をいれる
|
|
17 loadObjXml(gl, "./xml/font_7.xml");//gl.objにxmlファイルの中身をいれる
|
|
18 loadObjXml(gl, "./xml/font_8.xml");//gl.objにxmlファイルの中身をいれる
|
|
19 loadObjXml(gl, "./xml/font_9.xml");//gl.objにxmlファイルの中身をいれる
|
|
20 loadObjXml(gl, "./xml/font_hige.xml");//gl.objにxmlファイルの中身をいれる
|
|
21 loadObjXml(gl, "./xml/font_1997yas_k.xml");//gl.objにxmlファイルの中身をいれる
|
|
22 loadObjXml(gl, "./xml/font_gameover.xml");//gl.objにxmlファイルの中身をいれる
|
12
|
23
|
23
|
24 loadObjXml(gl, "./xml2/bullets.xml");//gl.objにxmlファイルの中身をいれる
|
|
25 loadObjXml(gl, "./xml2/enemy.xml");//gl.objにxmlファイルの中身を入れる
|
|
26 loadObjXml(gl, "./xml2/player.xml");//gl.objにxmlファイルの中身を入れる
|
|
27 loadObjXml(gl, "./xml2/redbomb_anim.xml");//gl.objにxmlファイルの中身を入れる
|
|
28 loadObjXml(gl, "./xml2/boss1.xml");//gl.objにxmlファイルの中身を入れる
|
|
29 loadObjXml(gl, "./xml2/boss2.xml");//gl.objにxmlファイルの中身を入れる
|
13
|
30
|
23
|
31 jiki = new makePlayer(gl.obj);//自機の情報をいれておくクラス、グローバル
|
13
|
32
|
|
33 gamesyokika();
|
9
|
34
|
|
35 enemy = [];//敵の情報を入れておく配列を用意、グローバル
|
|
36 pushEnemy(gl,enemy);//配列enemy[]に敵をpush
|
12
|
37 // pushEnemyBullets(gl, enemy);//配列enemy[]に敵の弾情報をpush
|
9
|
38
|
|
39 boss = [];//bossの情報を入れておく配列を用意,グローバル
|
|
40 pushBoss(gl, boss);//配列boss[]にbossの情報をpush
|
|
41
|
|
42 bullets = [];//弾の情報を入れておく配列を用意、グローバル
|
|
43 pushPlayerBullets(gl,bullets);//配列bullets[]に弾をpush
|
11
|
44
|
|
45 bomImage = [];//撃破時の爆発の情報をいれておく配列を用意。グローバル
|
|
46 pushBom(gl, bomImage);//配列 bom[]に爆発をpush
|
|
47
|
12
|
48 font = [];//fontを入れておく配列
|
|
49 pushFont(gl, font);//
|
11
|
50 // ebullets = [];//敵の弾の情報を入れておく配列を用意、グローバル
|
|
51 // pushEnemyBullets(gl, ebullets);
|
9
|
52 }
|
|
53
|
13
|
54
|
23
|
55 function loadObjXml(gl,url)
|
9
|
56 {
|
23
|
57 if(gl.obj == undefined) gl.obj = new Object();
|
9
|
58 var xmlChara = new Object();
|
|
59 xmlChara = parsePanel(url);
|
|
60 for (var name in xmlChara)
|
|
61 {
|
23
|
62 gl.obj[name] = makeXmlObj(gl, xmlChara[name]);
|
|
63 gl.obj[name].texture = loadImageTexture(gl, xmlChara[name].image);
|
9
|
64 }
|
|
65 }
|
|
66
|
|
67 function pushBoss(gl, boss)
|
8
|
68 {
|
23
|
69
|
|
70 boss.push(gl.obj["blackhole"]);
|
|
71 boss.push(gl.obj["boss_orgun"]);//透過ずみ
|
|
72 boss.push(gl.obj["boss2_dummy"]);
|
|
73 boss.push(gl.obj["boss2_rightpalm"]);
|
|
74 boss.push(gl.obj["boss2_lefthand"]);
|
|
75 boss.push(gl.obj["boss2_left_s_gird"]);
|
|
76 boss.push(gl.obj["boss3_body"]);
|
|
77 boss.push(gl.obj["boss_4"]);
|
|
78 boss.push(gl.obj["boss_corpse"]);
|
|
79 boss.push(gl.obj["boss2_righthand"]);
|
|
80 boss.push(gl.obj["boss2_openbattery"]);
|
|
81 boss.push(gl.obj["boss2_rightarm_b"]);
|
|
82 boss.push(gl.obj["boss2_leftpalm"]);
|
|
83 boss.push(gl.obj["boss2_leftarm"]);//以下透過ずみ
|
|
84 boss.push(gl.obj["boss2_rightarm"]);
|
|
85 boss.push(gl.obj["boss2_leftshoulder"]);
|
|
86 boss.push(gl.obj["boss2_left_s_up"]);
|
|
87 boss.push(gl.obj["boss2_battery"]);
|
|
88 boss.push(gl.obj["boss2_brokenhatch"]);
|
|
89 boss.push(gl.obj["boss2_leftbattery"]);
|
|
90 boss.push(gl.obj["boss2_r_shoulderup"]);
|
|
91 boss.push(gl.obj["boss2_body"]);
|
|
92 boss.push(gl.obj["boss2_rightshoulder"]);
|
9
|
93 }
|
|
94
|
|
95
|
|
96 function pushEnemy(gl, enemy)
|
|
97 {
|
23
|
98 enemy.push(gl.obj["missile"]);
|
|
99 enemy.push(gl.obj["enemy_greencrab"]);
|
|
100 enemy.push(gl.obj["enemy_plane"]);
|
|
101 enemy.push(gl.obj["gunbattery"]);
|
|
102 enemy.push(gl.obj["enemy_redbullet"]);
|
|
103 enemy.push(gl.obj["enemy_bluebullet"]);
|
|
104 enemy.push(gl.obj["tama_s_01"]);
|
|
105 enemy.push(gl.obj["tama_s_02"]);
|
|
106 enemy.push(gl.obj["tama_s_03"]);
|
|
107 enemy.push(gl.obj["meteo"]);
|
|
108 enemy.push(gl.obj["tama_l_02"]);
|
|
109 enemy.push(gl.obj["tama_l_03"]);
|
|
110 enemy.push(gl.obj["enemy_lightning"]);
|
|
111 enemy.push(gl.obj["enemy_lasersplosh.001"]);
|
|
112 enemy.push(gl.obj["enemy_lasersplosh.002"]);
|
|
113 enemy.push(gl.obj["enemy_lasersplosh.003"]);
|
|
114 enemy.push(gl.obj["missile"]);
|
|
115 enemy.push(gl.obj["spacefish"]);
|
|
116 enemy.push(gl.obj["tama_s_04"]);
|
8
|
117 }
|
|
118
|
9
|
119
|
|
120
|
|
121 function pushPlayerBullets(gl,bullets)
|
8
|
122 {
|
23
|
123 bullets.push(gl.obj["bluebarrier"]);
|
|
124 bullets.push(gl.obj["lockon_sight"]);
|
|
125 bullets.push(gl.obj["bulebullet_right"]);
|
|
126 bullets.push(gl.obj["bulebullet_left"]);
|
|
127 bullets.push(gl.obj["redbullet"]);
|
|
128 bullets.push(gl.obj["greenbullet"]);
|
|
129 bullets.push(gl.obj["lonlaser"]);
|
8
|
130 }
|
|
131
|
11
|
132 function pushBom(gl, bomImage)
|
|
133 {
|
23
|
134 bomImage.push(gl.obj["redbomb_anim_0"]);
|
|
135 bomImage.push(gl.obj["redbomb_anim_1"]);
|
|
136 bomImage.push(gl.obj["redbomb_anim_2"]);
|
|
137 bomImage.push(gl.obj["redbomb_anim_3"]);
|
|
138 bomImage.push(gl.obj["redbomb_anim_4"]);
|
|
139 bomImage.push(gl.obj["redbomb_anim_5"]);
|
|
140 bomImage.push(gl.obj["redbomb_anim_6"]);
|
|
141 bomImage.push(gl.obj["redbomb_anim_7"]);
|
11
|
142 }
|
|
143
|
|
144 function pushEnemyBullets(gl, ebullets)
|
|
145 {
|
23
|
146 ebullets.push(gl.obj["enemy_redbullet"]);
|
|
147 ebullets.push(gl.obj["enemy_bluebullet"]);
|
|
148 ebullets.push(gl.obj["tama_s_01"]);
|
|
149 ebullets.push(gl.obj["tama_s_02"]);
|
|
150 ebullets.push(gl.obj["tama_s_03"]);
|
|
151 ebullets.push(gl.obj["tama_s_04"]);
|
|
152 ebullets.push(gl.obj["tama_l_02"]);
|
|
153 ebullets.push(gl.obj["tama_l_03"]);
|
|
154 ebullets.push(gl.obj["tama_l_04"]);
|
12
|
155 }
|
|
156
|
|
157 function pushFont(gl, font)
|
|
158 {
|
23
|
159 font.push(gl.obj["font_0"]);
|
|
160 font.push(gl.obj["font_1"]);
|
|
161 font.push(gl.obj["font_2"]);
|
|
162 font.push(gl.obj["font_3"]);
|
|
163 font.push(gl.obj["font_4"]);
|
|
164 font.push(gl.obj["font_5"]);
|
|
165 font.push(gl.obj["font_6"]);
|
|
166 font.push(gl.obj["font_7"]);
|
|
167 font.push(gl.obj["font_8"]);
|
|
168 font.push(gl.obj["font_9"])
|
|
169 font.push(gl.obj["titlefont"]);
|
|
170 font.push(gl.obj["font_pushstart"]);
|
|
171 font.push(gl.obj["font_superdandy"]);
|
|
172 font.push(gl.obj["font_hige"]);
|
|
173 font.push(gl.obj["font_font_1997yas_k"]);
|
|
174 font.push(gl.obj["font_gameover"]);
|
12
|
175 }
|
|
176
|
|
177 function PutSpriteF(ctx, x, y, scale, glObj)
|
|
178 {
|
|
179
|
|
180 // setup VBOs
|
|
181 ctx.enableVertexAttribArray(0);
|
|
182 ctx.enableVertexAttribArray(1);
|
|
183 ctx.enableVertexAttribArray(2);
|
|
184
|
|
185 ctx.bindBuffer(ctx.ARRAY_BUFFER, glObj.vertexObject);
|
|
186 ctx.vertexAttribPointer(2, 3, ctx.FLOAT, false, 0, 0);
|
|
187 ctx.bindBuffer(ctx.ARRAY_BUFFER, glObj.normalObject);
|
|
188 ctx.vertexAttribPointer(0, 3, ctx.FLOAT, false, 0, 0);
|
|
189
|
|
190 ctx.bindBuffer(ctx.ARRAY_BUFFER, glObj.texCoordObject);
|
|
191 ctx.vertexAttribPointer(1, 2, ctx.FLOAT, false, 0, 0);
|
26
|
192
|
12
|
193 ctx.bindBuffer(ctx.ELEMENT_ARRAY_BUFFER, glObj.indexObject);
|
|
194
|
26
|
195
|
12
|
196 // generate the model-view matrix
|
23
|
197 var mvMatrix = new J3DIMatrix4();
|
12
|
198 mvMatrix.scale(scale, scale, scale);
|
26
|
199 mvMatrix.translate( x, y, 10);
|
12
|
200
|
|
201 // construct the normal matrix from the model-view matrix
|
23
|
202 var normalMatrix = new J3DIMatrix4(mvMatrix);
|
12
|
203 normalMatrix.invert();
|
|
204 normalMatrix.transpose();
|
23
|
205 normalMatrix.setUniform(ctx, ctx.getUniformLocation(ctx.program, "u_normalMatrix"), false);
|
12
|
206
|
|
207 // construct the model-view * projection matrix
|
23
|
208 var mvpMatrix = new J3DIMatrix4(ctx.perspectiveMatrix);
|
|
209 mvpMatrix.multiply(mvMatrix);
|
26
|
210 mvpMatrix.setUniform(ctx, ctx.getUniformLocation(ctx.program, "u_modelViewProjMatrix"), false);
|
23
|
211
|
12
|
212
|
|
213 ctx.bindTexture(ctx.TEXTURE_2D, glObj.texture);
|
|
214 ctx.drawElements(ctx.TRIANGLES, glObj.numIndices, ctx.UNSIGNED_SHORT, 0);
|
|
215
|
|
216
|
13
|
217 }
|
|
218
|
26
|
219 function PutSpriteA(ctx, x, y, scale, angle, glObj)
|
13
|
220 {
|
|
221
|
|
222 // setup VBOs
|
|
223 ctx.enableVertexAttribArray(0);
|
|
224 ctx.enableVertexAttribArray(1);
|
|
225 ctx.enableVertexAttribArray(2);
|
|
226
|
|
227 ctx.bindBuffer(ctx.ARRAY_BUFFER, glObj.vertexObject);
|
|
228 ctx.vertexAttribPointer(2, 3, ctx.FLOAT, false, 0, 0);
|
|
229 ctx.bindBuffer(ctx.ARRAY_BUFFER, glObj.normalObject);
|
|
230 ctx.vertexAttribPointer(0, 3, ctx.FLOAT, false, 0, 0);
|
|
231
|
|
232 ctx.bindBuffer(ctx.ARRAY_BUFFER, glObj.texCoordObject);
|
|
233 ctx.vertexAttribPointer(1, 2, ctx.FLOAT, false, 0, 0);
|
|
234
|
|
235 ctx.bindBuffer(ctx.ELEMENT_ARRAY_BUFFER, glObj.indexObject);
|
|
236
|
|
237 // generate the model-view matrix
|
23
|
238 var mvMatrix = new J3DIMatrix4();
|
13
|
239 mvMatrix.scale(scale, scale, scale);
|
26
|
240 mvMatrix.translate( x, y, 10);
|
13
|
241 mvMatrix.rotate(angle, 0, 0, 1);
|
|
242
|
|
243 // construct the normal matrix from the model-view matrix
|
23
|
244 var normalMatrix = new J3DIMatrix4(mvMatrix);
|
13
|
245 normalMatrix.invert();
|
|
246 normalMatrix.transpose();
|
23
|
247 normalMatrix.setUniform(ctx, ctx.getUniformLocation(ctx.program, "u_normalMatrix"), false);
|
13
|
248
|
|
249 // construct the model-view * projection matrix
|
26
|
250 var mvpMatrix = new J3DIMatrix4(ctx.perspectiveMatrix);
|
|
251 mvpMatrix.multiply(mvMatrix);
|
23
|
252 mvpMatrix.setUniform(ctx, ctx.getUniformLocation(ctx.program, "u_modelViewProjMatrix"), false);
|
|
253
|
13
|
254
|
|
255 ctx.bindTexture(ctx.TEXTURE_2D, glObj.texture);
|
|
256 ctx.drawElements(ctx.TRIANGLES, glObj.numIndices, ctx.UNSIGNED_SHORT, 0);
|
|
257
|
11
|
258 } |