Body speeding off ignoring scrolling ground

Viewed 15

I am currently trying to make a 2D car game with pybox2D
I have gotten to the stage where the ground needs to scroll with the car so it stays on screen.
I have this bit of code doing this currently:

ground.body.worldCenter[0] = SW/PPM - car.chassis.worldCenter[0] - (SW//2)/PPM

(SW/PPM - and - (SW//2)/PPM are just used to keep it in the middle of the screen and make sure it moves opposite of the car)
ground and car are instances of special classes I made to connect all parts of the bodies (different sections of ground for concave shapes, wheels, chassis, etc) into objects.
The problem is that the car just speeds off screen still, even though worldCenter should always keep track of the object so the car should always be in the center of the screen.
My car movement system is a simple joint motor system.

Does anyone know why this is happening?
More importantly, is this code efficient or is there a better way of tracking a body?

0 Answers
Related