python - how do I place the pygame screen in the middle? -


i made game using pygame includes init. in other ".py" file created init run main game. but, second init opened on [0,0] place of main init, , want move it. part marked in red frame @ photo, visual part second init.

i'm using python 2.7, thanks!!

i belive looking this: os.environ['sdl_video_centered'] = '1'. put line before call pygame.init(). line of code tries center window best can. if wan position window self, can use line: os.environ['sdl_video_window_pos'] = str(position[0]) + "," + str(position[1]) put x value in 0's place , y value in 1's place. more info pygame/sdl environment variables, see here: https://www.libsdl.org/release/sdl-1.2.15/docs/html/sdlenvvars.html.

~mr.python


Comments