我正在制作一个游戏,并且在标题屏幕上,当我在坐标 278,365 处悬停时按返回键时,我希望它能够显示新背景(background1)。如何做到这一点,以便当我在这些坐标处按 Enter 键时,它会删除当前背景并用新的 background1 替换它?
screen=pygame.display.set_mode((1024,768),0,32)
background=pygame.image.load(bif).convert()
background1=pygame.image.load(wi1).convert()
cursor=pygame.image.load(mif).convert_alpha()
x,y =278,365
while True:
for event in pygame.event.get():
if event.type == QUIT:
pygame.quit()
sys.exit()
if event.type == KEYDOWN:
if event.key == K_DOWN:
x=420
y=508
elif event.key == K_UP:
x=278
y=365
elif event.key == K_RETURN and x==420 and y==508:
pygame.quit()
sys.exit()
elif event.key == K_RETURN and x==278 and y==365:
screen.blit(background, (0,0))
screen.blit(cursor, (x,y))
pygame.display.update()