Git Product home page Git Product logo

pybox2d's Introduction

Build Status Coverage Status

pybox2d

2D Game Physics for Python

https://github.com/pybox2d/pybox2d

How to get it

pybox2d is available on conda-forge with the package name pybox2d. To create a new conda environment with pybox2d, run the following:

$ conda create -n pybox2d -c conda-forge python=3.6 pybox2d
$ conda activate pybox2d

Recent builds should be available for Windows, Linux, and OS X, with Python 3.6, 3.7, and 3.8.

What is it?

pybox2d is a 2D physics library for your games and simple simulations. It's based on the Box2D library, written in C++. It supports several shape types (circle, polygon, thin line segments), and quite a few joint types (revolute, prismatic, wheel, etc.).

Getting Started

For building instructions, see INSTALL.md. Check out the testbed examples to see what pybox2d can do. Then take a look at the getting started manual located on the pybox2d wiki.

Bugs

Please submit any bugs that you find to the issue tracker.

Testbed examples

You can browse the testbed examples on GitHub here

  1. Install a backend such as pygame or pyglet to use as a renderer.

    Backend Install Homepage
    pygame pip install pygame http://pygame.org
    pyqt4 conda install pyqt4 https://www.riverbankcomputing.com/
    pyglet pip install pyglet (or use conda-forge) http://pyglet.org
    opencv pip install opencv http://opencv.org
  2. Run your first example with the pygame backend:

    # As a start, try the web example with the pygame backend:
    $ python -m Box2D.examples.web --backend=pygame
  3. Take a look at the other examples, setting the backend as appropriate:

    $ python -m Box2D.examples.apply_force
    $ python -m Box2D.examples.body_types
    $ python -m Box2D.examples.box_cutter
    $ python -m Box2D.examples.breakable
    $ python -m Box2D.examples.bridge
    $ python -m Box2D.examples.bullet
    $ python -m Box2D.examples.cantilever
    $ python -m Box2D.examples.car
    $ python -m Box2D.examples.chain
    $ python -m Box2D.examples.character_collision
    $ python -m Box2D.examples.cloth
    $ python -m Box2D.examples.collision_filtering
    $ python -m Box2D.examples.collision_processing
    $ python -m Box2D.examples.confined
    $ python -m Box2D.examples.convex_hull
    $ python -m Box2D.examples.conveyor_belt
    $ python -m Box2D.examples.distance
    $ python -m Box2D.examples.edge_shapes
    $ python -m Box2D.examples.edge_test
    $ python -m Box2D.examples.gish_tribute
    $ python -m Box2D.examples.hello
    $ python -m Box2D.examples.liquid
    $ python -m Box2D.examples.mobile
    $ python -m Box2D.examples.motor_joint
    $ python -m Box2D.examples.one_sided_platform
    $ python -m Box2D.examples.pinball
    $ python -m Box2D.examples.pulley
    $ python -m Box2D.examples.pyramid
    $ python -m Box2D.examples.raycast
    $ python -m Box2D.examples.restitution
    $ python -m Box2D.examples.rope
    $ python -m Box2D.examples.settings
    $ python -m Box2D.examples.theo_jansen
    $ python -m Box2D.examples.tiles
    $ python -m Box2D.examples.time_of_impact
    $ python -m Box2D.examples.top_down_car
    $ python -m Box2D.examples.tumbler
    $ python -m Box2D.examples.vertical_stack
    $ python -m Box2D.examples.web

These framework examples are included in the distribution, but they are also written in a way such that you can copy the examples directly and modify them yourself.

For example, the following would be possible:

