Why does my game made with Pygame suddenly lag for a few seconds? [duplicate]
问题 This question already has an answer here : Lag when win.blit() background pygame (1 answer) Closed 4 months ago . I made a little space invaders game with pygame, I noticed that the game lags for a few seconds periodically. I do not know what the problem is. I am a beginner. Can you tell me why this happens? Is there any fix to this? Also, why does everything slow down once you add the background image in the main game loop? import pygame from pygame import mixer import random import math #