4
|
1 active_chara_list = new Object();
|
|
2 active_chara_list.enemy = [];
|
8
|
3 count = 0;
|
|
4 rinkx = 0;
|
|
5 rinky = 0;
|
|
6 rinkf1 = 0;rinkf2 = 0;
|
|
7 asteroidi = 0;
|
|
8 enemyfaste = 0;
|
|
9 sf = 0;
|
|
10 amari = 0;
|
|
11 fastebos = 0;
|
|
12 tekino0 = new Character();
|
4
|
13
|
3
|
14 function Character()
|
|
15 {
|
6
|
16 this.x=0;
|
|
17 this.y=0;
|
|
18 this.dx=0;
|
|
19 this.dy=0;
|
7
|
20 this.w=0;
|
|
21 this.h=0;
|
6
|
22 this.vit=0;
|
|
23 this.score=0;
|
|
24 this.dt1=0;
|
|
25 this.dt2=0;
|
|
26 this.charano=0;
|
|
27 this.tama=0;
|
|
28 this.f=false;
|
7
|
29 this.flag=false;
|
6
|
30 this.s=0;
|
4
|
31
|
6
|
32 this.state=0;
|
|
33 this.collision=0;
|
4
|
34
|
6
|
35 this.next=0;
|
|
36 this.prev=0;
|
|
37
|
|
38 this.image=new Object();
|
|
39 this.texture=new Object();
|
4
|
40
|
|
41 return this;
|
|
42 }
|
|
43
|
|
44 function PutSprite( ctx, glObj)
|
|
45 {
|
6
|
46
|
|
47 // setup VBOs
|
|
48 ctx.enableVertexAttribArray(0);
|
|
49 ctx.enableVertexAttribArray(1);
|
|
50 ctx.enableVertexAttribArray(2);
|
4
|
51
|
6
|
52 ctx.bindBuffer(ctx.ARRAY_BUFFER, glObj.image.vertexObject);
|
|
53 ctx.vertexAttribPointer(2, 3, ctx.FLOAT, false, 0, 0);
|
|
54 ctx.bindBuffer(ctx.ARRAY_BUFFER, glObj.image.normalObject);
|
|
55 ctx.vertexAttribPointer(0, 3, ctx.FLOAT, false, 0, 0);
|
|
56
|
|
57 ctx.bindBuffer(ctx.ARRAY_BUFFER, glObj.image.texCoordObject);
|
|
58 ctx.vertexAttribPointer(1, 2, ctx.FLOAT, false, 0, 0);
|
4
|
59
|
6
|
60 ctx.bindBuffer(ctx.ELEMENT_ARRAY_BUFFER, glObj.image.indexObject);
|
|
61
|
|
62 // generate the model-view matrix
|
|
63 var mvMatrix = new CanvasMatrix4();
|
|
64 mvMatrix.scale(1, 1, 1);
|
|
65 mvMatrix.translate(0,0,0);
|
|
66 mvMatrix.rotate(180, 0,0,1);
|
|
67 mvMatrix.translate(glObj.x,glObj.y,10);
|
|
68
|
|
69 // construct the normal matrix from the model-view matrix
|
|
70 var normalMatrix = new CanvasMatrix4(mvMatrix);
|
|
71 normalMatrix.invert();
|
|
72 normalMatrix.transpose();
|
|
73 ctx.uniformMatrix4fv(ctx.getUniformLocation(ctx.program, "u_normalMatrix"), false, normalMatrix.getAsWebGLFloatArray());
|
|
74
|
|
75 // construct the model-view * projection matrix
|
|
76 var mvpMatrix = new CanvasMatrix4(mvMatrix);
|
|
77 mvpMatrix.multRight(ctx.perspectiveMatrix);
|
|
78 ctx.uniformMatrix4fv(ctx.getUniformLocation(ctx.program, "u_modelViewProjMatrix"), false, mvpMatrix.getAsWebGLFloatArray());
|
|
79
|
|
80 ctx.bindTexture(ctx.TEXTURE_2D, glObj.texture);
|
|
81 ctx.drawElements(ctx.TRIANGLES, glObj.image.numIndices, ctx.UNSIGNED_SHORT, 0);
|
4
|
82 }
|
6
|
83
|
4
|
84 function obj_draw( ctx )
|
|
85 {
|
|
86 for(var i = 0; Boolean(active_chara_list.enemy[i]) ; i++)
|
6
|
87 {
|
7
|
88 if(active_chara_list.enemy[i].flag == true)
|
6
|
89 {
|
4
|
90 PutSprite(ctx,active_chara_list.enemy[i]);
|
|
91 }
|
7
|
92 //敵が消えたら配列から消す
|
|
93 if(active_chara_list.enemy[i].flag == false)
|
|
94 {
|
|
95 active_chara_list.enemy.splice(i,1);
|
|
96 }
|
6
|
97 }
|
|
98 }
|