Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/arrays/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/tfs/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 子弹z位置_Javascript_Arrays_Math_Simulation - Fatal编程技术网

Javascript 子弹z位置

Javascript 子弹z位置,javascript,arrays,math,simulation,Javascript,Arrays,Math,Simulation,我使用的代码工作正常,除了Z位置。 最大距离是以53度左右的角度获得的,而不是应该的45度。 我制作了自己的toDegree和toRadian函数,因为js从弧度的角度解释了正反两个方向。 有什么帮助吗 function Bullet(I) { I.zVelocity = Math.sin(toRadians(turretpitch)) * 5; } 第二部分: bullets.forEach(function (bullet) { bullet.zVelocity -

我使用的代码工作正常,除了Z位置。 最大距离是以53度左右的角度获得的,而不是应该的45度。 我制作了自己的toDegree和toRadian函数,因为js从弧度的角度解释了正反两个方向。 有什么帮助吗

function Bullet(I) {
    I.zVelocity = Math.sin(toRadians(turretpitch)) * 5;
}
第二部分:

bullets.forEach(function (bullet) {
        bullet.zVelocity -= 0.05;
        bullet.z += bullet.zVelocity;
        if (bullet.x > bgImage.width || bullet.x < 0 ||
            bullet.y > bgImage.height || bullet.y < 0 ||
            bullet.z < 0) {
            bullet.explode();
        }
    }
);
bullets.forEach(函数(bullet){
bullet.zVelocity-=0.05;
bullet.z+=bullet.zVelocity;
如果(bullet.x>bgImage.width | | bullet.x<0||
bullet.y>bgImage.height | | bullet.y<0||
项目符号z<0){
子弹。爆炸();
}
}
);

检查调用
toRadians前后的
炮塔俯仰
是什么。你的炮口在
z=0
吗?是的,炮口在z0trretpitch不是问题,我在屏幕上有它的文本值,我可以自己控制它的值,问题在于公式