Mercurial > hg > Members > e085711
comparison webGL/dandy/resources/parse.js @ 12:61febc94fa62
upload dandy4.html,new xmlFile
author | NOBUYASU Oshiro |
---|---|
date | Thu, 15 Jul 2010 07:08:37 +0900 |
parents | 680b5b0cd1e4 |
children | 4684e849866c |
comparison
equal
deleted
inserted
replaced
11:680b5b0cd1e4 | 12:61febc94fa62 |
---|---|
1 function parseXml(gl) | 1 function parseXml(gl) |
2 { | 2 { |
3 | 3 |
4 loadCharaXml(gl, "./xml/character.xml");//gl.charaにxmlファイルの中身を入れる | 4 loadCharaXml(gl, "./xml/character.xml");//gl.charaにxmlファイルの中身を入れる |
5 loadCharaXml(gl, "./xml2/enemy.xml");//gl.charaにxmlファイルの中身を入れる | |
6 | |
5 loadEffectXml(gl, "./xml/effect.xml");//gl.effectにxmlファイルの中身をいれる | 7 loadEffectXml(gl, "./xml/effect.xml");//gl.effectにxmlファイルの中身をいれる |
8 loadEffectXml(gl, "./xml2/bullets.xml");//gl.effectにxmlファイルの中身をいれる | |
9 | |
10 | |
6 loadBossXml(gl, "./xml/boss.xml");//gl.bossにxmlファイルの中身を入れる | 11 loadBossXml(gl, "./xml/boss.xml");//gl.bossにxmlファイルの中身を入れる |
7 | 12 |
8 loadCharaXml(gl, "./xml/titlefont.xml");//gl.effectにxmlファイルの中身をいれる | 13 loadCharaXml(gl, "./xml/titlefont.xml");//gl.effectにxmlファイルの中身をいれる |
9 loadCharaXml(gl, "./xml/font_pushstart.xml");//gl.effectにxmlファイルの中身をいれる | 14 loadCharaXml(gl, "./xml/font_pushstart.xml");//gl.effectにxmlファイルの中身をいれる |
10 loadCharaXml(gl, "./xml/font_superdandy.xml");//gl.effectにxmlファイルの中身をいれる | 15 loadCharaXml(gl, "./xml/font_superdandy.xml");//gl.effectにxmlファイルの中身をいれる |
11 loadCharaXml(gl, "./xml/font_0.xml");//gl.effectにxmlファイルの中身をいれる | 16 loadCharaXml(gl, "./xml/font_0.xml");//gl.effectにxmlファイルの中身をいれる |
12 loadCharaXml(gl, "./xml/font_1.xml");//gl.effectにxmlファイルの中身をいれる | 17 loadCharaXml(gl, "./xml/font_1.xml");//gl.effectにxmlファイルの中身をいれる |
13 loadCharaXml(gl, "./xml/font_2.xml");//gl.effectにxmlファイルの中身をいれる | 18 loadCharaXml(gl, "./xml/font_2.xml");//gl.effectにxmlファイルの中身をいれる |
19 loadCharaXml(gl, "./xml/font_3.xml");//gl.effectにxmlファイルの中身をいれる | |
20 loadCharaXml(gl, "./xml/font_4.xml");//gl.effectにxmlファイルの中身をいれる | |
21 loadCharaXml(gl, "./xml/font_5.xml");//gl.effectにxmlファイルの中身をいれる | |
22 loadCharaXml(gl, "./xml/font_6.xml");//gl.effectにxmlファイルの中身をいれる | |
23 loadCharaXml(gl, "./xml/font_7.xml");//gl.effectにxmlファイルの中身をいれる | |
24 loadCharaXml(gl, "./xml/font_8.xml");//gl.effectにxmlファイルの中身をいれる | |
25 loadCharaXml(gl, "./xml/font_9.xml");//gl.effectにxmlファイルの中身をいれる | |
26 loadCharaXml(gl, "./xml/font_hige.xml");//gl.effectにxmlファイルの中身をいれる | |
27 loadCharaXml(gl, "./xml/font_1997yas_k.xml");//gl.effectにxmlファイルの中身をいれる | |
28 loadCharaXml(gl, "./xml/font_gameover.xml");//gl.effectにxmlファイルの中身をいれる | |
14 | 29 |
15 jiki = new makePlayer(gl.chara);//自機の情報をいれておくクラス、グローバル | 30 jiki = new makePlayer(gl.chara);//自機の情報をいれておくクラス、グローバル |
31 | |
32 gamesyokika(); | |
16 | 33 |
17 enemy = [];//敵の情報を入れておく配列を用意、グローバル | 34 enemy = [];//敵の情報を入れておく配列を用意、グローバル |
18 pushEnemy(gl,enemy);//配列enemy[]に敵をpush | 35 pushEnemy(gl,enemy);//配列enemy[]に敵をpush |
19 // pushEnemyBullets(gl, enemy);//配列enemy[]に敵の弾情報をpush | 36 // pushEnemyBullets(gl, enemy);//配列enemy[]に敵の弾情報をpush |
20 | 37 |
30 font = [];//fontを入れておく配列 | 47 font = [];//fontを入れておく配列 |
31 pushFont(gl, font);// | 48 pushFont(gl, font);// |
32 // ebullets = [];//敵の弾の情報を入れておく配列を用意、グローバル | 49 // ebullets = [];//敵の弾の情報を入れておく配列を用意、グローバル |
33 // pushEnemyBullets(gl, ebullets); | 50 // pushEnemyBullets(gl, ebullets); |
34 } | 51 } |
52 | |
53 | |
35 | 54 |
36 function loadCharaXml(gl,url) | 55 function loadCharaXml(gl,url) |
37 { | 56 { |
38 if(gl.chara == undefined) gl.chara = new Object(); | 57 if(gl.chara == undefined) gl.chara = new Object(); |
39 var xmlChara = new Object(); | 58 var xmlChara = new Object(); |
79 | 98 |
80 | 99 |
81 function pushEnemy(gl, enemy) | 100 function pushEnemy(gl, enemy) |
82 { | 101 { |
83 enemy.push(gl.chara["meteo"]); | 102 enemy.push(gl.chara["meteo"]); |
84 enemy.push(gl.chara["enemy_greenclab"]); | 103 enemy.push(gl.chara["enemy_greencrab"]); |
85 enemy.push(gl.chara["missile"]); | 104 enemy.push(gl.chara["missile"]); |
86 enemy.push(gl.chara["gunbattery"]); | 105 enemy.push(gl.chara["gunbattery"]); |
87 enemy.push(gl.effect["enemy_redbullet"]); | 106 enemy.push(gl.effect["enemy_redbullet"]); |
88 enemy.push(gl.effect["enemy_bluebullet"]); | 107 enemy.push(gl.effect["enemy_bluebullet"]); |
89 enemy.push(gl.effect["tama_s_01"]); | 108 enemy.push(gl.effect["tama_s_01"]); |
90 enemy.push(gl.effect["tama_s_02"]); | 109 enemy.push(gl.effect["tama_s_02"]); |
91 enemy.push(gl.effect["tama_s_03"]); | 110 enemy.push(gl.effect["tama_s_03"]); |
92 enemy.push(gl.effect["tama_s_04"]); | 111 enemy.push(gl.effect["tama_s_04"]); |
93 enemy.push(gl.effect["tama_l_02"]); | 112 enemy.push(gl.effect["tama_l_02"]); |
94 enemy.push(gl.effect["tama_l_03"]); | 113 enemy.push(gl.effect["tama_l_03"]); |
95 enemy.push(gl.chara["meteo"]); | 114 enemy.push(gl.chara["enemy_plane"]); |
96 | 115 enemy.push(gl.chara["spacefish"]); |
97 } | 116 } |
98 | 117 |
99 | 118 |
100 | 119 |
101 function pushPlayerBullets(gl,bullets) | 120 function pushPlayerBullets(gl,bullets) |
102 { | 121 { |
103 // if(bullets == undefined) var bullets = []; | |
104 bullets.push(gl.effect["bluebarrier"]); | 122 bullets.push(gl.effect["bluebarrier"]); |
123 bullets.push(gl.effect["lockon_sight"]); | |
124 bullets.push(gl.effect["bulebullet_right"]); | |
105 bullets.push(gl.effect["bulebullet_left"]); | 125 bullets.push(gl.effect["bulebullet_left"]); |
106 bullets.push(gl.effect["bulebullet_right"]); | |
107 bullets.push(gl.effect["redbullet"]); | 126 bullets.push(gl.effect["redbullet"]); |
108 bullets.push(gl.effect["greenbullet"]); | 127 bullets.push(gl.effect["greenbullet"]); |
109 bullets.push(gl.effect["lonlaser"]); | 128 bullets.push(gl.effect["lonlaser"]); |
110 | |
111 // return bullets; | |
112 } | 129 } |
113 | 130 |
114 function pushBom(gl, bomImage) | 131 function pushBom(gl, bomImage) |
115 { | 132 { |
116 bomImage.push(gl.effect["redbomb_anim_0"]); | 133 bomImage.push(gl.effect["redbomb_anim_0"]); |
138 function pushFont(gl, font) | 155 function pushFont(gl, font) |
139 { | 156 { |
140 font.push(gl.chara["font_0"]); | 157 font.push(gl.chara["font_0"]); |
141 font.push(gl.chara["font_1"]); | 158 font.push(gl.chara["font_1"]); |
142 font.push(gl.chara["font_2"]); | 159 font.push(gl.chara["font_2"]); |
143 font.push(gl.chara["font_2"]); | 160 font.push(gl.chara["font_3"]); |
144 font.push(gl.chara["font_2"]); | 161 font.push(gl.chara["font_4"]); |
145 font.push(gl.chara["font_0"]); | 162 font.push(gl.chara["font_5"]); |
146 font.push(gl.chara["font_1"]); | 163 font.push(gl.chara["font_6"]); |
147 font.push(gl.chara["font_2"]); | 164 font.push(gl.chara["font_7"]); |
148 font.push(gl.chara["font_2"]); | 165 font.push(gl.chara["font_8"]); |
149 font.push(gl.chara["font_2"]); | 166 font.push(gl.chara["font_9"]) |
150 font.push(gl.chara["titlefont"]); | 167 font.push(gl.chara["titlefont"]); |
151 font.push(gl.chara["font_pushstart"]); | 168 font.push(gl.chara["font_pushstart"]); |
152 font.push(gl.chara["font_superdandy"]); | 169 font.push(gl.chara["font_superdandy"]); |
170 font.push(gl.chara["font_hige"]); | |
171 font.push(gl.chara["font_font_1997yas_k"]); | |
172 font.push(gl.chara["font_gameover"]); | |
153 } | 173 } |
154 | 174 |
155 function PutSpriteF(ctx, x, y, scale, glObj) | 175 function PutSpriteF(ctx, x, y, scale, glObj) |
156 { | 176 { |
157 | 177 |
189 ctx.bindTexture(ctx.TEXTURE_2D, glObj.texture); | 209 ctx.bindTexture(ctx.TEXTURE_2D, glObj.texture); |
190 ctx.drawElements(ctx.TRIANGLES, glObj.numIndices, ctx.UNSIGNED_SHORT, 0); | 210 ctx.drawElements(ctx.TRIANGLES, glObj.numIndices, ctx.UNSIGNED_SHORT, 0); |
191 | 211 |
192 | 212 |
193 } | 213 } |
214 | |
215 function PutSpriteLock(ctx, x, y, scale, angle, glObj) | |
216 { | |
217 | |
218 // setup VBOs | |
219 ctx.enableVertexAttribArray(0); | |
220 ctx.enableVertexAttribArray(1); | |
221 ctx.enableVertexAttribArray(2); | |
222 | |
223 ctx.bindBuffer(ctx.ARRAY_BUFFER, glObj.vertexObject); | |
224 ctx.vertexAttribPointer(2, 3, ctx.FLOAT, false, 0, 0); | |
225 ctx.bindBuffer(ctx.ARRAY_BUFFER, glObj.normalObject); | |
226 ctx.vertexAttribPointer(0, 3, ctx.FLOAT, false, 0, 0); | |
227 | |
228 ctx.bindBuffer(ctx.ARRAY_BUFFER, glObj.texCoordObject); | |
229 ctx.vertexAttribPointer(1, 2, ctx.FLOAT, false, 0, 0); | |
230 | |
231 ctx.bindBuffer(ctx.ELEMENT_ARRAY_BUFFER, glObj.indexObject); | |
232 | |
233 // generate the model-view matrix | |
234 var mvMatrix = new CanvasMatrix4(); | |
235 mvMatrix.scale(scale, scale, scale); | |
236 mvMatrix.rotate(angle, 0, 0, 1); | |
237 mvMatrix.translate( x, y, 10); | |
238 | |
239 // construct the normal matrix from the model-view matrix | |
240 var normalMatrix = new CanvasMatrix4(mvMatrix); | |
241 normalMatrix.invert(); | |
242 normalMatrix.transpose(); | |
243 ctx.uniformMatrix4fv(ctx.getUniformLocation(ctx.program, "u_normalMatrix"), false, normalMatrix.getAsWebGLFloatArray()); | |
244 | |
245 // construct the model-view * projection matrix | |
246 var mvpMatrix = new CanvasMatrix4(mvMatrix); | |
247 mvpMatrix.multRight(ctx.perspectiveMatrix); | |
248 ctx.uniformMatrix4fv(ctx.getUniformLocation(ctx.program, "u_modelViewProjMatrix"), false, mvpMatrix.getAsWebGLFloatArray()); | |
249 | |
250 ctx.bindTexture(ctx.TEXTURE_2D, glObj.texture); | |
251 ctx.drawElements(ctx.TRIANGLES, glObj.numIndices, ctx.UNSIGNED_SHORT, 0); | |
252 | |
253 } |