0

I have an error on my Pygame Project here is the code

def text(window, text, loc, color, font_size):
    font = pygame.font.Font('Fonts/Sticky_koala-Regular.ttf', font_size)
    
    text = font.render(text, True, color)

    window.blit(text, loc)

    return (text)
text(window, "/" + numerictext(maxvariable), (variablebox[0][0] + variablebox[1], popuprect.top + 80), (255, 255, 255), 36)
Rabbid76
  • 202,892
  • 27
  • 131
  • 174

1 Answers1

1

As showed here, the error object is not subscriptable means that you're trying to use a pygame surface as a container. From what you've showed to us the only place there is this kind of instance is the moment you are calling the function:

text = drawText(
    window,                                                    #surface where to blit the string
    "/" + numerictext(maxvariable),                            #string to render
    (variablebox[0][0] + variablebox[1], popuprect.top + 80),  #tuple of int of the location of the text on the window
    (255, 255, 255),                                           #color of the rendered text
    36)                                                        # dimension of the text 

So, if the error shows up in the slice of code you shared, has to be in the loc, calling one of variablebox[0][0] or variablebox[1]

Scarlet
  • 106
  • 5