pygame get screen width and height 1

pygame get screen width and height

w, h = pygame.display.get_surface().get_size()

#w = width
#h = height

Here is what the above code is Doing:
1. We import the pygame module.
2. We initialize pygame.
3. We create a display surface object named screen (which is the same as a window).
4. We set the width and height of the screen to 600 and 400 respectively.
5. We set the program caption to My Game.
6. We initialize the clock.
7. We create a while loop.
8. We fill the screen with a color.
9. We update the display.
10. We tick the clock.

Similar Posts