HipsterRules
HipsterRules

Reputation: 67

How to draw a charcter to screen on pygame

How do you draw an ascii character to the screen in pygame? All I have been able to find is how to draw a rectangle with: pygame.draw.rect(screen, color, (x,y,width,height), thickness).

I was wondering if there is a way to draw a character on the screen such as 'A' and have that appear on screen.

Thanks.

Upvotes: 0

Views: 1463

Answers (1)

user5653854
user5653854

Reputation:

I would do it like that:

font = pygame.font.Font(<Font>, 36)
text = font.render("<Char>", 1, (10, 10, 10))
textpos = text.get_rect()
<Surface>.blit(text, textpos)

EDIT: Note that the names between the greater/less signs are placeholders...

Upvotes: 4

Related Questions