0

I almost created own game, and I have to fix shortcomings, however, my program shows me error linked with font. Game is working normal without bugs, font initialized. What's wrong? Probably, error linked with cycles of game. I don't know.

pygame.font.init()
class Button(pygame.sprite.Sprite):
    def __init__(self, width, height):
       #[...]
    def draw(self, x, y, message, action = None):
        mouse = pygame.mouse.get_pos()
        click = pygame.mouse.get_pressed()
        if x < mouse[0] < x + self.width and y < mouse[1] < y + self.height:
             pygame.draw.rect(screen, self.active_color, (x, y, self.width, self.height))
             #[...]
        else:
            pygame.draw.rect(screen, self.inactive_color, (x, y, self.width, self.height))
        print_text_4(message, x + 10, y + 10)
def print_text(message, x, y, font_color = (0,0,0), font_type = 'ExcellentdisplayfontBold.ttf', font_size = 50):
    font_type = pygame.font.Font(font_type, font_size)
    text = font_type.render(message, True, font_color)
    screen.blit(text, (x,y))
def game_over():
    Game_over = True
    while Game_over:
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                pygame.quit()
#[...]
def victory():
    Victory = True
    while Victory:
        clock.tick(FPS)
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                pygame.quit()            
#[...]       
def pause():
    Pause = True
    while Pause:
        clock.tick(FPS)
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                pygame.quit()
#[...]        
def game():
    global health 
    Game = True
    while Game:
        clock.tick(FPS)
        for event in pygame.event.get(): 
            #[...]
            if event.type == pygame.QUIT:
                beginning = False
        #[...]
        if player.score >= 10:
            victory()
        if health <= 0:
            game_over()
           #[...]
def beginning():
    Beginning = True
    while Beginning:
        clock.tick(FPS)
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                pygame.quit()

Classes Button2 and print_text(2,3,4,5) similar Error:print_text_5 font_type = pygame.font.Font(font_type, font_size) pygame.error: font not initialized

Vildan
  • 131
  • 6
  • 1
    "Error linked with font" is not going to help. What is the actual error message, including the full traceback? – kindall Dec 14 '21 at 18:03
  • My game works normal, but program also shows this error. I don't even know how to say. I added error of code – Vildan Dec 14 '21 at 18:23

0 Answers0