Placeholder Image

字幕表 動画を再生する

  • All right, guys, welcome to the spite on game development.

  • Video Siris on.

  • We'll be using the famous spy game library off Fight on to create the school space in Reno.

  • Game on.

  • We're going to go really in depth into the spy game and learn about a lot of different concepts on Specifically, we'll be learning a lot about, like, new parts off pipe down that you haven't exploded on new parts off my game Lake moving characters, shooting bullets, understanding game concepts like game loops and stuff like that.

  • So if you haven't ever created a game or you have only created a very basic game, this would be a very good starting point for you guys.

  • So before we get started on all of that cool stuff, learning about game, the Le Pen and stuff like that, you should make sure that the basic stuff is in start.

  • So first basic stuff.

  • It's obviously bite onto.

  • If by Thomas Norden start.

  • If you're using, fight on for the first time, just goto fight on door arc and then click on downloads and just download the legal portion off.

  • Fight on after downloading Fight on.

  • We are going to be using i e.

  • Vision.

  • Basically a cool Oh, wait, right, good off, fight on.

  • So I'm going to using my charm on if you don't want to buy the professional version, although you have a 30 day trial, which you can use for this course.

  • But if you don't want to buy it, just download the community was in, which is free, and you won't need more than the community was in.

  • But if you're using something like sublime text or maybe the mean fight on terminal, that's also fine.

  • It won't matter.

  • But if you want to follow along completely, make sure that you don't by chance.

  • And thirdly, you can just have a look at the buy game.

  • Let's say that you're going to be using to create our game so you can just have a look at it.

  • It's not really necessary, but you can just have a look at what has been done with this by game on.

  • Dhe.

  • Look at the games, maybe, and, you know, just kind of get ideas.

  • Phyllis gets started.

  • Make sure that you have downloaded by jump after you have downloaded by jump, it will look somewhat like this.

  • Now that we have everything in start, we need to make sure that we have this new project over here.

  • So for that, just go to file, click on New Project on, then tried down the project name over here.

  • I want to be created the project, and I'm calling it space in reader because it's the game that will be creating on Probably have already played this game when you were a child, but the main idea is that there's a ship at the bottom.

  • I'm going to hit the enemies that are under dog by shooting a bullet, and every time you hit the enemy, your point increases and the enemy slowly come down.

  • If it touches the spaceship, you lose on the final score is what?

  • How many enemies you have shot.

  • So that's the basic idea off the game.

  • But you'll understand mood as we go through the videos.

  • So after you have created this project, we are going to create a new file over here.

  • I'm just gonna call it Main because most of her court is going to go inside this mean God bite on fire.

  • And after that, we need to install my game.

  • So if you're using terminal, you can just open up your terminal by typing in CMG and you get a statement pip install by game.

  • And this is for people who are not using by chump or you're using something else likes to blame.

  • Takes a bite on terminal.

  • But if you're using my charm Ward, you would do is you would go to file and then you would go to settings on in settings.

  • You would goto project name the whatever name you have given if wanna follow along, called Space and read up and then go to project onto Britto And what there you can see you have already installed by game.

  • And if this, by giving is not already in story, just goto this plus sign over here on search for my game by game, and then you can select it and click on Install package, and this will install by game onto your computer.

  • Now already installed by games, I'm not gonna install it again, and after that you can just type in by import by game.

  • And if this doesn't show on editor, that means that my game is in Start on your computer.

  • So this is pretty much a This is a pretty small video, just an introduction video.

  • We're going to be doing a lot of cool stuff from the next we do.

  • We are going to be creating our team.

  • We are not going to go into a jury and stuff here that's gonna start with practical stuff and actually start creating again.

  • So we're going to be creating a game window next time.

  • So as you can see, the spike has a window right now.

  • So we're going to be creating this kind off a window in the next video with the cross button over here.

  • So I'll see you over there and this to recap what we did in the last meteor.

  • What installed by game.

  • And in this video, we are going to be creating our first fight on game window using biking.

  • So obviously the first thing we need to do is import my game in tow, our program and hopefully have already created this means or my file.

  • If you haven't just created right now on first of all, get into import my game and then we need to initialize fighting toe access.

  • All of the code methods and all of the other stuff that is inside the spy game.

  • More deal.

  • So to initiate this, I gave model what we need to do it.

  • Just type in my game dot in it.

  • So when you go from no one who create a game or create a new game, just make sure you act this lane.

  • Otherwise, your pipe on my game court is not going to work.

  • So let me just act a little bit coming over.

  • You're saying off initial A's my game, All right, so after initialization we have to create our screen on my game makes it really, really easy.

  • It's just one line of code.

  • It's crazy.

  • So it is going to write Scream on.

  • This is our available on.

  • We can just right by game on.

  • This is to access the methods that are inside this bag, a model on neither ancestor display dot said more metal.

  • And then inside these brackets, we need to add another bracket.

  • So this is a pupil.

  • Make sure you add another bracket inside it.

  • Otherwise it's not going to work on our people mess up over here and then ask why they're not working is because you haven't 100 Another bracket over here and then inside it is gonna take Duke values the height and the weight off the window that you want to create.

  • So I'm just gonna give it for no no value off 800 pixels off height and 600 pixels off wit.

  • So this should be good.

  • And let me this either comment create the screen on Let me just for my just probably So this is all you need to create a screen.

  • But as you'll see after you run this program that it has won me back.

  • Think about it.

  • So as you can see, the game window was created.

  • But after a few seconds is just went away.

  • Be sure to you guys again so quickly.

  • Complete stays there for, like, one or two seconds.

  • Then it goes away on.

  • This is because our fighting program goes through these three lines and then just exits the program.

  • And therefore you can't see that screen for a long time because it just takes one or two seconds for this program run and that's it.

  • So when we do buy parts, that is, just create an infinite loop over here on this also has problems.

  • But just to show you guys that it works, I'm gonna do it.

  • And I'm gonna make sure that my task manager's open because this will hang my computer.

  • So make sure that your past managers are open because this will Hank the window, at least that you're working on.

  • But just to show you guys, I'm gonna run this and you will receive that the window is dead, but it is totally had.

  • So you can see the window is there.

  • But it's nothing is walking over here on this crowd, but and it's not working.

  • Let me just go back over here in close.

  • My, I don't know, click on and task, and it has been closed.

  • Now why is it hanging by?

  • Did not just closing down by pressing this cross, but it is because we don't have an event off a quick function over here.

  • There's no we do create the program.

  • Our program is just inside this.

  • If I look on snow able to end on windows, make sure that that program gets hung.

  • That's why we need to add a quick functionality.

  • R.

  • I gave keep window, just like this window has on pressing disclosed.

  • But in this window closes.

  • So for that, we're going to be using something known as evidence.

  • No, we'll get into evidence more a little bit later.

  • But for, you know, just understand that even is anything that is happening inside your G.

  • Brendel my game.

  • And oh, I just mean a window inside which your game is being played.

  • So anything happening inside that game window is basically even So, For example, if you press arrow keys or anything on your keyboard, you move your mouse.

  • That is an event I'm even when you press this close button, that is also an event in again.

  • So this pressing off the close button actually known as a quid, even in again.

  • So we're gonna make sure that we exit this loop when this close button expressed.

  • So for that, what we're gonna do ESPIRIT is gonna create very bill.

  • Let's call it running on.

  • We're gonna get a value off true on inside this by Lupita, instead of just having invited true to make it an infinite loop, gets a phone, call it running, and when we want to break outside of this infinite loop, you're just gonna turn the variable off running into false on its will automatically break this by Lou.

  • So if you don't know the basics, our fight on our programming basically by through grants for nightly and then this value off, truest onto falls, it comes out on the loop.

  • But we're not gonna go in too much into that because that's just like, very basic programming.

  • So anyways, after writing by running, what we need to do is go through the list off events that are happening inside a game window.

  • So for that, we're gonna create a for loop and create available event on.

  • Then we're gonna look through all of the events that are happening inside the game window.

  • How do you do that I gained Makes it really easy.

  • Just typing by game.

  • Don't even don't get on the brackets on this.

  • Make sure that all of the events that are there that happening get into this.

  • I gave not even dark get and then we can loop all off these events using the four loop on one by one check.

  • If this cross button has been pressed on women better with this cross, but it is being pressed You just telling this by Lou into false.

  • So this is pretty easy.

  • So inside this father in Bergen, a chick If the close button has been pressed on how you do that, just a pin.

  • If even dog type equal equals two and then we're gonna check whether the event in my game is quit or not.

  • If it's great, then we're gonna change the family off running into faults.

  • This is pretty easy.

  • So we have changed our value off through into force.

  • Whenever the close button is being pressed on, this close button is basically occurred.

  • Event on.

  • We're gonna look through all of the events to find this quit.

  • Even so, we're gonna go into mourning to events a little bit later.

  • But for right now, just understand.

  • This is what we are doing.

  • Lists displayed this, understand?

  • But it's working or not.

  • Let's see.

  • So right now you can see that video system is not initialize is giving us a better.

  • It's a spy game.

  • Don't even don't get all right to the problem is that we have misspelled this.

  • It's not my game dot small letters quit is just my game.

  • Not quick on it has pretty much it.

  • So when you were dealing with a lot of syntax, you have to make sure that your current one but small problem here's gonna click on play.

  • And now you can see that this is working on our window.

  • Is not going anywhere.

  • The computer is not hanging.

  • It's looking pretty good.

  • Alright, guys, let me just go through this once more what we are doing over here.

  • So we have created our screen.

  • We have initialized by game on.

  • Then over here we have created a game.

  • Luke, Let's actually call it the game.

  • Look about here.

  • We're gonna add a comment that say's came loop.

  • So this is an infinite loop, which makes sure that the game it's running always and the window doesn't close down on, you know, we want to do something like move a bullet or move a play or something like that movie human being inside a window.

  • We have to make sure that we do stuff inside this by infinite loop, which only exists when this close button is pressed on.

  • We have implemented that lose functionality over here by pressing by getting the events, all of the events using this by game board, he went, don't get mattered.

  • And then we're looping through all of the events.

  • So if more events are added, for example, if somebody presses on, I look you to move forward.

  • That is also going to be looped.

  • And thus I gamed out every guard here, Luke, and then we can add under condition that if he is pressed, move that player.

  • But more of that in the future.

  • For right now this understand?

  • We look that if even your type, because to him quick, let me change the running into falls to make sure that we come on this way.

  • Luke and I know guys.

  • I'm revealing a lot of stuff right now, but this is like the B six off game developments.

  • I want to make sure that you guys understand properly.

  • Anyways, Guys is pretty much it for this video.

  • In the next video, we are going to change the idol and at some stuff into our game window, so I really look forward to that.

  • So right now it's just black and it's just saying I get window.

  • It's not cool So we're going to look into that in the next video and see you over there.

  • So in the last video, we learned how to create this game window using my game.

  • So this window is a little bit not personalized because it saves by giving over here.

  • The background is weird.

  • The lower is not there.

  • So in this video, we are going to be learning or dreaming things.

  • The first thing is how they changed the caption off this window instead of my game window.

  • We'll make it something saying something like space and radios.

  • We're going to learn how to change the logo off this window Night nine.

  • Slater sneak on a total or something like that on how to change the background color off this window.

  • Now, these three things are very basic, but obviously very important when you're creating again.

  • So let's get started on that.

  • On first thing we're gonna do is obviously just coming died so that you guys can come back to this court on Look what's happening.

  • So we're gonna write a comment title, and I can, and after that, we're gonna change the caption or the title off window and my game makes it very, very easy.

  • You just write it by game, don't display because we are meddling with the display off our window.

  • So we have to write and don't display on then DOT said underscored caption.

  • And it requires the title of the window.

  • Let's just call it space in Reader's because that is what we are created.

  • And then we're going to create the image.

  • So you must have been seeing this year four dot PNG image over here.

  • We're going to be using this image in just a second.

  • I'm gonna show you how you can get this image.

  • But before that, let me just add this icon inside our program so far that this is also very easy.

  • First of all, what you can do if you want to get the same image, is that you can go to this that site known as flat Aiken dot com on, then search for spaceships on any kind off I could sew.

  • I have searched for a spaceship and anger disc you'd UFO Aiken, So download this.

  • You can just click on downward collection on make sure that you select PNG and then 32 by 32 big cell sites.

  • So we know you're working with an icon and by game, make sure your select that 32 into 22.

  • I haven't experimented with 24 or 16 pictures.

  • It might work, but I'm just gonna go over 32 32 pixels.

  • You can select any other I can if you want.

  • So I selected this.

  • I can, and I just downloaded it into my project.

  • On here Is your four don't p and G?

  • No.

  • Add this inside our fighting program.

  • It's pretty easy.

  • You just They've been gone equals to buy game dot image because you are using an image.

  • So we're going to be using the image model added inside by game on, then dot Lord, we want image to Lord and then we just write the name of the images.

  • In my case, it's you for Dr P and G.

  • So you and I use that you have four dog PNG and then the next line is pretty simple.

  • We are going to use the same dot display that we did with the idol and he was gonna write that over here and then just said it's not showing, but I think it's safe.

  • Underscore I can, so you can use that.

  • And then you just type in the available limb off I can over here that we have created on this will make sure that the Aiken has, Bean added.

  • So let's just run this on, see if it's working or not.

  • So, as you can see, the Aiken is also working on the space in readers.

  • Is this so this is looking pretty good.

  • We have learned how to add an image.

  • Not exactly an image just off Aiken over here and change the title off window.

  • So this is looking pretty good.

  • The 30 minute to learn is how to change the look or the background off our window.

  • So for that, we need to do something known as screen Don't fill.

  • So we're gonna go inside our while running loop, and over here we're gonna scream.

  • So anything that you want to be persistent insider game window, that you want to make sure that appears continuously, it can be an image, or it can be some text.

  • It has to go inside this running infinite.

  • Why, Lou, That is why we are going to change the color inside this running in tonight.

  • Why do so?

  • We're gonna just eight screen don't fit.

  • And then inside this, you're gonna create a pupil.

  • Make sure you act under bracket inside it.

  • So there are two brackets and then you give it three values off RGB.

  • So we're gonna give it.

  • I'm gonna explain what Jimmy is in just a second.

  • I'm gonna give it value of 000 right now.

  • Joe, just to understand this are Jimmy Means is red, green, blue on.

  • Basically, every color in this world is made up off these three values.

  • On one more, you can say a pacer teabag.

  • Let's not go into that.

  • So argue me, basically stands for red, green and blue on.

  • This is the value.

  • These are three values that began usedto basically implement any color on the screen.

  • So this make sure on this value goes from 0 to 2 55 so you can make it to 55 but not more than that.

  • And you can use it in a combination.

  • So they say we want just a pure red color.

  • So we'll say that we want to 55 on green zero and blue zero.

  • And similarly, if you just want a green color began, say 0 to 55 on blue zero.

  • What if he wanted a light, light green color?

  • We can lowered on this value to maybe play 1 50 So this will be a lighter version off pure green.

  • So this is how it works.

  • Basically, Andi, just to show you guys are more diversion off RGB or what you can do with RGB if you haven't understood it properly, let's go to Google and you can just type in color toe rgb on goto any website?

  • What?

  • I'm just going to go to this rapid tables upside and over here you can see these are TV values.

  • So obviously I told you, Read is to 55 00 Lane is to 55 0 Deal this on dhe similarly and so on.

  • So let's go with this.

  • Right?

  • Hello.

  • Right now on you can choose any values on.

  • There are a lot more colors.

  • You can even make your own colors by trying on different three values.

  • So just experiment with it a little bit, so I'm gonna just use the red color.

  • So we're gonna go back to our court and I'm going to write down to 55 but it is not going to work even though we had try it.

  • But this is not gonna work, just telling you want, so you can see that it's not working.

  • It's just a black screen.

  • So over here, we need to use something.

  • Noone has update.

  • So right now, our display is not updating.

  • So that's why I improvise a method known as display update to make sure that if he had anything inside our display window, it gives updated inside this while running blue.

  • So before that, it's pretty easy.

  • Just make sure that you added after every game, so it's by game dot display.

  • So that's just a display dot update, and that's it.

  • So you have to add a couple of flames inside your by Eitan Game Court.

  • The first line is this innit line, and also you need to make a scream.

  • But two lines that are always going to be there is this innit line on the the second line that's always going to be There is this update line because you want to update your screen because your players is going to meet with The bullets are moving.

  • Amy is going to move.

  • Moving the score is going to be changing.

  • So you want to make sure that your display is always updating on by display.

  • I just mean the game window that we are working on for this program.

  • It means this screen very been so anyways.

  • So now we have a bridge, it less given a short left click on play.

  • And as you can see now, it's in color.

  • Looks good.

  • We have changed the title.

  • We have changed the logo and our screen is updating red.

  • I don't like red.

  • I just wanted to show you guys that you can change the color and maybe we'll change.

  • Do something a little bit more funky in the later videos train.

  • I'm just gonna go with Black, that 000 and that's pretty much it.

  • So guys are seeing the next video where we are going to be finally adding images on our player that there's maybe a spaceship, some kind inside our game window on Dhe.

  • So I'll see you over there where we're going to learn how black images inside our game so So the last video we learned how to add a caption on a logo on how to change the background screen off our game window.

  • In this video, we are going to learn how to add an image to our game window, which is pretty cool on Pretty easy, because off again.

  • But first of all, let's look at the player PNG, which we're goingto ad insider game window, which is kind of a spaceship just shooting beams sort of its arms.

  • So if you want this image, you can just go to flat.

  • I couldn't dot com on download this image.

  • Obviously, you can use any other image you want, but I'm just gonna stick with this image and you can go to download collection and also the search for our kids space over here.

  • If you want this exact image and then choose PNG, choose that 64 by 64 picks it.

  • Obviously you can't decide it by game, but I've seen that it's better if you already get the image of the science that you want.

  • In this case, I wanted sex Table 64 by 64 pixel version, so I'm gonna take that and I wanted.

  • He added it to my project Over here.

  • After you have done that over here, then you can come back and we can start adding the image.

  • But before we even start that, I just want to discuss What is this?

  • 806 100 I have here.

  • I wanted to discuss this, but this 800 is the weight on the 600 is the height.

  • I think I might have said something wrong about this in the starting videos.

  • Uh, this eternity is actually the wit and not the height.

  • And the 600 is the height.

  • So if you look at our window, this is the X axis.

  • You can think off this window as an X and Y axis window.

  • So if you go from left to right, this is an X axis.

  • And if you could go from top to bottom, this is a wide access.

  • So it's always starts from zero comma zero, which is at the top left corner, and then we as we go on the right hand side, the X value starts to increase on on this top right going on.

  • The X value is 800 because that's time.

  • So what?

  • And now if you go from top to bottom, the value off by increases while the explanatory means to seem so over here, the value is 600 but the value off zero.

  • So if you don't understand it a lot, don't worry about it.

  • Just think off it as this left left to right is basically X on the value.

  • Right now, off this whole window is 800 in terms off.

  • Its wit on the value from top to bottom is 600 on the value at the bottom is 600.

  • And if you want to go into into the middle, it's approximately 300 not approximately exactly 300.

  • So I'm telling you this because we want to place our image in a particular position.

  • So that's why we need to give it its that coordinates.

  • Obviously, you can experiment with gardeners a little bit, but we'll go into it.

  • So let me decide a comet over here so that we know that we're talking about the player and then we need to add the player image registry easy, like we have done it in the dumps of the local religious copy and paste this over here on change the UFO to play a doctor, p and G.

  • And then we're going to give it the X and Y access where we want the image.

  • Toby Coalition.

  • Let's create two more very birth.

  • Let's call display an ex on.

  • We're gonna give it the value off.

  • 3 70 on.

  • I'm going to go into why we give these values to Player X simply away.

  • So these were it builds basically presence the cornice that we want.

  • And over this, we're going to give the Vita Valu off for 80.

  • So why have you done that?

  • So if you look at this window, we want them clear image to appear somewhere over here, which is exactly the half off the screen picked.

  • So we wanted to appear at the starting off the game.

  • It least we wanted to appear in the middle on.

  • We wanted to appear in the lower half off this window, so the Y axis should be closer to 600 because this 0.600 if you guys remember this law art.

  • So you wanted to appear a little bit about what?

  • So we can give it a value of about 4 80 or 4 50 whatever you guys want and then the X value.

  • We're giving it 3 70 which is a little bit half less than half off the bed.

  • So the weight is 800.

  • And if you go a little bit less than this, this is 3 70 because we have to consider the size off the image itself.

  • If you give it exactly the value off 400 snorkel defect perfectly.

  • That's why we have given these value so you can see that the 3 70 is somewhat half off.

  • 800 on Disparity is close to 600.

  • Obviously, when we change the values, you'll understand this concept better and feel free to change these values and see the effect it has Now, after this bill is gonna create our function and we're gonna call it Blue.

  • Now, I'm gonna go into why we are creating a function.

  • But let's just clear the function for now.

  • And then we're going to use a matter known as cream dot split.

  • So basically means to draw, so we're drawing on image off player on our screen on this Green is actually known as the surface off our game.

  • We're going to what?

  • It is this office which later?

  • I know I'm saying that a lot, but it's not living to this video.

  • But just understand that we're trying this image off clear, dark PNG on our game window by using this method known as dot blip on dot blade blade actually means to draw, so we after learning the image, you also need to draw it on the screen.

  • But that's why we're using the screen door blade mattered.

  • And over here, it requires two para mi does our values.

  • The flip first value is off the image itself.

  • So we're gonna give it the image.

  • And the second thing it requires are the coordinates.

  • So we're gonna give it the coordinates off player X and clear.

  • Why?

  • So the X and Y coordinates after this we're going to call it.

  • I'm just gonna ask you a question.

  • Where do you think we should call this player?

  • He won't display her toe appear in every frame off the screen.

  • We don't ever want this place to disappear.

  • If you guys said inside this my loop.

  • You guys are correct.

  • So we're gonna call this player method inside over here, so let's just call it on.

  • We're gonna just call it over here like this on.

  • Make sure that display emitter discord after this cream dot film, 1/3 of the ways this player won't appear on the screen.

  • My, do you think that is?

  • This is because the screen is drawn first and then on top of the screen, we draw a player or a spaceship.

  • If the opposite waas to, then the spaceship will be drawn underneath the skin, the scream, not the skin.

  • But then it would be drawn underneath the screen.

  • So that is why we always want it to be drawn after screen dot Phil.

  • Actually, let's change.

  • Let's remove this position Tau from there to over here somewhere so that we guys know where this So because we're going to be adding a lot off images and stop.

  • That's why we need to make sure that this screen dark Phil is just about everything on all the other things.

  • I'm drawn on top of this creep.

  • All right, guys.

  • So this is pretty much let me just add under comment.

  • I don't know where he disappeared.

  • The standard for RGB on dread green blue just to make sure that you guys still remember what this is.

  • All right, so this is looking pretty good on a player should appear on the screen, So let's run it on.

  • Then we just go through all of this stuff again to see what is happening, all right, So as you can see, our image has appeared on the street.

  • So first we loaded the image in this play, an image available, he pointed out, the X and Y values and the X and Y values were dependent on the screen size that we give over here.

  • 806 100 because he wanted it to appear in the Libby disclosed this one, the old one all right on because he wanted it to appear in the middle.

  • That is why we gave it the value of approximately half off the screen.

  • For example, if I gave it the value off, let's say just to experiment, let's say we give it the value off.

  • Let's a 7 50 that is close to write and say on we reloaded it on Let's go for you can see it appeared on the right inside so you can see that the X value has increased.

  • And similarly, if we decrease the toe, let's say about 30.

  • I'm just showing you this guy so that you guys can understand the extent why positions.

  • Clearly you can see that it appears on the left hand side.

  • So left you two back to about 3 70 on similarly in.

  • Why?

  • If we change this to maybe 30 you'll see that it appears on top of this cream instead of the bottom of the screen.

  • So as we could go down, we are getting closer to that 600 value.

  • So we're going from 0 to 600.

  • So let's bring it back to for Eddie and hoping now you guys have understood probably the meaning on this X and y axis.

  • So anyways, after that we created this function known as on Escape, that we drew this so image onto the screen, and it required to values the image Tex and my coordinates.

  • And then to make sure that display here is always shown on the screen, we added it to this wild game loop in finance blue.

  • So, guys, this is pretty much it for this video might be repeating a lot of things a lot of times that my real little bit irritating for some guys, but hopefully you guys understood it properly in the next week.

  • We're going to learn how to move this.

  • So blow from left inside, right inside, using our arrow keys on a keyboard.

  • That's going to be really exciting.

  • Let's wait for that.

  • So I see in the next video the last week, we learned how to add an image inside our game window, and this we do.

  • We are going to learn how to move this image left right, our top or bottom.

  • So basically, we're concerned about the movement.

  • Often object inside on game window or anything that we draw.

  • It can be emitted can be on text.

  • After you watch this, you'll understand how the mechanics off movement in a game works.

  • So just to make sure that you guys understand it, I've created an image so that you guys can understand what we are going to do it on the basics off, movement, off on image or anything that you want.

  • So obviously we have created a game window.

  • This is our game window.

  • It is 800 white that is 800 X axis and then it's 600 is height.

  • That is.

  • You can see it.

  • This, as my access on our special currently is at 3 30 pixels as we have added this over here, that is a player excess 3 70 pictures If you go back to image.

  • What if we wanted this image to move from over here?

  • Toe here we can.

  • This are five pixels store already existing 3 70 pixels on this image will move in the right direction on now.

  • What if we added five pixels continuously?

  • So this five pixel?

  • If he added continuously, this image will continue to move towards the right hand side.

  • So, for example, we can add a functionality which adds five pixels to our existing 3 70 pixels in awhile.

  • Loop something off of I look on.

  • This will happen continuously after every iteration off our flu.

  • Similarly, if you want to move it to the left hand side, we can just degrees some value from a 3 70 pixel value that does.

  • We can decrease some X player X value and will move towards the left hand side.

  • And similarly, if you want to move up, we can subtract some high value.

  • So currently the value off this is for 80.

  • So if you subtract some value from this for 80 it will move towards up direction.

  • And if we add some value if we move in their downward direction, so adding and subtracting values from X and Y coordinates off a current position off the object or in this case patient, can lead to a movement off that object on DDE, you have to add it to a by Lou because we want it to happen continuously.

  • So if you go back to our court, we need to add one thing before I can show you guys how we can act values to our player X and player by.

  • Are we hoping and subtracted?

  • So before that, we need to make some changes because currently there is no way to man you played the X and Y coordinates from our while running blue.

  • And if you didn't understand what I meant by this over here, don't worry about it.

  • When we actually the court, you'll understand what is happening and what I mean by increasing the X value to move towards that I can direction.

  • Basically, if you move it very, very quickly, it won't seem that the image is moving.

  • It will just seem like that the spaceship is continuously moving because off the effect off persistence and I can't see things that are happening very, very quickly.

  • Like magicians do the decree delusions by moving things real quickly on the persistence.

  • And I'd Elsa's That image hasn't bean raised and then created over here.

  • It just assumes that image has moved on the right hand direction if you're adding the five value to our already existing X coordinate, so anyways, we need to do something so that we can manipulate the value off Clear X and Clearwire from the running by Lou.

  • So what we can do is go to this death player function and over here at X comma why, so that we can send in the values off the new X and by cordons that we want, and then insula player X and we arrive in just on X and why, so that the values that we sent to this player instead off the the last values that it got from Player X and they're white and sort of that new values that we send in off X and Y are being shown on the screen or being drawn on the screen.

  • So now we have to go back to the place where we're calling this functions over here right now.

  • Let's just brighten player X and clear by, and you will see that there has been no change.

  • So let me just exit this first and then play it again.

  • Let's play it.

  • So you see that there has been no change because you're not manipulating the Player X and player by value right now.

  • So let's go through this once as to what's happening over here.

  • So first it goes to escort it creates the spaceship, then takes the coordinates off the X and Y off the player of the spaceship on.

  • Then there is this player exchange.

  • Let me remove this right now.

  • We don't need it.

  • And then if we go down, we have greater dysfunction off their player X, Come away on then.

  • This is being drawn on the screen.

  • So this court hasn't been executed yet because it is inside this one vial turning blue.

  • But the program just sees that this exists now when we go down over here than this player thing is called on, it takes the player X and player by value from hell on sends it to this deaf player function and inside X and Y.

  • Currently the 3 74 80 exists, So this image is being drawn.

  • Actus coordinate.

  • What if we change the value insider while turning function?

  • So, for example, let's say we increase the value off player X by something small.

  • This let's, uh let's increase continuously by five.

  • So this will move really, really quickly, and you won't be able to see the image moving doors right hand side.

  • But I just want to show it to you guys for the speed so you can see how quickly moved.

  • I hope you got it just slow down and was gonna give it the value of 0.1 so that you guys can see properly and you'll see that it is moving in the right hand side direction slowly.

  • So why is this happening?

  • So every time this vile group is running the player X coordinate increased by 0.1 on this value has stayed over here in this function player function on.

  • Then it is sent to this nuclear function on the new image is basically drawn on.

  • A new coordinate on the original image is being removed.

  • So what example?

  • Let's also just let's make it 0.2.

  • And this time you're also going to print out the value off Player X so that you guys can see that the player X value is increasing from our production value.

  • So here you can see that being increased by 0.1 and it's going on.

  • Let's stop it right now on Dhe.

  • Let's actually try it to move it in the left hand.

  • Left hand side direction.

  • So let's give it a minus value of 0.1.

  • So now we want to decrease the value.

  • So instead of increasing the value, we want to decrease the value and moving towards the left hand side.

  • So let's play it again this time on.

  • Hopefully, let's just removed the play up the print function because we don't need it.

  • So now let's played and you can see it's moving towards the left hand, say similarly, if we do instead of the X coordinate, we do the Y coordinate and decrease its value is gonna goto us up connections.

  • Let's reload it, and you will be able to see that it's moving.

  • Tow us up direction.

  • And similarly, if the AG stock it was going to go down, hopefully you guys understood The mechanics off a movement often object just to reiterate why this movement happening by is when, when we're decreasing the value and why it's going up.

  • So because it had the bottom the value off by coordinate six hundreds if you decrease the value it was going up.

  • So over here it's about for 80 and if we decrees it more, it's gonna goto us direction.

  • And similarly, if we increase it is good to go below more than 600 coordinates right now, you can see there are some some fallacies with this system right now.

  • We can't control where this is going on.

  • You really see that just goes outside the screen.

  • So we need to do a couple of things First, we need to make sure that we can control this movement off the spaceship in the left and the right direction, using a arrow keys on the keyboard on The second thing you need to do is add a boundary so that the spaceship doesn't go beyond our game with the right.

  • Nice just disappearing by going outside the game window.

  • So we'll be handling these two things in the next coming videos and the next.

  • We were going to learn how to add keyboard support to our game.

  • So basically, we're going to control our spaceship using arrow keys, and that's when we really exciting.

  • So I'll see you in the next video.

  • This is pretty much it.

  • For in the last week we learned about the movement mechanics off the objects in our game window.

  • So, for example, if you do player because two minus equals 0.1, then it will move in the direction.

  • So if I run this man, you can see that our spacious is moving in upward direction.

  • But right now we don't have any way to control the spaceship.

  • You can't control it using our keyboard, and this is exactly what we'll be learning in spirit.

  • So what we'll be doing is that many places left a rookie on a keyboard.

  • The spaceship is going to move to us.

  • The left hand side.

  • And when you pressed the right hand side a rookie, then our spaceship is going to move on the rest tonight and say So what is the algorithm to do that?

  • So, first of all, we're going to check whether any stroke is being pressed on her keyboard on after we check that we're gonna check with the cute stroke breast is either left hand side a rookie or the right hand side Iraqi.

  • So we're gonna do that.

  • So let me just write down.

  • And if condition, let me just remove this over here.

  • We don't need it.

  • So after that, let me just tell you one more thing.

  • So any keystroke that is pressed on a keyboard is actually, and it went on, as we have discussed before, that event is anything that is happening.

  • Insider game, window, any kind of input control.

  • So, for example, if we move on Mama's, we clicked somewhere.

  • We close this window, so this is a great event, and similarly, whenever we press any key stroke on keyboard, it is a key stroke.

  • Even so, for example, every even gets locked inside this by game, not even dot get on we loop through all the events that are being stored inside it on, then after every operation.

  • So, for example, let's say in the first operation off this by loop are key.

  • Stroke is not being placed, but on a tent decoration, a keystroke is being pressed and will get stored inside the spy game.

  • God even don't get on.

  • We'll be able to look through that and check whether a keystroke has bean pressed or not.

  • Who's inside this?

  • I'm just gonna write an if condition which says, actually, before that let me just come in so that you guys understand what we are doing.

  • I'm gonna write if, uh, keystroke key stroke expressed chick better.

  • It is right or left.

  • So this is basically what we'll be doing.

  • Monkey stroke A keystroke.

  • Oh, God.

  • I'm gonna mess up my spilling All right, keystroke.

  • I get this feeling right.

  • It's all right.

  • So anyways, how do you check with their key stroke is being pressed or not by game makes it really, really easy.

  • It's kind of an event, which is I game dot g down.

  • So this basically check if any key stroke, it doesn't have to be left or the right, It can be alphabet, a even backspace or space.

  • It basically checks if any key stroke is being pressed.

  • So first, we're gonna do that, right?

  • If he went door type, which we did inside this if condition.

  • So we have to go actually, inside this four loop, so we'll just press this button away here less Prestes.

  • So now you're inside this event for Luke and now we're looking through all the events that are there.

  • And if the event door type is equals equals to buy him dot key key down, then this means that a keystroke has impressed on a computer.

  • And now we have to check whether the keystroke that what's pressed is left or right.

  • So this is also pretty easy.

  • We just again type event dot this time be typing dot key because you want to find out the key that is repressed.

  • And we just type in my game dot He left.

  • He left on this would just check whether the key that is being pressed is the left arrow or not.

  • If that is the left eye releases for right now, Brenda left at all is pressed after that I'm gonna write again.

  • I'm just gonna copy in pieces over here like this.

  • Andi, over here.

  • I'm gonna write, right.

  • And instead, off k underscore left.

  • I'm gonna act the right.

  • All right.

  • So basically, what this does is it checks that any case stroke is pressed, and then it checks with the keystroke that is being pressed is left or right after that, we're gonna check when the keystroke is being released.

  • So after pressing down on the left, a rookie, when we remove our finger from the left a rookie that is known as the removal of the key stroke or the key up so cute down is pressing that key or pressing any button on the keyboard.

  • And key up is basically releasing that pressed.

  • So we're gonna check for that over here.

  • If you meant Don't Type is equals equals stupid game dot ke up.

  • So hopefully we'll be able to find that key up for him, and then we're here.

  • We're just gonna check if it was the lefty on the right, a rookie, and then we're gonna bring something, So that is pretty simple.

  • We can just copy too strong here This copy this.

  • Base this on.

  • We're gonna give a condition that if the left or the right arrow key was pressed breaking just copied this from here on.

  • But the school in mark and then over here, over here, just gonna write keystroke.

  • Has Bean released this tree?

  • You So you guys know what is going on?

  • And I want you do, like this go down and then actually tried out yourself so that you guys know what's happening behind the scenes.

  • So now we can just press play and over here is gonna do nothing but on our Prince King.

  • Over here, we're printing all of these things.

  • So let's press the left a rookie and see if something happened.

  • So we have to first wait a window over here, and then we can press the left, a rookie and you can see that the left arrow is pressed on when I remove my finger.

  • It says keystroke has been released.

  • What if I keep pressing on the left Iraqi?

  • If I keep pressing, it will just say left out of this place and the keystroke has been released.

  • And similarly, if I pressed the right arrow, key states right arrow expressed.

  • But if I press any of the G eight prints, nothing.

  • So let's actually bring a statement over here.

  • Do let's say a keystroke is pressed so that we know when any other key expressed it also runs.

  • So what hero began Just rest left Anarchy again.

  • As you can see, a keystroke express left arrow keys pressed hankie Stroke has been released.

  • But if you play something else, let's say Endo, it just says a keystroke is pressed and not the left on the night.

  • Archy on.

  • That means that a keyboard strokes are working.

  • So now we can just minimize it, and we're gonna create a new very below.

  • Here on this will signify the change that we want an egg.

  • So if you want the extra move in writing and direction, we need to add value to this 3 70 existing.

  • Manu and we wanted to move on the left hand side direction.

  • We need to decrease its value from it.

  • So I'm gonna just call it over here, create a new available and call it player X underscore.

  • Change equals two.

  • And right now I'm gonna give it value off.

  • Zero on inside our if conditions.

  • When the left key is pressed, I want it to increase by cedar 0.1 on Gwen.

  • Sorry.

  • Decreased by 0.1 on.

  • We don't change the Cedar 0.1 number.

  • It basically signifying the speed with which you born the object Move in thi

All right, guys, welcome to the spite on game development.

字幕と単語

ワンタップで英和辞典検索 単語をクリックすると、意味が表示されます

A2 初級

初心者のためのPygameチュートリアル - Pythonゲーム開発コース (Pygame Tutorial for Beginners - Python Game Development Course)

  • 0 0
    林宜悉 に公開 2021 年 01 月 14 日
動画の中の単語