[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] Center a display rect on screen



To center the window do...
os.environ['SDL_VIDEO_CENTERED'] = '1'
...before pygame.init()

To center a rectangle inside the window, the top left is...
x = (ScreenWidth/2) - (RectWidth/2)
y = (ScreenHeight/2) - (RectHeight/2)
TopLeftOfRect = (x,y)

HTH,
Ian