#๐Ÿ”’ Cant get pymunk-pygame code to work for a physics simulation due to the parameters of space.step

9 messages ยท Page 1 of 1 (latest)

bitter wigeon
#

error:

 line 26, in <module>
    space.step(1/FPS)
TypeError: Space.step() missing 1 required positional argument: 'dt'```
Code:
```py
import pygame as pg
from pygame.examples.moveit import WIDTH
from pygame.examples.moveit import HEIGHT
import pymunk.pygame_util

pymunk.pygame_util.positive_y_is_up =  False

RES = WIDTH, HEIGHT = 1200,1000
FPS = 60

pg.init()
surface = pg.display.set_mode(RES)
clock = pg.time.Clock()
draw_options = pymunk.pygame_util.DrawOptions(surface)

space = pymunk.Space
space.gravity = 0, 2000

while True:
    surface.fill(pg.Color('black'))

    for i in pg.event.get():
        if i.type == pg.QUIT:
            exit()

    space.step(1 / FPS) #heres the error
    space.debug_draw(draw_options)

    pg.display.flip()
    clock.tick(FPS)```
Returning programmer go easy on me ๐Ÿ˜…
verbal lanternBOT
#

@bitter wigeon

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

neon prism
#

just try providing the argument dt.

#

do you know how that function class or whatever works?

#

am pretty sure that i don't kno wwhat that thing is, but it can be helpful if you try reading the error message

bitter wigeon
# neon prism just try providing the argument dt.

Yes but in the documentation for pymunk I've seen the space.step used with one argument py import pymunk s = pymunk.Space() steps = 10 for x in range(steps): # move simulation forward 0.1 seconds: s.step(0.1 / steps)

bitter wigeon
verbal lanternBOT
#
Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.