bitcraft / pyscroll

make scrolling games with animated maps in pygame
GNU General Public License v3.0
177 stars 28 forks source link

pygame.error: cannot convert without pygame.display initialized #37

Closed joereynolds closed 4 years ago

joereynolds commented 4 years ago

Hi,

Forgive me if this is user error but I'm trying to use pyscroll with a pre-existing game. Doing the bare minimum of the following:

self._map = load_pygame(self.tmx_file)
self.map_data_for_camera = pyscroll.TiledMapData(self._map)
Causes the following trace: Traceback (most recent call last): File "./run.py", line 4, in import src.environment as environment File "/home/joe/code/me/mr-figs/src/environment.py", line 40, in level_obj_list = create_level_list() File "/home/joe/code/me/mr-figs/src/environment.py", line 18, in create_level_list level_dict[levels.level1.KEY_NAME] = level_base.LevelBase(levels.level1.LOCATION, 'NoNextScene', 1) File "/home/joe/code/me/mr-figs/src/scenes/levelbase.py", line 22, in __init__ self.tiled_level = level_editor.LevelData(file) File "/home/joe/code/me/mr-figs/src/level_editor.py", line 22, in __init__ self._map = load_pygame(self.tmx_file) File "/home/joe/.local/lib/python3.6/site-packages/pytmx/util_pygame.py", line 144, in load_pygame return pytmx.TiledMap(filename, *args, **kwargs) File "/home/joe/.local/lib/python3.6/site-packages/pytmx/pytmx.py", line 354, in __init__ self.parse_xml(ElementTree.parse(self.filename).getroot()) File "/home/joe/.local/lib/python3.6/site-packages/pytmx/pytmx.py", line 417, in parse_xml self.reload_images() File "/home/joe/.local/lib/python3.6/site-packages/pytmx/pytmx.py", line 465, in reload_images self.images[gid] = loader(rect, flags) File "/home/joe/.local/lib/python3.6/site-packages/pytmx/util_pygame.py", line 118, in load_image tile = smart_convert(tile, colorkey, pixelalpha) File "/home/joe/.local/lib/python3.6/site-packages/pytmx/util_pygame.py", line 59, in smart_convert tile = original.convert() pygame.error: cannot convert without pygame.display initialized

I have already initialised the pygame display long ago and have also tried forcing it with pygame.display.init() to no avail. For the record, the self.tmx_file is a valid tmx file. I have been using your pytmx library for a while with success but I'm having issues with pyscroll.

Thanks for the help, let me know if you need more info!

Edit: I'm on pygame 2 though I don't think that affects this.

joereynolds commented 4 years ago

Ignore me, I've had a look through your tutorial and it looks like I need to pass the screen down. My bad.