Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

add text to pygame window

import pygame, sys
from pygame.locals import *

pygame.init()
window = pygame.display.set_mode((600,400))
pygame.display.set_caption('Test')

fontSize = 40
font = pygame.font.SysFont('your font name', fontSize) #if you want to use the font you download use Font(), if not use SysFont()

def draw_text(text,x,y,color):
  label = font.render(text, True, color)
  
  window.blit(label, (x,y))

while True:
  window.fill((50,50,50)) #you can put any color here
  
  draw_text('your text',50,50,(255,255,255))
  
  for event in pygame.event.get():
	if event.type == QUIT:
      pygame.quit()
      sys.exit()
  
  pygame.display.update()
  
 
PREVIOUS NEXT
Tagged: #add #text #pygame #window
ADD COMMENT
Topic
Name
4+2 =