 Okay, welcome to basic animation in Python 3 part 4 using images. So for this Program this animation program so far what we've been doing is changing the player's shape From a square to a circle square to a circle square to a circle. It's animation, but it's kind of boring So in this case what we want to do is we want to actually use some images So what I've got here is I've got two images From my space invaders tutorial. I got invader and I've got invader 2 Okay, so it's a very simple animation where they're going to be jumping back and forth between two different frames And that's an important keyword that we'll be using. Okay, so Let me explain how images work in the turtle module if you haven't seen any of my other Tutorials this is kind of important one of the limitations of the turtle module Is that you have to use GIF or GIF images? However, you want to say it dot GIF can't use PNGs. You can't use What JPEGs anything like that? I think you can use bitmaps if you even know what those are anymore But you got to use a GIF so that's one of the limitations so what I've done is I have a folder where I've put my code and I Have these two same files in here and this is how you got to do it The first step is you need to register the shapes so And this basically tells the computer tells Python I've got these shapes and I want to use them Okay, so I'm going to type win register shape and In this case, it's invader dot GIF And if you don't register it, it's not gonna work register shape Invader to dot GIF. Okay now at this point I strongly recommend testing the program and you're not gonna see any changes Okay, but hopefully you'll see no errors and this is working fine a lot of people Particularly Windows users This doesn't work for them and they have to enter the full path of the users and blah blah blah There's a bunch of stuff you have to enter the full path to that file Windows and Linux it usually doesn't matter sometimes. I think it depends on your Editor in the case of genie. I don't need it and I'm on a Mac right now. Okay, so I've registered the shape So now instead of a square. I want to use invader dot GIF So down here say invader dot GIF Invader dot GIF and this is gonna be Asa is invader to and this is gonna be Invader to dot GIF. So basically I'm just switching back and forth I'm gonna get rid of this in a bit there, but you get the idea Okay, so all I've done is I've swapped where it says square. I've put invader dot GIF Okay, and where it said circle. I've put invader to dot GIF Okay, and that should be all we need to do Should be let's try it out Okay, there we go. So we got our cool little space invader character And it's little legs are moving back and forth every half a second just like we programmed Now what I want to do next is I want to update the code just a little bit With the idea of frames because that's gonna come in handy in our next video So what I do is I'm say player dot frame Equals zero. Okay, so as I mentioned in the first video when you animate It's it's a series of frames each frame is slightly different to the previous one now combined Your eye sees that as smooth motion. Okay, so what I want to do here is instead of using the shape I'm gonna use frames and that's there'll be a reason for that which you'll see later So instead of if player shape equals invader dot GIF. I'm gonna say if player dot frame Equals two equal signs zero Then I'm gonna change the shape to invader two dot GIF And I'm gonna I'm gonna set the frame player that frame Equal to one because now I'm on frame one it starts at zero not starts at one That's kind of a programming thing and then here If player dot frame equals one I want to Send it back to the original Invader GIF and I'll say player dot frame Equals zero So I'm just cycling back and forth now if I had an invader three I could go if player frame equals one player shape equals invader three Player frame equals two and I could go that way but in this case I only got two frames again. I'm gonna test my code just to make sure it's working and there we go Okay So there's a lot more in that one than we've had in some previous ones So we had to register our shapes And we also are using the concept of frames Like I said what this will come in handy a little bit later In one of the future tutorials Coming up so basically if we're on frame zero we want to show the second Invader and now we're in frame one and then if we're on frame one We want to jump back to the original image and tell it that we are on frame zero Okay, so I'm gonna stop that there and we'll come back for part five here shortly Thanks for tuning in