0

i am trying to make a score in the top left corner of my screen but it is returning an error.

i have searched it up online and followed the exact steps but still it returns an error.

def score(rounds):
    font = pygame.font.SysFont(None, 25)
    text = font.render(f'ROUND {rounds}', True, size=25)
    game_display.blit(text, (0,0))

render() takes no keyword arguments i have tried putting the True in as False but that didn't work. btw what does the middle argument True do?

BOBTHEBUILDER
  • 318
  • 1
  • 3
  • 16

1 Answers1

2

When you see the following error:

render() takes no keyword arguments

it means, well, that the render function does not take keyword arguments.

Look at your code:

text = font.render(f'ROUND {rounds}', True, size=25)

You call render with a keyword argument.

Just don't do it. Don't use a keyword argument. It's as simple as that.

Also, the third parameter has to be a color-like object, so your code should look like this:

text = font.render(f'ROUND {rounds}', True, pygame.Color('orange'))

Some more notes:

  • render takes an optional 4th argument (a background color). The documentation of pygame wrongly shows it as keyword argument.

  • it's better to load your fonts once. Currently, you load the font everytime you call the score function

  • instead of the font module, consider using the freetype module, which can to everything the font module can, and much more

sloth
  • 95,484
  • 19
  • 164
  • 210