set_caption ( 'First Game' ) walkRight = walkLeft = bg = pygame. This means we are going to move our old drawing code that is inside the main loop into a function and make a few modifications. It is often good practice to do all of our drawing from within a function. # This goes outside the while loop, near the top of the program walkRight = walkLeft = bg = pygame. This is the code to load all of our images (I recommend you copy and paste). Since we need to load so many images we will be storing some of them in lists for easier accessing later on. To load an image in pygame we use (path). # This goes outside the while loop, near the top of our program left = False right = False walkCount = 0 The first step is to create a few variables which will be used to determine which way we are facing and keep track of the current image we are showing. Character AnimationĪfter we've downloaded our images we can start getting ready to anime our character. Please place all of these images in the same directory as your python script. IMPORTANT Please download the images for this tutorial from my GitHub or the download button below.