草庐IT

pygame-surface

全部标签

python 和 pygame - 在这个包装器的执行过程中发生了什么?

It'smyhopethatthebountywilldrawanindividualwhoknowsathingortwoabouttheinnerworkingsofPyGame(Itriedlookingatthesourcecode..there'sabunchofit)andcantellmeifthisistrulyrelatedtothepresenceofthreading.py,orifthereissomepracticeIcanavoidingeneraltopreventthisfromhappeninginotherPyGameprojects.我为obj.k

python - Pygame:允许点击穿过窗口

我正在pygame中制作一个伪透明窗口,目的是像“HUD”一样显示各种信息该脚本使用PIL抓取桌面图像并将其用作窗口背景。一个简单的版本:importpygameaspyfromctypesimportwindllimportImageGrab,ImageSetWindowPos=windll.user32.SetWindowPospy.init()defget_image():im=ImageGrab.grab((0,0,window_x,window_y))mode=im.modesize=im.sizedata=im.tobytes()im=py.image.fromstring

python - Mac OS X pygame 输入进入终端而不是 Python

我无法通过终端在MacOSX上运行基于pygame的应用程序。输入事件(例如击键)进入终端而不是我的Python应用程序,并由pygame检测到。例如我有如下测试脚本:importpygamepygame.init()screen=pygame.display.set_mode((640,480))done=Falsewhilenotdone:pygame.event.pump()keys=pygame.key.get_pressed()ifkeys[pygame.K_ESCAPE]:done=Trueifkeys[pygame.K_SPACE]:print"gothere"当我从Ma

python - Pygame headless (headless)设置

我正在使用pygame的操纵杆api在headless(headless)系统上对我的项目使用操纵杆,但是pygame需要一个“屏幕”,所以我设置了一个虚拟视频系统来克服这个问题。它工作正常但现在突然给我这个错误:Traceback(mostrecentcalllast):File"compact.py",line10,inscreen=display.set_mode((1,1))pygame.error:Unabletoopenaconsoleterminal这就是我所拥有的headless(headless)设置,应该可以解决这个问题。frompygameimport*impor

python - 我无法修复的 Pygame2Exe 错误

我做了一个“游戏”。我喜欢玩它,我想把它分发给我的friend,而不必在他们的计算机上安装Python和Pygame。我对Py2Exe和Pyinstaller做了很多研究。我浏览了许多教程、修复程序、错误,但似乎没有一个对我有帮助。Pyinstaller是无用的,因为它不喜欢Pygame中的字体,并且Py2exe不会编译内置模块,所以我找到了Pygame2exe,它只是一个预制的安装脚本,用于包含pygame和字体的py2exe。它应该构建良好,但exe无法使用...我收到错误:"MicrosoftVisualC++RuntimeLibraryRuntimeError!ProgramC

python - libpng 警告 : interlace handling should be turned on when using png_read_image in Python/PyGame

我正在使用PyGameforPython,并且在使用pygame.image.load加载.png图像时收到以下警告:libpngwarning:Interlacehandlingshouldbeturnedonwhenusingpng_read_image它不影响程序,但变得特别烦人。我在网上搜索了一个无济于事的答案。我目前正在使用32位Python3.3和PyGame1.9.2关于如何让警告消失的任何想法? 最佳答案 我遇到了同样的问题。这似乎是旧版libpng的一些错误(有关详细信息,请参阅http://sourceforge

python - 一起使用 Tkinter 和 pygame 有什么我需要知道的吗?

我正在使用pygame编写程序,我需要一些GUI配置文本字段和按钮来进行控制。我已经使用pygame制作了按钮,但我只能用pygame编写一个文本字段。也许我需要将tkinter与pygame一起使用。我认为如果没有办法将pygame部分和tkinter部分放在一个窗口中,那么我可以将它们放在两个单独的窗口中。我希望tkinter部分可以更新我的pygame部分中的全局变量,如果有问题吗?我可能会从pygame部分创建一个tkinter的子进程,这样tkinter部分就可以“看到”pygame部分中的全局变量并修改它们。我可以这样做吗?有什么陷阱吗? 最佳答

python - 使用pygame旋转图像

这个问题在这里已经有了答案:HowdoIrotateanimagearounditscenterusingPygame?(6个答案)Howtorotateanimage(player)tothemousedirection?(2个答案)HowcanyourotateanimagearoundanoffcenterpivotinPygame(1个回答)关闭2年前。我是pygame的新手,想编写一些代码,每10秒将图像简单地旋转90度。我的代码如下所示:importpygameimporttimefrompygame.localsimport*pygame.init()display_su

python - 如何在pygame中反转图像的颜色?

我有一个pygameSurface并且想要反转颜色。有没有比这更快更pythonic的方法?它相当慢。我知道从255中减去该值并不是“反转颜色”的唯一定义,但这是我现在想要的。我很惊讶pygame没有内置这样的东西!感谢您的帮助!importpygamedefinvertImg(img):"""InvertsthecolorsofapygameScreen"""img.lock()forxinrange(img.get_width()):foryinrange(img.get_height()):RGBA=img.get_at((x,y))foriinrange(3):#InvertR

pygame 中用于 MVC 事件处理的 Python 鸭子类型(duck typing)

我和一个friend一直在玩pygame,遇到了thistutorialforbuildinggames使用游戏。我们真的很喜欢它如何将游戏分解为以事件为中介的模型-View-Controller系统,但是代码大量使用isinstance检查事件系统。例子:classCPUSpinnerController:...defNotify(self,event):ifisinstance(event,QuitEvent):self.keepGoing=0这会导致一些非常不符合Python的代码。有没有人对如何改进有任何建议?或者实现MVC的替代方法?这是我根据@Mark-Hildreth的回