import pygame
pygame.init()
screen = pygame.display.set_mode((400,400))
clock = pygame.time.Clock()
font = pygame.font.SysFont("Arial", 18)
def update_fps():
fps = str(int(clock.get_fps()))
fps_text = font.render(fps, 1, pygame.Color("coral"))
return fps_text
loop = 1
while loop:
screen.fill((0, 0, 0))
screen.blit(update_fps(), (10,0))
for event in pygame.event.get():
if event.type == pygame.QUIT:
loop = 0
clock.tick(60)
pygame.display.update()
pygame.quit()
FPS = 30 # frames per second setting
fpsClock = pygame.time.Clock()
while True: # the main game loop
#...
for event in pygame.event.get():
if event.type == QUIT:
pygame.quit()
sys.exit()
pygame.display.update()
fpsClock.tick(FPS)