# Скелет проекта import pygame # import random # import time WIDTH = 360 HEIGHT = 480 FPS = 30 # Define useful colors WHITE = (255, 255, 255) BLACK = (0, 0, 0) RED = (255, 0, 0) GREEN = (0, 255, 0) BLUE = (0, 0, 255) # Инициализация пайгейма и создание окна pygame.init() pygame.mixer.init() screen = pygame.display.set_mode((WIDTH, HEIGHT)) pygame.display.set_caption('Project 404') clock = pygame.time.Clock() # GAME LOOP running = True while running: clock.tick(FPS) for event in pygame.event.get(): # check for closing the window if event.type == pygame.QUIT: running = False # keep loop running at the right speed # Process inputs (events) # Update # Draw / Render screen.fill(WHITE) # After drawing everything flip display. pygame.display.flip() # pygame.quit() 

What is wrong in the code? On Windows, the same code consumes only 12% of the CPU.

  • And the truth is the load, a strange phenomenon - andreymal
  • Because control is not transferred to other processes or threads? Somewhere in the code you should have a sleep able code, but it apparently does not exist, so the task rarely switches when it has time to "slip" between critical sections. - 0andriy
  • Error in python, error in SDL, update, read the bugs on their bug trackers ... I would start with this. - 0andriy
  • @ 0andriy even if you replace clock.tick(FPS) with time.sleep(1) , it’s still eating percents, I tried it first - andreymal
  • 2
    @stackflow github.com/pygame/pygame/issues/331 , currently the bug is open. - Igor

0