-
Notifications
You must be signed in to change notification settings - Fork 156
Description
If anyone has a problem with pygame printing, whether it looks big, small, too zoomed in, etc.
I left the solution with a contribution from another issue that I saw but a little more generalized.
You can do something like this to see in what resolution pygame is seen when it generates frames in fullscreen:
import pygame
pygame.init()
# Create screen in fullscreen mode
screen = pygame.display.set_mode((0, 0), pygame.FULLSCREEN)
# Get screen dimensions
screen_width, screen_height = screen.get_size()
print(f"Screen size is: {screen_width} x {screen_height}")
pygame.quit()
And when you have the screen resolution, look for the conversion factor:
For example: 1920 * 1080 to 1600 * 900
1600/1920= 0.83333
And the parameters that are affected by this are the following, all rescaled to this number (0.83):
CAR_SIZE_X
CAR_SIZE_Y
self.position
text_rect.center (of both texts, this parameter is 2 times because there are 2 objects text)
So the new scaled values are given by:
scaled_values = old_values * conversion_ratio
So, we have for example:
Before (Resolution 1920 * 1080)
CAR_SIZE_X = 60
self.position = [830, 920]
After (Resolution 1600*900)
CAR_SIZE_X = (60 * 0.83) = 50
self.position = [( 830 * 0.83 ) , ( 920 * 0.83)] = [691, 766]
And so on with the rest of the parameters...
The text (text_rect.center ) should not cause you problems and it is easier to reposition where you want but the other parameters are important.
I hope it helps 😄