从昨天开始,我正在写一个乒乓球游戏。现在我遇到了一个我找不到的错误,希望你能帮助我。我唯一的想法是我没有在某个地方正确关闭函数,但我没有看到它......
您可以在此处阅读脚本和所有内容:
http://paste2.org/1EMV5Abb
http://jsfiddle.net/DerekL/hQB6V/
提前致谢 :)
脚本的一部分,所以我可以发布:
function main() {
if(runsGame == 1) {
// Drawing game elements
clear();
drawPlayer(xPlayer, yPlayer);
drawBall(xBall, yBall);
xBall += xBallSpeed;
yBall += yBallSpeed;
// Ball hits bottom
if(yBall > 590) {
yBallSpeed = -2;
}
// Ball hits right
if(xBall > 790) {
xBallSpeed = -2;
}
// Ball hits top
if(yBall < 0) {
yBallSpeed = 2;
}
// Ball hits Player
if(xBall <= xPlayer + 10 && yBall >= yPlayer && yBall <= yPlayer + 80) {
xBallSpeed = 2;
}
// Ball hits "Out"
if(xBall < 0) {
resetO();
drawPlayer(xPlayer, yPlayer);
drawBall(xBall, yBall);
clearInterval(runningGame);
runsGame = 0;
var button = document.getElementById("start");
button.value = "Start";
}
}