〜爲什麼地獄有這個倒票......你們的人很奇怪!計算遊戲過程中總共有多少秒鐘已過期
好吧,這是一個非常簡單的HTML5和jQuery和PHP遊戲。不好意思的人都回答了,我忘了說這是一個php腳本,我在這裏更新了反映。
第一關需要1分鐘。之後的每個關卡都需要比最後關卡多出10秒。像這樣;
level 1 = 60 seconds
level 2 = 70 seconds
level 3 = 80 seconds
level 4 = 90 seconds
等無限。
我需要一個公式,可以根據用戶級別計算出總播放的秒數是多少。
level = n 我從(n * 10) + (n * 60)
開始,但很快就意識到,這並沒有考慮到最後一級已經比最後一級長了10秒。我已經使用一個調用foreach循環的函數暫時修復它,並停止在這個級別並返回值。但我真的想要一個實際的方程。
因此,我知道你不會讓我失望:-) 在此先感謝。
這就是我正在使用的;
function getnumberofsecondsfromlevel($level){
$lastlevelseconds = 60;
while($counter < $level){
$totalseconds = $lastlevelseconds+$totalseconds;
$lastlevelseconds = $lastlevelseconds + 10;
$counter++;
}
return $totalseconds;
}
$level = $_SESSION['**hidden**']['thelevel'];
$totaldureationinseconds = getnumberofsecondsfromlevel($level);
,但我想用實際方程式
像這樣更換;(當然這是錯誤的,這是格式只是例子,我希望它在IE瀏覽器的方程)
$n = $_SESSION['**hidden**']['thelevel']; (level to get total value of
in seconds)
$s = 60; (start level)
$totaldureationinseconds = ($n * 10) + ($s * $n);
解決由Gopalkrishna納拉帕布:-)
$totalseconds = 60 * $level + 5* (($level-1) * $level);
檢查公佈的等式。比較它們匹配的循環值和方程值。 –