changeset 10:a959cdca5b62

add bom.js
author NOBUYASU Oshiro
date Sat, 10 Jul 2010 16:38:23 +0900
parents 1d76f5717ba7
children 680b5b0cd1e4
files webGL/dandy/resources/#Character.js# webGL/dandy/resources/.#Character.js webGL/dandy/resources/bom.js webGL/dandy/resources/bom.js~
diffstat 4 files changed, 220 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/webGL/dandy/resources/#Character.js#	Sat Jul 10 16:38:23 2010 +0900
@@ -0,0 +1,98 @@
+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.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=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(jiki.scale, jiki.scale, jiki.scale);
+    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 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);
+		}
+	}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/webGL/dandy/resources/.#Character.js	Sat Jul 10 16:38:23 2010 +0900
@@ -0,0 +1,1 @@
+e085711@NOBUYASUOshiro.local.6529
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/webGL/dandy/resources/bom.js	Sat Jul 10 16:38:23 2010 +0900
@@ -0,0 +1,105 @@
+bomend = 0;
+bchar = [];
+function bcharClass()
+{
+    this.x = 0;
+    this.y = 0;
+    this.no = 0;
+    this.flag = 0;
+    return this;
+}
+
+function bom2(x, y)
+{
+    var i;
+    if ( bomend > 49) {
+	bomend = 49;
+	return ;
+    }
+    i = bomend;
+    bchar[i] = new bcharClass();
+    bchar[i].x = x;
+    bchar[i].y = y;
+    bchar[i].no = 0;
+    bchar[i].flag = 0;
+    loadBomImage(0, bchar[i]);
+    bomend++;
+    return ;
+}
+
+function loadBomImage(charano, p)
+{
+    p.image = bom[charano];
+    p.texture = bom[charano].texture;
+    p.w = bom[charano].w;
+    p.h = bom[charano].h;
+}
+
+function PutBom(gl)
+{
+    for(var i=0; i < bomend; i++)
+	{
+	    if(bchar[i].no != 8) {
+		count++;
+		//		DefSpriteEx(30 + bchar[i].no, 8, 8);
+		//		PutSpriteEx(30 + bchar[i].no, bchar[i].x+96, bchar[i].y+96, 2, 2, 1);
+		//		PutSpriteEx(gl, bchar[i], bom[bchar[i].no]);
+		//		PutSpriteEx(gl, bchar[i], enemy[0]);
+		PutSprite(gl, bchar[i], bchar[0]);
+		bchar[i].no++;
+	    }
+	    //	    if(bchar[i].no == 8){
+	    if(bchar[i].no == 7){
+		if(bonmed == i) {
+		    bomend--;
+		    break;
+		}
+		if(bomend > i) {
+		    bchar[i] = bchar[bomend];
+		    bomend--;
+		    i--;
+		}
+	    }
+	}
+}
+
+//function PutSpriteEx(number, x, y, scalex, scaley, angle)
+function PutSpriteEx( ctx, glObj, image)
+{
+
+    // setup VBOs
+    ctx.enableVertexAttribArray(0);
+    ctx.enableVertexAttribArray(1);
+    ctx.enableVertexAttribArray(2);
+				
+    ctx.bindBuffer(ctx.ARRAY_BUFFER, image.vertexObject);
+    ctx.vertexAttribPointer(2, 3, ctx.FLOAT, false, 0, 0);
+    ctx.bindBuffer(ctx.ARRAY_BUFFER, image.normalObject);
+    ctx.vertexAttribPointer(0, 3, ctx.FLOAT, false, 0, 0);
+    
+    ctx.bindBuffer(ctx.ARRAY_BUFFER, image.texCoordObject);
+    ctx.vertexAttribPointer(1, 2, ctx.FLOAT, false, 0, 0);
+
+    ctx.bindBuffer(ctx.ELEMENT_ARRAY_BUFFER, image.indexObject);
+
+    // generate the model-view matrix
+    var mvMatrix = new CanvasMatrix4();
+    mvMatrix.scale(1.0, 1.0, 1.0);
+    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, image.texture);
+    ctx.drawElements(ctx.TRIANGLES, image.numIndices, ctx.UNSIGNED_SHORT, 0);
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/webGL/dandy/resources/bom.js~	Sat Jul 10 16:38:23 2010 +0900
@@ -0,0 +1,16 @@
+bomend = 0;
+bchar = [];
+
+
+function bom()
+{
+
+
+}
+
+function Putbom()
+{
+
+
+
+}
\ No newline at end of file