firstwe'll create an empty pygame window here' the basic structure of game written in pygamealien_ invasion py import sys import pygame def run_game()initialize game and create screen object pygame init( screen pygame display set_mode(( )pygame display set_caption("alien invasion" start the main loop for the game while truewatch for keyboard and mouse events for event in pygame event get()if event type =pygame quitsys exit(make the most recently drawn screen visible pygame display flip(run_game(firstwe import the sys and pygame modules the pygame module contains the functionality needed to make game we'll use the sys module to exit the game when the player quits alien invasion starts as the function run_game(the line pygame init(at initializes background settings that pygame needs to work properly at vwe call pygame display set_mode(to create display window called screenon which we'll draw all of the game' graphical elements the argument ( is tuple that defines the dimensions of the game window by passing these dimensions to pygame display set_mode()we create game window pixels wide by pixels high (you can adjust these values depending on the size of your display the screen object is called surface surface in pygame is part of the screen where you display game element each element in the gamelike the aliens or the shipis surface the surface returned by display set_mode(represents the entire game window when we activate the game' animation loopthis surface is automatically redrawn on every pass through the loop the game is controlled by while loop that contains an event loop and code that manages screen updates an event is an action that the user performs while playing the gamesuch as pressing key or moving the mouse to make our program respond to eventswe'll write an event loop to listen for an event and perform an appropriate task depending on the kind of event that occurred the for loop at is an event loop ship that fires bullets