我正在製作一款簡單的Galaga-esk遊戲。雖然,他們只是偶爾移動一次(別的東西我不能工作,但那是不同的)。所以,由於他們不能自行移動,我想要一種方法來爲遊戲添加一個定時器,但我似乎無法找到任何關於此的東西。這是我的計時器和周圍的代碼重置爲每個級別到目前爲止。會有這樣的工作,我有它嗎?如何添加計時器到我的遊戲?
from livewires import games, color, random, time
start = time.time()
for items in enemies:
items.destroy()
if Enemy_amount > 0:
display_balloons()
elif Enemy_amount == 0 and (time.time() - start <= 120):
start = time.time()
level += 1
Enemy_amount = load_enemies()
#Just telling the code to load the next group of enemies.
您使用的遊戲庫?這是在一個遊戲循環? – Khaelid
是的,有一個遊戲循環。沒有時間部分,遊戲運行良好。更新代碼以顯示導入的所有內容。 – user3470570