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

Reply via email to