0swald
0swald

Reputation: 23

Pygame. TypeError: 'pygame.Surface' object is not callable

I am new to Python, Pygame, and just coding in general.

I do not know why my code is getting:

"TypeError: 'pygame.Surface' object is not callable"

and a black screen.

Here is my code:


import pygame
pTypeError: 'pygame.Surface' object is not callableygame.init

black = (0,0,0)
white = (255,255,255)
red = (255,0,0)
green = (0,255,0)
blue = (0,0,255)

char_sprite = pygame.image.load("man.png")

display_height = 800
display_width = 1000
dead = False
framerate = 60

game_display = pygame.display.set_mode((display_width,display_height))
pygame.display.set_caption("Tiny Fighter")
clock = pygame.time.Clock()


def char(x,y):
    game_dispaly.blit(char_sprite,(x,y))

x= display_width / 2
y= display_height / 2

while not dead:
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            dead = True

    game_display.fill(green)

    char_sprite(x,y)
    pygame.display.update()
    clock.tick(framerate)

pygame.QUIT()
quit()

Full Traceback:


Traceback (most recent call last): File "/home/hayden/Desktop/Tiny fighter/Tiny Fighter.py", line 35, in char_sprite(x,y) TypeError: 'pygame.Surface' object is not callable


Upvotes: 0

Views: 1179

Answers (1)

ButteredQwaffles
ButteredQwaffles

Reputation: 196

You have a typo. You spelled display wrong. Also, you misspelled the method name; should be char(x, y) not char_sprite(x, y).

Upvotes: 1

Related Questions