0
import pygame
pygame.init()

#colors
black = (0,0,0)
white = (255,255,255)
#Screen Display
Width = 1000
Height = 500
gameDisplay = pygame.display.set_mode((Width, Height))
pygame.display.set_caption('Trock')
clock = pygame.time.Clock()
S_1= pygame.image.load('S1.png')

def car(x,y):
    gameDisplay.blit(S_1,(x,y))

x = (Width * 0)
y = (Height * 0.3)

crashed = False

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

            crashed = True
    gameDisplay.fill(white)
    S_1(x,y)

    pygame.display.update()
    clock.tick (60)

pygame.quit()
quit()

I am Trying to load and image onto the display screen (image is called S1 and variable is S_1) but it wont show and says

Pygame.Surface object is not callable.

Any assistance will be greatly appreciated

PRMoureu
  • 12,817
  • 6
  • 38
  • 48

1 Answers1

0

S_1 is a Surface object. Use blit to draw an image. Actually blit draws one Surface onto another. Hence you need to blit the image onto the Surface associated to the display.

gameDisplay = pygame.display.set_mode((Width, Height))

# [...]

S_1 = pygame.image.load('S1.png')

# [...]

while not crashed:
    # [...]

    gameDisplay.fill(white)

    gameDisplay.blit(S_1, (x, y))

    pygame.display.update()

    # [...]

See also How to Display Sprites in Pygame?

Rabbid76
  • 202,892
  • 27
  • 131
  • 174