Mercurial > hg > Members > e085711
view webGL/dandy/resources/Character.js @ 20:fac103fcf60d
update dandy
author | NOBUYASU Oshiro |
---|---|
date | Sun, 03 Oct 2010 02:37:00 +0900 |
parents | 4684e849866c |
children | 7c1ff1927da3 |
line wrap: on
line source
stage = 0; active_chara_list = new Object(); active_chara_list.enemy = []; active_chara_list.tama = []; count = 0; rinkx = 0; rinky = 0; rinkf1 = 0;rinkf2 = 0; asteroidi = 0; enemyfaste = 0; enemycount = 0; sf = 0; amari = 0; tekino0 = new Character(); gameflag = 0; function Character() { this.x=0; this.y=0; this.scale=1.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=true; 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 J3DIMatrix4(); mvMatrix.scale(glObj.scale, glObj.scale, glObj.scale); mvMatrix.translate(glObj.x,glObj.y,10); // construct the normal matrix from the model-view matrix var normalMatrix = new J3DIMatrix4(mvMatrix); normalMatrix.invert(); normalMatrix.transpose(); normalMatrix.setUniform(ctx, ctx.getUniformLocation(ctx.program, "u_normalMatrix"), false); // construct the model-view * projection matrix var mvpMatrix = new J3DIMatrix4(ctx.perspectiveMatrix); mvpMatrix.multiply(mvMatrix); mvpMatrix.setUniform(ctx, ctx.getUniformLocation(ctx.program, "u_modelViewProjMatrix"), false); 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++) { var p = active_chara_list.enemy[i]; if(p.flag) { PutSprite(ctx, p); if((p.x < -30) || ( p.x > 230) || (p.y < -30) || (p.y > 170)) { p.flag = false; } } } } function delete_obj( ctx ) { for(var i = 0; Boolean(active_chara_list.enemy[i]); i++) { //敵が消えたら配列から消す if(active_chara_list.enemy[i].flag == false) { active_chara_list.enemy.splice(i,1); } } for(i=0; Boolean(bchar[i]); i++ ) { //ボム(撃破)処理を終えたら配列から消す if(bchar[i].no == 8) { bchar.splice(i,1); bomend--; } } }