所以,我写了这段代码,它真的应该工作。主要问题是代码在打开窗口并运行时停止响应。
bif = "back.jpeg"
mif = "image2.png"
import pygame, sys
from pygame.locals import *
pygame.init()
screen = pygame.display.set_mode((640,360),0,32)
background = pygame.image.load(bif).convert()
mouse_c = pygame.image.load(mif).convert_alpha()
while True:
for event in pygame.event.get():
if event.type == QUIT:
pygame.quit
sys.exit()
screen.blit(background,(0,0))
x,y = pygame.mouse.get_pos()
x -= mouse_c.get_width()/2
y -= mouse_c.get_height()/2
screen.blit(mouse_c, (x,y))
pygame.display.update()
另外,我在 IDLE 中收到此错误。
Traceback (most recent call last):
File "C:\Users\Liam\Documents\game\Game", line 10, in <module>
background = pygame.image.load(bif).convert()
error: Couldn't open back.jpeg