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

Re: [pygame] Center a display rect on screen



Mark Halegua wrote:
I want to center a rect on the screen. I know the formula for doing this based on the size of the rect and the screen resolution, but don't know how to specify where the rect starts on the screen.
I've looked at the documentation, but don't see how to do this.

this code is what I'm using to create the windows I want, and it works.

Anyone know how to specify the start position of the upper left corner, or any part? Or point me to the documentation where I can read it for myself?

screen = pygame.display.set_mode(...)
screen_rect = screen.get_rect()
...
spr.rect.center = screen_rect.center

Attachment: signature.asc
Description: OpenPGP digital signature