如果语句Debug

时间:2019-01-24 11:03:15

标签: if-statement

我将如何在第31行修复if语句。它只是不想工作。我使用的源代码使我可以轻松创建3D对象。这是代码:

<script src="http://koda.nu/simple3d.js">
ambientLight("white");

var debug = false;

var player = {x: 0, y: 0, z: 500, item: box(0, 0, 500, 200, 200, 1, "red"), speed: 7};

var ball = {x: 0, y: 0, z: -200, item: sphere(0, 0, -200, 100, "yellow"), xSpeed: 0, ySpeed: 0, zSpeed: -15};

var enemy = {x: 0, y: 0, z: -700, item: box(0, 0, -700, 200, 200, 1, "red"), speed: 7};

box(450, 0, -100, 1, 875, 1200, "blue");

box(-450, 0, -100, 1, 875, 1200, "blue");

box(0, 450, -100, 875, 1, 1200, "blue");

box(0, -450, -100, 875, 1, 1200, "blue");

function update() {

    if (keyboard.w && player.y < 350) {
        player.item.translateY(player.speed);
        player.y += player.speed;
    }

    if (keyboard.s && player.y > -350) {
        player.item.translateY(-player.speed);
        player.y -= player.speed;
    }

    if (keyboard.d && player.x < 350) {
        player.item.translateX(player.speed);
        player.x += player.speed;
    }

    if (keyboard.a && player.x > -350) {
        player.item.translateX(-player.speed);
        player.x -= player.speed;
    }

    /*(This line just don't want to work ---->)*/ if (ball.z == enemy.z) { ball.zSpeed *= -1; }

    if (keyboard.shift && keyboard.y) {
        debug = true;
    }

    ball.x += ball.xSpeed;

    ball.item.translateX(ball.xSpeed);


    ball.y += ball.ySpeed;

    ball.item.translateY(ball.ySpeed);


    ball.z += ball.zSpeed;

    ball.item.translateZ(ball.zSpeed);

    while (debug) {

        if (keyboard.up) {
            moveCameraZ(-player.speed);
        }

        if (keyboard.down) {
            moveCameraZ(player.speed);
        }


        if (keyboard.left) {
            moveCameraX(-player.speed);
        }

        if (keyboard.right) {
            moveCameraX(player.speed);
        }

        if (keyboard.shift && keyboard.y) {
            debug = True;
        }

    }

}

</script>

1 个答案:

答案 0 :(得分:0)

您的代码非常混乱,我认为它必须代替{debug = True; }必须为{debug = False; }