I have this rectangle drawn using PyBox2D
Roger_Waters = Box_2_World.CreateStaticBody(position=(3, 3) ) Roger_Waters_Fixtures = Roger_Waters.CreateEdgeChain([(-10, -10), (-10, 10), (10, 10), (10, -10), (-10, -10)] )
And I use this function to draw it:
def my_draw_edge(edge, body, fixture): vertices = [body.transform * edge.vertex1 * PPM, body.transform * edge.vertex2 * PPM] pygame.draw.line(screen, colors[body.type], vertices, vertices) edgeShape.draw = my_draw_edge
And this loop to draw all bodies (edge, polygon and circle shapes)
for body in Box_2_World.bodies: for fixture in body.fixtures: fixture.shape.draw(body, fixture)
This for loop is nested into main PyGame loop
PPM means Pixels per meter and my problem is that when I either want to make the PyGame window fullscreen or change PPM using this for loop
for event in pygame.event.get(): if event.type == QUIT or (event.type == KEYDOWN and event.key == K_ESCAPE): # The user closed the window or pressed escape running = False # Zoom In/Out elif event.type == KEYDOWN and event.key == pygame.K_KP_PLUS: PPM += 5 elif event.type == KEYDOWN and event. key == pygame.K_KP_MINUS: PPM -= 5
Something weird happens, Circle and Polygon shapes are OK, but the edge shape drawing is moving even though it shouldn’t, and when any other dynamic body hits the edge (not the drawing but their physical location) it collides with the body (as expected)
How can I fix it, the problem would be in the my_draw_edge function
Thank you very much for any help
- Treadmill Weight Loss Workouts to Build a Leaner, Healthy and Fit Body
- How Does Mind-Body Healing Work?
- Body Type and Weight Loss - Does Your Body Type Make You Lose Weight Slower Than Other People?
- How Does You Body Language Determine Your Success In Home Business?
- What Does Your Body Language Say About You
- Stretching, it Really Does a Body Good
- Digestion - It Does A Body Good
- Massage Therapy Does Your Body Good
- Does Extra Body Weight Define Me
- Does Your Body Harbor Disgusting Parasites and 20 Lbs of Waste? You'd be Surprised!