pymunk
pymunk copied to clipboard
pypi page example throwing Python-CFFI error and not terminating
Summary
- Initial example code not breaking on
Ctrl + c
- Throwing
Python-CFFI error
![image](https://user-images.githubusercontent.com/4431953/210183897-28a4dda6-cc39-4134-b8b6-edf779fd3f5f.png)
- Keeps running and need to find and kill the Python process
Expectation
- Code should probably terminate on
Ctrl + c
and gracefully close.
Other considerations
- It would be great if the demo has visual output:
- there could be a tiny screenshot depicting the expected output
- maybe a very short description of what the user should expect to see on screen.
Note: I see the code comments and they don't say what I should see on-screen.
So, textual output maybe the only output?
Not sure, but as a user it would be nice to know what to expect before I run the code.
Also, it would be great if
- Ctrl+c worked to break the loop (just for this example) so the user could quickly kill it.
Code
import pymunk # Import pymunk..
space = pymunk.Space() # Create a Space which contain the simulation
space.gravity = 0, -981 # Set its gravity
body = pymunk.Body() # Create a Body
body.position = 50, 100 # Set the position of the body
poly = pymunk.Poly.create_box(body) # Create a box shape and attach to body
poly.mass = 10 # Set the mass on the shape
space.add(body, poly) # Add both body and shape to the simulation
print_options = pymunk.SpaceDebugDrawOptions() # For easy printing
while True: # Infinite loop simulation
space.step(0.02) # Step the simulation one step forward
space.debug_draw(print_options) # Print the state of the simulation