0

I am making 2D Tank game and I have a problem with rotating my turret. Turret should rotate around its middle bottom but it rotates around the center.

def turret_rotate(self):
    turret_rot_image = pygame.transform.rotate(self.turret_image,self.turret_angle)
    turret_rot_rect = turret_rot_image.get_rect(center = self.turret_rect.midbottom)
    return turret_rot_image,turret_rot_rect

can anyone help me?

solved

Yeonje Kim
  • 41
  • 9
  • 1
    `pygame.transform.rotate()` always rotate around center point and `get_rect(center = self.turret_rect.midbottom)` can't change it. It only corrects center point after rotation. You need bigger surface with your image and with your midbottom in center of this surface. Or you have to calculate center point manually using trigonometry – furas Nov 19 '16 at 01:14
  • Thanks but I have already solved it^^ – Yeonje Kim Nov 19 '16 at 02:08
  • @furas can you help me with another question in pygame: ''pygame: I am trying to shoot a bullet from my Tank but I can't find the start point of the bullet'' – Yeonje Kim Nov 19 '16 at 02:10
  • can't you get tank position ? – furas Nov 19 '16 at 02:16
  • @furas yes i can't and i 've posted my question in stackoverflow – Yeonje Kim Nov 19 '16 at 02:19
  • @furas search "pygame: I am trying to shoot a bullet from my Tank but I can't find the start point of the bullet" in stackoverflow – Yeonje Kim Nov 19 '16 at 02:19

0 Answers0