Fixed too big images.
This commit is contained in:
parent
0c39f7abbc
commit
a8e25e4add
1 changed files with 11 additions and 5 deletions
|
@ -41,10 +41,16 @@ class Wobbler:
|
||||||
|
|
||||||
self.image_original = random.choice(images)
|
self.image_original = random.choice(images)
|
||||||
|
|
||||||
self.max_width, self.max_height = self.image_original.get_size()
|
self.divider = 1
|
||||||
|
|
||||||
self.width = self.max_width * self.size / 100
|
self.max_width, self.max_height = self.image_original.get_size()
|
||||||
self.height = self.max_height * self.size / 100
|
while self.max_width > max_wobbler_size * 2 or self.max_height > max_wobbler_size * 2:
|
||||||
|
self.divider += 0.01
|
||||||
|
self.max_width = self.image_original.get_width() / self.divider
|
||||||
|
self.max_height = self.image_original.get_height() / self.divider
|
||||||
|
|
||||||
|
self.width = self.max_width * self.size / 100 / self.divider
|
||||||
|
self.height = self.max_height * self.size / 100 / self.divider
|
||||||
|
|
||||||
self.image = self.image_original
|
self.image = self.image_original
|
||||||
self.image = pygame.transform.scale(self.image, (self.width, self.height))
|
self.image = pygame.transform.scale(self.image, (self.width, self.height))
|
||||||
|
@ -56,8 +62,8 @@ class Wobbler:
|
||||||
screen.blit(self.image, self.image_rect)
|
screen.blit(self.image, self.image_rect)
|
||||||
|
|
||||||
def update(self):
|
def update(self):
|
||||||
self.width = self.max_width * self.size / 100
|
self.width = self.max_width * self.size / 100 / self.divider
|
||||||
self.height = self.max_height * self.size / 100
|
self.height = self.max_height * self.size / 100 / self.divider
|
||||||
|
|
||||||
self.image = self.image_original
|
self.image = self.image_original
|
||||||
self.image = pygame.transform.scale(self.image, (self.width, self.height))
|
self.image = pygame.transform.scale(self.image, (self.width, self.height))
|
||||||
|
|
Loading…
Reference in a new issue