def update_screen(ai_settings, screen: pyg.SurfaceType, stats, score_board, ship, aliens, bullets, play_button): """Update images on the screen and flip to the new screen""" screen.fill(ai_settings.bg_color) for bullet in bullets.sprites(): bullet.draw_bullet() ship.blitme() aliens.draw(screen) # Draw the Score information. score_board.show_score() # Draw the play button if the game is inactive. if not stats.game_active: play_button.draw_button() # Make the most recently drawn screen visible. pyg.display.flip()
def draw(self, surface: pygame.SurfaceType): surface.fill(BACKGROUND_COLOR) image = self.scaled_image.copy() for plant in self.environment.plants: radius = self.scale // 2 - 1 params = (image, *(plant.position * self.scale + radius), radius, plant.get_color()) gfxdraw.aacircle(*params) gfxdraw.filled_circle(*params) for corpse in self.environment.corpses: radius = self.scale // 2 - 1 params = (image, *(corpse.position * self.scale + radius), radius, corpse.get_color()) gfxdraw.aacircle(*params) gfxdraw.filled_circle(*params) for creature in self.environment.creatures: radius = int(self.scale / 2 * creature.get_size()) radius = radius if creature.get_size() < 1 else radius - 1 params = (image, *(creature.position * self.scale + radius), radius, creature.get_color()) gfxdraw.aacircle(*params) gfxdraw.filled_circle(*params) surface.blit(image, -np.array(self.rect.center) + self.position)