My game mechanics involve a game map getting smaller and smaller, resulting in player images being scaled up to fit the screen. My problem is that my images start out at a size of 39x39, and when scaled up to 142x142 after 15 pygame.transform.scale commands, get a really junky resolution.
A perfectly fine 8-bit Mario image turns into this:
The following code was how I was able to retain some image resolution for some images, but the technique didn’t work for my OOP player objects.
grnd = pygame.image.load("grndsprite.png")#this image already exists, but loading it again resets resolution
grnd = pygame.transform.scale(grnd,(grndwth*((len(grid)+1)/len(grid)),grndht*((len(grid)+1)/len(grid))))#scale it to the ratio of how much the game map has changed
grndwth = grnd.get_rect().width#update the registered width of the image
grndht = grnd.get_rect().height#same for height
The link to my project is here:
What you could do is go into an image editor, scale up the image by, say 10 times, and then scale it down using pygame instead of having to scale it up. Scaling images can be weird in pygame and I’m not sure why they get handled like that, but scaling down usually works fine.
Thanks for the suggestion! I was able to figure out how to get the program to remember the past width/height of the image along with loading it again, so it has slightly better resolution now. I’m not sure if expanding the width/height of the image would take up more memory and resources, but that would definitely up the resolution of the image.
@arn5891 You could also convert your images into any vector image format supported by python, because vector images can retain their original quality no matter how often they are resized. You may need to install addition libraries to handle the vector files.
Ah, thanks. I’m doing the graphics in JS now, so they should have better resolution. How do I resolve a post if I’ve figured it out myself? I’m just gonna mark my comment as a solution.
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.