Mercurial > hg > Members > e085711
changeset 6:881478004f18
update Bullet.js
author | NOBUYASU Oshiro |
---|---|
date | Mon, 21 Jun 2010 17:37:26 +0900 |
parents | e6bdfa6616a6 |
children | 4343c1feedb5 |
files | webGL/dandy/dandy2.html webGL/dandy/resources/Character.js webGL/dandy/resources/Character.js~ webGL/dandy/resources/Character_state.js webGL/dandy/resources/Character_state.js~ webGL/dandy/resources/Player.js webGL/dandy/resources/Player.js~ webGL/dandy/resources/bullet.js webGL/dandy/resources/bullet.js~ webGL/dandy/resources/ene webGL/dandy/resources/enemy.js webGL/dandy/resources/enemy.js~ webGL/dandy/resources/schedule.js webGL/dandy/resources/schedule.js~ |
diffstat | 14 files changed, 714 insertions(+), 246 deletions(-) [+] |
line wrap: on
line diff
--- a/webGL/dandy/dandy2.html Mon Jun 14 15:17:48 2010 +0900 +++ b/webGL/dandy/dandy2.html Mon Jun 21 17:37:26 2010 +0900 @@ -37,6 +37,7 @@ <script src="resources/schedule.js"> </script> <script src="resources/Player.js"> </script> <script src="resources/enemy.js"> </script> + <script src="resources/bullet.js"> </script> <script id="vshader" type="x-shader/x-vertex"> uniform mat4 u_modelViewProjMatrix; @@ -75,12 +76,23 @@ </script> <script> + pad = new Pad(); - const KEY_D = 65; - const KEY_A = 68; + const LEFT_ARROW = 37; + const UP_ARROW = 38; + const RIGHT_ARROW = 39; + const DOWN_ARROW = 40; + const KEY_D = 68; + const KEY_A = 65; const KEY_W = 87; const KEY_S = 83; const KEY_Z = 90; + const KEY_X = 88; + const KEY_Z = 90; + const KEY_R = 82; + const KEY_E = 69; + const KEY_W = 87; + const KEY_S = 83; var audio = window.Audio && new Audio("sound/sample.wav"); var audioShoot = window.Audio && new Audio("sound/shotc.wav"); @@ -96,9 +108,12 @@ gl.enable(gl.TEXTURE_2D); - loadXml( gl,"./xml/character.xml"); - player = new Player(gl.chara); - enemy = new enemySelect(gl); + loadEnemyXml( gl,"./xml/character.xml"); + loadBulletXml( gl,"./xml/effect.xml"); + + player = new makePlayer(gl.chara); + enemy = new parseEnemy(gl); + bullets = new parseBullet(gl); return gl; } @@ -125,15 +140,15 @@ - function loop(ctx) + function loop(ctx,canvas) { reshape(ctx); ctx.clear(ctx.COLOR_BUFFER_BIT | ctx.DEPTH_BUFFER_BIT); - - movePlayer(player, pad); +// movePlayer( player, pad); +// drawPlayer(ctx, player, 1.2); - drawPlayer(ctx, player, 1.2); + Player(ctx, player, pad); obj_draw(ctx); ctx.flush(); @@ -161,18 +176,24 @@ var ctx = init(); currentAngle = 0; - var f = function() { loop(ctx) }; + var f = function() { loop(ctx,c) }; setInterval(f, 10); framerate = new Framerate("framerate"); } function keybordDown() { var code = event.keyCode; - if(code == KEY_D) pad.right+=1.5; - if(code == KEY_A) pad.left+=1.5; - if(code == KEY_W) pad.up+=2; - if(code == KEY_S) pad.down+=2; + if(code == KEY_D) pad.right+=0.5; + if(code == KEY_A) pad.left+=0.5; + if(code == KEY_W) pad.up+=1; + if(code == KEY_S) pad.down+=1; if(code == KEY_Z) audioShoot && audioShoot.play(); + if(code == KEY_X) pad.k4++; + if(code == KEY_S) pad.k3++; + if(code == LEFT_ARROW) pad.left+=0.5; + if(code == RIGHT_ARROW) pad.right+=0.5; + if(code == UP_ARROW) pad.up+=1; + if(code == DOWN_ARROW) pad.down+=1; } function keybordPress() { @@ -185,7 +206,12 @@ if(code == KEY_A) pad.left = 0; if(code == KEY_W) pad.up = 0; if(code == KEY_S) pad.down = 0; - + if(code == KEY_X) pad.k4 = 0; + if(code == LEFT_ARROW) pad.left = 0; + if(code == RIGHT_ARROW) pad.right = 0; + if(code == UP_ARROW) pad.up = 0; + if(code == DOWN_ARROW) pad.down = 0; + pad.state=0; pad.count=0; }
--- a/webGL/dandy/resources/Character.js Mon Jun 14 15:17:48 2010 +0900 +++ b/webGL/dandy/resources/Character.js Mon Jun 21 17:37:26 2010 +0900 @@ -1,17 +1,6 @@ active_chara_list = new Object(); active_chara_list.enemy = []; -function loadXml(gl,url) -{ - gl.chara = new Object(); - var xmlChara = new Object(); - xmlChara = parsePanel(url); - for (var name in xmlChara) - { - gl.chara[name] = makeXmlObj(gl, xmlChara[name]); - gl.chara[name].texture = loadImageTexture(gl, xmlChara[name].image); - } -} function Character() { @@ -40,76 +29,6 @@ return this; } -function Putenemy(charano, x, y, vx, vy, chara_state) -{ - - var q = new Character(); - - - // q.collision = atari; - q.x = x; - q.y = y; - q.vx = vx; - q.vy = vy; - // q.tama = tf; - // q.vit = enemystate[charano].p; - // q.score = enemystate[charano].sc; - // q.s = 0; - q.f = true; - loadState(chara_state, q); - loadImage(charano, q); - - active_chara_list.enemy.push(q); -} - -chara_state0 = function character_state0( q ) -{ - q.x += q.vx; - q.y += q.vy; - q.state = chara_state0; - return q; -} - -chara_state1 = function character_state1( q ) -{ - q.x -= q.vx; - q.y -= q.vy; - q.state = chara_state1; - return q; -} - -function loadState(charano, q) -{ - if(charano == 0) q.state = chara_state0; - if(charano == 1) q.state = chara_state1; - if(charano == 3) q.state = chara_state1; - if(charano == 4) q.state = chara_state1; -} - -function loadImage(charano, q) -{ - if(charano == 0) - { - q.image = enemy[0]; - q.texture = enemy[0].texture; - } - if(charano == 1) - { - q.image = enemy[1]; - q.texture = enemy[1].texture; - } - if(charano == 2) - { - q.image = enemy[2]; - q.texture = enemy[2].texture; - } - if(charano == 3) - { - q.image = enemy[3]; - q.texture = enemy[3].texture; - } -} - function PutSprite( ctx, glObj) { @@ -120,7 +39,6 @@ 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);
--- a/webGL/dandy/resources/Character.js~ Mon Jun 14 15:17:48 2010 +0900 +++ b/webGL/dandy/resources/Character.js~ Mon Jun 21 17:37:26 2010 +0900 @@ -1,113 +1,93 @@ active_chara_list = new Object(); active_chara_list.enemy = []; +function loadXml(gl,url) +{ + gl.chara = new Object(); + var xmlChara = new Object(); + xmlChara = parsePanel(url); + for (var name in xmlChara) + { + gl.chara[name] = makeXmlObj(gl, xmlChara[name]); + gl.chara[name].texture = loadImageTexture(gl, xmlChara[name].image); + } +} function Character() { - this.x; - this.y; - this.dx; - this.dy; - this.vit; - this.score; - this.dt1; - this.dt2; - this.charano; - this.tama; - this.f; - this.s; + this.x=0; + this.y=0; + this.dx=0; + this.dy=0; + this.vit=0; + this.score=0; + this.dt1=0; + this.dt2=0; + this.charano=0; + this.tama=0; + this.f=false; + this.s=0; - this.state; - this.collision; + this.state=0; + this.collision=0; - this.next; - this.prev; + this.next=0; + this.prev=0; + + this.image=new Object(); + this.texture=new Object(); return this; } -function initCharacter() -{ - active_chara_list = new Character(); -} -function Putenemy(charano, x, y, vx, vy) -{ - var q = new Object(); - for( q = active_chara_list; q != NULL ; q = q.next) - { - if(Boolean(q.f) == false) - break; - } - - // Q.state = action; - // q.collision = atari; - q.x = x; - q.y = y; - q.vx = vx; - q.vy = vy; - // q.tama = tf; - // q.vit = enemystate[charano].p; - // q.score = enemystate[charano].sc; - // q.s = 0; - q.f = true; - -} -// function drawOne(ctx, glObj, angle, x, y, z, scale) -//function PutSprite( zorder, x, y, number) function PutSprite( ctx, glObj) { - // setup VBOs - ctx.enableVertexAttribArray(0); - ctx.enableVertexAttribArray(1); - ctx.enableVertexAttribArray(2); - - ctx.bindBuffer(ctx.ARRAY_BUFFER, glObj.vertexObject); - ctx.vertexAttribPointer(2, 3, ctx.FLOAT, false, 0, 0); + + // setup VBOs + ctx.enableVertexAttribArray(0); + ctx.enableVertexAttribArray(1); + ctx.enableVertexAttribArray(2); - ctx.bindBuffer(ctx.ARRAY_BUFFER, glObj.normalObject); - ctx.vertexAttribPointer(0, 3, ctx.FLOAT, false, 0, 0); - - ctx.bindBuffer(ctx.ARRAY_BUFFER, glObj.texCoordObject); - ctx.vertexAttribPointer(1, 2, ctx.FLOAT, false, 0, 0); - - ctx.bindBuffer(ctx.ELEMENT_ARRAY_BUFFER, glObj.indexObject); + 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); - // generate the model-view matrix - var mvMatrix = new CanvasMatrix4(); - mvMatrix.scale(scale, scale, scale); - mvMatrix.translate(0,0,0); -// mvMatrix.rotate(30, 1,0,0); - mvMatrix.rotate(180, 0,0,1); - mvMatrix.translate(x,y,z); -/* - var mvNormalMatrix = new CanvasMatrix4(); - mvMatrix.rotate(angle, 0,1,0); - mvMatrix.rotate(30, 1,0,0); - mvMatrix.translate(x,y,z); -*/ - // 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, texture); - ctx.bindTexture(ctx.TEXTURE_2D, glObj.texture); - ctx.drawElements(ctx.TRIANGLES, glObj.numIndices, ctx.UNSIGNED_SHORT, 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].f == true){ + { + if(active_chara_list.enemy[i].f == true) + { PutSprite(ctx,active_chara_list.enemy[i]); } - } - -} \ No newline at end of file + } +}
--- a/webGL/dandy/resources/Character_state.js Mon Jun 14 15:17:48 2010 +0900 +++ b/webGL/dandy/resources/Character_state.js Mon Jun 21 17:37:26 2010 +0900 @@ -9,4 +9,74 @@ } } } +function Putenemy(charano, x, y, vx, vy, chara_state) +{ + var p = new Character(); + // p.collision = atari; + p.x = x; + p.y = y; + p.vx = vx; + p.vy = vy; + // p.tama = tf; + // p.vit = enemystate[charano].p; + // p.score = enemystate[charano].sc; + // p.s = 0; + p.f = true; + p.state = chara_state; + + loadEnemyImage(charano, p); + + active_chara_list.enemy.push(p); + +} + +chara_state0 = function character_state0( p ) +{ + p.x += p.vx; + p.y += p.vy; + p.state = chara_state0; + return p; +} + +chara_state1 = function character_state1( p ) +{ + p.x -= p.vx; + p.y -= p.vy; + p.state = chara_state1; + return p; +} + +chara_state2 = function character_state2( p ) +{ + p.x -= 0.25; + p.y += p.vy; + p.state = chara_state2; + return p; +} + + +function loadEnemyImage(charano, p) +{ + if(charano == 0) + { + p.image = enemy[0]; + p.texture = enemy[0].texture; + } + if(charano == 1) + { + p.image = enemy[1]; + p.texture = enemy[1].texture; + } + if(charano == 2) + { + p.image = enemy[2]; + p.texture = enemy[2].texture; + } + if(charano == 3) + { + p.image = enemy[3]; + p.texture = enemy[3].texture; + } +} +
--- a/webGL/dandy/resources/Character_state.js~ Mon Jun 14 15:17:48 2010 +0900 +++ b/webGL/dandy/resources/Character_state.js~ Mon Jun 21 17:37:26 2010 +0900 @@ -1,14 +1,112 @@ -var chara_state0 = function character_state0( q ) +function state_update() +{ + for(var i = 0; Boolean(active_chara_list.enemy[i]) ; i++) + { + var p = active_chara_list.enemy[i]; + if(p.f == true) + { + p = p.state(p); + } + } +} + +function Putenemy(charano, x, y, vx, vy, chara_state) { - q.x += q.vx; - q.y += q.vy; - q.state = chara_state0; - return q; + + var p = new Character(); + + + // p.collision = atari; + p.x = x; + p.y = y; + p.vx = vx; + p.vy = vy; + // p.tama = tf; + // p.vit = enemystate[charano].p; + // p.score = enemystate[charano].sc; + // p.s = 0; + p.f = true; + loadState(chara_state, p); + loadImage(charano, p); + + active_chara_list.enemy.push(p); +} +function Putenemy2(charano, x, y, vx, vy, chara_state) +{ + + var p = new Character(); + + + // p.collision = atari; + p.x = x; + p.y = y; + p.vx = vx; + p.vy = vy; + // p.tama = tf; + // p.vit = enemystate[charano].p; + // p.score = enemystate[charano].sc; + // p.s = 0; + p.f = true; + p.state = chara_state; + loadImage(charano, p); + + active_chara_list.enemy.push(p); } -var chara_state1 = function character_state1( q ) + +chara_state0 = function character_state0( p ) +{ + p.x += p.vx; + p.y += p.vy; + p.state = chara_state0; + return p; +} + +chara_state1 = function character_state1( p ) +{ + p.x -= p.vx; + p.y -= p.vy; + p.state = chara_state1; + return p; +} + +chara_state2 = function character_state2( p ) +{ + p.x -= 0.25; + p.y += p.vy; + p.state = chara_state2; + return p; +} + + +function loadState(charano, p) { - q.x += q.vx; - q.y += q.vy; - q.state = chara_state0; - return q; + if(charano == 0) p.state = chara_state0; + if(charano == 1) p.state = chara_state1; + if(charano == 3) p.state = chara_state1; + if(charano == 4) p.state = chara_state1; } + +function loadImage(charano, p) +{ + if(charano == 0) + { + p.image = enemy[0]; + p.texture = enemy[0].texture; + } + if(charano == 1) + { + p.image = enemy[1]; + p.texture = enemy[1].texture; + } + if(charano == 2) + { + p.image = enemy[2]; + p.texture = enemy[2].texture; + } + if(charano == 3) + { + p.image = enemy[3]; + p.texture = enemy[3].texture; + } +} +
--- a/webGL/dandy/resources/Player.js Mon Jun 14 15:17:48 2010 +0900 +++ b/webGL/dandy/resources/Player.js Mon Jun 21 17:37:26 2010 +0900 @@ -1,15 +1,31 @@ function Pad() { + this.up=0; + this.down=0; this.right=0; this.left=0; - this.up=0; - this.down=0; this.count=0; this.state=0; + this.k0=0; + this.k1=0; + this.k2=0; + this.k3=0; + this.k4=0; + this.r2=0; + this.r1=0; + this.r2=0; + this.l1=0; + this.l2=0; + this.l3=0; + this.se=0; + this.st=0; + + //勝手につけた + this.quit=0; return this; } -function Player( object ) +function makePlayer( object ) { this.x = 0; this.y = 0; @@ -27,36 +43,40 @@ function movePlayer( player, pad ) { - pad.right = Math.min(pad.right, 3); - pad.left = Math.min(pad.left, 3); - pad.up = Math.min(pad.up, 4); - pad.down = Math.min(pad.down, 4); + pad.right = Math.min(pad.right, 0.7); + pad.left = Math.min(pad.left, 0.7); + pad.up = Math.min(pad.up, 0.7); + pad.down = Math.min(pad.down, 0.7); - player.x += pad.right; - player.x -= pad.left; + player.x -= pad.right; + player.x += pad.left; player.y += pad.up; player.y -= pad.down; + player.x = Math.min(player.x, 100); + player.x = Math.max(player.x, -100); + player.y = Math.min(player.y, 70); + player.y = Math.max(player.y, -70); + if( pad.count == 1) pad.state=0; if( pad.count > 0) pad.state=1; if( pad.count > 10 ) pad.state=2; if( pad.state == 0 ) player.image = player.idle; if( pad.state == 1 ) { - if( pad.right > 0 ) player.image = player.turntoleft; - if( pad.left > 0 ) player.image = player.turntoright; + if( pad.right > 0 ) player.image = player.turntoright; + if( pad.left > 0 ) player.image = player.turntoleft; } if( pad.state == 2 ) { - if( pad.right > 0 ) player.image = player.leftmove; - if( pad.left > 0 ) player.image = player.rightmove; + if( pad.right > 0 ) player.image = player.rightmove; + if( pad.left > 0 ) player.image = player.leftmove; } - if ( pad.right > 0) pad.right -= 1.5; - if ( pad.left > 0) pad.left -= 1.5; - if ( pad.up > 0) pad.up -= 2; - if ( pad.down > 0) pad.down -= 2; + + } + function drawPlayer(ctx, player, scale) { // setup VBOs @@ -95,3 +115,123 @@ ctx.bindTexture(ctx.TEXTURE_2D, player.image.texture); ctx.drawElements(ctx.TRIANGLES, player.image.numIndices, ctx.UNSIGNED_SHORT, 0); } + + +function Player(ctx, player, pad ) +{ + pad.right = Math.min(pad.right, 0.7); + pad.left = Math.min(pad.left, 0.7); + pad.up = Math.min(pad.up, 0.7); + pad.down = Math.min(pad.down, 0.7); + + player.x -= pad.right; + player.x += pad.left; + player.y += pad.up; + player.y -= pad.down; + + player.x = Math.min(player.x, 100); + player.x = Math.max(player.x, -100); + player.y = Math.min(player.y, 70); + player.y = Math.max(player.y, -70); + + if( pad.count == 1) pad.state=0; + if( pad.count > 0) pad.state=1; + if( pad.count > 10 ) pad.state=2; + + if( pad.state == 0 ) player.image = player.idle; + if( pad.state == 1 ) { + if( pad.right > 0 ) player.image = player.turntoright; + if( pad.left > 0 ) player.image = player.turntoleft; + } + if( pad.state == 2 ) { + if( pad.right > 0 ) player.image = player.rightmove; + if( pad.left > 0 ) player.image = player.leftmove; + } + + + drawPlayer(ctx, player, 1.2);//自機の描画(一先ずここでしておく) + + + //玉レベル1登録 + if ((pad.k4 % 3 == 1) && (pad.k3 % 3 == 0)){ + pad.k4 = 1; + + tama_lv1_end++; + + // if(tama_lv1_end > 19) tama_lv1_end = 0; + var i = tama_lv1_end; + + + var tama = new Tama1(); + tama.x = player.x; + tama.y = player.y; + tama.r = 1; + tama.l = 1; + tama_lv1[i] = tama; + } + + //玉レベル1表示 + for (i = 0; i < tama_lv1_end + 1; i++) + { + tama_lv1[i].y += 10; + + if (tama_lv1[i].r == 1) { + PutSpriteBullet(ctx, tama_lv1[i], bullets[1]); + } + if (tama_lv1[i].y < -70) { + if(tama_lv1_end == i){ + tama_lv1_end--; + break; + } + if(tama_lv1_end > i){ + tama_lv1[i] = tama_lv1[tama_lv1_end]; + tama_lv1_end--; + break; + } + + } + + } + +} + + +function PutSpriteBullet( ctx, tama, glObj) +{ + + // setup VBOs + ctx.enableVertexAttribArray(0); + ctx.enableVertexAttribArray(1); + ctx.enableVertexAttribArray(2); + + ctx.bindBuffer(ctx.ARRAY_BUFFER, glObj.vertexObject); + ctx.vertexAttribPointer(2, 3, ctx.FLOAT, false, 0, 0); + ctx.bindBuffer(ctx.ARRAY_BUFFER, glObj.normalObject); + ctx.vertexAttribPointer(0, 3, ctx.FLOAT, false, 0, 0); + + ctx.bindBuffer(ctx.ARRAY_BUFFER, glObj.texCoordObject); + ctx.vertexAttribPointer(1, 2, ctx.FLOAT, false, 0, 0); + + ctx.bindBuffer(ctx.ELEMENT_ARRAY_BUFFER, glObj.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(tama.x,tama.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.numIndices, ctx.UNSIGNED_SHORT, 0); +}
--- a/webGL/dandy/resources/Player.js~ Mon Jun 14 15:17:48 2010 +0900 +++ b/webGL/dandy/resources/Player.js~ Mon Jun 21 17:37:26 2010 +0900 @@ -1,15 +1,31 @@ function Pad() { + this.up=0; + this.down=0; this.right=0; this.left=0; - this.up=0; - this.down=0; this.count=0; this.state=0; + this.k0=0; + this.k1=0; + this.k2=0; + this.k3=0; + this.k4=0; + this.r2=0; + this.r1=0; + this.r2=0; + this.l1=0; + this.l2=0; + this.l3=0; + this.se=0; + this.st=0; + + //勝手につけた + this.quit=0; return this; } -function Player( object ) +function makePlayer( object ) { this.x = 0; this.y = 0; @@ -26,10 +42,21 @@ } function movePlayer( player, pad ) { - if ( 3 <= pad.right) pad.right = 3; - if ( 3 <= pad.left) pad.left = 3; - if ( 3 <= pad.up) pad.up = 4; - if ( 3 <= pad.down) pad.down = 4; + + pad.right = Math.min(pad.right, 0.7); + pad.left = Math.min(pad.left, 0.7); + pad.up = Math.min(pad.up, 0.7); + pad.down = Math.min(pad.down, 0.7); + + player.x -= pad.right; + player.x += pad.left; + player.y += pad.up; + player.y -= pad.down; + + player.x = Math.min(player.x, 100); + player.x = Math.max(player.x, -100); + player.y = Math.min(player.y, 70); + player.y = Math.max(player.y, -70); if( pad.count == 1) pad.state=0; if( pad.count > 0) pad.state=1; @@ -37,24 +64,19 @@ if( pad.state == 0 ) player.image = player.idle; if( pad.state == 1 ) { - if( pad.right > 0 ) player.image = player.turntoleft; - if( pad.left > 0 ) player.image = player.turntoright; + if( pad.right > 0 ) player.image = player.turntoright; + if( pad.left > 0 ) player.image = player.turntoleft; } if( pad.state == 2 ) { - if( pad.right > 0 ) player.image = player.leftmove; - if( pad.left > 0 ) player.image = player.rightmove; + if( pad.right > 0 ) player.image = player.rightmove; + if( pad.left > 0 ) player.image = player.leftmove; } - player.x += pad.right; - player.x -= pad.left; - player.y += pad.up; - player.y -= pad.down; + - if ( pad.right > 0) pad.right -= 1.5; - if ( pad.left > 0) pad.left -= 1.5; - if ( pad.up > 0) pad.up -= 2; - if ( pad.down > 0) pad.down -= 2; + } + function drawPlayer(ctx, player, scale) { // setup VBOs @@ -93,3 +115,123 @@ ctx.bindTexture(ctx.TEXTURE_2D, player.image.texture); ctx.drawElements(ctx.TRIANGLES, player.image.numIndices, ctx.UNSIGNED_SHORT, 0); } + + +function Player(ctx, player, pad ) +{ + pad.right = Math.min(pad.right, 0.7); + pad.left = Math.min(pad.left, 0.7); + pad.up = Math.min(pad.up, 0.7); + pad.down = Math.min(pad.down, 0.7); + + player.x -= pad.right; + player.x += pad.left; + player.y += pad.up; + player.y -= pad.down; + + player.x = Math.min(player.x, 100); + player.x = Math.max(player.x, -100); + player.y = Math.min(player.y, 70); + player.y = Math.max(player.y, -70); + + if( pad.count == 1) pad.state=0; + if( pad.count > 0) pad.state=1; + if( pad.count > 10 ) pad.state=2; + + if( pad.state == 0 ) player.image = player.idle; + if( pad.state == 1 ) { + if( pad.right > 0 ) player.image = player.turntoright; + if( pad.left > 0 ) player.image = player.turntoleft; + } + if( pad.state == 2 ) { + if( pad.right > 0 ) player.image = player.rightmove; + if( pad.left > 0 ) player.image = player.leftmove; + } + + + drawPlayer(ctx, player, 1.2);//自機の描画(一先ずここでしておく) + + + //玉レベル1登録 + if ((pad.k4 % 3 == 1) && (pad.k3 % 3 == 0)){ + pad.k4 = 1; + + tama_lv1_end++; + + // if(tama_lv1_end > 19) tama_lv1_end = 0; + var i = tama_lv1_end; + + + var tama = new Tama1(); + tama.x = player.x; + tama.y = player.y; + tama.r = 1; + tama.l = 1; + tama_lv1[i] = tama; + } + + //玉レベル1表示 + for (i = 0; i < tama_lv1_end + 1; i++) + { + tama_lv1[i].y += 10; + + if (tama_lv1[i].r == 1) { + PutSpriteBullet(ctx, tama_lv1[i], bullets[1]); + } + if (tama_lv1[i].y > 70) { + if(tama_lv1_end == i){ + tama_lv1_end--; + break; + } + if(tama_lv1_end > i){ + tama_lv1[i] = tama_lv1[tama_lv1_end]; + tama_lv1_end--; + break; + } + + } + + } + +} + + +function PutSpriteBullet( ctx, tama, glObj) +{ + + // setup VBOs + ctx.enableVertexAttribArray(0); + ctx.enableVertexAttribArray(1); + ctx.enableVertexAttribArray(2); + + ctx.bindBuffer(ctx.ARRAY_BUFFER, glObj.vertexObject); + ctx.vertexAttribPointer(2, 3, ctx.FLOAT, false, 0, 0); + ctx.bindBuffer(ctx.ARRAY_BUFFER, glObj.normalObject); + ctx.vertexAttribPointer(0, 3, ctx.FLOAT, false, 0, 0); + + ctx.bindBuffer(ctx.ARRAY_BUFFER, glObj.texCoordObject); + ctx.vertexAttribPointer(1, 2, ctx.FLOAT, false, 0, 0); + + ctx.bindBuffer(ctx.ELEMENT_ARRAY_BUFFER, glObj.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(tama.x,tama.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.numIndices, ctx.UNSIGNED_SHORT, 0); +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/webGL/dandy/resources/bullet.js Mon Jun 21 17:37:26 2010 +0900 @@ -0,0 +1,56 @@ +tama_lv1 = []; +tama_lv1_end = -1; +tama_lv2 = []; +tama_lv2_end = -1; + +function loadBulletXml(gl,url) +{ + gl.bullet = new Object(); + var xmlChara = new Object(); + xmlChara = parsePanel(url); + for (var name in xmlChara) + { + gl.bullet[name] = makeXmlObj(gl, xmlChara[name]); + gl.bullet[name].texture = loadImageTexture(gl, xmlChara[name].image); + } +} + +function parseBullet(gl) +{ + var bullets = []; + for(var name in gl.bullet) + { + bullets.push(gl.bullet[name]); + } + return bullets; +} + +function Tama() +{ + this.x=0; + this.y=0; + return this; +} + + +function Tama1() +{ + this.x=0; + this.y=0; + this.r=0; + this.l=0; + return this; +} + +function tama2() +{ + this.x=0; + this.y=0; + this.r=0; + this.l=0; + this.rr=0; + this.sr=0; + this.sl=0; + this.ll=0; + return this; +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/webGL/dandy/resources/bullet.js~ Mon Jun 21 17:37:26 2010 +0900 @@ -0,0 +1,6 @@ +function bulletSelect() +{ + + + +} \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/webGL/dandy/resources/ene Mon Jun 21 17:37:26 2010 +0900 @@ -0,0 +1,1 @@ + \ No newline at end of file
--- a/webGL/dandy/resources/enemy.js Mon Jun 14 15:17:48 2010 +0900 +++ b/webGL/dandy/resources/enemy.js Mon Jun 21 17:37:26 2010 +0900 @@ -1,4 +1,17 @@ -function enemySelect(gl) +function loadEnemyXml(gl,url) +{ + gl.chara = new Object(); + var xmlChara = new Object(); + xmlChara = parsePanel(url); + for (var name in xmlChara) + { + gl.chara[name] = makeXmlObj(gl, xmlChara[name]); + gl.chara[name].texture = loadImageTexture(gl, xmlChara[name].image); + } +} + + +function parseEnemy(gl) { var enemy = []; enemy.push(gl.chara["enemy_greenclab"]);
--- a/webGL/dandy/resources/enemy.js~ Mon Jun 14 15:17:48 2010 +0900 +++ b/webGL/dandy/resources/enemy.js~ Mon Jun 21 17:37:26 2010 +0900 @@ -1,6 +1,9 @@ -function enemy(gl) +function enemySelect(gl) { - - - + var enemy = []; + enemy.push(gl.chara["enemy_greenclab"]); + enemy.push(gl.chara["missile"]); + enemy.push(gl.chara["gunbattery"]); + enemy.push(gl.chara["meteo"]); + return enemy; } \ No newline at end of file
--- a/webGL/dandy/resources/schedule.js Mon Jun 14 15:17:48 2010 +0900 +++ b/webGL/dandy/resources/schedule.js Mon Jun 21 17:37:26 2010 +0900 @@ -8,16 +8,21 @@ case 1: break; case FRAME_RATE * 2: - Putenemy(0, 30, 80, 0, 0.3, 1); + Putenemy(0, 30, 80, 0, 0.3, chara_state1); +// for(var x = 0; x < 1000; x+=2){ +// Putenemy(0, x-50, 80, 0, 0.3, 1); +// } break; case FRAME_RATE * 10: - Putenemy(1, -30, 80, 0, 0.3, 1); + Putenemy(1, -30, 80, 0, 0.3, chara_state1); + Putenemy(0, 30, -80, 0, 0.3, chara_state0); break; case FRAME_RATE * 15: - Putenemy(2, -40, 80, 0, 0.5, 1); + Putenemy(2, -40, 80, 0, 0.5, chara_state1); + Putenemy(0, -30, -80, 0, 0.3, chara_state0); break; case FRAME_RATE * 20: - Putenemy(3, 30, 80, 0, 0.4, 1); + Putenemy(3, 30, 80, 0, 0.4, chara_state1); break; }
--- a/webGL/dandy/resources/schedule.js~ Mon Jun 14 15:17:48 2010 +0900 +++ b/webGL/dandy/resources/schedule.js~ Mon Jun 21 17:37:26 2010 +0900 @@ -4,15 +4,25 @@ function schedule() { - switch (filpcount) { case 1: break; case FRAME_RATE * 2: + Putenemy2(0, 30, 80, 0, 0.3, chara_state1); +// for(var x = 0; x < 1000; x+=2){ +// Putenemy(0, x-50, 80, 0, 0.3, 1); +// } break; - case FRAME_RATE * 3: + case FRAME_RATE * 10: + Putenemy2(1, -30, 80, 0, 0.3, chara_state1); + Putenemy2(0, 30, -80, 0, 0.3, chara_state0); break; - case FRAME_RATE * 4: + case FRAME_RATE * 15: + Putenemy2(2, -40, 80, 0, 0.5, chara_state1); + Putenemy2(0, -30, -80, 0, 0.3, chara_state0); + break; + case FRAME_RATE * 20: + Putenemy2(3, 30, 80, 0, 0.4, chara_state1); break; }