我正在嘗試創建一個簡單的關卡系統,但它以某種方式不更新關卡。誰能幫我這個? (錢和XP下運行)xp,金錢和關卡的簡單關卡系統
var money = 0;
var xp = 0;
var level = 1;
window.onload = function() {
document.getElementById("money").innerHTML = 'Money: ' + money;
document.getElementById("xp").innerHTML = 'XP: ' + xp;
document.getElementById("level").innerHTML = 'Current level: ' + level;
}
function giveExp(number){
money = parseInt(money) + 50;
xp = xp + 100;
document.getElementById("money").innerHTML = 'Money: ' + money;
document.getElementById("xp").innerHTML = 'XP: ' + xp;
}
if (xp > 150 && xp < 450) {
level = level + 1;
document.getElementById("level").innerHTML = 'Current level: ' + level;
}
就把如果到gibeExp功能 –