我正在尋找一些幫助,以在Tumult Hype中使用JavaScript爲Breakout遊戲添加一些代碼。我期待這樣做,所以一旦你達到一定的分數,球速會提高。JavaScript的突圍遊戲。在得分區間更改球速度
這是迄今沒有速度助推器的代碼。
var input1 = event.which || event.keyCode;
if ((input1 == "37") && (window.setLoopLeft == false)) { // LEFT ARROW PRESSED
window.setLoopLeft = true;
window.intervalLeft = setInterval(moveLeft, 5);
} else if ((input1 == "39") && (window.setLoopRight == false)) { // RIGHT ARROW PRESSED
window.setLoopRight = true;
window.intervalRight = setInterval(moveRight, 5);
} else if ((input1 == "32") && (window.ballLaunched == false)) { // SPACE BAR PRESSED
window.ballLaunched = true;
// RUN THE MOVEBALL FUNCTION EVERY 10 MILLISECONDS
window.intervalMoveBall = setInterval(moveBall, window.ballSpeed);
}
function moveBall() {
var ballLeft = parseInt(hypeDocument.getElementById("ball").style.left);
var ballTop = parseInt(hypeDocument.getElementById("ball").style.top);
這是我加入的代碼。現在我正在計劃的是創建一個全局變量來應用於window.intervalMoveBall。然後我會寫會在1000點檢測分值新功能和雙重球的速度使得它每5毫秒移動,而不是10
現在是什麼我不知道該怎麼辦實際上是寫if語句以便它檢測得分值。我想知道是否有人能夠告訴我如何正確,甚至能夠告訴我,如果使用全局函數和新函數並且if語句甚至可以爲此工作。
你目前如何移動球體,你如何保持得分? –
當頁面初始化樂譜時,會出現單獨的功能。該代碼是 hypeDocument.getElementById(「scoreValue2」)。innerHTML = window.score; 球根據擊中每個塊或槳板的位置以設定的角度移動。 – Zephyranthes