0

i keep trying to add text to my project but it keeps giving me errors. here is the error

skip past this next part it wanted more details for me to post this simple question 'oi;ashfluighsdflkjguasdlghufaulgdlgaul

pygame 2.1.2 (SDL 2.0.14, Python 3.9.2) Hello from the pygame community. https://www.pygame.org/contribute.html /home/owen/Desktop/Tycoon_Game/Main_Code.py:3: RuntimeWarning: use font: libSDL2_ttf-2.0.so.0: cannot open shared object file: No such file or directory (ImportError: libSDL2_ttf-2.0.so.0: cannot open shared object file: No such file or directory) pygame.font.init() Traceback (most recent call last): File "/home/owen/Desktop/Tycoon_Game/Main_Code.py", line 3, in <module> pygame.font.init() File "/home/owen/.local/lib/python3.9/site-packages/pygame/__init__.py", line 59, in __getattr__ raise NotImplementedError(missing_msg) NotImplementedError: font module not available (ImportError: libSDL2_ttf-2.0.so.0: cannot open shared object file: No such file or directory)

and here is my code:

import pygame, math, sys
pygame.init()
pygame.font.init()
font_path = "/home/owen/Desktop/Tycoon_Game/Font/Pixle_Font.ttf"
font_size = 32
fontObj = pygame.font.Font(font_path, font_size)


SCREEN_WIDTH = 750
SCREEN_HEIGHT = 500\

screen = pygame.display.set_mode((SCREEN_WIDTH, SCREEN_HEIGHT))
SCREEN_COLOR = (250, 200, 100)
Black = (0, 0, 0)
White = (250, 250, 250)

Money = 0



PlayerX = 1
PlayerY = 20
    
Start = True
FPS = pygame.time.Clock()
run = True
while run:
        FPS.tick(100000)
        if PlayerX > 100:
                PlayerX = 1
                Money = Money + 1
                
        if Start == True:            
            screen.fill((SCREEN_COLOR))
            PlayerX = PlayerX + .1
            pygame.draw.rect(screen, Black ,(200,200,PlayerX,PlayerY))
            if PlayerX > 100:
                PlayerX = 1
                

            
        

        pygame.display.update()
        
        
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                run = False
          

    
pygame.quit()

  • From answers to [this question](https://stackoverflow.com/questions/31716754/pygame-importerror-libsdl-ttf-2-0-so-0-cannot-open-shared-object-file-no-suc) you might need to install an appropriate version of `libsdl-ttf2`. – import random Jul 12 '22 at 05:31
  • 2
    If stackoverflow says that you should add more details, you should do so and __not__ just type random characters. You could, for example, explain what your code does and how it works. – The_spider Jul 15 '22 at 13:18

0 Answers0