我正在用 python 和 pygame 编写游戏,我试图创建一个主菜单,但我的标签不会显示????我也收到这个错误:第 22 行,在 x,y = pygame.mouse.get_pos( ) 错误:视频系统未初始化???我不明白这里发生了什么,因为我对 python 很陌生,这是我的代码:
bif="menubg.jpg"
load_check_x = "null"
load_check_y = "null"
import pygame, sys
from pygame.locals import *
x = 0
y = 0
pygame.init()
screen=pygame.display.set_mode((640,360),0,32)
background=pygame.image.load(bif).convert()
pygame.display.set_caption("Some random Title")
pygame.display.flip()
#screen.fill((0,0,0))
while True:
evc = pygame.event.get()
for event in evc:
if event.type == pygame.QUIT:
pygame.quit()
x,y = pygame.mouse.get_pos()
#Setup mouse pos!!!
if x >= 340 and x <= 465:
load_check_x = "True"
if x < 340 or x > 465:
load_check_x = "False"
if y >= 425 and y <= 445:
load_check_y = "True"
if y < 425 or y > 445:
load_check_y = "False"
if load_check_x == "True" and load_check_y == "True":
for event in evc:
if event.type ==pygame.MOUSEBUTTONUP:
clear()
labelfont = pygame.font.SysFont("Comic Sans MS", 12)
new_text = labelfont.render('Play!!!!', 1, (255, 255, 255))
screen.blit(new_text, (340, 425))
谁来帮帮我!!!