Mercurial > hg > Members > e085737 > sample
view Reserve/resources/pants.js @ 26:943490f525c5
latest
author | <e085737> |
---|---|
date | Wed, 16 Feb 2011 22:01:34 +0900 |
parents | |
children |
line wrap: on
line source
pants_move = function(node, sgroot, w, h){ if(node.frame > 200){ node.dx = Math.sin(Math.random()*360) * 2; node.dy = Math.sin(Math.random()*270) * 2; node.dz = Math.sin(Math.random()*360) * 2; node.frame = 0; } node.xyz[0] += node.dx; node.xyz[2] += node.dz; if(node.xyz[1] <= 0){ node.xyz[1] += node.dy; }else{ node.xyz[1] = 0; } this.frame++; } pants_fall_move = function(node, sgroot, w, h){ var g = 0.098; node.dx = 0; node.dz = 0; if(node.xyz[1] < 100){ node.dy += g; node.xyz[0] += node.dx; node.xyz[1] += node.dy; node.xyz[2] += node.dz; } } pants_collision = function(node, sgroot, w, h){ for(num in sg_exec_tree.child){ if(sg_exec_tree.child[num].id == "yellow"){ var bullet = sg_exec_tree.child[num]; var dx = node.xyz[0] - bullet.xyz[0]; var dy = node.xyz[1] - bullet.xyz[1]; var dz = node.xyz[2] - bullet.xyz[2]; var dxy = Math.sqrt(Math.pow(dx,2) + Math.pow(dy,2) + Math.pow(dz,2)); if(dxy < 20){ node.set_move_collision(pants_fall_move, no_collision_idle); } } } } land_move = function(node, sgroot, w, h){ node.xyz[0] -= 0.5; }