[Godot Tutorial] Basic Breakout! [P1]

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
good morning afternoon or evening wherever and whenever you are my name is Benjamin and welcome to another game making tutorial this isn't a game maker tutorial this is going to be a tutorial on the Godot engine I'm going to pronounce it Godot because their logo is a robot and they rhyme and also because I've seen the developers and they pronounce it Godot so that's why I'm choosing to other people like to pronounce it Godot or gato because of the story the play you can look that up if you want to but I'm choosing to pronounce it Godot now I'm not going to quit game maker so don't worry about that there's more game maker videos coming soon and I'm excited to get those to you so don't worry about that I just want to show you guys some of the things that Godot can do I've been learning it I quite like the engine it's free and open source some of the things I like about it is the EV runs on PC well I guess Windows Linux and Mac OS so it will run on all three natively so no matter what system you're using you can start using this engine and that's kind of cool it's free and open source I don't remember if I said that already or not so you can go to go to engine org and you can download version 2.0 and it's a pretty nice little engine for being free and open source so you can donate here if you like the engine I recommend doting donating to them to help with the future of the project since it's free so just go to download and download the engine it should just give you a single file that you run and once you've done that you can run the engine and you should come up with a screen something like this now my I change the font size so there's a few little glitches because of that because of the font size change that I did I made it quite large to make it better for tutorial videos so you may see those come up but I didn't have any issues when I had the smaller font size and I didn't mind their font size I just needed it bigger Oriol videos so we're going to do a new project and we're going to browse the project path and go I've already created a folder called project so I'm going to go into that folder and then I'm going to create a new folder and I'm going to name this folder die bricks video and then I'm just going to press open and hit create okay so I've got this project right here die bricks video now if you guys want to see what we're going to be making in this series I can show you that let me run the project real quick it is a simple breakout clone and you can see we've got up all moving around we can destroy the bricks and we can aim where the the ball goes based on where it hits the paddle so the player has control over that so pretty cool simple little project that we're going to be doing for our first Godot project so let's open up die bricks video and it will open up the Godot editor and you can see Godot supports both 2d and 3d its native 2d which is really nice so we're going to be switching to 2d and this is your scene now your scene is kind of like your level your game level there's a lot more that you can do with the scene than just use it as a level but we're not going to go into all of that right now now if you want to you can run your game by pressing the Run button right here but we don't actually have anything inside of here in this scene isn't actually saved so over here on the left you can see this little area this is the resource well this is the this is the tree for the elements inside of the scene and down here is the file system and then over here on the right is the inspector so when we click on it's called a node when you click on a node inside of the tree over here the inspector will give you information on node so I'm going to create a new node and you can use a little this little icon right here now every scene needs a base node so we're just going to do node 2d and this will be our base node it's a node that doesn't really do very much it has some properties attached to it but not a lot so I'm going to name this world because it's the base node that all of our other nodes will be in you want to make sure as you look over here you can see the information on this node you'll want to make sure that its position is set to 0 0 right up here in the top corner ok now we're just going to hit a ctrl s to save this scene and I like to organize my project so I'm going to do create folder and name this folder scenes ok and then I'm going to name this scene level 1 dot XML you can save the scene as a few different types here but I like XML because it's easier to edit later or if you're using version control like git it's it's much easier ok we have our level now we don't have a lot going on inside of this level yet so let's get started with that the first thing we're going to want to do is create the paddle so click on the world node that we have and click new node and we're going to create one of the physics bodies if you type in body it will give you the different physics bodies that you can use inside of Godot now there are three main physics bodies and and we're going to use all three and part of the reason I chose this example as the first tutorial was because it will teach you how to use the different physics bodies so a static body is kind of like it's it's a physics object that would be solid it's not going to move at all but it will prevent other physics bodies from entering the area but you shouldn't move it it's generally not intended to be moved so this will be a good one for our bricks a kinematic body is a body that collides with other physics objects but it doesn't actually have physics properties that move it like forces that move it it's designed for player characters where you might want to have that character collide with the other physics objects but you want to control its physics and have it have a simplified version of physics so maybe you have your own gravity so that you can do something like a Ledge grab so that's the reason you'd want to use a kinematic body a rigidbody is just a normal physics object it's going to move it's going to have forces applied to it and it's going to react according to those forces and properties so for the paddle we're going to want to use the kinematic body because we don't really want it to have a gravity we don't want it to have all the properties of a physics object but we want our physics the other physics objects to be able to interact with it like the ball so select the kinematic body 2d and rename this paddle okay so we have our paddle it's in the world but there's there's we can't see it because it's just an empty node so now if we want to see this node we'll want to attach a sprite to it now when you create a new node it will create it as you can see that the paddle is now a parent of the work or a child of the world node so every time you create a new node it's going to add it as a child to one of the other nodes and it's going to do that depending on which one you have selected so we want to select the paddle node and we want to do create new node that way this new node will be a child of the paddle node and I'll show you what that does so look up sprite and choose sprite right down here make sure it's the blue one you don't want sprite 3d so sprite and you can just leave it named sprite now I'm going in the description there's going to be a Dropbox link where you can download the resources to this so I'm actually going to go get them right now I have those resources so if I come into documents and instead of Godot projects die bricks sprites ok so there's three sprites here I'm just going to copy these you should already have these and I'm going to go into here and I'm going to create a new folder new folder and name it textures or sprites I'll do it textures oops I want to ask on their textures and then I'm going to paste those inside of here so I've got ball brick and paddle for those textures now you can see that they'll show up down here inside of our file system here is textures if we go inside of here we have these three textures okay now when we select the sprite node you can see it has a texture property but it's set to null so click on that and do load and go into textures and do paddle now you can see up here if we scroll to zoom in scroll to zoom in middle click to pan if we scroll to zoom in we've got our paddle but it's pretty small compared with the rest of the room here so we're going to do a couple things number one we're going to scale it so make sure you've got the sprite selected and come over here and switch the scale to 2 and 2 press Enter there we go it is scaled now what we're going to do is change the viewport size because it's actually pretty large so if we go to scene and then go to project settings and then display you can see some information on the display we're going to set the width and the height and I'm going to do 640 by 360 we've got a nice width and height I'll press close you can see it updates the width and height of our scene right here and we're ready to go that way now let's save the scene and we're going to move the paddle but I want to set snap inside of the scene so if you come to edit right here click show snap or use snap and then show grid and then configure snap you can see mine's a little messed up here because of the scaling and we're going to do a grid step of 16 actually I might go to 32 and 32 for now there we go and then we select the paddle but you want to make sure that you don't select the the sprite node because you can select the sprite node and move it but we don't want to we want it to be attached to the paddle so we're going to lock it that will prevent this from selecting the sprite node but now we can select the paddle node and move it around in the room I'm going to put it right there I'm going to save the scene just using ctrl s and then you can see I can press this little Run button and it will run the scene and there we go we've got the paddle inside of the scene but we can't do anything with it yet I'm going to move it down one more so it's a little lower now we can't use this play button it says no main scene has ever been defined select one from the project settings under the application category I see so we haven't defined our main scene that's the starting scene but if we go to scenes and we go to project settings you can see under application right where it told us there's a main scene we'll click that and then select a file and go into scenes and select level 1 now our main scene is selected if we press this run it will just run the game automatically and you can now hit f5 to run the game as well now let's add the ball in so click on the world node that way when we add this new node it will be a child of the world and we're going to add type in body we're going to add a rigidbody 2d because that's what we're going to use for the ball okay name this ball and then I'm going to add a new node to it make sure it's selected and I'm going to do a sprite sprite and I'm going to select the texture load texture the ball and I'm going to scale it I'm going to give it a scale of 4 actually now it's all fuzzy and you probably are like why is it fuzzy well if you come up to texture up here you can see there's a little arrow click on this arrow and you can see Godot has generated some flags here now the reason is because 3d games that these flags are really useful for making 3d textures look a little bit better without actually having to have large textures so but we don't want them in a 2-d game because they mess up our pixel art so we're going to come in here and we're going to uncheck MIT Maps and we're going to uncheck filter because we don't need either of those now you can change the default way that it imports textures so that you don't have to uncheck that for every single one I'm not going to worry too much about that right now I'm just going to uncheck both of them on these two images okay okay click on the sprite for the ball and we're going to lock it as well make sure you lock it and then we're going to click on the ball and we're going to drag it right above the paddle here now because this ball is a physics object you can see when we click on it we already get information about it over here so it has a way it has a bounce it has gravity a bunch of information we're going to change these properties we're going to change the bounce to one so that it bounces we're going to set the gravity to zero and we're going to set the gravity scale to zero and we're going to set the linear and angular dampening override to zero because this will make these two things we'll make it so that the balls kind of slows down as it's moving through the air and kind of adds air friction air resistance I guess we don't want that so we want to turn those off because we want this ball to continue moving at the same speed that it starts out as unless we tell it to otherwise and then we're going to set if you scroll down a little more you can see let's see where is it Elle velocity here we go so we've got our velocity and our linear velocity we're going to set this to 200 and the X and negative 200 in the Y and save our scene now when we press sf5 the ball flies off in that direction right looking pretty good but it doesn't bounce off the edges of the room so we need to create those walls to make it bounce off the edges of the room so click on the world and add a new node and we're going to do the last body that we haven't done yet which is the static body the one that doesn't move and we're going to name this walls now currently our walls they don't actually have any sort of a collision attached to them and neither does our ball or paddle so we need to make sure that they have a collision attached to them so that the game knows kind of the area that they take up inside of the physics world so with our wall we're going to add a new node and if you type in poly you should get a collision polygon 2d right here and this is what we want now that we've attached this collision polygon to the I'm just going to rename it collision and but now that we've done that we can actually draw this polygon that will make up the collisions so if you click this little edit button here you can see that it's only available when we're actually on the this polygon node the collision polygons but if you click this right here we can actually start drawing a polygon I'm going to start just below the room on the on this green line here and draw a nice big wall that surrounds the outside of the room and let's actually try that again turn off let's turn off editing here because it didn't seem to work so let's try this one more time make sure your snap is set yep snap is on click on the collision and try again okay come around the outside edge here there we go okay not sure why it didn't complete it last time but it seems just clicking over here and redoing it seemed to have worked okay so our walls now have a collision right there done but the ball in the paddle don't so we need to add one for those two so let's start with the ball click on the ball node click create new node and we're going to do collision shape 2d instead of polygon because the ball is just a square so over here we will change the node name to collision and over here we can create a new shape you can see it says shape and it's null we're going to create a rectangle shape and that creates a collision but it's too big it's bigger than the ball now we could use we could use these little red dots here to edit it but make sure you don't use the outside red dots because these outside ones will scale it and scaling collision shapes doesn't work not if you're using these outside ones or the scale you want to make sure you use the inside dots but if you want to be a hundred percent sure you're doing it right click this little arrow over here and you can just change the X tense so I'm going to change these to 4 and 4 maybe yeah so 4 and 4 and that guess gets us the exact shape we need for the ball so now let's save and run the game and that wasn't exactly how we wanted that to work right it killed it hit the wall but then the ball started spinning and kind of weird stuff was going on so we want to prevent the ball from spinning so click on the ball here on the ball node and you can see that it has a mode if we set it to character mode that will prevent the ball from rotating when it hits stuff that's what we want we also want to turn off the friction because you can see there is enough friction that it stopped the balls movement when it hit the wall so we're going to turn friction off now let's try running our game and see what happens okay that's more like how we want the ball to bounce but it didn't hit our paddle so let's fix that come on to the paddle add a node we know how to do this collision shape to D and rename it collision we're going to give it a new shape which is going to be a rectangle and we're going to change its extents because that's the easy way to solve this problem so we're going to do thirty six maybe forty forty on the X and four is four too small for on the Y note looks like four is just right so forty on the x four on the way okay now our paddle has a collision attached to it so when the ball comes down it'll bounce off the paddle so we've already got the collisions and physics working for this game really cool looking that's all we're going to do in this tutorial I'm going to do prop this is probably going to be at least a two part series maybe a three part series so in the next series I'm going to help you write your first line of code inside of the engine to where we can move the paddle around inside of the room so thank you guys so much for watching hopefully you guys enjoy this video you can appreciate this engine that's a little bit different from game maker and I hope to show you guys more of it and the things that I like about it thank you for watching if you enjoyed the video be sure and like favorite and subscribe check out my website there's a link in the description and I appreciate you guys to support I'll talk to you guys later
Info
Channel: HeartBeast
Views: 224,679
Rating: undefined out of 5
Keywords: Game Design, Game Development, Indie Game, Indie, Tutorial, Video Games, Game Builder, Programming, Coding, Art, Godot, Godot Engine, Godot Tutorial, Godot Engine Tutorial, Free Game Engine, Open Source Game Engine, Linux Game Engine, Breakout, Brick Break, First Game, Physics
Id: ntYjl_obUDo
Channel Id: undefined
Length: 23min 39sec (1419 seconds)
Published: Fri May 06 2016
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.