我试图让游戏每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