擅长:python、mysql、java
<p>你可以尝试在每次点击时添加一种冷却时间。时间(). 你知道吗</p>
<pre><code># Start of program
import time
cooldown = 0
cooleddown = time.time() - cooldown > 0.7
if pygame.mouse.get_pressed()[0] and cooleddown:
cooleddown = time.time()
if grid[y][x] == 0:
mouse_x,mouse_y = pygame.mouse.get_pos()
x = mouse_x // (size + 1)
y = mouse_y // (size + 1)
grid[y][x] = 1
elif grid[y][x] == 1:
mouse_x,mouse_y = pygame.mouse.get_pos()
x = mouse_x // (size + 1)
y = mouse_y // (size + 1)
grid[y][x] = 0
</code></pre>
<p><code>time.time()</code>所做的是返回自1970年1月1日午夜以来的当前秒数。因此,如果您在再次检查之前测试它是否已经过了一定的时间,这可能有助于解决问题。你知道吗</p>
<p><strong>*这没有经过测试,您可能需要等待0.7秒,我不知道等待时间有多短</p>