Oct-06-2022, 08:14 AM
First. You only want one main loop. Have it waiting as loop is not good. Look at fourth tip.
Second. Pygame has many predefine colors. Just use strings. "white", "black"
Fourth. Pygame.clock should not be use to limit your update. They will vary. It best to match monitor refresh rate. Use pygame.time.get_ticks() or a pygame.time.set_timer to control update speed.
Fifth. You do not want to keep render text in main loop. Render it and save the surface that returns. You just using more cpu then what you need. Render text uses a lot of cpu.
Second. Pygame has many predefine colors. Just use strings. "white", "black"
import pygame for color in list(pygame.color.THECOLORS): print(color)Third. Update the code. No need keeping the old ways. Computer don't work like that any more. Use some classes and sprites.
Fourth. Pygame.clock should not be use to limit your update. They will vary. It best to match monitor refresh rate. Use pygame.time.get_ticks() or a pygame.time.set_timer to control update speed.
Fifth. You do not want to keep render text in main loop. Render it and save the surface that returns. You just using more cpu then what you need. Render text uses a lot of cpu.
99 percent of computer problems exists between chair and keyboard.