$ git clone https://github.com/pybox2d/pybox2d pybox2d
$ mkdir my_new_examples
$ cp -R pybox2d/library/Box2D/examples/* my_new_examples
$ cd my_new_examples
$ python web.py --backend=pygame

Simple examples

There are also some simple examples that are not weighed down by testbed architecture. You can browse them on GitHub here

These can also be run directly from your pybox2d installation:

$ python -m Box2D.examples.simple.simple_01
$ python -m Box2D.examples.simple.simple_02

A similar opencv-based example is here:

$ python -m Box2D.examples.simple_cv

pybox2d's People

Contributors

bakwc avatar bobbysoon avatar goretkin avatar jarl-haggerty avatar kne avatar mbednarski avatar nzjrs avatar sytelus avatar xzfn avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pybox2d's Issues

userData, reference counting, and destructors

From sirkne on July 19, 2008 19:30:41

Take this sample code, according to Hypnos on the Box2D forums ( http://www.box2d.org/forum/viewtopic.php?f=5&t=241&start=40 ):

{{{
import Box2D2 as box2d

worldAABB = box2d.b2AABB()
worldAABB.lowerBound.Set( -10, -10 )
worldAABB.upperBound.Set( 10, 10 )
gravity = box2d.b2Vec2(0.0, 0.0)
doSleep = True
world = box2d.b2World( worldAABB, gravity, doSleep)

class c:
def init( self ):
print "c.init"
bodyDef = box2d.b2BodyDef()
self.body = world.CreateBody( bodyDef )
self.body.SetUserData( self )
shapeDef = box2d.b2CircleDef()
shapeDef.radius = 0.5
shapeDef.density = 1.0
self.shape = self.body.CreateShape( shapeDef )
self.shape.SetUserData( self )

def del( self ):
print "c.del"

def destroy( self ):
print "c.destroy"
self.body.SetUserData( None )
self.shape.SetUserData( None )

a = c()

for i in xrange(100):
world.Step( 0.1, 1 )
world.Validate()

}}}

As the reference count for the instance of the 'c' class is increased twice
in its initialization routine, the destructor (del) of the class is
never called once it goes out of context.

Original issue: http://code.google.com/p/pybox2d/issues/detail?id=6

Box2D imports fine, nothing else does

From Anonymouse2048 on April 01, 2010 12:37:46

I tried to run every one of the examples from the testbed (after compiling
pybox2d myself), and none of them worked because Box2D had no child
objects.

For example, test_Car.py:
Traceback (most recent call last):
File "test_Car.py", line 22, in
from test_main import *
File "/home/linus/pybox2d-read-only/testbed/test_main.py", line 31, in

exec("from %s_main import *" % fwSettings.backend)
File "", line 1, in
File "/home/linus/pybox2d-read-only/testbed/pygame_main.py", line 57, in

class fwDestructionListener(box2d.b2DestructionListener):
AttributeError: 'module' object has no attribute 'b2DestructionListener'

Here's why:

import Box2D
dir(Box2D)
['builtins', 'doc', 'file', 'loader', 'name',
'package', 'path', 'version', 'version_info']

I'm using the latest SVN version (currently 258) on ubuntu 9.10 (Karmic).

Original issue: http://code.google.com/p/pybox2d/issues/detail?id=30

Reorganize the repository

From santagada on October 29, 2008 15:37:50

A more pythonic repository will make it simple for new people to checkout
and install the library

the new format would be:

INSTALL all the info on installing the library on linux/windows/osx
README a simple description of the library and the project
LICENSE the license
setup.py the new setuptools based setup?
Box2d/ the old directory or maybe it could be box2d2 to be compliant
to PEP-8
testbed/ the now Python/testbed directory
contrib/ Should this directory stay? maybe we can move one level down to
be like trunk, branches, tag, wiki, contrib. Maybe also a README there to
explain each of the projects

Original issue: http://code.google.com/p/pybox2d/issues/detail?id=13

Problem with pyBox2d and Python 2.7.2

From pgrandeau on March 20, 2012 03:37:30

I installed pyBox2D on Windows7 and Python 2.7.2 and when I run demos.py (in testbed) I get the error :

Traceback (most recent call last):
File "C:\Users...\testbed\demos.py", line 29, in
from test_main import fwDebugDraw
File "C:\Users...\testbed\test_main.py", line 32, in
exec("from %s_main import *" % fwSettings.backend)
File "", line 1, in
File "C:\Users\Pascal\Desktop\pyBox2d\testbed\pygame_main.py", line 78, in
class fwBoundaryListener(box2d.b2BoundaryListener):
AttributeError: 'module' object has no attribute 'b2BoundaryListener'

I do not know what this mean.
How can I use pyBox2D and testbed with my configuration ?
Thank you.

Pascal Grandeau

Original issue: http://code.google.com/p/pybox2d/issues/detail?id=45

accessing fixture.aABB raises an exception

From mikkelin on October 17, 2010 08:44:11

What steps will reproduce the problem? 1. fixture.aABB 2. 3. What is the expected output? What do you see instead? >>> fixture.aABB
Traceback (most recent call last):
File "", line 1, in
File "/Library/Python/2.6/site-packages/Box2D-2.1b0-py2.6-macosx-10.6-universal.egg/Box2D/Box2D.py", line 3227, in __GetAABB
return _Box2D.b2Fixture___GetAABB(self, _args, *_kwargs)
TypeError: Required argument 'childIndex' (pos 2) not found What version of the product are you using? On what operating system? branches/box2d_2.1, revision 275 Please provide any additional information below. C++ signature:

const b2AABB& b2Fixture::GetAABB(int32 childIndex) const

So, this C++ member function needs to be wrapped as a Python method, not a property.

Original issue: http://code.google.com/p/pybox2d/issues/detail?id=34

The Mac os x python 2.5 installer refuses to install

From tiktuk on December 24, 2008 12:25:01

What steps will reproduce the problem? 1. Run the installer
2. Select the install volume

What is the expected output?
It should let me continue. I have System Python 2.5.

What do you see instead?
"You cannot install Box2D 2.0.2b0 on this volume. Box2D requires System Python 2.5 to install." What version of the product are you using? On what operating system? Box2D 2.0.2b0 on Mac os x 10.5.5. Please provide any additional information below. It worked when I installed from source.
Actually Pygame's installer have the same problem for me.

Original issue: http://code.google.com/p/pybox2d/issues/detail?id=16

pybox2d not installing in Python 2.7.3

From [email protected] on January 16, 2013 12:28:54

I am using Windows 7 32-bit and using the SVN repository for the build.

I build using MINGW32 as described in the "Source Section". It build fines with gcc but when it gets to building with g++, i get the following :

c:/mingw/bin/../lib/gcc/mingw32/4.7.2/../../../../mingw32/bin/ld.exe: build\temp .win32-2.7\Release\box2d\box2d_wrap.o: bad reloc address 0x48 in section `.data'
collect2.exe: error: ld returned 1 exit status
error: command 'g++' failed with exit status 1

Please tell me what can be the cause for this problem?? am i missing something??

Original issue: http://code.google.com/p/pybox2d/issues/detail?id=48

Contact listener refcount not increased with SetContactListener

From brandyn.webb on September 13, 2009 21:56:43

See the bottom for the punchline first. Everything in the middle is just
context fyi: What steps will reproduce the problem? 1. world.SetContactListener(b2ContactListener())
2. run a simulation that causes a contact What is the expected output? What do you see instead? gdb of python catches a segfault as follows:

(gdb) where
#0 0xb756518f in b2PolyAndCircleContact::Evaluate (this=0x836b574,
listener=0x832fe58) at Box2D/Dynamics/Contacts/b2PolyAndCircleContact.cpp:122
#1 0xb7564cf4 in b2Contact::Update (this=0x836b574, listener=0x832fe58) at
Box2D/Dynamics/Contacts/b2Contact.cpp:153
#2 0xb755ec01 in b2World::SolveTOI (this=0x8313db8, step=@0xbfdb42ac) at
Box2D/Dynamics/b2World.cpp:651
#3 0xb755f18b in b2World::Step (this=0x8313db8, dt=0.0166666675,
velocityIterations=20, positionIterations=16) at Box2D/Dynamics/b2World.cpp:878
#4 0xb75500a2 in _wrap_b2World_Step (args=0xb7db5a54) at
Box2D/Box2D_wrap.cpp:27850
#5 0xb54765c8 in ?? ()
Backtrace stopped: previous frame inner to this frame (corrupt stack?)
(gdb) list
117 b2Vec2 v2 = b2->GetLinearVelocityFromLocalPoint(mp->localPoint2);
118 cp.velocity = v2 - v1;
119 cp.normal = m_manifold.normal;
120 cp.separation = mp->separation;
121 cp.id = id;
122 listener->Add(&cp);
123 }
124 }
125
126 m_manifoldCount = 1;
(gdb) print listener->Add
$5 = {void (b2ContactListener , const b2ContactPoint *)} 0xb7559b20
<b2ContactListener::Add(b2ContactPoint const
)>
(gdb) print listener
$6 = (b2ContactListener *) 0x832fe58
(gdb) print *listener
$7 = {_vptr.b2ContactListener = 0x1}
(gdb) print *0x832fe58
$8 = 1 What version of the product are you using? On what operating system? Ubuntu Hardy, version 2.0.2b1 Please provide any additional information below. No other problems. The simulation runs fine until what I assume is the
first contact, and then dies as above. If I never call SetContactListener,
the sim runs fine indefinitely. I have tried with my own class (subclass
of b2ContactListener) and just passing in a naked b2ContactListener as above.

Ok -- I just figured out what the problem is:

SetContactListener does not increment the reference count to the passed
object, so if you don't store it, it gets GC'd and causes a segfault. Easy
to fix, I assume?

Original issue: http://code.google.com/p/pybox2d/issues/detail?id=24

Error during install: KeyError: '_Box2D' (Ubuntu Karmic 64bit; setuptools)

From thehans on September 13, 2009 03:22:12

What steps will reproduce the problem? 1. run easy_install box2d

I get the following output which ends in an error:

Processing Box2D-2.0.2b1-py2.5-linux-i686.egg
Removing
/usr/local/lib/python2.6/dist-packages/Box2D-2.0.2b1-py2.5-linux-i686.egg
Copying Box2D-2.0.2b1-py2.5-linux-i686.egg to
/usr/local/lib/python2.6/dist-packages
Box2D 2.0.2b1 is already the active version in easy-install.pth

Installed
/usr/local/lib/python2.6/dist-packages/Box2D-2.0.2b1-py2.5-linux-i686.egg
Processing dependencies for Box2D==2.0.2b1
Searching for Box2D==2.0.2b1
Reading http://pypi.python.org/simple/Box2D/ Reading http://pybox2d.googlecode.com/ Reading https://code.google.com/p/pybox2d/downloads/list Best match: Box2D 2.0.2b1
Downloading http://pybox2d.googlecode.com/files/Box2D-2.0.2b1.zip Processing Box2D-2.0.2b1.zip
Running Box2D-2.0.2b1/setup.py -q bdist_egg --dist-dir
/tmp/easy_install-ROjLE6/Box2D-2.0.2b1/egg-dist-tmp-5i2MYq
Using setuptools.
Traceback (most recent call last):
File "/usr/local/bin/easy_install", line 8, in
load_entry_point('setuptools==0.6c9', 'console_scripts', 'easy_install')()
File "build/bdist.linux-i686/egg/setuptools/command/easy_install.py",
line 1671, in main

File "build/bdist.linux-i686/egg/setuptools/command/easy_install.py",
line 1659, in with_ei_usage

File "build/bdist.linux-i686/egg/setuptools/command/easy_install.py",
line 1675, in

File "/usr/lib/python2.6/distutils/core.py", line 152, in setup
dist.run_commands()
File "/usr/lib/python2.6/distutils/dist.py", line 975, in run_commands
self.run_command(cmd)
File "/usr/lib/python2.6/distutils/dist.py", line 995, in run_command
cmd_obj.run()
File "build/bdist.linux-i686/egg/setuptools/command/easy_install.py",
line 211, in run

File "build/bdist.linux-i686/egg/setuptools/command/easy_install.py",
line 427, in easy_install

File "build/bdist.linux-i686/egg/setuptools/command/easy_install.py",
line 478, in install_item

File "build/bdist.linux-i686/egg/setuptools/command/easy_install.py",
line 519, in process_distribution

File "build/bdist.linux-i686/egg/pkg_resources.py", line 522, in resolve
dist = best[req.key] = env.best_match(req, self, installer)
File "build/bdist.linux-i686/egg/pkg_resources.py", line 758, in best_match
return self.obtain(req, installer) # try and download/install
File "build/bdist.linux-i686/egg/pkg_resources.py", line 770, in obtain
return installer(requirement)
File "build/bdist.linux-i686/egg/setuptools/command/easy_install.py",
line 446, in easy_install

File "build/bdist.linux-i686/egg/setuptools/command/easy_install.py",
line 476, in install_item

File "build/bdist.linux-i686/egg/setuptools/command/easy_install.py",
line 655, in install_eggs

File "build/bdist.linux-i686/egg/setuptools/command/easy_install.py",
line 930, in build_and_install

File "build/bdist.linux-i686/egg/setuptools/command/easy_install.py",
line 919, in run_setup

File "build/bdist.linux-i686/egg/setuptools/sandbox.py", line 27, in
run_setup
File "build/bdist.linux-i686/egg/setuptools/sandbox.py", line 63, in run
File "build/bdist.linux-i686/egg/setuptools/sandbox.py", line 29, in
File "setup.py", line 109, in
File "/usr/lib/python2.6/distutils/core.py", line 152, in setup
dist.run_commands()
File "/usr/lib/python2.6/distutils/dist.py", line 975, in run_commands
self.run_command(cmd)
File "/usr/lib/python2.6/distutils/dist.py", line 995, in run_command
cmd_obj.run()
File "build/bdist.linux-i686/egg/setuptools/command/bdist_egg.py", line
174, in run
File "build/bdist.linux-i686/egg/setuptools/command/bdist_egg.py", line
161, in call_command
File "/usr/lib/python2.6/distutils/cmd.py", line 333, in run_command
self.distribution.run_command(command)
File "/usr/lib/python2.6/distutils/dist.py", line 995, in run_command
cmd_obj.run()
File "build/bdist.linux-i686/egg/setuptools/command/install_lib.py", line
20, in run
File "/usr/lib/python2.6/distutils/command/install_lib.py", line 113, in
build
self.run_command('build_ext')
File "/usr/lib/python2.6/distutils/cmd.py", line 333, in run_command
self.distribution.run_command(command)
File "/usr/lib/python2.6/distutils/dist.py", line 995, in run_command
cmd_obj.run()
File "build/bdist.linux-i686/egg/setuptools/command/build_ext.py", line
46, in run
File "/usr/lib/python2.6/distutils/command/build_ext.py", line 340, in run
self.build_extensions()
File "/usr/lib/python2.6/distutils/command/build_ext.py", line 449, in
build_extensions
self.build_extension(ext)
File "build/bdist.linux-i686/egg/setuptools/command/build_ext.py", line
175, in build_extension
File "/usr/lib/python2.6/distutils/command/build_ext.py", line 460, in
build_extension
ext_path = self.get_ext_fullpath(ext.name)
File "/usr/lib/python2.6/distutils/command/build_ext.py", line 633, in
get_ext_fullpath
filename = self.get_ext_filename(modpath[-1])
File "build/bdist.linux-i686/egg/setuptools/command/build_ext.py", line
85, in get_ext_filename
KeyError: '_Box2D'

Running this on Ubuntu Karmic 64bit

Original issue: http://code.google.com/p/pybox2d/issues/detail?id=23

b2Body.CreateCircleFixture() returns None

From mikkelin on October 06, 2010 16:50:59

What steps will reproduce the problem? 1. Call CreateCircleFixture(...) on a b2Body instance 2. 3. What is the expected output? What do you see instead? Should return the newly created fixture object. Returns None. What version of the product are you using? On what operating system? revision 274 of branches/box2d_2.1 Please provide any additional information below. See patch (attached).

Attachment: create-shape-fixture-returns-none.patch

Original issue: http://code.google.com/p/pybox2d/issues/detail?id=32

pybox2d fails to build on snow-leopard with swig error

From jc.lopes on January 07, 2010 15:05:01

What steps will reproduce the problem? 1. follow the steps on the INSTALL file for mac osx What is the expected output? What do you see instead? running build
running build_py
copying ./init.py -> build/lib.macosx-10.6-i386-2.6/Box2D
running build_ext
building 'Box2D._Box2D' extension
swigging Box2D/Box2D.i to Box2D/Box2D_wrap.cpp
swig -python -c++ -IBox2D -O -includeall -ignoremissing -w201 -outdir . -o
Box2D/Box2D_wrap.cpp Box2D/Box2D.i
Box2D/Box2D_printing.i:29: Error: Syntax error in input(3).
error: command 'swig' failed with exit status 1 What version of the product are you using? On what operating system? mac os 10.6 snow leopard, pybox2d-2.0.2b1, swig 1.3.40 Please provide any additional information below.

Original issue: http://code.google.com/p/pybox2d/issues/detail?id=27

Windws 7 Python x64 build fails / distutils

From mason.green on October 31, 2009 00:21:42

System setup:

Windows 7 x64
Python 2.6.4 x64
MSVC Express '08

$ python setup.py build
Setuptools not found; falling back on distutils.
running build
running build_py
copying .\Box2D.py -> build\lib.win-amd64-2.6\Box2D
copying .init.py -> build\lib.win-amd64-2.6\Box2D
running build_ext
building 'Box2D._Box2D' extension
swigging Box2D/Box2D.i to Box2D/Box2D_wrap.cpp
c:\swig\swig.exe -python -c++ -IBox2D -O -includeall -ignoremissing -w201
-outdi
r . -o Box2D/Box2D_wrap.cpp Box2D/Box2D.i
Traceback (most recent call last):
File "setup.py", line 109, in
setup( **setup_dict )
File "c:\Python26\lib\distutils\core.py", line 152, in setup
dist.run_commands()
File "c:\Python26\lib\distutils\dist.py", line 975, in run_commands
self.run_command(cmd)
File "c:\Python26\lib\distutils\dist.py", line 995, in run_command
cmd_obj.run()
File "c:\Python26\lib\distutils\command\build.py", line 134, in run
self.run_command(cmd_name)
File "c:\Python26\lib\distutils\cmd.py", line 333, in run_command
self.distribution.run_command(command)
File "c:\Python26\lib\distutils\dist.py", line 995, in run_command
cmd_obj.run()
File "c:\Python26\lib\distutils\command\build_ext.py", line 340, in run
self.build_extensions()
File "c:\Python26\lib\distutils\command\build_ext.py", line 449, in
build_exte
nsions
self.build_extension(ext)
File "c:\Python26\lib\distutils\command\build_ext.py", line 499, in
build_exte
nsion
depends=ext.depends)
File "c:\Python26\lib\distutils\msvc9compiler.py", line 448, in compile
self.initialize()
File "c:\Python26\lib\distutils\msvc9compiler.py", line 358, in initialize
vc_env = query_vcvarsall(VERSION, plat_spec)
File "c:\Python26\lib\distutils\msvc9compiler.py", line 274, in
query_vcvarsal
l
raise ValueError(str(list(result.keys())))
ValueError: [u'path']

Original issue: http://code.google.com/p/pybox2d/issues/detail?id=26

cannot build on os x

From Leif.Theden on April 12, 2011 08:04:15

What steps will reproduce the problem? 1. download svn
2. attempt to build Did you check the issue list? pybox2d 2.0.2b1 is old, and some issues are marked fixed (as in the SVN), but they have not been released yet. yes What is the expected output? What do you see instead? lipo: can't figure out the architecture type of: /var/tmp//ccbzGtkX.out What version of pybox2d are you using? On what operating system? 32-bit or 64-bit? 64 Please provide any additional information below. cannot compile from svn.

i have a game written with pybox2d 2.02b2. most people cannot get it compile under any circumstances. on my system, i was able to get it to work after upgrading swig. one user has the following error:

tried svn as well, will not build.

swigging Box2D/Box2D.i to Box2D/Box2D_wrap.cpp
swig -python -c++ -IBox2D -O -small -includeall -ignoremissing -w201 -outdir . -o Box2D/Box2D_wrap.cpp Box2D/Box2D.i
Box2D/Box2D_printing.i:29: Error: Syntax error in input(3).

Original issue: http://code.google.com/p/pybox2d/issues/detail?id=40

Line joints are not cast properly

From mangabasi on September 20, 2009 22:51:19

What steps will reproduce the problem? 1. Create a joint definition (jointDef) by using b2LineJointDef()
2. Create a joint (lineJoint) by using world.CreateJoint(jointDef)
3. If you try to get the joint object by using lineJoint.asLineJoint()
it fails. What is the expected output? What do you see instead? Expect to get a joint object. Get an error message.

AttributeError: 'b2Joint' object has no attribute 'asLineJoint' What version of the product are you using? On what operating system? Python 2.5 on Windows Please provide any additional information below. In Box2D2.py line no 688 (in class b2JointDef) types dictionary is missing
e_lineJoint

Similarly line no 761 (in class b2Joint) types dictionary is missing
e_lineJoint as well.

Original issue: http://code.google.com/p/pybox2d/issues/detail?id=25

Examples using pgu will crash with pygame 1.8.1

From ccanepacc on September 04, 2008 21:07:03

What steps will reproduce the problem? 1. install pygame 1.8.1
2. run demos.py , it will crash
3. Its a known compatibility problem with pgu - pygame 1.8.1 What is the expected output? What do you see instead? crash What version of the product are you using? On what operating system? Box2D-2.0.1b4.win32-py2.4.exe - win XP + SP3 Please provide any additional information below. Its a pgu incompatibility with pygame 1.8.1 . There is a pgu patch for
this, plus aditional compatibility notes in a thread of pygame users: http://thread.gmane.org/gmane.comp.python.pygame/15580

Original issue: http://code.google.com/p/pybox2d/issues/detail?id=8

pyglet/test_main.py raising an exception when a test is closed. Also a set_fps_limit() is not needed anymore

From santagada on October 25, 2008 21:40:09

Every time I closed a test on the ported to pyglet testbed an exception was
raised, on Mac OS X at least. The traceback is displayed bellow and the
problem I think was a race condition between the closing of the window and
the drawing of the last frame (which I think is strange).

-----------------traceback-------------
-----------------traceback-------------

Apfelstrudel:pyglet santagada$ python test_Car.py

Loading Car...
Traceback (most recent call last):
File "test_Car.py", line 190, in
main(Car)
File
"/Users/santagada/projects/pybox2d/Python/testbed/pyglet/test_main.py",
line 971, in main
test.run()
File
"/Users/santagada/projects/pybox2d/Python/testbed/pyglet/test_main.py",
line 631, in run
pyglet.app.run()
File "/Library/Python/2.5/site-packages/pyglet/app/init.py", line
264, in run
EventLoop().run()
File "/Library/Python/2.5/site-packages/pyglet/app/carbon.py", line 84,
in run
self._timer_proc(timer, None, False)
File "/Library/Python/2.5/site-packages/pyglet/app/carbon.py", line 133,
in _timer_proc
sleep_time = self.idle()
File "/Library/Python/2.5/site-packages/pyglet/app/init.py", line
187, in idle
dt = clock.tick(True)
File "/Library/Python/2.5/site-packages/pyglet/clock.py", line 696, in tick
return _default.tick(poll)
File "/Library/Python/2.5/site-packages/pyglet/clock.py", line 303, in tick
item.func(ts - item.last_ts, _item.args, *_item.kwargs)
File
"/Users/santagada/projects/pybox2d/Python/testbed/pyglet/test_main.py",
line 836, in SimulationLoop
self.debugDraw.batch.draw()
File "/Library/Python/2.5/site-packages/pyglet/graphics/init.py",
line 538, in draw
func()
File
"/Users/santagada/projects/pybox2d/Python/testbed/pyglet/test_main.py",
line 176, in set_state
gl.gluOrtho2D(0, self.window.width, 0, self.window.height)
File "/Library/Python/2.5/site-packages/pyglet/gl/lib.py", line 105, in
errcheck
raise GLException(msg)
pyglet.gl.lib.GLException: invalid value

-----------------traceback-------------
-----------------traceback-------------

If I print the values of self.window.width and self.window.height they are
both 0.

Also from http://www.pyglet.org/doc/programming_guide/new_features_replacing_standard_practice.html#application-event-loop :

"Usually applications can update at a less frequent interval. For example,
a game that is designed to run at 60Hz can use clock.schedule_interval:

def update(dt):
pass
clock.schedule_interval(update, 1/60.0)

This also removes the need for clock.set_fps_limit."

here is my patch:

--- test_main.py ( revision 105 )
+++ test_main.py (working copy)
@@ -502,6 +502,13 @@
self.world.SetContactListener(self.contactListener)
self.world.SetDebugDraw(self.debugDraw)

  • def on_close(self):

  •    """
    
  •    Callback: user tried to close the window
    
  •    """
    
  •    pyglet.clock.unschedule(self.SimulationLoop)
    
  •    super(Framework, self).on_close()
    

    def on_show(self):
    """
    Callback: the window was shown.
    @@ -627,7 +634,6 @@
    """
    if self.settings.hz > 0.0:
    pyglet.clock.schedule_interval(self.SimulationLoop, 1.0 /
    self.settings.hz)

  •        pyglet.clock.set_fps_limit(1.0 / self.settings.hz)
     pyglet.app.run()
    

    def SetTextLine(self, line):

Original issue: http://code.google.com/p/pybox2d/issues/detail?id=11

64-Bit Linux Support

From gnatty on June 15, 2009 15:12:47

Unable to compile extension on 64-bit Linux/Python

Is this a limitation of the original Box2D API, or a problem with the Box2D
interface assuming only 32-bit Python? What version of the product are you using? On what operating system? 2.0.2b1 Please provide any additional information below. Output From 'setup.py build'

/usr/tmp/Box2D/Box2D-2.0.2b1/ 62$ python setup.py build
Using setuptools.
running build
running build_py
copying ./init.py -> build/lib.linux-x86_64-2.5/Box2D
copying ./Box2D.py -> build/lib.linux-x86_64-2.5/Box2D
running build_ext
building 'Box2D.Box2D' extension
swigging Box2D/Box2D.i to Box2D/Box2D_wrap.cpp
swig -python -c++ -IBox2D -O -includeall -ignoremissing -w201 -outdir . -o
Box2D/Box2D_wrap.cpp Box2D/Box2D.i
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -O3 -Wall -Wstrict-prototypes
-fPIC -I/imd/tool/app/python/python_UC4-2.5.1/linux64/include/python2.5 -c
Box2D/Box2D_wrap.cpp -o build/temp.linux-x86_64-2.5/Box2D/Box2D_wrap.o -I.
cc1plus: warning: command line option "-Wstrict-prototypes" is valid for
Ada/C/ObjC but not for C++
Box2D/Box2D_wrap.cpp: In function ‘int32 b2Joint___hash
_(b2Joint_)’:
Box2D/Box2D_wrap.cpp:3520: error: cast from ‘b2Joint_’ to ‘int32’ loses
precision
Box2D/Box2D_wrap.cpp: In function ‘int32 b2Shape___hash__(b2Shape_)’:
Box2D/Box2D_wrap.cpp:4062: error: cast from ‘b2Shape_’ to ‘int32’ loses
precision
Box2D/Box2D_wrap.cpp: In function ‘int32 b2Controller___hash__(b2Controller_)’:
Box2D/Box2D_wrap.cpp:4348: error: cast from ‘b2Controller_’ to ‘int32’
loses precision
Box2D/Box2D_wrap.cpp: In function ‘int32 b2Body___hash__(b2Body_)’:
Box2D/Box2D_wrap.cpp:4418: error: cast from ‘b2Body_’ to ‘int32’ loses
precision
Box2D/Box2D_wrap.cpp: In function ‘PyObject*
wrap_b2Vec2_add_vector(PyObject, PyObject_)’:
Box2D/Box2D_wrap.cpp:5891: warning: format ‘%d’ expects type ‘int’, but
argument 3 has type ‘Py_ssize_t’
Box2D/Box2D_wrap.cpp: In function ‘PyObject*
wrap_b2Vec2_sub_vector(PyObject, PyObject_)’:
Box2D/Box2D_wrap.cpp:5942: warning: format ‘%d’ expects type ‘int’, but
argument 3 has type ‘Py_ssize_t’
Box2D/Box2D_wrap.cpp: In function ‘PyObject*
wrap_new_b2Vec2__SWIG_2(PyObject, int, PyObject_*)’:
....

Original issue: http://code.google.com/p/pybox2d/issues/detail?id=21

(2.1.0 svn) Tests fail with AssertionError on index

From mikkelin on February 01, 2010 14:51:00

What steps will reproduce the problem? 1. Run the tests. 2. 3. What is the expected output? What do you see instead? Expected output:

Passing tests.

Actual output:

test_body, test_kwargs, and test_world all fail with the following output:

AssertionError: 0 <= index && index < m_count What version of the product are you using? On what operating system? pyBox2D 2.1b0 (Subversion rev. 255), Python 2.6.1, Mac OS X 10.6.2 Please provide any additional information below.

Original issue: http://code.google.com/p/pybox2d/issues/detail?id=29

pybox2d 2.1 OS X issues

From reto.spoerri on October 11, 2010 06:06:09

hi, i've tried compiling the alpha version you uploaded under osx. however i seem to be missing some files that are required to compile it (or i am understanding something wrong). as i'd like to do some tests with the 2.1.x version of box2d it would be awesome if you could update the repository.

thanks

Original issue: http://code.google.com/p/pybox2d/issues/detail?id=33

How to pan/zoom the pygame backend?

From stodge on May 09, 2011 09:13:24

My test application uses cartesian coordinates from -5000,-5000 to 5000,5000. When objects are created I don't see them in the pygame window. This is using the default rendering backend in pybox2d. I was wondering if there is support in the rendering backend for zoom/pan so I can view the objects outside of the current viewport? Thanks

Original issue: http://code.google.com/p/pybox2d/issues/detail?id=41

segmentation fault in test_CollisionProcessing.py (from testbed)

From claudiu725 on May 01, 2010 13:17:15

What steps will reproduce the problem? 1. Start test_CollisionProcessing.py (obviously)
2. press space (so a small circle will be spawned)
3. collide the big circle with the newly spawned one (so the small circle
would get destroyed)
4. press space a second time, and you get a segmentation fault

I used the testbed that came out with pybox2d ver. 2.0.2b1

It doesn't seem like an important bug, but i feel it should be taken care of.

Original issue: http://code.google.com/p/pybox2d/issues/detail?id=31

64-bit build fails on 2.0.2b1 source release (zip or easy_install)

From comedaybreak on March 10, 2011 20:07:05

What steps will reproduce the problem? 1. try to install pybox2d with: easy_install box2d What is the expected output? What do you see instead? expected: builds and installs pybox2d
instead:
build failure. see attached log, but here is a suspicious excerpt:
Box2D/Box2D_wrap.cpp: In function ‘int32 b2Joint___hash__(b2Joint_)’:
Box2D/Box2D_wrap.cpp:3528: error: cast from ‘b2Joint_’ to ‘int32’ loses precision
Box2D/Box2D_wrap.cpp: In function ‘int32 b2Shape___hash__(b2Shape_)’:
Box2D/Box2D_wrap.cpp:4070: error: cast from ‘b2Shape_’ to ‘int32’ loses precision
Box2D/Box2D_wrap.cpp: In function ‘int32 b2Controller___hash__(b2Controller_)’:
Box2D/Box2D_wrap.cpp:4356: error: cast from ‘b2Controller_’ to ‘int32’ loses precision
Box2D/Box2D_wrap.cpp: In function ‘int32 b2Body___hash__(b2Body_)’:
Box2D/Box2D_wrap.cpp:4426: error: cast from ‘b2Body_’ to ‘int32’ loses precision What version of the product are you using? On what operating system? Box2D 2.0.2b1
Mac OS X 10.6.6 Please provide any additional information below.

Attachment: log.txt

Original issue: http://code.google.com/p/pybox2d/issues/detail?id=37

Fails to build due to missing encoding on setup.py

From lamego.pinto on March 29, 2011 16:02:24

What steps will reproduce the problem? 1. Trying to install the library from svn, using the Portugues locale
2. Dduring python setup.py install, the following error is shown:
SyntaxError: Non-ASCII character '\xc3' in file setup.py on line 20, but no encoding declared; see http://www.python.org/peps/pep-0263.html for details

What version of pybox2d are you using? On what operating system?
64-bit, Fedora Please provide any additional information below. Adding the # -- coding: utf-8 -- line to setup.py resolves the problem.

Original issue: http://code.google.com/p/pybox2d/issues/detail?id=38

Error building in OS X / SWIG syntax error

From TimWJones123 on June 21, 2011 22:12:35

Running 'python setup.py build' on my system, I receive the error:
~~
swigging Box2D/Box2D.i to Box2D/Box2D_wrap.cpp
swig -python -c++ -IBox2D -small -O -includeall -ignoremissing -w201 -globals b2Globals -outdir library/Box2D -keyword -w511 -D_SWIG_KWARGS -o Box2D/Box2D_wrap.cpp Box2D/Box2D.i
Box2D/Box2D_dir.i:49: Error: Syntax error in input(1).
error: command 'swig' failed with exit status 1
~~

I'm running the current SVN checkout on the most recent version of OSX.

This could be related to https://code.google.com/p/pybox2d/issues/detail?id=40

Original issue: http://code.google.com/p/pybox2d/issues/detail?id=42

Assertions -> Exceptions?

From sirkne on October 31, 2008 18:33:59

With a few changes to the source code and the SWIG interface, it's possible
to take Box2D's assertions and make them into Python exceptions. The
question is, however, if we really want to do that.

Exceptions will likely slow the code down (Erin Catto cited this as the
main reason for not using them), and perhaps won't really help in all
cases. After the return from the assert, you might be left with a world
that can't be used anymore. The C++ code wasn't designed with this in mind.

In any case, I turn to all of you, the users, to see what you'd like
implemented.

No patch for now, but here's the changes you'd need to make:

(b2Settings.h)

#include <Python.h>

class b2AssertException {};

#define b2Assert(A) if (!(A)) { PyErr_SetString(PyExc_AssertionError, #A);
throw b2AssertException(); }

(Box2D.i)

&#37;include "exception.i"
&#37;exception {
    try {
        $action
    } catch(b2AssertException) {
        // error already set, pass it on to python
    }
}

Original issue: http://code.google.com/p/pybox2d/issues/detail?id=14

Error on test_BoxCutter, trying to create an invalid shape (typo)

From santagada on October 25, 2008 21:28:14

Index: test_BoxCutter.py

--- test_BoxCutter.py ( revision 105 )
+++ test_BoxCutter.py (working copy)
@@ -178,7 +178,7 @@
# Make sure the shapes are valid before creation
try:
for n in range(2):

  •            box2d.b2PythonCheckPolygonDef(newPolygon[0])
    
  •            box2d.b2PythonCheckPolygonDef(newPolygon[n])
     except ValueError, s:
         print "Created bad shape:", s
         return False
    

ps: Should I attach the patch as a file or inline is ok?

Original issue: http://code.google.com/p/pybox2d/issues/detail?id=10

Error in pygame_main.py

From alexander.neberekutin on August 15, 2011 21:10:36

1.Don't work testbet
2. Error in pygame_main.py

pybox2d 2.0.2b2
Ubuntu 11.04 64X

In pygame_main.py, line 273.

Replace:

return ((pt[0] * self.viewZoom) - self.viewOffset.x, self.height - ((pt[1] * self.viewZoom) - self.viewOffset.y))

on

return (int((pt[0] * self.viewZoom) - self.viewOffset.x), int(self.height - ((pt[1] * self.viewZoom) - self.viewOffset.y)))

Attachment: pygame_main.py

Original issue: http://code.google.com/p/pybox2d/issues/detail?id=44

pybox2d and py2exe

From psnim2000 on January 19, 2010 17:54:23

What steps will reproduce the problem? 1. Attempt to build an executable with py2exe, have the program use
pybox2d. What is the expected output? What do you see instead? Error-
Traceback (most recent call last):
File "main.py", line 5, in
File "zipextimporter.pyo", line 82, in load_module
File "util.pyo", line 1, in
File "zipextimporter.pyo", line 82, in load_module
File "Box2D__init__.pyo", line 23, in
File "zipextimporter.pyo", line 82, in load_module
File "Box2D\Box2D.pyo", line 44, in
File "Box2D\Box2D.pyo", line 39, in swig_import_helper
ImportError: No module named _Box2D What version of the product are you using? On what operating system? 2.0.21b, with Python 2.6 (x86)

Original issue: http://code.google.com/p/pybox2d/issues/detail?id=28

Fails to build with error: missing binary operator before token "0"

From lamego.pinto on March 30, 2011 08:49:20

What steps will reproduce the problem? 1.python setup.py build on a Fedora 14 (64 bits system) What is the expected output? What do you see instead? Fails to build with the following error:
./Box2D/Collision/b2DynamicTree.h:289:26: error: missing binary operator before token "0" Please provide any additional information below. Edited ./Box2D/Collision/b2DynamicTree.h:289, replaced
#elif B2_USE_BRUTE_FORCE 0
with
#elif B2_USE_BRUTE_FORCE == 0

And it built successfully.

Original issue: http://code.google.com/p/pybox2d/issues/detail?id=39

OS X Universal Binaries

From sirkne on May 05, 2008 20:20:00

OS X Binaries need to be created.

For PPC-based Macs, apparently the current Source\Makefile works for
compiling the code, but the Python shared library needs some work.

For Intel-based Macs, the build-script I helped Andrew W. with should work,
though it is rather messy. I'd like to clean this up and have it build
universal binaries, or use the Makefile, whichever is easiest.

Original issue: http://code.google.com/p/pybox2d/issues/detail?id=2

Fix installation on x64-based Linux

From sirkne on June 18, 2008 01:14:55

According to the user the.trav:

"installing from the source package gave me an error when it got to the g++
stage

g++ -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions
build/temp.linux-x86_64-2.5/Box2D_wrap??.o -o Box2D2??.so
Gen/float/libbox2d.a /usr/bin/ld: Gen/float/libbox2d.a(b2Body.o):
relocation R_X86_64_32?? against `a local symbol' can not be used when
making a shared object; recompile with -fPIC Gen/float/libbox2d.a: could
not read symbols: Bad value collect2: ld returned 1 exit status error:
command 'g++' failed with exit status 1
"

Original issue: http://code.google.com/p/pybox2d/issues/detail?id=4

OSX: cannot import box2d after installation

From TimWJones123 on June 25, 2011 02:06:10

I'm using OSX10.6, with system python (2.6).

It appears as if I've been able to successfully compile pybox2d. The build/install process finished with the encouraging message:

Installed /Library/Python/2.6/site-packages/Box2D-2.0.2b2-py2.6-macosx-10.6-universal.egg
Processing dependencies for Box2D==2.0.2b2
Finished processing dependencies for Box2D==2.0.2b2

However -- when I try to "import Box2D2" from the python prompt, I'm told the module does not exist.

I can confirm that an egg file has been created in my Python's packages directory:
/Library/Python/2.6/site-packages/Box2D-2.0.2b2-py2.6-macosx-10.6-universal.egg

I'm not sure what's gone wrong here.

Original issue: http://code.google.com/p/pybox2d/issues/detail?id=43

installer fails to detect python on OS X 10.6.6

From comedaybreak on March 10, 2011 19:24:37

What steps will reproduce the problem? 1. download and run either of the pybox2d mac installers
2. click through to the drive selection page of the installer What is the expected output? What do you see instead? expected: click continue to install
instead: continue button is disabled. drive icon has a warning badge which when clicked explains that System Python 2.x cannot be found and thus installation cannot continue. What version of the product are you using? On what operating system? pybox2d 2.0.2b1 (py2.5 or py2.6)
Mac OSX 10.6.6 Please provide any additional information below.

Original issue: http://code.google.com/p/pybox2d/issues/detail?id=36

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.