0

I'm trying to change the color of my program by pressing some specific keys. Below is some pieces of my code. I tried the following but it doesn't seem to work.

color = (0,0,255)
chars = []

for char in characters:
    item = font.render(char, True, (color))
    chars.append(item)


gray = (127, 127, 127)
white = (255, 255, 255)

for event in pygame.event.get():
        if event.type == pygame.QUIT:
            run = False
        if event.type == pygame.KEYDOWN:
            if event.key == pygame.K_ESCAPE:
                quit()
            if event.key == pygame.K_g:
                color = gray
            if event.key == pygame.K_w:
                color = white
  • 2
    It is not enough to change the `color`. The color of the text does not magically change when you change the `color`. You need to `font.render` the text again with the new `color`. – Rabbid76 Oct 11 '22 at 19:20
  • Can you share an example? –  Oct 12 '22 at 19:07

0 Answers0