if (key != (VK_RIGHT || VK_DOWN)) //in this line bluej saying that's not correctly written. i want when the user is not pressing the down or up arrow it makes the error sound.
{
playSound("error");
}
Run Code Online (Sandbox Code Playgroud)
我想当用户没有按下向下或向上箭头时,它会使错误发出声音.但是在bluej中它向我显示了|| 不管用.
因为没有这样的捷径语法.你想要&&(不是||).
if (key != VK_RIGHT && key != VK_DOWN)
Run Code Online (Sandbox Code Playgroud)
你不想要的原因or是因为这些条件总是正确的(没有任何关键不是正确或没有关键 - 这是所有关键).