Задать вопрос
@pk135

Почему Python выдает нулевой показатель?

Код:
import pygame  
pygame.init()  
screen = pygame.display.set_mode((1200, 600))  
pygame.display.set_caption("MyGame")  
icon = pygame.image.load("icon/icon.webp")
pygame.display.set_icon(icon)  # после чего запускаем

squar = pygame.Surface((100, 100))  
squar.fill("White")  

myfont = pygame.font.Font("font/manc.ttf", 10)
text_surface = myfont.render("itProger", False, "Red")

running = True
while running:
    
    screen.blit(squar, (600, 300))

    
    pygame.draw.circle(screen, "Red", (10, 7), 5)

    screen.blit(text_surface, (40, 50))
    pygame.display.update()

    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            running = False
            pygame.quit()


В 14 строке выдаёт нулевой показатель, не могу понять почему.

Ошибка:
line 14, in <module>
    text_surface = myfont.render("itProger", False, "Red")
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
pygame.error: Passed a NULL pointer
  • Вопрос задан
  • 203 просмотра
Подписаться 1 Простой 2 комментария
Помогут разобраться в теме Все курсы
  • Нетология
    Python-разработчик с нуля
    6 месяцев
    Далее
  • Skillfactory
    DevOps-инженер
    6 месяцев
    Далее
  • SF Education
    Бэкенд-разработчик на Python
    3 месяца
    Далее
Пригласить эксперта
Ответы на вопрос 1
@IsMakar
import pygame

pygame.init()
screen = pygame.display.set_mode((600,300))
pygame.display.set_caption("Ведьмак")
pygame.display.set_icon(pygame.image.load("images/icon.jpg"))

square = pygame.Surface((50,170))
square.fill("Blue")

myfont = pygame.font.Font("icon/Schol Waverly.zip", 40)
text_surface =myfont.render('icon/Schol Waverly.zip', False, (0, 0, 0), 0)

i = True
while i:

pygame.draw.circle(screen,"Red", (10,7), 5)
screen.blit(square, (10,0))
screen.blit(text_surface,(300,50))

pygame.display.update()

for event in pygame.event.get():
if event.type == pygame.QUIT:
i = False
pygame.quit()
Ответ написан
Комментировать
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Похожие вопросы