I used these 2 methods to write in the center
import pygame from pygame.locals import * pygame.init() pygame.font.init() SURF = pygame.display.set_mode((600, 400)) # font object.................................. def create_font(t,s=72,c=(255,255,0), b=False,i=False): font = pygame.font.SysFont("Arial", s, bold=b, italic=i) text = font.render(t, True, c) textRect = text.get_rect() return [text,textRect] # Text to be rendered with create_font game_over, gobox = create_font("GAME OVER") restart, rbox = create_font("Press Space to restart", 36, (9,0,180)) centerx, centery = SURF.get_width()
source share