class Visualizer(QWidget): def __init__(self, json_dict, images_folder, window_width, window_height): super(Visualizer, self).__init__() self.threshold_selector = ThresholdSelector(show_delay=True) self.image_selector = ImageSelector( json_dict, images_folder, self.threshold_selector.get_current_threshold(), show_delay=True) self.viewer = Viewer(window_width, window_height) self.painter = Painter(json_dict, images_folder, self.image_selector.get_current_image_idx(), self.threshold_selector.get_current_threshold()) self.image_selector.imageChanged.connect(self.painter.new_image) self.threshold_selector.thresholdChanged.connect( self.image_selector.new_threshold) self.threshold_selector.thresholdChanged.connect( self.painter.new_threshold) self.painter.boxesDrawn.connect(self.viewer.set_scene) self.init_UI() self.painter.draw(reset_scale=True) def init_UI(self): vbox = QVBoxLayout() vbox.addWidget(self.image_selector) vbox.addWidget(self.viewer) hbox = QHBoxLayout() hbox.addLayout(vbox) hbox.addWidget(self.threshold_selector) self.setLayout(hbox)
def getShootContent(player): strike = EnergyStrike(pygame, gameDisplay, gameParams) shootContent = Content( strike, firstStage.getShootConduct((player.get_x() + 20, player.get_y() - 5)), 1) return [shootContent] while running: for event in pygame.event.get(): gameDisplay.fill(colour_white) if event.type == pygame.QUIT: running = False if event.type == pygame.KEYDOWN: player.update(event.type, event.key) if event.key == pygame.K_SPACE: contentManager.setContents(getShootContent(player)) if event.type == pygame.KEYUP: player.update(event.type, event.key) fon.draw(gameDisplay) player.changeCoord(player.x_c, player.y_c) player.display((player.get_x(), player.get_y())) painter.draw(time.time()) contentManager.analize() draw() contentManager.clearContent() pygame.display.flip() clock.tick(60) pygame.quit()