def update(self, screen, event_queue, dt,clock,joystick, netmodel, vizmodel):
# Logos/titles
screen.blit(self.logo,(screen.get_width() / 4 - 265,screen.get_height() * 3 / 4-500))
screen.blit(self.intel,(screen.get_width() / 4 - 300,screen.get_height()-130))
screen.blit(self.activestate,(screen.get_width() - 980,screen.get_height() - 130))
nextState = self
displaytext('Play', 32, screen.get_width() / 4 - 20, screen.get_height() * 3 / 4
- 80, WHITE, screen)
displaytext('Train', 32, screen.get_width() / 4 - 20, screen.get_height() * 3 / 4
- 40, WHITE, screen)
displaytext('Exit', 32, screen.get_width() / 4 - 20, screen.get_height() * 3 / 4,
WHITE, screen)
displaytext(u'\u00bb', 32, screen.get_width() / 4 - 60, screen.get_height() * 3 / 4
- 40*self.menu_selection, WHITE, screen)
# Each game state processes its own input queue in its own way to avoid messy input logic
for event in event_queue:
if event.type == pygame.KEYDOWN or event.type == pygame.JOYBUTTONDOWN:
if (event.type == pygame.KEYDOWN and (event.key == pygame.K_DOWN)) or (event.type == pygame.JOYBUTTONDOWN and (event.button == 1)) or (event.type == pygame.JOYAXISMOTION and (event.axis == 1 or event.value >= DEADZONE)):
self.menu_selection -= 1
if self.menu_selection == -1:
self.menu_selection = 2
if (event.type == pygame.KEYDOWN and (event.key == pygame.K_UP)) or (event.type == pygame.JOYBUTTONDOWN and (event.button == 0)) or (event.type == pygame.JOYAXISMOTION and (event.axis == 1 or event.value <= -DEADZONE)):
self.menu_selection += 1
if self.menu_selection == 3:
self.menu_selection = 0
if (event.type == pygame.KEYDOWN and event.key == pygame.K_RETURN) or (event.type == pygame.JOYBUTTONDOWN and event.button == 11):
if self.menu_selection == 2:
nextState = Play(False)
elif self.menu_selection == 1:
nextState = Play(True)
else:
nextState = None
if (event.type == pygame.KEYDOWN and event.key == pygame.K_x):
self.ExportModel()
if (event.type == pygame.KEYDOWN and event.key == pygame.K_d):
self.DumpData()
if (event.type == pygame.KEYDOWN and event.key == pygame.K_w):
self.DumpWeights()
return nextState
评论列表
文章目录