python library pygame: centering text -
i have code:
# draw text font = pygame.font.font(none, 25) text = font.render("you win!", true, black) screen.blit(text, [screen_width / 2, screen_height / 2])
how can text width , height methods in java, can center text like:
screen.blit(text, [screen_width / 2 - text_w / 2, screen_height / 2 - text_h / 2])
if not possible, way ? i've found this example, didn't understand it.
you can dimensions of rendered text image using text.get_rect()
, returns rect object width
, height
attributes, among others (see linked documentation full list). i.e. can text.get_rect().width
.
Comments
Post a Comment