Reputation: 153
Every time I try to run the Pygame program, I get this error:
TypeError: Invalid foreground RGBA argument
Here is my code, do you have any idea why ?
text = font.render(b’Score:’ , dude.score, 1, (0, 0, 0))
Upvotes: 4
Views: 1616
Reputation: 210890
The first 3 parameters of pygame.font.Font.render
are position-only parameters. Positional-Only Parameters. The text, antialiasing and the color. Therefore, you can just pass a single string to the rendering function.
Use a formatted string literal
text = font.render(f'Score: {dude.score}', 1, (0, 0, 0))
or use the 'str()' function to convert the number to a string and concatenate the strings
text = font.render('Score: ' + str(dude.score), 1, (0, 0, 0))
Upvotes: 0