0

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


1
  • 1
    it should be char(x, y), not char_sprite(x, y). Additionally game_display is misspelled in the char() method. Commented Apr 22, 2016 at 0:10

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks you! i feel dumb now ._.

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.