Create Flappy Birds clone in GameMaker Studio 2 [DND] with random pipes

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
okay in this quick tutorial we are going to make a flappy bird's clone and we're going to import a few sprites we're also going to have the bars hopefully coming in in some sort of random order um and we are going to obviously say things like backgrounds and we'll look at running some sort of score in there as well so the first thing we're gonna do is i'm gonna click on my sprites folder and i'm gonna right click go to create and then i'm gonna click on sprite so we're gonna name this first sprite s player and what i'm gonna do is i'm gonna import a few of the sprite images now handily i've got a small folder somewhere here here it is so this little folder here has some sprite images in it so you can see i've got a yellow bird so i'm just gonna drag that down a little bit click drag and drop let me just get rid of that for a second uh now it gives me a little bit of a warning you should be able to import these sprites yeah click on yes and you can see my sprite is imported now by default these images are rather small i'm running on a fairly high resolution screen so what we're going to do is we're going to resize all of these three images so if i click on sorry if i click on edit image here and then we go to image and then resize our frames what we can do is we can change it to be a certain um size now even by default a set of pixels you've got a percent as an example you can add this to 200 as an example there and if i say linear interpolation click on apply now it looks really blurry but trust me it's basically double the size of it so when you zoom back out it's uh it's not too bad so hello it's still relatively small 268 by 48 pixels that'll be enough for this type of game okay so we've done that now i'm going to click on the close there for s player sprite and i'm also going to just change this origin here where the collision is going to hit so i'm going to say middle center and that is pretty much done now if i click on the play let me just zoom this in a little bit if i click on the play what you'll notice is a little bit there it is flapping quite quickly so we need to stop that and we need to slow it down so i'm gonna just adjust my frames per second there i'm gonna use six so basically what that means is every second it's gonna play six frames well you can see there we've got three so basically this animation will play twice every second so if we click on the play there you can see that's not too bad now if you wanted to you can up that a little bit so if you want to do 12 or 24 or something like that you can you can change the values there so i'm happy with how this is so let's close it and let's make an object so let's right click go to create and go to objects and we're going to call this o player and we're going to then select the player sprite by clicking on the sprite option there go to player and we're done now i'm not going to put anything in this at the moment but what we are going to do is i'm going to put this directly in my room so if i double click on the room and just drag my object on and let's play this see what happens lovely so um we under mature already but you can kind of see there now my uh object is flapping and it's uh happy there now it can't move because we haven't set anything to move yet but you can see the animations play within the room so that's a good start so let's close the room and let's add in a few more things so uh back in my images here you can see i've got a background and i've got my uh base and i've got a few other bits and bobs here we've got the pipes so we're going to look at importing these now so the first thing i'm going to do is right click on sprites go to create and then we're going to create another sprite and this one's going to be called s background i'm going to go to i'm just going to drag this image in here now really quickly so that's my first image there now you can if you wanted to resize it it's 512 pixels high by 288 pixels i'm probably going to keep it i tell about let's edit it slightly if you go here let's go to the image and let's go to resize all frames so let's make this image say 700 now what you will notice because i've got this maintain aspect ratio on if i change one part of this and click in the other it'll maintain obviously the the sort of structure of our um image so if i click on apply there great that's done it says close so i know my room is going to be just over 700 high because i'm going to be putting the bottom part on it and let's add in another one there for the base so if i right click on sprites go to sprite and we're going to call this s i can call it base of flow i'm going to call this floor so i know what it's doing or drag that in click on yes and there well we've got that in which is nice okay so i'm going to just click on i to be honest i don't need to change any of the markers in there so if i close that that's done and let's close that background as well so if i go back to my room double click on my room you'll notice on the side here i've got layers on the right hand side so if i click on my background layer by default it's set there to color black and no sprite so if i click on my uh no sprite there and we select our background you can see now my background's added in which is quite nice what we can do is we can tile it so i can tile it vertically or i can tile it horizontally or if i really wanted to make it awful i could stretch it out so let's tie lap x is a nice repeating pattern and let's just see what that's done so there you are we've got the start now of our game where we've got the background in we're now going to look at putting the floor into the bottom and then uh we're going to look at iodine gravity and getting a little bit of movement there as well okay so what we can do is we've got a horizontal speed and a vertical speed so let's say for example we wanted the background to appear to be moving so if i do this as a say minus five as example if i play that you can see there now the background appears to be moving well i say appears to be moving it looks if it's moving it looks as if my little bird is actually flying in the background is going there now minus five maybe a little bit quick so we can change that and we can make a little bit smaller and obviously that'll alter the background speed for you okay so let's add in another object called flow so create object and we're gonna call this s flow and we're gonna then select strike object sorry i should have called the s flow i need to call it overflow so click on sprite click on flow there that's okay and let's go back to our room and we're gonna just drag that into the bottom now notice when i try and drag this in it comes up with a little x i know it's quite small on the screen here that's basically telling me that i can't drag it into a background layer i need to be on my instances or i need to create another instance so that's what we're going to do we're going to create another instance i'm going to rename this instance and we're going to call this flow and i'm just going to drag this down a little bit and then make sure i'm on my flow instance and we're just going to drag that in there and it doesn't matter if it's slightly off the uh the thing there and what i'm gonna do is i'm just gonna stretch this out a little bit now i'm gonna change my room width uh ever so slightly so if you notice my room is 1366 wide so let's change it to 800 see if that does yeah well that's enough and just gonna drag that a little bit more and that'll be okay right so so far i've got my player i've got my floor and we've started animate the background which is great so let's add something called gravity now to our uh player so what we're going to do is double click on our player and then once we've done that we're going to now look at adding in our gravity so we are going to look at clicking what's called a step event now the step event happens every step of the game so in our game at the moment it's set at 60 frames so every step will obviously run 60 times so if i click on add event let's click on uh cr step and then begin step and what we're going to do is we're going to look for the gravity option now you could if you want to do manually make this but i'm just going to use the inbuilt gravity for now so i'm going to set that at a force of 0.5 and let's play let's see what happens so hopefully now what you should see is my flappy bird just falling out to the sky gone lovely okay fantastic right okay so our flappy bird now has fallen obviously we haven't put a collision on yet so if the if the bird does hit the bottom here it's not going to do anything but you can see the gravity has worked so let's add another thing uh what i want to do is basically when i press the space bar i want the bird to go up i want a little bit of vertical um a little bit of vertical speed put on him so i'm going to click on add event and then we're going to go down to key press and then we're going to look at space so what this does is it's basically a key press event so every time i press the space bar something is going to happen so what we want to do is i'm going to look for my speed option i'm going to drag that in and we're then going to say we want vertical speed and because we wanted to go up we're going to have to put a negative figure in and i'm just going to put a negative 7 there for now so if i just play this just show you what happens so every time i press the spacebar you can see it's going up and then the gravity is still pushing me down so this now is the first part of our game nearly set okay let's just close that that's great so what's the next thing we need to do well the next thing we're gonna look at is getting our bars in so i'm just gonna close everything a really quick trick for you if you wanted to close everything to make uh everything look quite nice if i right click on here go to windows and then close all it makes the workspace much much neater so i know i've got everything there ready set to call okay so we're gonna now add in some bars so i'm going to right click on my sprite there and i'm going to go to create sprite i'm going to call this uh espa or s topper and then we're going to import the image so i'm gonna just drag this image in now you notice this bar is the wrong way around right so this is actually the bottom bar so what we're gonna do is we're gonna use the image editor inbuilt so i'm going to click on edit image and then we're going to go to images and then we are going to flip so we're going to flip all frames and you can see now that's gone the other way which is good so i'm going to close that one and then we're going to do the same thing then for a bottom bar now what you can do if you want to do then just copy that but we're going to add in another sprite instead so right click create sprite and let's call this one s bottom bar and then again we're just going to import this image and this time we don't have to flip it because it's the right way around okay now we are going to change the origins on this but we'll do that late then i'll tell you and explain to you why we'll change it later on right so so far i've got my sprites let's create a few objects for these so if i go to create object and what i'm going to do is click on object and we're going to call this one oh bottom bar just select then the correct sprite i'm just going to click close for that for the moment and then let's create another one and we're going to call this oh topper okay so let's close both of them and what we can do and what some people do is this they just drag in a lot of bars now one thing i just want to be wary of i'm not spacing these out properly at the moment i'll explain to you why so if i just drag in the top bar there another moment and the bottom bar what some people do is they basically add in a number of these so if i copy and paste it and then basically they'll they'll have a load of bars outside of the room and then what you can do is with the bar object i'm only going to do it with the bottom bar at the moment but you can basically say this so add event create and then we can use the speed variable and we want it to be a horizontal speed minus five so what you can see happening now is those three bars will obviously appear to be moving um and that does work the downside with using that methodology is that you would obviously have to have a finite number of bars so if you can imagine this is my world you could if you wanted to have all these bars if i just drag these over here so you could if you really wanted to just have in loads and loads and loads of bars move them over i can have all the bars here and then that would appear as if everything is uh is moving normally but we're not going to do that we are going to try and make these bars appear at a random point uh in time right now to do this we are going to use something called an alarm and we are going to use um an alarm every sort of few seconds right so what will happen is the alarm will basically trigger and then one of these will move in at a certain angle and then once that's gone another one maybe they're made at the top and it'll drag over and so forth so i'm just going to delete all of these just to get rid of them and then we're gonna start making our alarm okay so we're gonna now get our bars to move across our screen okay so to do this what i'm gonna do is i'm gonna make a new object and i'm going to call this one game manager so right click on objects go to create and then click on object so i'm going to call this o game manager and you'll notice i've just typed this in directly here and it'll set the name now when i press enter you can see that it's done and we are now really ready to go now the reason i've made a new game manager is because the code that i'm going to be putting in here is going to have influence on a few different objects it's going to influence our bottom bar our top bar and another object which we'll create later on to work out our points so what we're going to do is we're going to use something called an alarm now an alarm is an event which can happen at specified time so i'm going to click on add event and we're going to go to alarm and i'm going to start with alarm zero so this first part is essentially my first alarm so we're gonna start by adding a random number so i'm gonna say get random number and you'll look this it's the dice event now you can see mine's at the top because it's recently used but if it's not there with you just look on the bottom and it's under the random so i'm going to click drag and drop that in we're then going to make a whole number so an integer and we're going to give it a value of between 5 and 100. now we can change these values we'll play around with them later and then we need to take a target variable and we're going to call this one top bar now you notice i've just typed top bar in this is a random variable that i've just made here now it's not an object or a sprite so leave it at that we could make it temporary if we want but i won't need to do it for this moment in time so what we want to do then is we want to create a new instance so a new object on our canvas so what i'm going to do is i'm going to look for the next one which is create instance which is the light bulb and what we want to do is i want to create new objects we're going to do the top bar first and what i essentially want is it to be in a certain position now if i just open my room for a second there's a built-in variable called room width which automatically gets the width of the room now we've set ours to 800 to be dynamic i'm going to use the variable room and the score width and what we're going to be doing is this we are going to be if i just drag one of these in really quickly we're going to be making the object outside the room and then it will appear to be moving out and then when it goes outside the room again we'll just remove it we'll delete the instance so the idea is we could if we wanted to just create the object randomly here and then have it moving but it's nicer really to make it outside the room and then have it appear to move over so if i go back to my game manager so we're going to create new object we're going to use room underscore width and then i'm going to say plus 10 so that means it'll make it 10 pixels outside the room and we're going to use the y variable top bar notice i've used top bar with a capital b because i've used capital b here now where do we want to place this well we don't really want all our instances layouts my my flappy birds on there at the moment so i'm going to create a new instance layer and i'm going to call this one if i right click on it rename i'm going to call this um random bars press enter and i'm gonna go back then to my game manager and when we put the layer let's change that to random bars note this if you've used capital b or capital r as an example you have to then obviously do the same with that and then what we want to do is set the alarm so we kind of once the alarm is repeated once we then need to reset it again so we're going to look for the set alarm countdown because we want this really to run every sort of 60 seconds i see every 60 frames every one second so i'm going to change that alarm 0 to 60 which is good now we need to um start the alarm off so we need to create an event so if i click on add event go to create and then we're going to set the alarm again so again it's alarm 0 after 60 frames and then we should be nearly ready to go now when we play this nothing's gonna happen in fact i'm not gonna play it yet and i'll tell you why at the moment the code there should work but what will happen is the object will be made but it won't move all right so the object will be made but it's not actually going to move and not going to do anything so what we're going to do is we're going to open up my top bar and i'm going to click on add event create and what we're going to do is just add in as speed set speed i want horizontal and we're going to set the speed to -5 so that then should mean the bar once it's created will start to go across so there's one last thing we need to do before we uh play this game we need to make sure the game manager is on our room so i'm going to double click our room and i'm going to drag the object gear manager on and you can see i put this in the top left hand corner it doesn't really matter where this goes the reason i put it there is essentially so i can keep track of it you'll notice there is a question mark that it's um that it appears as reason being is there's no sprite attached to it because we don't need a sprite attached it's going to run things for us and it's basically going to make instances of our object uh here so let's play that and see what happens okay so our flappy birds are gone and you can see the bars now are appearing and they are not appearing completely random i haven't uh dragged a lot of bars in they'll take the room these bars now are appearing um as the random number generator is building so you can see that has worked quite well so the next thing we're going to look at doing is creating the bottom set of bars now for this so i'm going to open my game manager back up and what we're going to do is we're almost going to duplicate this create instance event it's eventually pattern so instead of obviously the object being top bar we're going to build a bottom bar and the room width is going to be exactly the same so room with plus 10 so we want it to be made outside the room and what we're going to do for the y is we're going to say top bar plus 500. so what this will do is it'll put 500 pixels between the top and the bottom and we're gonna then uh say to for it to be on the random bars now this isn't going to be exact we have to play around with this variable for a moment so let's just see what that does so let's play and we're up so flappy's gone and you look this now the bottom bars coming in but there is a very slight issue the issue is these bars aren't perfectly aligned which isn't brilliant but we can change that very very very easily and you can see the bars on top of our little floor as the floor was passed so let's sort those two problems out so the first thing is gonna be quite easy to fix if i double click on the bottom bar then this sort of anchor point here at the moment is set to the top left so if i set it to say top center or even middle center like the other one let's play that so flappy's gone what you'll notice is these now are much better now you'll notice they are the width there is always going to be the same because they are going to be up and around you'll notice they are a little bit higher than what you would expect but don't worry because the um floor now is going to be moved in front of these bars so these bars are randomly being created which is great so oh there was one that was a little bit too high so we may need to change our uh variables here in a moment i don't know if it's going to happen again because these are all obviously being randomly created so that was very close very very very so what we can do is we can set the minimum they are looking to see there so we can set the minimum height so let's change two things here let's go back to our game manager and let's set the minimum now to say 10 pixels and what we're also going to do to sort that issue out where the floor is underneath the bars i'm going to take the floor layer and just move this up and put it above all of our instances it doesn't really matter that it's it's there so let's play that okay so flappy's gone and you can see now the bars are lovely and they're perfect there as they are which is great so the next thing we are going to look at in this game i was putting collisions in with the bars and obviously the floor then to run the vent obviously when this happens just before we do that let's double click on the bottom bar and let's add an event so when we collide no sorry when we are outside of the room so with the bottom bar we did this with the top one so when we're outside of the room we want to destroy that instance otherwise uh we're gonna have a build up of uh bars and we don't really want that we don't want instances uh if they're not in use we just want to destroy them so that will make our program a little bit slicker next on the list are collisions so when we play our game what we want if i just replay it uh what we want is that when our flappy bird is going so when he's or she is going we want to be able to go through here no problem but if we hit one of the green pipes we want to at the moment we start the game now we will do something later maybe in the video we'll see where we have um a score coming up but essentially for now what we want to do is have some sort of collision event so let's get to it if we open the old player and we go to add event and then we go down to collision object if we collide with the top bar first so if we collide with the top bar what we want to do is we want to restart the room so you can see that's added in there for us and we can do exactly the same then so add event collision object if we do the bottom bar we then again want to add in a restart so the way you find restart if you start looking for just restart you need to reset the room or restart the game at this moment in time it doesn't matter i'm just going to put restart game in there just for us to play around with so you can see i'm flying here no problem and we're making it great but let's see what happens when we hit one of the uh green bars bam so you can see it start again if we try this again again it just restarts there for us so we need to put a collision into the floor as well so if we click on object player again add event collision object flow and just for now we're gonna restart the game as well lovely so we've got now our collisions working so what we are now going to look at is our score counter so in order for us to have some form of scroll character which is up in my room what we want is if we had uh in fact let me just drag that on to here temporarily so if we have our bars here what we want is something in the middle here so that when our little flappy bird goes through so when it goes through the gap we count that as a collision and we increment the score by one so ideally the easiest way to do this is to draw a object or rather sprite and assign it to an object so that when that's clamped as a collision then it'll increment as one so this is what we're gonna do we're gonna create a new sprite so i'm gonna right click create sprite let's have a look and what we're gonna do with this one we're going to click on edit image we're just going to make this really really small and and thin so if i go to image and then we are going to resize our frames and i'm going to untick this maintain aspect ratio and the width is going to be something like i would do something really small five and the height will say 150 right in fact i'm just going to go up to 200 with this just in case we need a little bit more to play with okay so in fact no let's go more school 300 so i'm going to click on apply and you can see there's a really long strip so let's click our pink bucket and i'm going to click on pink so we've got now a strip which stands out now if i close that let's call this uh s score i tell my s score let's call it s4 count and let's then close that in fact to be it doesn't matter where this uh origin is if we put it in the middle center that should be fine now okay so let's go for our object so let's create new object and we're going to call this o score count and that is essentially pretty much done so let's select the sprite and then what we're going to do is we're going to put this into our we're going to add this into our game manager so again we've got these instances let's create another instance i put it in the middle there because that's like our little sandwich so what we're going to do is we're going to have that means the scroll counter again we'll have these set up in exactly the same the only difference we're gonna have on this one ever so slightly is that i'm gonna change the way that this works on our y-axis so at the moment we have our top bar so i'm gonna have top bar and i'm going to say plus 200 now i might need to change this right i might need to change this so we'll see now what that does so hopefully our score counter should start to come in nope you can see it hasn't now the reason it hasn't is because i haven't set the object to move across so again if i double click on scroll counter click on add event create let's move that along let's use the speed horizontal minus five now that should work there up so you can see that's coming in now good right excellent right so what we now need to do is if i make this invisible so if i detect this visible it'll still be there but we won't be able to see it so our little objects are still there and flappy can go through it but we can't see it of the game it doesn't show it to us but it is still being generated in this field in there so what we're going to do is we're going to add in a collision so we're going to basically say when our flappy bird collides with our object we're going to add some points on now we can do it in two ways i'm actually going to do it a slightly different way so i'm going to go to scroll count so i'm going to say add event so when we have a collision with the player so notice i'm doing this in exactly the opposite way it'll still work so when we collide with our player what i want to do is i want to first of all destroy that instance and if i don't every time that the flappy bird goes through it it's just gonna keep on adding one one one one one i don't want to do that so i'm gonna add in a new variable and i'm gonna call it score now there is already a built-in variable called score so that's fine so i'm going to say one and i'm going to make that what's called a relative so what's going to happen is every time we hit one of those pink bands one will be added to the score now if i detect that i'll check out uh what it'll do a little it'll only set the score to one so it'll never increment so by adding relative there it'll always add in score now what i'm going to also do is i'm going to use the debugger here and we're going to add the debugging and the debug is going to show us the variable score so another one score now what's going to happen is at the bottom here we've got the output we should see the value just incremented so let's play this and we'll see then if everything's right okay so keep an eye on the bottom here so i'm going through the first one look that's one that's two that's three four five lovely okay so you can see that's working quite well um although i can't play this game that well but you can kind of see there that's working now our score doesn't actually reset the zero so we can sort that out in a moment but you can see that's uh working quite well okay so first of all let's go back to our player so we need to go back to our player object and what we're going to do is in fact we're not going to go back to our player object we're going to make another object because i want to display the score now in order to display the score i'm going to make a points manager now in order to make the points manager it's just going to be relatively sort of easy um what we're going to do is we're going to use something called a draw gui event so in fact i'm probably doing it in my game manager yeah let's keep it all in one game manager so if i click on my gear manager and we've got to add event and then we're going to go down to draw and then draw gui what i'm going to do is we are going to have a score variable appearing so if i go to draw value so i look at the draw value which is this one here you can see it's got caption value and then where you want to put it so if we put it here just as example and we say score and then we use the value is score the variable score what i want to do is i want to put it on the top so room width divided by 2 and then what we want to do is i'm going to put it sort of 10 pixels down so it'll be from the bottom again we may need to change this value to see obviously how it works let's play and you can see there look score is now at the top there and as i go through this it is incrementing up three four five and it's a little bit small so let's sort that out now what we can do is we can use certain types of fonts so i'm gonna make a font on the top here i'm going to right click on fonts go to create and then we are going to go down to font where that is front and i have loaded in a font called flappy bird so if i use font flappy and let's look for it here it'll be under f i would have thought oh i thought i'd load it in maybe i haven't okay so i thought i'd loaded a font thing called flappy font let's open that so definitely it's there just install it all right so it's randomly on my system called zero four b underscore 19 yeah okay so i think that's already there yeah okay so zero b4 there it is perfect um what we want to do is we want to make it quite large so i'm going to make this a little bit bigger there that's about 40 that's fine so that's good we've got our size set there we've got a front set there front flap is going to be called for some reason it's giving it a weird name let's close that let's go back to our game manager and let's now add in a few more things this so what we want to do is we want to set the font which is here so i'm going to set the font to the flappy font i'm also going to set the alignment so if we look at there we are text alignment and what i want to do is h line and v line so each line is going to be center and it's going to be on the top and then obviously that's there so let's have a look let's play that let's see what it's done we might need to change the color in a moment we'll see oh that's okay so you can see my score when i was at the top hey and it's there it's working quite well look so every time it increments it adds downside is at the moment when the game restarts it doesn't reset the score so we can sort that out now in a moment let's look at our player so what we can do with that is we can basically say when the player is created so we've got to create event there look let's set our variable we'll set score to zero not the most elegant way of doing it but it'll work i'm sure let's have a look so score zero there are one two three four there are and we've reset and come back down to zero okay so that's our score done for that one so for our last part of the game we are going to create some sort of overlay which is going to um basically happen when we end the game and we're going to create another room just to have a little um start there before we actually run the game so we'll probably look at doing that first so let's first of all start a new room but before we do that let's rename this room to of course game as an example and then we're going to create a new room so right click on rooms create and then we're going to create another room and we're going to call this um start and what we're going to do is we're going to change the home position on this so we don't want our game to start directly in the game we wanted to start on the start so if i click on this order here and then move the start to the top you can see this home there means that it's going to be the uh the first part of the game now as you probably recall in the game i set the height and the width to 800 by 768 so i'm gonna do the same there so 800 768 and it's currently black at the moment so let's add in uh well click on background instead of no sprite we'll use the same background sprites we've used before and let's horizontally tile it and stretch it out a little bit there okay in fact we probably won't need to we can probably add in our floor uh if floor's not going to really do anything on this one so if i just click on instances drag the floor there that'll be fine okay now what we're going to do is we're going to add in a play button in the top here so i'm going add in a sprite and where's my sprite there's my sprite there it is so we're gonna call this play button i should call it s play button and i'm gonna add in two frames now you'll notice there's gonna be a slight difference to the sun so if i click on this one here play button drag that in so that's one of them and we're going to add in another one now in a moment so if i drag the other one in so the difference between these is one has now to glow on it the other one doesn't and the reason being is what i want to do is when i hover over with a mouse i want that one to view whereas when it's normal i want that one to remove okay so we'll have a look at how we do that in a moment let me set the frames per second to zero because i don't want it um move it all the time i don't really need to change the ordinary at all so that is pretty much done let me close that one and let's go back to my start and what we're going to do is going to make a new object in fact i've got one there so i'll just delete that one because i don't need that one anymore so if i right click create and go to object i'm gonna call this one play button and we're gonna then go set the sprite to play button it's great and i'm just going to just drag that on really quickly to my start bar here so play button is there lovely okay so what we want to do is we want to basically change the um instance so when i hover over it um it's going to do something so the way we do that is if i double click on the play button we're going to add an event and then we want to look for mouse and what i want to do is mouse enter so when the mouse enters uh we need to change it's the frame of the sprite so if you look here you got something it said instance says instance set uh set sprite uh i said it's a scale says alpha in fact if we do here set sprite it's the same sprite but we're gonna be setting free number one and we're gonna do i'm gonna copy that because we're gonna do when mouse leave so my center and then let's do mouse leave says mouse let's mouse leave we're going to paste that in and we're just going back to frame 0 here so let's just try that one out really quickly let's play that one as you can see there's my game and you can see as my mouse enters it it glows so it's acting like a rollover i don't know those leaves it doesn't know i could have done the uh they have to glow a little bit better than this but it was just really quickly just to show you the purpose of this now what i want to do is when i click on that play button i want the game then to start so let's go back over here let's add an event and let's say when mouse left pressed so when i press the left key on the mouse what do we want to do well we want to go to the room so i use this one here which is go to room now if you can't see that go to room it's under the rooms and you can drag that in and we're basically going to say we want to go to the game so we just try that for a second let's play there that works and then it restarts the game entirely which is fantastic that's exactly what i wanted it to do now at the moment the game just ends without just seeing our score so really what we need to do is show our high score for a little bit so if i now close that and in fact what i'm going to do i'm just going to close everything at the moment so right click windows close all and then we can start then by looking at our game sort of high sorry high school game now to go for okay so so far game plays well and what we're gonna do now for this last part is have some sort of screen coming up when the game ends so to do this i'm gonna add in a game over object so i'm gonna call it oh game over and what we then are going to do is we are going to add in a new instance here instance layer and i'm going to call this gui so this is going to be my graphical overlay so if i go back here to my uh image over what we're gonna do is we are going to add an event then we're gonna go down to draw draw gui and we're gonna add a few things in so the first thing that we're going to do is we're going to add in some sort of color overlay so if i click on set draw color so if i grab a set roll so cetera color at the moment is white let's change that to [Music] let's go for a light shade of blue blue is quite nice and click on it okay and what we can also do we can feed that a little bit so if we wanted to set the alpha so draw alpha so we'll set that instead of 100.70 as an example so that'll be slightly see-through which is great and let's go to drawing a rectangle so you can see here we've got your rectangle now 0 zero is the top left corner and then right bottom and there needs to be in the bottom corner so it covers the whole thing so what we're gonna do is we're gonna say room width and room height and i'm going to fill that okay so the next thing we're going to do is you're going to have a font on there now we need to change the color of the font otherwise it's going to be blue again so i'm going to use another pink bucket and we're going to leave that as white i'll be fine we're then going to add some text in so we're going to draw a text value now again i'm just going to make sure it's centered so i'm going to drag that in and we're going to set the font as well because the font is going to be using the flappy bird's font that i've used before so the font flappy and then the h line is going to be set to center and vertical line can be left to top let's draw the value in so the first part is your score so i'm going to say your score and then we're going to use the value of score and what we're going to do is we're going to put that in the middle so i'm going to say room width divided by 2 and then we basically say room height um let's see about forty percent so that's gonna be four percent down now we also need to give some sort of instruction what to do when the game ends so let's drag that in and we can say something like and press i press press enter to restart the now i would use escape but the screen recording software use when i press escape it stops the screen recording so i'm not going to do that again we're going to use the same width there and the height is going to be ever so slightly different so i'm just going to copy this for a second and we're going to change that to 0.6 so that basically we mean it's 60 down the screen and that one's going to be 40 down the screen there as well we now need to set up an event so that when we press enter the game goes for a certain room just go to add event let's go to [Music] key pressed uh enter and let's then say we start the room so we've got to go to room so go to room and i'm going to go back to my other room now you can do this in a number of different ways right you have to do it in this way but i just basically got a restart there for that okay so in that that looks okay so far i think and what we now need to do is we need to alter one of the uh collision events so in the bottom bars an example normally we restart game so what we're going to do is we're going to create an instance of the game so sorry instance of the object so if i click on that object and then oh game nope oh game over there and that then is going to be placed on our gui layer which i've made there so if i change the layers here to gui that should be enough now basically when i crash into the bottom bar this should appear fingers crossed okay so there are my rollover cell works let's play one two there we are good okay so let's crash into the bottom bar oh now then you've seen that did come up very very very quickly but then it um kind of went now the reason for that is in the background the game is just restarting so what happens is flappy bird is just going down and down and down so what we ideally need to do is back in our game over um where we draw the gui what i'm going to do is i'm going to destroy the instance and i think destroy instance and i'm going to set that to our player so that's one two that's enough bam okay so you can see there is a bit of an issue there it's gone over the uh the the screen a little bit now we can do one of two things you can either add another uh ui box in here or i could if i wanted to make the font a little bit smaller or i could even widen the room a little bit but you can kind of see what this is supposed to do and when we press enter then it obviously restarts the the game so in total that is how we make flappy birds with a skull counter and random bars if you've liked it please leave a comment
Info
Channel: A bit of everything
Views: 631
Rating: undefined out of 5
Keywords: gamemaker, game maker, game maker studio 2, game design, game development, GMS, flappy birds, variables and games, random bars, flappy bird clone
Id: 6RsPJJAqAKM
Channel Id: undefined
Length: 52min 20sec (3140 seconds)
Published: Sat Apr 10 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.