I've got a little problem that I can't seem to solve. I can't find it on stackoverflow yet.
It's about rotating an image. I've got two 'gamepieces' in the example here, where I can show the problem. If I click on one line, it rotates 90 degrees. But after it rotated 180 degrees (which is precise, because I made sure it ends on exactly 90, 180, 270 etc degrees) the images don't connect well anymore. if I rotate it another 180 degrees, then it's fine again..
Screen 2, here you see the two lines don't connect well.
I tried changing the resolution to different pixel sizes (64, 64) and (81, 81) for example. But this does not cure the problem.
And here is part of the code:
class Piece:
def __init__(self, piece, x, y):
self.image = pygame.image.load(piece)
self.rotated_image = self.image
self.rect = self.rotated_image.get_rect()
self.rect.center = x, y
self.current_degrees = 0
self.degrees = 0
self.values = [0, 1, 0, 1]
def rotate_piece(self):
self.rotated_image = pygame.transform.rotozoom(self.image, lerp(self.current_degrees, self.degrees, 0.3), 1)
self.rect = self.rotated_image.get_rect(center=self.rect.center)
self.current_degrees = lerp(self.current_degrees, self.degrees, 0.3)
def rotate_values(self):
temp = self.values[0]
for i in range(len(self.values) - 1):
self.values[i] = self.values[i+1]
self.values[3] = temp
print(self.values)
pieces = []
piece1 = Piece(images['line'], 32, 32)
piece2 = Piece(images['line'], 96, 32)
pieces.append(piece1)
pieces.append(piece2)