Pygame - Align screen in the center

Asked

Viewed 787 times

0

People you have knowledge of how to align the screen of my game in the center of the desktop screen?

  • 1

    Do you have the code that generates your window? It is easier to receive answers.

  • 1

    You have to put more information in your question. How to know what to line up without seeing the code? Placing images also helps.

1 answer

3


SDL, engine that the Pygame is based, uses the environment variable SDL_VIDEO_CENTERED to indicate that the window must be centered. The variable must be declared before the Pygame be initiated by the function init().

import pygame
import os 
os.environ['SDL_VIDEO_CENTERED'] = '1'
pygame.init()

Browser other questions tagged

You are not signed in. Login or sign up in order to post.