active_chara_list = new Object(); active_chara_list.enemy = []; count = 0; rinkx = 0; rinky = 0; rinkf1 = 0;rinkf2 = 0; asteroidi = 0; enemyfaste = 0; sf = 0; amari = 0; fastebos = 0; tekino0 = new Character(); function Character() { this.x=0; this.y=0; this.dx=0; this.dy=0; this.w=0; this.h=0; this.vit=0; this.score=0; this.dt1=0; this.dt2=0; this.charano=0; this.tama=0; this.f=false; this.flag=false; this.s=0; this.state=0; this.collision=0; this.next=0; this.prev=0; this.image=new Object(); this.texture=new Object(); return this; } function PutSprite( ctx, glObj) { // setup VBOs ctx.enableVertexAttribArray(0); ctx.enableVertexAttribArray(1); ctx.enableVertexAttribArray(2); ctx.bindBuffer(ctx.ARRAY_BUFFER, glObj.image.vertexObject); ctx.vertexAttribPointer(2, 3, ctx.FLOAT, false, 0, 0); ctx.bindBuffer(ctx.ARRAY_BUFFER, glObj.image.normalObject); ctx.vertexAttribPointer(0, 3, ctx.FLOAT, false, 0, 0); ctx.bindBuffer(ctx.ARRAY_BUFFER, glObj.image.texCoordObject); ctx.vertexAttribPointer(1, 2, ctx.FLOAT, false, 0, 0); ctx.bindBuffer(ctx.ELEMENT_ARRAY_BUFFER, glObj.image.indexObject); // generate the model-view matrix var mvMatrix = new CanvasMatrix4(); mvMatrix.scale(1, 1, 1); mvMatrix.translate(0,0,0); mvMatrix.rotate(180, 0,0,1); mvMatrix.translate(glObj.x,glObj.y,10); // construct the normal matrix from the model-view matrix var normalMatrix = new CanvasMatrix4(mvMatrix); normalMatrix.invert(); normalMatrix.transpose(); ctx.uniformMatrix4fv(ctx.getUniformLocation(ctx.program, "u_normalMatrix"), false, normalMatrix.getAsWebGLFloatArray()); // construct the model-view * projection matrix var mvpMatrix = new CanvasMatrix4(mvMatrix); mvpMatrix.multRight(ctx.perspectiveMatrix); ctx.uniformMatrix4fv(ctx.getUniformLocation(ctx.program, "u_modelViewProjMatrix"), false, mvpMatrix.getAsWebGLFloatArray()); ctx.bindTexture(ctx.TEXTURE_2D, glObj.texture); ctx.drawElements(ctx.TRIANGLES, glObj.image.numIndices, ctx.UNSIGNED_SHORT, 0); } function obj_draw( ctx ) { for(var i = 0; Boolean(active_chara_list.enemy[i]) ; i++) { if(active_chara_list.enemy[i].flag == true) { PutSprite(ctx,active_chara_list.enemy[i]); } //敵が消えたら配列から消す if(active_chara_list.enemy[i].flag == false) { active_chara_list.enemy.splice(i,1); } } }