Skip to content Skip to sidebar Skip to footer

Can I Use The .format Feature When Using Screen.blit In Pygame?

Heys, I recently couldnt figure out how to blit lists onto my pygame screen using certain x and y values, allowing the text to blit say x += 20, moving every other string in my lis

Solution 1:

The format is an operator on the string, so it's no problem to use it with pygame.

For Example:

hp = 56
player_hp_text = "Hit Points: {:>3}".format( hp )

player_hp_bitmap = myfont.render( player_hp_text, 16, (255, 255,0) )
screen.blit( player_hp_bitmap, ( 10, 10 ) )

Post a Comment for "Can I Use The .format Feature When Using Screen.blit In Pygame?"