I have this function, where player can type his name, but I want each letter to appear on the screen as he types them. Here is my function :
def input_player_name():
player_name_screen = True
name = ""
win.blit(player_name_bg, (0, 0))
while player_name_screen:
for event in pygame.event.get():
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_RETURN:
print(name)
player_name_screen = False
else:
name += event.unicode
pygame.display.update()
clock.tick(fps)
If I write print(name)
right after name+=event.unicode
, each thing typed appears in the console. Do I have to use something like this
textsurface = game_font.render(str(name), False, (255, 255, 255))
win.blit(textsurface, (0, 0))
and make it update each time something new goes into name
?
Thanks for your help