[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] car game mechanics



Yeah indeed it works for the rotation but the movement are not realist at all the way i did. I found this on the internet :

http://engineeringdotnet.blogspot.com/2010/04/simple-2d-car-physics-in-games.html

it's illustrated by C++ example so i would like to know if there is an equivalent class to the Vector2 C++ class? Or maybe can i just a numpy array instead?

2011/8/30 Joe Ranalli <jranalli@xxxxxxxxx>
You already have self.angle.  Why not just do your transform as a function of that?

a_deg = self.angle % 360

sprite = pygame.transform.rotate(self.original, a_deg * -1)

On Tue, Aug 30, 2011 at 7:21 AM, Nathan BIAGINI <nathan.open@xxxxxxxxx> wrote:
Doing something like :

a_rad = math.atan2(speedy, speedx)

?

I can turn 360 degrees yeah but it does not make proper rotation... i ll try to find something on the internet about 2d car physics.


2011/8/30 Weeble <clockworksaint@xxxxxxxxx>


On Aug 30, 2011 10:46 AM, "Nathan BIAGINI" <nathan.open@xxxxxxxxx> wrote:

>> a_rad = math.asin(speedx/SPEED)

Try math.atan2, feeding it both the x and y components of the velocity.