devnix / chipmunkphp
A PHP FFI binding for Chipmunk physics engine
Installs: 0
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 3
Forks: 0
Open Issues: 5
Language:C
Requires
- php: >=8.0
Requires (Dev)
- phpunit/phpunit: ^9.5
- squizlabs/php_codesniffer: ^3.0
This package is auto-updated.
Last update: 2024-10-26 08:52:19 UTC
README
This project aims to provide a full FFI wrapper around Chipmunk 2D physics engine for PHP. What a time to be alive!
Install
Via Composer
$ composer require devnix/chipmunkphp
Dependencies
Linux
You will need to compile and install Chipmunk 7
cd /tmp git clone git@github.com:slembcke/Chipmunk2D.git cd Chipmunk2D
Find the latest 7.x tag and checkout it
git tag
Chipmunk-6.0.0
Chipmunk-6.0.1
Chipmunk-6.0.2
Chipmunk-6.0.3
Chipmunk-6.1
Chipmunk-6.1.1
Chipmunk-6.1.2
Chipmunk-6.1.3
Chipmunk-6.1.4
Chipmunk-6.1.5
Chipmunk-6.2.0
Chipmunk-6.2.1
Chipmunk-6.2.2
Chipmunk-7.0.0
Chipmunk-7.0.1
Chipmunk-7.0.2
Chipmunk-7.0.3
Cocos2D-3.0
git checkout Chipmunk-7.0.3
Then compile, install and clear shared libraries cache.
cmake .
make
sudo make install
sudo ldconfig
And should be done. Please, give us feedback if you have problems opening an issue.
Change log
Please see CHANGELOG for more information on what has changed recently.
Hacking
The header file for the FFI API must be already processed. You can do it with GCC (I'm just messing with the parameters...):
cpp -P -E -D "__attribute__(ARGS)=" ~/tmp/Chipmunk2D/include/chipmunk/chipmunk.h -o include/chipmunk.h -save-temps
Don't forget to hange the /tmp/Chipmunk2D
path to your needs.
After that, manually remove code of inline functions and let there only the signature. You will also have to manually delete the stdio.h and math.h (I guess) signatures.
I've been messing with ircmaxell/FFIMe but it seems like there is some kind of problem when parsing with ircmaxell/php-c-parser. I would love to find a way to automatically get the working header file automatically to ease the work.
Testing
$ composer test
Contributing
Please see CONTRIBUTING and CODE_OF_CONDUCT for details.
Security
If you discover any security related issues, please email devnix.code@gmail.com instead of using the issue tracker.
Credits
- Pablo Largo Mohedano, author of this package.
- Victor Blomqvist, I have stolen documentation and ideas from Pymunk.
- Scott Lembcke and Howling Moon Software, makers of Chipmnunk, parts of C header files are in this project.
- All Contributors
License
The MIT License (MIT). Please see License File for more information.