简体   繁体   English

Pygame.transform.rotate 导致致命的 pygame 错误

[英]Pygame.transform.rotate causes fatal pygame error

I'm trying to make a game using python and pygame, but need to use pygame.transform.rotate.我正在尝试使用 python 和 pygame 制作游戏,但需要使用 pygame.transform.rotate。 As I call it following Error message occurs: ( c:/Users/foxcirc/Desktop/rxry is the project path)正如我所说,出现以下错误消息:( c:/Users/foxcirc/Desktop/rxry是项目路径)

Fatal Python error: (pygame parachute) Segmentation Fault
Thread 0x00002890 (most recent call first):
  File "C:\Users\foxcirc\AppData\Local\Programs\Python\Python37-32\lib\threading.py", line 296 in wait
  File "C:\Users\foxcirc\AppData\Local\Programs\Python\Pycharm\plugins\python-ce\helpers\pydev\_pydev_comm\pydev_io.py", line 40 in read
  File "C:\Users\foxcirc\AppData\Local\Programs\Python\Pycharm\plugins\python-ce\helpers\pydev\_pydev_comm\pydev_transport.py", line 27 in read_request
  File "C:\Users\foxcirc\AppData\Local\Programs\Python\Pycharm\plugins\python-ce\helpers\pydev\_pydev_comm\pydev_transport.py", line 215 in read
  File "C:\Users\foxcirc\AppData\Local\Programs\Python\Pycharm\plugins\python-ce\helpers\third_party\thriftpy\_shaded_thriftpy\transport\buffered\__init__.py", line 39 in _read
  File "C:\Users\foxcirc\AppData\Local\Programs\Python\Pycharm\plugins\python-ce\helpers\third_party\thriftpy\_shaded_thriftpy\transport\__init__.py", line 14 in readall
  File "C:\Users\foxcirc\AppData\Local\Programs\Python\Pycharm\plugins\python-ce\helpers\third_party\thriftpy\_shaded_thriftpy\transport\__init__.py", line 32 in read
  File "C:\Users\foxcirc\AppData\Local\Programs\Python\Pycharm\plugins\python-ce\helpers\third_party\thriftpy\_shaded_thriftpy\protocol\binary.py", line 164 in read_message_begin
  File "C:\Users\foxcirc\AppData\Local\Programs\Python\Pycharm\plugins\python-ce\helpers\third_party\thriftpy\_shaded_thriftpy\protocol\binary.py", line 372 in read_message_begin
  File "C:\Users\foxcirc\AppData\Local\Programs\Python\Pycharm\plugins\python-ce\helpers\third_party\thriftpy\_shaded_thriftpy\thrift.py", line 212 in process_in
  File "C:\Users\foxcirc\AppData\Local\Programs\Python\Pycharm\plugins\python-ce\helpers\third_party\thriftpy\_shaded_thriftpy\thrift.py", line 257 in process
  File "C:\Users\foxcirc\AppData\Local\Programs\Python\Pycharm\plugins\python-ce\helpers\pydev\_pydev_comm\pydev_server.py", line 34 in handle
  File "C:\Users\foxcirc\AppData\Local\Programs\Python\Python37-32\lib\threading.py", line 865 in run
  File "C:\Users\foxcirc\AppData\Local\Programs\Python\Python37-32\lib\threading.py", line 917 in _bootstrap_inner
  File "C:\Users\foxcirc\AppData\Local\Programs\Python\Python37-32\lib\threading.py", line 885 in _bootstrap
Thread 0x00002e58 (most recent call first):
  File "C:\Users\foxcirc\AppData\Local\Programs\Python\Pycharm\plugins\python-ce\helpers\pydev\_pydev_comm\pydev_io.py", line 110 in readall
  File "C:\Users\foxcirc\AppData\Local\Programs\Python\Pycharm\plugins\python-ce\helpers\pydev\_pydev_comm\pydev_transport.py", line 45 in _read_frame
  File "C:\Users\foxcirc\AppData\Local\Programs\Python\Pycharm\plugins\python-ce\helpers\pydev\_pydev_comm\pydev_transport.py", line 37 in _read_and_dispatch_next_frame
  File "C:\Users\foxcirc\AppData\Local\Programs\Python\Pycharm\plugins\python-ce\helpers\pydev\_pydev_comm\pydev_transport.py", line 64 in _read_forever
  File "C:\Users\foxcirc\AppData\Local\Programs\Python\Python37-32\lib\threading.py", line 865 in run
  File "C:\Users\foxcirc\AppData\Local\Programs\Python\Python37-32\lib\threading.py", line 917 in _bootstrap_inner
  File "C:\Users\foxcirc\AppData\Local\Programs\Python\Python37-32\lib\threading.py", line 885 in _bootstrap
Current thread 0x00002964 (most recent call first):
  File "<string>", line 9 in __init__
  File "C:/Users/foxcirc/Desktop/rxry/game/scripts/main.py", line 132 in <module>
  File "C:\Users\foxcirc\AppData\Local\Programs\Python\Pycharm\plugins\python-ce\helpers\pydev\_pydev_imps\_pydev_execfile.py", line 18 in execfile
  File "C:\Users\foxcirc\AppData\Local\Programs\Python\Pycharm\plugins\python-ce\helpers\pydev\_pydev_bundle\pydev_umd.py", line 197 in runfile
  File "<input>", line 1 in <module>
  File "C:\Users\foxcirc\AppData\Local\Programs\Python\Python37-32\lib\code.py", line 90 in runcode
  File "C:\Users\foxcirc\AppData\Local\Programs\Python\Python37-32\lib\code.py", line 74 in runsource
  File "C:\Users\foxcirc\AppData\Local\Programs\Python\Pycharm\plugins\python-ce\helpers\pydev\_pydev_bundle\pydev_console_types.py", line 35 in run
  File "C:\Users\foxcirc\AppData\Local\Programs\Python\Pycharm\plugins\python-ce\helpers\pydev\pydevconsole.py", line 84 in do_add_exec
  File "C:\Users\foxcirc\AppData\Local\Programs\Python\Pycharm\plugins\python-ce\helpers\pydev\_pydev_bundle\pydev_code_executor.py", line 106 in add_exec
  File "C:\Users\foxcirc\AppData\Local\Programs\Python\Pycharm\plugins\python-ce\helpers\pydev\pydevconsole.py", line 258 in process_exec_queue
  File "C:\Users\foxcirc\AppData\Local\Programs\Python\Pycharm\plugins\python-ce\helpers\pydev\pydevconsole.py", line 411 in start_client
  File "C:\Users\foxcirc\AppData\Local\Programs\Python\Pycharm\plugins\python-ce\helpers\pydev\pydevconsole.py", line 483 in <module>

Here are all my imports, if that's important:如果这很重要,这是我所有的进口:

import pygame
from pickle import load as pickload
from os import chdir, walk; chdir(gamedir); del chdir
from sys import path; path.extend(gamedir); del path 

I have tried to not importing pickle but nothing changed.我试图不进口泡菜,但没有任何改变。 Also I've tried to call the function from another "part" of the program.我还尝试从程序的另一个“部分”调用 function。

Here is how I use pygame.tranform.rotate: pygame.transform.rotate(self.bsurface, 10)这是我使用 pygame.tranform.rotate 的方法: pygame.transform.rotate(self.bsurface, 10)

Using python 3.7 (32-bit) and pygame version 1.9.6.使用 python 3.7(32 位)和 pygame 版本 1.9.6。

I tried several things and now I found the error!我尝试了几件事,现在我发现了错误!

It turns out, that the surface I used in the function initialy had a width and a length of 0 .事实证明,我在 function 中使用的表面最初的宽度和长度为0
Calling the pygame.transform.rotate function on a surface with a width and / or height of 0 apparently doesn not result in a fancy "You can't call this with a surface wich has a width of 0" message.在宽度和/或高度为0的表面上调用pygame.transform.rotate function 显然不会导致“你不能用宽度为 0 的表面来调用它”消息。 You just get a segfault.你只是得到一个段错误。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM