ifIf you remove the part bellow, maybe it can work. I do this in the javascriptJavaScript game and worked, try it:
if event.type == pygame.KEYUP: if event.key == pygame.K_LEFT: self.left_is_down = False if self.right_is_down: self.speed_x = self.velocity else: self.speed_x = 0 if event.key == pygame.K_RIGHT: self.right_is_down = False if self.left_is_down: self.speed_x = -self.velocity else: self.speed_x = 0 if event.key == pygame.K_UP: self.up_is_down = False if self.down_is_down: self.speed_y = self.velocity else: self.speed_y = 0 if event.key == pygame.K_DOWN: self.down_is_down = False if self.up_is_down: self.speed_y = -self.velocity else: self.speed_y = 0
if event.type == pygame.KEYUP:
if event.key == pygame.K_LEFT:
self.left_is_down = False
if self.right_is_down:
self.speed_x = self.velocity
else:
self.speed_x = 0
if event.key == pygame.K_RIGHT:
self.right_is_down = False
if self.left_is_down:
self.speed_x = -self.velocity
else:
self.speed_x = 0
if event.key == pygame.K_UP:
self.up_is_down = False
if self.down_is_down:
self.speed_y = self.velocity
else:
self.speed_y = 0
if event.key == pygame.K_DOWN:
self.down_is_down = False
if self.up_is_down:
self.speed_y = -self.velocity
else:
self.speed_y = 0