` def move(self):
self.rect.center = (self.rect.center[0] + self.speed * math.cos(math.radians(self.direction)),
self.rect.center[1] + self.speed * math.sin(math.radians(self.direction)))
self.image = pygame.transform.rotate(self.orig_image, -self.direction)
if abs(self.speed) > 0: #Friction
self.speed /= 1.001
def accelerate(self):
self.speed += 0.04
def brake(self):
self.speed -= 0.04
def turn_left(self):
angle = 1
self.direction -= angle
print("direction =", self.direction % 360)
def turn_right(self):
angle = 1
self.direction += angle `
print("direction =", self.direction % 360)
The problem that I am experiencing is the car will move in a direction by itself when I am not pressing any keys, and this will happen at certain directions that I am facing. For example, when I am at direction = 91-93, the car is faced down and slightly to the left and not moving at all, but it starts moving left by itself with no friction taking place for some odd reason. The only way to make it stop moving left is to go back to direction = 90, which is directly facing down, and the car is still. (Keep in mind this only happens once I start accelerating than I come to a complete stop.)