1

I am trying make a game pygame library.But there is an error. I looked some forums but i can't anything. If can help me , i be happy.

File C:/Users/User/PycharmProjects/zaxd/main.py", line 34, in <module>
    screen.blit(playerImg(playerX, playerY))
TypeError: pygame.Surface object is not callable

''' import pygame

    # Initialize library
    pygame.init()
    # Variables
    running = True
    pd = pygame.display
    pi = pygame.image
    # Create Screen
    screen = pygame.display.set_mode((800, 600))
    # Caption and Icon
    pd.set_caption("Space Invaders")
    icon = pi.load('ufo.png')
    pd.set_icon(icon)
    # Player
    playerImg = pi.load('plane.png')
    playerX = 370
    playerY = 480


    def player():
        screen.blit(playerImg(playerX, playerY))


    # Game Loop
    while running:

        screen.fill((0, 0, 0))
        for event in pygame.event.get():
            if event == pygame.QUIT:
                running = False
        # Change BG Color (Black)
        player()
        pd.update()
    '''

1 Answer 1

2

You were missing a comma between playerImg and the (x,y) coordinates

screen.blit(playerImg,(playerX, playerY))
Sign up to request clarification or add additional context in comments.

1 Comment

Thank you very much.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.