Skip to content

Fix physics example #168

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

Merged
merged 1 commit into from
May 3, 2025
Merged

Fix physics example #168

merged 1 commit into from
May 3, 2025

Conversation

3demax
Copy link
Contributor

@3demax 3demax commented Apr 15, 2025

I was playing around with the library (thanks for publishing, BTW) and noticed that physac.py example wasn't working well, because "UpdatePhysics" function was not defined:

Traceback (most recent call last):
  File "/home/max/Projects/Projects/Dichronauts/raylib/physac.py", line 27, in <module>
    UpdatePhysics()  # TODO no longer works
    ^^^^^^^^^^^^^
NameError: name 'UpdatePhysics' is not defined

So I just commented it out and to my surprise it worked well :D

I digged a bit deeper to try to figure out what happened and realized that it seems like physac was updated (to v1.1) since initial bindings were created.
It still has InitPhysics, but now it seems to include it's own, so you don't need to call UpdatePhysics anymore.
ResetPhysics was removed, but nobody stops you to ClosePhysics(); InitPhysics() to the same effect.

That's what I did and now it works as expected:
Screenshot from 2025-04-14 17-46-55

@electronstudio
Copy link
Owner

The version of Physac that we ship with has UpdatePhysics:

https://github.com/raysan5/physac/blob/4a8e17f263fb8e1150b3fbafc96f880c7d7a4833/src/physac.h#L201

I think you are trying to use a newer version of Physac.

@3demax 3demax mentioned this pull request Apr 15, 2025
@electronstudio
Copy link
Owner

There’s a proposal to use the newer version here

#165

but until/unless this is done the examples should not be updated.

@3demax
Copy link
Contributor Author

3demax commented Apr 15, 2025

I have decided to reach out because I ran into errors with physics example in the the package for nixOS.

It builds fine, but it uses an upstream version of physac (which is currently 1.1), instead of the local one.
Technically, I can force it to build against the old version of Physac, but I don't know if that makes sense, since building against the most recent upstream version works well, even though with some caveats.

@electronstudio
Copy link
Owner

Sounds like an issue with the Nixos package then. I mean you can build raylib-python-CFFI against any versions you want. You could make a package with Raylib 5.6-dev right now. But it would be wrong to confuse these packages with mine.

@3demax
Copy link
Contributor Author

3demax commented Apr 15, 2025

Fair point. I just realized how this might look from your perspective: you have pulled in very specific versions of c libraries to make sure it all works and here I am tearing it apart and building against the versions that I like.

This is something I wanted to follow-up, but let me bring this up in another conversation.

@electronstudio
Copy link
Owner

No problem with you using whatever versions you like, and I will eventually merge this PR when I update Physac.

Issue seems to be Nixos has broken it up into separate packages for Raylib-Python-CFFi, Raylib, Raygui and GLFW. Which is fine, it still builds a valid Raylib-Python-CFFI. But it doesn’t build Raylib-Python-CFFI 5.5.0.2 unless all those package versions match ours, and they don’t. So either NixOS needs to specify specific versions of those dependencies, or else not claim the resultant package is 5.5.0.2.

@electronstudio electronstudio merged commit 2df1ac4 into electronstudio:master May 3, 2025
22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants