-
Notifications
You must be signed in to change notification settings - Fork 82
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Is it possible to use pytmx along with pygame_sdl2 for easy android deployment? #95
Comments
I am assuming that there is some issue with how pytmx imports pygame....maybe? Pytmx makes heavy use of software surfaces and the mask module, and that may also have some conflicts. I don't have the test environment to work with this issue, but if you are willing to try a few things, then we can maybe pinpoint the issue and work something out. My first request is to find a more specific traceback, if possible. That call to load_pygame is just a function call to more python code, the actual cause of the crash is likely somewhere else. |
Ehi, thanks for your feedback!
|
Not certain that this is related but I've also found that pgame_sdl2 doesn't play nicely with pygame on windows after freezing a program including both. Do you think it would be possible to change the init file of PyTMX so that it doesn't always include pygame (and consequently bring along all of pygame's dlls) whether you are using it or not? To explain a bit more I'm using both PyTMX and pygame_sdl2 to try and create an isometric tiled prototype rendering engine (it runs really nicely by the way!). The problem comes when I try to freeze the program on windows. Even though I'm using a custom image loader and not actually using any of the pygame code, the
Which, following the chain of imports, means that freezing tools like py2exe, pyInstaller and cx_freeze are going to try and pull pygame and all it's associated dlls into your program. I think this pulling in of unnecessary dlls is probably happening with pyglet using programs and well as sdl2 using ones, but it probably only causes a crash with sdl2 - or at least with pygame_sdl2. As far as I can tell those lines are just there as a debug warning, which may now be out of date because there are several official image loaders. |
@MyreMylar Nice work btw, on the iso view game. Are you using the SDL2 Renderer? |
Yep. I'm also trying to improve the library to work better for Tiled/TMX games in general. I have the basics of a custom image loader for pyTMX written that uses the Renderer module's TextureNodes. Ends up running about eight times faster than nearly the same code in pygame (about 350FPS vs 45FPS in my current prototypes).
Well I believe the reason it breaks is because SDL2 and SDL1 are incompatible at the c library level - you should get the same problems with the pysdl2 importer. I was initially pursuing fixing this problem in the pygame_sdl2 library but other than pygame_sdl2 moving to sdl1 (which would rather undo the point of the library) there is nothing that can be done over there. I don't think that removing the util_pygame import from the The only other proper long term option I can see is creating a permanent PyTMX_sdl2 fork that would be basically the same as the root but with proper sdl2 support by removing this import. Perhaps we could add a deprecation warning to the init.py file mentioning that pygame users will have to import util_pygame in the future and leave it there for a few months? At the least if it is not going to be fixed then we should probably document this problem because otherwise people will keep running into it and it is in no way immediately obvious what the problem is (it took me several days to track the crash down to PyTMX and then on to pygame). Happy to create some pull requests for any of the three methods:
|
I've made some branches with the three proposed options over on my fork of PyTMX:
My preference would be for the library to move towards solution 2 just because I think it'll create less issues going forward into the future as more people migrate to using pygame alternatives. Plus, it's a lot easier to fix any issues that do crop up with pygame users by saying 'import pytmx.util_pygame' or 'refer to the docs' than it is for users that get these crashes to figure out they are coming from PyTMX and then how to solve them. Anyway, let me know which you prefer and I'll convert it to a pull request. Then hopefully I'll be back in a few weeks/months (however long it takes me to get pygame_sdl2 updated) with a |
Thanks for thinking about the problem @MyreMylar. PyTMX is pretty old at this point, and I've made a few mistakes along the way. I really don't want to break people's projects by changing too much. Pygame is not required for pytmx, as you know. It will happily run if it cannot find it. The problem is, that as it is checking for pygame, other things beyond my control are breaking....why is it my responsibility to make sure pysinstaller, pygame_sdl2, etc don't break if pygame is imported? I'm not convinced its my problem that things break when i do a reasonable attempt to import pygame and fail gracefully if not found (using try/except). To summarize, you've got a problem with your build environment where two libraries will not import at the same time. I don't see how it is the responsibility of pytmx to be aware of that. Who knows, maybe next week pygame_sdl2 will work with both imported and then I would have wasted all this time developing a solution to a problem that has effected just one person at this point. Blacklist pygame in your build script, or use a venv, both are very reasonable solutions. Adding documentation stating the incompatibility is fine, i guess, but i don't think anything should be done really; its not an issue with pytmx. |
OK, I will submit the documentation pull request. I do think it is worth trying to make your library work with other commonly used libraries if possible, but I can understand losing enthusiasm for an old project. Heck knows I've done that enough in the past. You would know better than I if using PyTMX with SDL2 is unpopular and not worth supporting. |
I haven't lost enthusiasm; I'm stating that it is old and stable, and I
wouldn't want to break it for the other people who use it by fiddling with
how it checks for pygame, or dropping the statement where it tries to
import it. It works great with other commonly used libraries, pyglet,
kivy, even pygame_sdl2...but that last one doesn't play well with pygame
and that's not my problem....at all.
Look, I'll be honest, I'm not sure why you are pushing me so hard to change
this. It works great with pygame_sdl2 (you know that already), but fails
in your dev environment. Think about it, why should I make changes to
something that is not my fault at all? You're submitting patches to
pygame_sdl2, so why don't you fix that, the root of the problem?
…On Tue, Apr 17, 2018 at 11:48 AM, Dan Lawrence ***@***.***> wrote:
OK, I will submit the documentation pull request.
I do think it is worth trying to make your library work with other
commonly used libraries if possible, but I can understand losing enthusiasm
for an old project. Heck knows I've done that enough in the past.
You would know better than I if using PyTMX with SDL2 is unpopular and not
worth supporting.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#95 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AAh-p6Jf9waDXZBlb5opJubGVfQb6wuzks5tphz5gaJpZM4Rl3uz>
.
|
Hi @bitcraft.
First of all, thanks for this great project!
I've been experimenting with it and have been very satisfied so far.
I just discovered pygame_sdl2 and I would really like to use it along with rapt for testing my game on my android device.
However, when I import pygame_sdl2 the game does not work anymore like before (it does not even inizialize) giving error like "no mode has been set". Apparently, this is happening during the call to
tiled_map = load_pygame('map.tmx')
as I explained in this issue.Does anybody know of a succesfull port of a pygame_sdl2 to android using pytmx?
Thanks!
The text was updated successfully, but these errors were encountered: