PyGame陷入Linux困境? [英] PyGame bogging down linux?

查看:131
本文介绍了PyGame陷入Linux困境?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我运行我的pygame代码时,它会使系统瘫痪. PyGame变得没有响应,并且它极大地减慢了Ubuntu的速度,以至于我不得不强制关闭两次.

When I run my pygame code it bogs down the system. PyGame becomes unresponsive and it slows down Ubuntu so much that I've had to force a shut down twice.

我在这里发布了一个非常类似的问题: 为什么我的基本PyGame模块太慢了?

I posted a very similar question here: Why is my basic PyGame module so slow?

但是我决定改写它,因为当我问最初的问题时,我并不了解完整的症状.

but I decided to rephrase it because when I asked the original question I wasn't aware of the full symptoms.

推荐答案

您应该限制fps,可以为此使用clock.tick

You should limit the fps, you can use clock.tick for that

while true:
    for event in pygame.event.get():
        #manage your events
    #update your sprites
    screen.blit(...) #draw to screen
    pygame.display.flip()
    clock.tick(30)

这篇关于PyGame陷入Linux困境?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