【发布时间】:2017-12-12 02:48:11
【问题描述】:
我想知道如果按住某个键的时间更长,如何增加变量。我正在使用 Python 和 PyGame。 这是我的代码示例(速度、圈数和距离在前几行中定义):
distance_control = 1
for i in range(amount):
x[i] += speedx[i]
if x[i] >= 800:
x[i] -= 800
lap[i] += 1
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_SPACE:
x[2] += 1
distance[i] = (lap[i] - 1)*800 + x[i]
我想知道如何让它按住空格键的时间越长,speed_control 越高,最大 speed_control 为 5,最好使用某种经过时间的东西。
【问题讨论】:
标签: python pygame elapsedtime