我試圖讓遊戲每0.8秒改變一次鼴鼠的波動。 (我的遊戲是簡單的「捶痣,對練)Slick2D每0.8渲染
我的代碼來改變波:
double TIME = 0.8;
if (Next) { //If 0.8 seconds is up
if (Over == false) { //make sure the game hasn't ended
start = (int) (cTime/1000); //cTime is the milisecond since game started
String wave = MolesWaves.RandomWave(); //getting the new wave data
initWave(wave);
Next = false; //disallow the game from changing wave
}
}
else {
if (((cTime/1000) - start) >= TIME) { //changing speed
System.out.println("Test: " + ((cTime/1000)-start));
Next = true; //allow game to change waves
}
}
從System.out.println("Test: " + ((cTime/1000)-start));
,這是我從輸出日誌得到
Test: 0.802
Test: 0.817
Test: 0.833
Test: 0.852
Test: 0.867
Test: 0.883
Test: 0.9
Test: 0.917
Test: 0.933
Test: 0.95
Test: 0.967
Test: 0.983
Test: 1.0
。
問題是波浪每秒改變13次,一旦它達到每秒一次就停止切換一段時間然後再次啓動它
如果TIME
的值是1
,ev一切都很好。波浪每隔1秒改變一次。
我正在使用0.8,因爲我試圖實施一個難度選擇(簡單,中等,難...)越難,波浪變化越快。
上面的代碼是我的問題的罪魁禍首?如果是這樣,請爲我解決這個問題。
感謝您的解釋! – junyi00