user13362421
user13362421

Reputation:

Pygame 'pygame.Surface' object is not callable

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()
    '''

Upvotes: 1

Views: 104

Answers (1)

Tomfus
Tomfus

Reputation: 83

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

screen.blit(playerImg,(playerX, playerY))

Upvotes: 2

Related Questions