ではありません、私はこのプログラムを実行しようとした、しかし、このエラーがアップします:私のプログラムではなく、黒の背景を使用しての私は、背景ERRORとして画像を使用しようとすると、実行されません。pygame.surface」オブジェクトが呼び出し可能
Traceback (most recent call last):
File "C:/Python/ComputingCW/ComputingCW.py", line 12, in <module>
Surface = pygame.image.load('Pygame_Background.jpg')((W, H), 0, 32)
TypeError: 'pygame.Surface' object is not callable
以前は: サーフェス= pygame.display.set_mode((W、H)、0、32)を使用し、 "Surface.fill(BLACK)"を使用して黒い背景を作成しました。
なぜ私は自分の背景として画像を使用できないのか理解できません。誰かが私を助けて、なぜこれが起こっているのか説明できますか?
import pygame, sys, time
from pygame.locals import *
pygame.init()
mainClock = pygame.time.Clock()
# all_fonts = pygame.font.get_fonts()
W = 1280
H = 900
Surface = pygame.image.load('Pygame_Background.jpg')((W, H), 0, 32)
pygame.display.set_caption('Physics in Motion')
BLACK = (0, 0, 0)
GREEN = (0, 255, 0)
WHITE = (255, 255, 255)
BLUE = (0, 0, 255)
RED = (255, 0, 0)
YELLOW = (255, 255, 0)
game = True
mouse_pos = (0, 0)
mouse_click = (0, 0)
text1B = False
text2B = False
text3B = False
output = ''
while game == True:
for event in pygame.event.get():
if event.type == QUIT:
pygame.quit()
sys.exit()
if event.type == KEYUP:
if event.key == K_ESCAPE:
pygame.quit()
sys.exit()
if event.type == MOUSEMOTION:
mouse_pos = event.pos
if event.type == MOUSEBUTTONUP:
mouse_click = event.pos
color = WHITE
Font = pygame.font.SysFont('arial', 72)
if text1B:
color = RED
text = Font.render('Start Simulation', True, color)
text_rect = text.get_rect()
text_rect.center = (W/2, H/5)
if text_rect.collidepoint(mouse_click):
output = 'Simulation()'
if text_rect.collidepoint(mouse_pos):
text1B = True
else:
text1B = False
Surface.blit(text, text_rect)
color = WHITE
if text2B:
color = RED
Font = pygame.font.SysFont('arial', 72)
text = Font.render('Graph Generator', True, color)
text_rect = text.get_rect()
text_rect.center = (W/2, H * 2/5)
if text_rect.collidepoint(mouse_click):
output = 'GraphG()'
if text_rect.collidepoint(mouse_pos):
text2B = True
else:
text2B = False
Surface.blit(text, text_rect)
color = WHITE
if text3B:
color = RED
Font = pygame.font.SysFont('arial', 72)
text = Font.render('Exit', True, color)
text_rect = text.get_rect()
text_rect.center = (W/2, H * 3/5)
if text_rect.collidepoint(mouse_click):
pygame.quit()
sys.exit()
if text_rect.collidepoint(mouse_pos):
text3B = True
else:
text3B = False
Surface.blit(text, text_rect)
Font = pygame.font.SysFont('arial', 72)
text = Font.render(output, True, BLUE)
text_rect = text.get_rect()
text_rect.center = (W/2, H * 4/5)
Surface.blit(text, text_rect)
pygame.display.flip()
mainClock.tick(100000)