简体   繁体   中英

I keep getting the "TypeError: 'pygame.Surface' object is not callable" error every time I try to run this project

import pygame,sys

pygame.init()
screen = pygame.display.set_mode((1366, 720))
clock = pygame.time.Clock()
test_surface = pygame.Surface((100,200))
test_surface.fill(pygame.Color(0, 0, 255))
x_pos = 200


while True:
   for event in pygame.event.get():
       if event.type == pygame.QUIT:
         pygame.quit()
         sys.exit()
screen.fill((175,201,70))
x_pos += 1
screen.blit(test_surface(x_pos,500))
pygame.display.update()
clock.tick(60)

This is the code. I cannot find any way to fix this problem. Any help on this would be appreciated.

import pygame,sys
if __name__ == "__main__":
    pygame.init()
    screen = pygame.display.set_mode((1366, 720))
    clock = pygame.time.Clock()
    test_surface = pygame.Surface((100,200))
    test_surface.fill(pygame.Color(0, 0, 255))
    x_pos = 200
    screen.fill((175,201,70))
    x_pos += 1
    screen.blit(test_surface, (x_pos,500))
    pygame.display.update()
    clock.tick(60)

    while True:
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                pygame.quit()
                sys.exit()

you can use this code
error was in screen.blit, first argument is surface, and second argument is coords

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM