N
N
New_account2018-01-11 21:31:31
Python
New_account, 2018-01-11 21:31:31

How to avoid overlapping text on top of each other in pygame?

I am writing a game in pygame. Faced with the fact that you need to display the speed of the target in the status bar (the speed increases with hitting the target). Wrote like this:

pygame.font.init()
speed_font = pygame.font.Font('freesansbold.ttf', 24)
info_string.blit(speed_font.render(u"Скорость: "+ str(zet.speed), True, (0, 255, 0)), (10, 5))

It turns out here such kotovasiya:
5a57acbd8561c332243894.png
Help! How to avoid overlapping text on top of each other?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Daniil Basmanov, 2018-01-11
@New_account

I suspect you don't clear the screen before drawing, so you're left with the picture from the last frame when you update the speed value. You need to fill the entire screen with a solid color at the beginning of the drawing method, then nothing will overlap.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question