Configuration of the Box2d physical engine in python, pythonbox2d
/*******************************
I come back!
I am looking for a job because I am a senior.
As a result, the blog has not been updated for the second time. Apologize to everyone
*******************************/
Preface
Box2d physical Engine
Box2d is an open-source 2d physical engine. It has many versions, such as C ++, Java, html5, and python.
The famous Angry Bird was developed using this physical engine.
Currently, many 2d game engines have built-in support for Box2d physical engines, such as cocos2d and HTML5 2D game engine flags.
The Box2d physical engine simulates a world in which you can set the gravity, add various objects to the world, and some of their physical characteristics, such as quality and friction, damping, etc.
After setting the update frequency of the world, box2d calculates the position and Rotation Angle of each updated object.
Since Box2d itself is not responsible for rendering, when we use the box2d physical engine, we actually convert the coordinates of the genie we need to draw in the project, it becomes an object in the internal world of box2d.
The box2d physical engine calculates the position and angle of the object after each update. Then, after obtaining the position and angle and performing coordinate transformation, it becomes the location of the genie we need to draw, and draw it out.
This is an image bird (http://www.dwz.cn/nD94d) game I used to play on windows phone)
The box2d physical engine is used in it. If you are interested, you can play it.
I. Configure the environment
Windows 7
Python2.7
Ii. configuration method
1. DownloadBox2d physical engine for pythonAfter decompression, you can find a setup. py file in it.
(Http://code.google.com/p/pybox2d/wiki/BuildingfromSource here explains the configuration of windows, linux, OS X
It is only in English. You can read it and try to configure it)
2. DownloadMinGWInstall and add the binfile in its path to the environment variable (here I am C: \ MinGW \ bin)
(MinGW (Minimalist GNU for Windows), also known as mingw32, is the product of porting gcc compiler and GNU Binutils to Win32 platform, including a series of header files (Win32API), library, and executable files .)
3. DownloadMSYSAnd install
(MSYS is a small GNU environment, including basic bash, make, and so on)
4. Download and installSWIGInstall it and add its path to the environment variable (I am here "D: \ swigwin-3.0.2 \ swigwin-3.0.2 ")
(SWIG is a development tool that simplifies the scripting language and C/C ++ interfaces. In short, SWIG is a tool for communicating with the scripting language by packaging and compiling C-language programs)
5. DownloadPython2.7Install it and add its path to the environment variable (I am "D: \ Python27 ")
(One way to make the environment variable take effect immediately is to open cmd,
Note that the result displayed in echo % PATH % does not contain the environment variable we just added,
We enter set PATH = C and close cmd,
Type echo % PATH % to see that the environment variable you just added has been displayed)
6. Open \ Lib \ distutils \ In the python path and create a new distutils. cfg file (here I am going to "D: \ Python27 \ Lib \ distutils ")
Content:
[build]
compiler=mingw32
[build_ext]
compiler=mingw32
7. To run the test _ headers example in box2d, we also need to download and installPygame
(Pygame is a cross-platform python module designed for video games, including image and sound functions)
After the installation is successful, open the python IDLE and enter
>>> Import pygame
>>> Print pygame. ver
The installed pygame version is displayed.
8. Open msys. bat under msys, cd to the previously downloaded box2d path, and reach the same path as setup. py.
Then type
Setup. py build
Enter
Setup. py install-force
The following items are displayed.
9. Now that pybox2d has been installed, we can start the hello. py running in example for verification.
And any example with the test _ headers, such as test_car for further verification.
How to Use the box2d physical engine in vc ++ 60?
It is estimated that you do not include box2d. X
An error occurs because the compiler cannot find the box2d. h or box2d. cpp file.
You need to find this file and put it in the Vc installation directory.
Or you can put the function of this file in a file named box2d. h or box2d. cpp.
Then add the project you wrote and compile it.
You should download and install the box2d for VC package.
How does vbnet reference the box2d physical engine?
Find a "Bullet cell trajectory simulation program ". Box2d.
On csdn.
Www.baidu.com/..f2&n=2