pygame 中的步行周期和计时
我的游戏中运行着 pygame.Timer,每秒调用绘制函数 32 次。绘图方法获取屏幕上所有元素的位置并相应地传输它们。然而,我希望主角走动的速度比其他物体的移动速度慢。
我应该专门为其设置一个计时器,还是应该将相同的帧传输几次?有没有更好的办法呢?朝着正确的方向推动会很棒:)
(如果有人感兴趣,这里是当前控制将哪些帧发送到绘图的代码:http://github.com/kallepersson/subterranean-ng/blob/master/Player.py#L88)
I have a pygame.Timer running in my game calling a draw function 32 times/second. The drawing method gets positions from all elements on my screen and blits them accordingly. However, I want the main character to walk around slower than other objects move.
Should I set up a timer specifically for it or should I just blit the same frames several times? Is there any better way to do it? A push in the right direction would be awesome :)
(If anyone's interested, here is the code that currently controls what frames to send to the drawing: http://github.com/kallepersson/subterranean-ng/blob/master/Player.py#L88)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的步行周期帧(像所有运动一样)应该是绝对时间的函数,而不是帧计数的函数。例如:
Your walk cycle frame (like all motion) should be a function of absolute time, not of frame count. e.g.: