method any keyboard or mouse event will cause the for loop to run inside the loopwe'll write series of if statements to detect and respond to specific events for examplewhen the player clicks the game window' close buttona pygame quit event is detected and we call sys exit(to exit the game the call to pygame display flip(at tells pygame to make the most recently drawn screen visible in this case it draws an empty screen each time through the while loop to erase the old screen so that only the new screen is visible when we move the game elements aroundpygame display flip(will continually update the display to show the new positions of elements and hide the old onescreating the illusion of smooth movement the last line in this basic game structure calls run_game()which initializes the game and starts the main loop run this code nowand you should see an empty pygame window setting the background color pygame creates black screen by defaultbut that' boring let' set different background coloralien_ invasion py --snip-def run_game()--snip-pygame display set_caption("alien invasion" set the background color bg_color ( start the main loop for the game while truewatch for keyboard and mouse events --snip- redraw the screen during each pass through the loop screen fill(bg_colormake the most recently drawn screen visible pygame display flip(run_game(firstwe create background color and store it in bg_color this color needs to be specified only onceso we define its value before entering the main while loop colors in pygame are specified as rgb colorsa mix of redgreenand blue each color value can range from to the color value ( is red( is greenand ( is blue you can mix rgb values to create million colors the color value ( mixes equal amounts of redblueand greenwhich produces light gray background color