The idea is that I have a few switches hooked up to the GPIO pins on a Raspberry Pi 3 B+, and once the first switch is on, 'text 2' appears. Only once the first switch is on, can the second switch be activated. After the second switch is on, 'text 3' will appear. Only once the second switch is on, can the third and last switch be activated. After activating the third switch, 'text 4' appears.
The text appears how it should, but there is a constant flickering of the text on top of one another. I suspect it is because I have multiple pygame.display.flip() within the same loop, but I cannot find a way to work around it. I could essentially change the background color and move where the new text appears to "hide" the flickering, but I feel as if there is a more sane solution. Does anyone have any ideas that can get me started?
Here is the relevant code (all constants for colors and text is not included here):
while running:
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
if GPIO.input(24) == 1:
window.fill(white)
color1 = white
color2 = black
color3 = white
color4 = white
window.blit(text2, (window_width/2 - 50,window_height/2 - 100))
pygame.display.flip()
if GPIO.input(18) == 0:
color3 = white
if GPIO.input(18) == 1:
window.fill(white)
color1 = white#Second puzzle GPIO
color2 = white
color3 = black
color4 = white
window.blit(text3, (window_width/2 - 50,window_height/2 - 100))
pygame.display.flip()
if GPIO.input(16) == 0:
color4 = white
if GPIO.input(16) == 1:
window.fill(white)
color1 = white
color2 = white
color3 = white
color4 = black
window.blit(text4, (window_width/2 - 50,window_height/2 - 100))
pygame.display.flip()