gpt4 book ai didi

python - 跟踪时间

转载 作者:行者123 更新时间:2023-11-28 20:53:20 24 4
gpt4 key购买 nike

我需要我的函数每秒更新新的时间值,有没有比设置 t1 来检查 t2 - t1 = 1 更好的跟踪方法?

希望编辑更清晰:轨道代码:

def orbit(center, radius, speed, t):
theta = math.fmod(t * speed, math.pi * 2)
c = math.cos(theta)
s = math.sin(theta)
x = int(round(center[0] + radius * c))
y = int(round(center[1] + radius * s))
coords=[x, y]
return coords

我需要的是在从绘制函数调用它时更改 t,我需要的是限制 fps 并为每一帧计算 t。我只在 pygame 中看到一个 get_fps 函数,它返回未设置的 fps 或我错了吗?

最佳答案

您可以使用线程的定时器对象:

http://docs.python.org/library/threading.html#timer-objects

关于python - 跟踪时间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5110138/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com