Recreate FLAPPY BIRD in just 13 MINUTES (Godot Game Engine)

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey heard you want to be a game developer well stick around because we're going to be ripping off flappy bird with godot in just 13 minutes [Music] [Music] first off node 2d let's start by renaming it as player node and by adding our first child node kinematic body 2d we're going to want to rename it as player as a child of the kinematic body 2d we're going to want to add in a collision shape 2d as well as a sprite 2d to make up for the form of our player lastly would be an area 2d with another collision shape as its child which will serve as our hitbox digging in deeper into each individual node let's start with our sprites your sprite node is going to serve as your physical representation of your player so add in an image of your preference any image would actually do but in my case i'll be using a 16 by 16 white square drag the image towards the texture tab in the inspector window and congratulations you have gotten your first sprite node to work next up collision shape click on the collision shape node and the inspector window will allow you to choose your preferred shape in my case i'll be using a rectangle which i'll be setting the extents to perfectly match our sprite note earlier next up would be the collision shape for our arroga 2d node we're going to be following the same process as we did with the previous collision shape however this time we're going to set up the collision shape that it overlaps the sprite node just a little bit this would help us identify collision and for us to easily call functions later on it seems that we're about done sounds easy let's move to something a little bit harder coding [Music] first we're going to be laying out our variables let's start with the constants up would be a vector 2 indicating the upwards direction through an x and y axis we're going to want to add in another constant to indicate the strength of each flap and constants to indicate maximum fall speed and gravity we're going to be adding in a variable for a blank vector 2 and we'll be using this as our controller to indicate direction on our physics process function we'll be setting it up that gravity will be pulling our bird down gradually until it accelerates and gets capped towards the maximum fall speed now before we get any further we would need to set up our input maps based highly on preference so i'll be mapping the flat button to my spacebar [Music] now we're down to our first if statement if we were to press space on her keyboard the player would be propelled upwards on its y-axis oh and make sure you put as negative that it goes upwards now for all of this to work we will need to set our motion variable to an inbuilt function called move and slide this would help the engine identify linear movement and collision and the next thing that you need to do is save your scene i don't know man that sounds like a lot of work for our walls we would need to have a new scene set up we're going to be naming our node 2d as wall node instead of using a kinematic body we'll be using a static body which we're going to name walls with three children namely sprite collision shape and light occluder we're going to be using the same image for the sprite however this time we'll be scaling the image that it sort of looks like a wall and you'll also need to move your first wall upwards what's this looks like sprite's going for a name change he wants to be called the upper wall sprite for some reason next up collision shape just like the previous collision shape from player node we'll be setting the collision extents that didn't fit the spray perfectly once you're done he'd like to have his name changed too next up would be your light occluder on the inspector window create a new clutter polygon click this button right here and trace the edges of your walls until you close it up adding light occluders would help us simulate dynamic shadows later on light occluders are optional but i tell you it's gonna be worth it hold shift and select all three child nodes right click and select duplicate now we have three extra clones to deal with instead of having our clones named as upper wall nodes we'll be renaming them one by one lower wall nodes to move them downwards remove the negative sign and the y-axis in position doing so would give you equal distance between both upper and lower walls now we're going to be doing the same process for all three clones however the position may come in differently for the light occluder make sure that it fit perfectly with your lower wall shape and we're just about done we're going to be adding in yet another area to denote as a child of her static body along with another collision shape as its child will be setting the extents of its collision shape that it would cover the whole entrance between both upper and lower walls this would be for the purpose of detecting our bird as it passes through later on next up click on the static body and brace yourselves because we're going to be doing some more coding first remove all the crap you don't need second under the physics process function we're gonna be setting the body's position and that it is constantly moving two points per tick to the left third well there is no third that's about it again make sure you save your work and we're going to be moving on to our next scene down to our last scene we're going to want to rename our main node 2d as world instead of adding in another node we're going to want to click this button right here doing so allows us to instance the other scenes into this new scene that we have in front of us in this case we're going to be adding in our player scene right click on your player scene and select make local doing so would localize our player node making it possible for us to gain access to our player's child nodes next up we're going to be adding the wall nodes as well click this button right here this one that one and uh those buttons there too doing so would allow us to drag nodes along with their children through gridlines making it easy for us to move the objects through the scene next would be a camera 2d as a child of her world node set the zoom extents to 0.5 or any zoom level of your preference just as long as a portion of your walls will be cut off of the screen as an allowance for movement later on save your scene right click on the world scene and set it as your main scene next hit the play button and congratulations you are awesome you have successfully made flappy bird if you did hit the subscribe button ring that bell just kidding we ain't done yet duplicate your wall nodes and move the clone 5 grids to the right make sure to randomize the height for an extra challenge do this for about um five times next up add yet another area 2d along with a collision shape as a child of her player node rename the node as resetter and set the collision extends to something like this make sure to have it outside of the camera balance i'll be explaining why later click on the resetter and inside the node window just beside the inspector tab click on body entered and connect the signal to your player body you may notice a new function added to your code but don't panic yet we're going to be adding in a variable to spawn additional walls into the game right click on your wall scene and select copy path paste the path into your preload variable as a string next up we're going to be setting up another function for a wall spawner first add in a variable to have your wall instantiated and set the precision of the instantiated walls to a constant 450 on the ax axis and a random number between negative 60 and 60 on the y-axis doing so would help us have that flappy bird difficulty with the randomness of the wall's height next would be a code to have the wall scene spawn once this function would be called wherein the instantiated walls would become a new child of the parent node on the function from the area 2d we'll be setting an if statement to identify the body that would enter the area if a body with the name walls enters the area the body would be deleted and we would be calling the function to reset and spawn an additional wall if you followed everything correctly the game would then look like this to break the illusion here's how it looks like if you zoom it out [Music] [Music] for the detect node connect a signal to area enter this would give us yet another function to work on if our player's area 2d collides with another area named point area which is basically the area in between the walls we're gonna be giving our score variable additional one point whenever it happens and we're going to be doing another signal if our player's area 2d collides with a body namely the walls our scene would be forced to reset so i wouldn't like to end the video without making the game look cool so we're going to be adding into additional nodes under the world node a canvas layer with a rich text label as its child don't forget to enable viewport follow for the text label and move it somewhere right above here or any of your preference though write this very long line of code down on your player body as this would allow us to access the properties of the rich text label despite having them in separate parents after doing so we would now be able to set it that the rich text label would be showing our current score variable [Music] before we celebrate success we're going to be adding in a sprite node under our world node again we're going to be using the same white square that we have been using earlier however this time we would be scaling it that it covers the whole screen and we'll be setting the z index to a negative number this would force your sprite to go underneath all other nodes making it look as if it's the background [Music] change the colors to something of your preference though i highly recommend setting it to something of a dark color reason why is we're going to be adding in a light 2d note as a child of our player upon adding the light 2d node add in an image of a spotlight into the inspector window don't forget to enable shadows and once you're done you may now hit the subscribe button [Music] [Music] me [Music] so [Music] so [Music] [Music] [Applause] you
Info
Channel: Eli Cuaycong
Views: 24,028
Rating: undefined out of 5
Keywords: godot, game, development, gamedev, developer, GDscript, game engine, how, programming, coding, beginner, game developer, GameDev, Devlog, Indie, Game, GameDeveloper, Godot, Game Engine, Unity, Game Development, 2d, Platformer, Side scroller, Programming, Code, Coding, ludum dare, game jam, tutorial, to, gaming, make, create, making, code, indie, how to, making a, make a, top-down, devblog, dev, movement, 2d-platformer, 2d platformer, side-scroller, sidescroller, flappy, bird, flappybird, short, quick, game mechanic
Id: Kt1njjNGbSg
Channel Id: undefined
Length: 13min 23sec (803 seconds)
Published: Wed Oct 07 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.