Pygame:位块传输移动背景会产生太多模糊
我想做的是创建一个视口来查看背景的一小部分。 (然后放入精灵)。
然而,我注意到的问题是,当它开始移动时,似乎存在背景模糊的问题。我不确定这是否是因为位图传送速度很慢,还是因为代码中存在问题。我正在寻找有关其他人如何 blit 或创建滚动背景的示例,并找到了这篇文章:滚动游戏
我使用了他们的简单示例,果然,当您滚动时,背景会显得模糊(又名用偏移量块传输背景)。我还认为这可能是 FPS 因某种原因而下降,但它根本没有偏离。我不记得其他 2D 游戏有这样的问题。据我所知,由于它不断移动,可能会出现一些运动模糊。只是想知道我是否可以做些什么来缓解这种情况。有人可以补充我可能遗漏的任何内容吗?我将不胜感激任何反馈或帮助。谢谢
What I am trying to do is create a viewport to view a small portion of a background. (And later put sprites in).
However the problem I have noticed is there seems to be an issue of the background blurring when it starts moving. I was not sure if this is because blitting is slow or because of a problem in the code. I was looking for examples on how others blit or create scrolling backgrounds and found this article: Scrolling Games
I used their simple example and sure enough the background appears blurry as you scroll (aka blit the background with an offset). I also thought it might be the FPS dropping for whatever reason however it doesn't deviate at all. I can't recall an issue like this with other 2D games. I understand there may be some motion blur due to it constantly shifting. Just wondering if I can do anything to alleviate this. Can someone chime in on anything I may be missing? I would appreciate any feedback or help. Thank you
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我不知道是什么导致了你遇到的问题,但我猜它与双缓冲有关。
您至少使用了两个表面吗?
如果直接在屏幕表面绘制图像,则会发生闪烁。
I couldn't know what caused the problem you faced, but I guess it is related to double buffering.
Did you use at least two surfaces?
If images are drawn on the screen surface directly, flicking occurs.
“模糊”是指背景看起来“加倍”吗?移动正常大小(例如 64x64)精灵时是否会得到相同的效果?
如果您看到双倍,则可能是刷新率问题。打开垂直同步可能会有所帮助。
您获得的帧速率是多少?
如果你把动画放慢到 10 FPS 左右,你是否也会遇到同样的问题?
By "blurry" do you mean that the background appears "doubled"? Do you get the same effect when moving a normal-sized (e.g., 64x64) sprite?
If you are seeing double, then it's probably a refresh rate problem. Turning on vsync may help.
What frame rate are you getting?
If you slow down the animation to around 10 FPS, do you have the same problem?