diff --git a/screensaver.py b/screensaver.py index 9ce8ae1..acec146 100644 --- a/screensaver.py +++ b/screensaver.py @@ -28,8 +28,6 @@ running = True class Wobbler: def __init__(self, position: tuple=(100, 100), rotation: int=0): self.size = 1 - self.width = self.size - self.height = self.size self.x, self.y = position @@ -43,23 +41,28 @@ class Wobbler: self.image_original = random.choice(images) + self.max_width, self.max_height = self.image_original.get_size() + + self.width = self.max_width * self.size / 100 + self.height = self.max_height * self.size / 100 + self.image = self.image_original self.image = pygame.transform.scale(self.image, (self.width, self.height)) self.image_no_rot = self.image - #self.image = pygame.transform.rotate(self.image, self.rotation) + # self.image = pygame.transform.rotate(self.image, self.rotation) self.image_rect = self.image.get_rect(center=self.image_no_rot.get_rect(center=(self.x, self.y)).center) def draw(self): screen.blit(self.image, self.image_rect) def update(self): - self.width = self.size - self.height = self.size + self.width = self.max_width * self.size / 100 + self.height = self.max_height * self.size / 100 self.image = self.image_original self.image = pygame.transform.scale(self.image, (self.width, self.height)) self.image_no_rot = self.image - #self.image = pygame.transform.rotate(self.image, self.rotation) + # self.image = pygame.transform.rotate(self.image, self.rotation) self.image_rect = self.image.get_rect(center=self.image_no_rot.get_rect(center=(self.x, self.y)).center) def move(self):