Questions tagged [pymunk]

Pymunk is a 2D physics library for Python built on top of Chipmunk.

Pymunk is a 2D rigid body physics library for Python based on the MIT licensed Chipmunk Project. It's home page is http://www.pymunk.org/en/latest/.

According to the home page, Pymunk is intended to be easy to use and "pythonic". Pymunk allows you to define and simulate the behaviour of objects with mass, position, velocity and collision properties (i.e. a shape) in a 2D space. It is frequently used for game development. Pymunk provides a large number of examples.

Further Information

176 questions
0
votes
0 answers

Pymunk draw lines on space which falls due to gravity(do physics)

I want to scrible on pymunk screen(pygame),which becomes a line like object and falls due to physics. I tried to make the code for most part, now i am able to get the vertices of points on screen, I want the line to be drawn on screen joining these…
Neptotech -vishnu
  • 1,096
  • 8
  • 23
0
votes
0 answers

how do I prevent a pymunk body centre becoming Nan after 2 frames?

I Tried to set up a simple ball that would fall using pymunk, but after two frames of running, the print statement outputs Vec2d(nan, nan), and the ball is no longer drawn to the screen. import pymunk import pygame screen =…
Bad
  • 1
  • 1
0
votes
1 answer

Pymunk : Rotate motor with limit joint continuously (go forward then backward)

How can I rotate a segment connected to another segment but limiting the angle of rotation. So, for example, if I have a static segment and another dynamic segment connected with a Pivot Joint and rotating around with a Simple Motor. The motor does…
amk
  • 1
0
votes
1 answer

Pygame handle collision

I want to check if a bullet has collided with my lines to keep the player from moving outside the screen. Here's my lines def create_lines(): """Prevent objects from moving out of the screen""" static_lines = [ …
Bart
  • 59
  • 5
0
votes
1 answer

Problem with pymunk while running in Visual Studio

I tried using the code so I can run a simulation of an object hitting on the ground but it just says draw_polygon ([Vec2d(55.0, -4779353554820.233), Vec2d(55.0, -4779353554810.233), Vec2d(45.0, -4779353554810.233), Vec2d(45.0, -4779353554820.233)],…
Malex
  • 1
0
votes
0 answers

How to implement gravity for a folding object (time dependent)?

I used Pygame to simulate an object that folds differently depending on time (two-dimensional, so you only see lines and joints). I would like to implement gravity so that this object "walks" on the ground. The joints are "infinitely" stiff. They do…
0
votes
1 answer

Defining a function in pymunk

I defined a function named add_spring in the following code import pymunk import pymunk.pygame_util import math pygame.init() wid, hei = 800, 700 window = pygame.display.set_mode((wid, hei)) def draw(space, window, draw_options): …
0
votes
1 answer

Static object with pymunk and pygame not working

I wrote a python game using pygame and pymunk, but the playground() section doesnt work. It supposed to show a static object, but it doesnt. I asked and it was supposed to interact with balls being dropped. heres the code: import pygame, sys import…
0
votes
1 answer

Pymunk: center_of_gravity doesn't change while simulating

import pymunk space = pymunk.Space() space.gravity = (0, -100) body = pymunk.Body(body_type=pymunk.Body.DYNAMIC) body.mass = 1 body.moment = pymunk.moment_for_box(body.mass, (100, 100)) shape = pymunk.Poly.create_box(body, (100, 100),…
Dooly
  • 1
  • 1
0
votes
1 answer

How to get contact forces in Pymunk?

I am having some trouble using Pymunk. Consider the following scenario, where a ball and a surface have been created and are touching: import pymunk # Create space space = pymunk.Space() space.gravity = (0, 900) # Create the surface surface_body =…
0
votes
1 answer

How to calculate Kinetic energy and potential energy of a Ball?

I want to calculate the Kinetic energy and potential energy of the ball I just Spawned inside a Pymunk space. I wanted to replicate this. Where the values change in real-time along with the graph. from what I saw in the documentation these are the…
TheFox
  • 79
  • 8
0
votes
1 answer

why is pymunk not letting me import it and saying "no module named "_cffi_backend""

i am making a hard version of atari breakout so when i import pymunk because I wanted to make the ball then it will say "no module named "_cffi_backend" i have asked people on Youtube and reddit but nobody answered the questions i have tried…
0
votes
0 answers

Visualize/Show Pymunk body shape

How do I visualize or show the shape of a pymunk body in pygame? This is what I have tried so far. import pygame, pymunk from pymunk.pygame_util import DrawOptions pygame.init() WIDTH, HEIGHT = 900, 500 win =…
0
votes
1 answer

How to add non-wrapped parts of chipmunk into pymunk/pygame code

I'm trying to code the solar system, but pymunk doesn't code for adding gravitational forces between bodies, whilst chipmunk does. One method I can use is trying to manually add it in. I attempted to follow what it said here:…
0
votes
1 answer

Python treating all instances of an object as the same

I'm making a game with pygame and pymunk as a physics engine. I'm trying to kill a bullet whenever it hits a player or goes past its lifetime. When I tried to space.remove(self.shape) and the second bullet hits the player, it gives me an…