3
我想寫一個python遊戲循環,希望考慮到FPS。什麼是調用循環的正確方法?我考慮過的一些可能性如下。我試圖不使用像pygame這樣的庫。在Python中編寫遊戲循環的正確方法是什麼?
1.
while True:
mainLoop()
2.
def mainLoop():
# run some game code
time.sleep(Interval)
mainLoop()
3.
def mainLoop():
# run some game code
threading.timer(Interval, mainLoop).start()
4. 使用sched.scheduler?
第二個和第三個選項,從自身開始同樣的方法,所以會有越來越多的東西隨着時間的推移... – eumiro 2013-04-30 13:33:28
「我不希望使用一個框架像pygame的」 - 那你想用什麼? 'Tkinter'?我想你需要告訴我們你的計劃,然後才能給你任何建議。 – mgilson 2013-04-30 13:33:44
另外,1應該寫成'while True:':) – mgilson 2013-04-30 13:34:48