def receive(self, message, emitter=None, data=None): if message == TitleScene.Events.DONE: current_scene = MenuScene() current_scene.render() current_scene.loop() elif message == MenuScene.Events.CREATE_CHARACTER: current_scene = CreateFighterScene() current_scene.render() current_scene.loop() elif message == CreateFighterScene.Events.CREATE: Director.characters.append(data) elif message == CreateFighterScene.Events.DONE: current_scene = MenuScene() current_scene.render() current_scene.loop() elif message == MenuScene.Events.LIST_CHARACTER: self.characters = Fighter.all() current_scene = ShowCharactersScene(self.characters) current_scene.render() current_scene.show_fighters() elif message == MenuScene.Events.SELECT_CHARACTER: # TODO: print('PENDING: make select character scene') elif message == MenuScene.Events.REMOVE_CHARACTER: # TODO: print('PENDING: make remove character scene')
import pygame from config import * from menu_scene import MenuScene pygame.font.init() pygame.init() screen = pygame.display.set_mode(DISPLAY) pygame.display.set_caption(GAME_TITLE) clock = pygame.time.Clock() done = False active_scene = MenuScene() while not done: clock.tick(FPS) pressed_keys = pygame.key.get_pressed() filtered_events = [] for event in pygame.event.get(): if event.type == pygame.QUIT: done = True else: filtered_events.append(event) active_scene.process_input(filtered_events, pressed_keys) active_scene.update() active_scene.render(screen) active_scene = active_scene.next pygame.display.update()