def start(self):
"""
Starts up the game menu, allowing the user to navigate through it.
"""
logging.info("Starting main loop for start menu")
self.currentMenu.draw()
while not self.exit:
for event in pygame.event.get():
if event.type == pygame.QUIT:
self.exit = True
elif event.type == pygame.KEYDOWN:
if event.key not in [pygame.K_RETURN, pygame.K_SPACE]:
if event.key in [pygame.K_DOWN, pygame.K_s]:
self.showMouse = False
self.updateMouseVisibility()
if self.currentItem < len(self.currentMenu.items) - 1:
self.currentMenu.items[self.currentItem].hovered = False
self.currentItem += 1
self.currentMenu.items[self.currentItem].hovered = True
elif event.key in [pygame.K_UP, pygame.K_w]:
self.showMouse = False
self.updateMouseVisibility()
if self.currentItem > 0:
self.currentMenu.items[self.currentItem].hovered = False
self.currentItem -= 1
self.currentMenu.items[self.currentItem].hovered = True
else:
self.currentMenu.items[self.currentItem].hovered = False
self.showMouse = True
self.updateMouseVisibility()
self.currentMenu.items[self.currentItem].clicked()
self.currentItem = 0
elif self.showMouse:
for item in self.currentMenu.items:
# hover state will always be checked
if item.checkHovered() and event.type == pygame.MOUSEBUTTONDOWN:
item.clicked()
break
self.currentMenu.draw()
pygame.display.flip()
self.clock.tick(self.fps)
logging.info("Ending main loop of start menu")
评论列表
文章目录