Saltar al contenido

mostrar texto grande en la pantalla en el ejemplo de código de Python

Ejemplo 1: Python cómo escribir texto en Pygame

import pygame
pygame.init()
window = pygame.display.set_mode((500, 500)) 

def set_text(string, coordx, coordy, fontSize): #Function to set text

    font = pygame.font.Font('freesansbold.ttf', fontSize) 
    #(0, 0, 0) is black, to make black text
    text = font.render(string, True, (0, 0, 0)) 
    textRect = text.get_rect()
    textRect.center = (coordx, coordy) 
    return (text, textRect)

window.fill((255, 255, 255)) #Fills the whole window with white
#Places "Text in Pygame!" with an x,y coord of 250, 250 and 60 font size
totalText = set_text("Text in Pygame!", 250, 250, 60)
window.blit(totalText[0], totalText[1])
pygame.display.update()

Ejemplo 2: como renderizar texto en pygame

pygame.font.init() # you have to call this at the start, 
                   # if you want to use this module.
myfont = pygame.font.SysFont('Comic Sans MS', 30)

textsurface = myfont.render('Some Text', False, (0, 0, 0))

screen.blit(textsurface,(0,0))
¡Haz clic para puntuar esta entrada!
(Votos: 0 Promedio: 0)



Utiliza Nuestro Buscador

Deja una respuesta

Tu dirección de correo electrónico no será publicada. Los campos obligatorios están marcados con *