Skip to content
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

box2d-py to wasm #16

Open
shblhy opened this issue Mar 9, 2023 · 8 comments
Open

box2d-py to wasm #16

shblhy opened this issue Mar 9, 2023 · 8 comments

Comments

@shblhy
Copy link

shblhy commented Mar 9, 2023

Hello, I want play gymnasium games in web page, so I use pygbag. The problem is gymnasium use box2d, so i need box2d wasm, but I dont know how to compile box2d. Can any one help?
https://github.com/pybox2d/pybox2d

@pmp-p
Copy link
Member

pmp-p commented Mar 9, 2023

building box2d release 2.4.1 to wasm succeed with emcmake cmake -DCMAKE_C_COMPILER=emcc -DCMAKE_INSTALL_PREFIX=${PREFIX} ${SDKROOT}/src/box2d-2.4.1 -DBOX2D_BUILD_TESTBED=OFF -DBOX2D_BUILD_DOCS=OFF

i'll try pybox2d soon that apparently has its own copy of box2d

@shblhy
Copy link
Author

shblhy commented Mar 20, 2023

I don't know how to compile a python project to wasm which has c-compiled files. If you have any document or idea, please tell me.

@pmp-p
Copy link
Member

pmp-p commented Mar 27, 2023

build of git unmodified pybox2d is available via import Box2D at top of main.py

NB: pygame_framework.PygameFramework.run must be converted upstream to async for running examples. I tested "Box2D/examples/pinball.py" which works but has a bug when framework finds pygame_gui ( balls are launched above table)

@pmp-p
Copy link
Member

pmp-p commented Mar 27, 2023

pygbag git now supports box2d example framework

https://pmp-p.github.io/pybox2d-wasm/

code https://github.com/pmp-p/pybox2d-wasm/

@shblhy
Copy link
Author

shblhy commented Mar 28, 2023

I meet an error and I can not pass the test:
This is the eror:
image
And this is my project:
image

@pmp-p
Copy link
Member

pmp-p commented Mar 28, 2023

that's not a box2d error, but a pygame.gfxdraw one.
Where is the source code of experiment ? Since stock gymnasium requires multiprocessing which is not available.

@shblhy
Copy link
Author

shblhy commented Mar 28, 2023

here the code:
https://github.com/shblhy/pygbagcompiles

@pmp-p
Copy link
Member

pmp-p commented Mar 31, 2023

Thanks, it's a wasm pygame port bug and issues is now there pygame-community/pygame-ce#2082
meanwhile you can remove the problematic gfxdraw calls
https://pmp-p.github.io/lunarlander-wasm?-i as i did here pmp-p/lunarlander-wasm@d43cb25

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants