Python Pygame程序代码问题
我使用pygame用python编写了一个程序代码,我不知道为什么它不起作用。 我想让程序显示菜单,我可以使用“w”和“s”切换按钮。 但它不起作用。 有人能帮我吗?我什么都试过了Python Pygame程序代码问题,python,pygame,Python,Pygame,我使用pygame用python编写了一个程序代码,我不知道为什么它不起作用。 我想让程序显示菜单,我可以使用“w”和“s”切换按钮。 但它不起作用。 有人能帮我吗?我什么都试过了 import pygame pygame.init() WHITE = (255, 255, 255) BLACK = (0, 0, 0) BLUE = (0, 26, 219) w = 1280 h = 800 screen = pygame.display.set_mode((w,h),pygame.FUL
import pygame
pygame.init()
WHITE = (255, 255, 255)
BLACK = (0, 0, 0)
BLUE = (0, 26, 219)
w = 1280
h = 800
screen = pygame.display.set_mode((w,h),pygame.FULLSCREEN)
clock = pygame.time.Clock()
done = False
marked = 1
while not done:
start = pygame.font.Font(None, 100)
option = pygame.font.Font(None, 100)
help = pygame.font.Font(None, 100)
end = pygame.font.Font(None, 100)
for event in pygame.event.get():
if event.type == pygame.QUIT:
done = True
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_ESCAPE:
done = True
if event.key == pygame.K_w:
marked -= 1
elif event.key == pygame.K_a:
marked += 1
if(marked == 0):
marked = 1
start = pygame.font.Font(None, 125)
if(marked == 1):
start = pygame.font.Font(None, 125)
if(marked == 2):
option = pygame.font.Font(None, 125)
if(marked == 3):
help = pygame.font.Font(None, 125)
if(marked == 4):
end = pygame.font.Font(None, 125)
if(marked == 5):
marked = 4
end = pygame.font.Font(None, 125)
starttext = start.render("Start the Game",True,BLACK)
optiontext = option.render("Options",True,BLACK)
helptext = help.render("Help",True,BLACK)
endtext = end.render("End the Game",True,BLACK)
screen.fill(WHITE)
screen.blit(starttext, [400,200])
screen.blit(optiontext, [400,300])
screen.blit(helptext, [400,400])
screen.blit(endtext, [400,500])
pygame.display.flip()
clock.tick(30)
谢谢你的回答 既然你还没有对错误做出很好的描述,我就尽力帮你。我认为你的代码没有达到你的目的是因为你在寻找
kua
,而不是kus
。把它改一下就可以了:)只需注意:您正在检测a
和w
的按键,而不是s
和w
。您应该指定哪个区域不起作用,以及您希望代码做什么。还有,如果有任何错误,请告诉我们它们是什么。谢谢,就是这样,比尔D初学者的错误!注意:您正在重新创建所有字体对象,并重新渲染每一帧。@user3393830 Oops对不起:)注意:回答之前请阅读注释!