Main

Tuto GDevelop 5 - Crée ton premier jeu vidéo ! ép. 3 (eng sub)

Au programme de ce troisième tuto GDevelop, je vous propose d'ajouter un menu, et des objets à ramasser ! 🔴 Ma chaîne Twitch : https://twitch.tv/outofreality 🧰 Télécharger GDevelop : https://gdevelop.io/fr-fr #tutoriel #gdevelop5 #tutorial #tuto #gamedev #développeur

AnkhM_

7 months ago

Hi everyone, we meet again for the last tutorial of discovery on the gdvlop5 software. In this tutorial, we will see how to add a very simple menu and how to earn points, earn score and display this score both in the game and on the menu. If I click on play, I arrive in game, I collect coins, I earn points, everything is fine, I'm not good at the game, I go back to the menu and hop, I got my score, so my 5 coins that I was able to collect. Before moving on to the tutorial, do not hesitate to sub
scribe to the channel if you have not already done so and to ring the bell so as not to miss the next videos. If you have any questions during this tutorial, do not hesitate to write them in the comments, I will try to answer them as simply as possible. Do not hesitate to put a little blue thumb, that's for to flatten the oversized ego of the tutorial maker, right? And especially to flatten the YouTube logo. I leave you with the tutorial, have fun, create well. So for this new tutorial, a few li
ttle things have changed since the last time. Already I gave you homework to add in the list of objects a piece object. I hope you succeeded, normally it's very simple, add a new object, we look for platform here and then you search and you find an object that looks like a piece or any object, anyway it's your game. Here I was on the coin here, which looked a little bit like the design global of what we already had on our game. I also allowed myself to add a background, quite simply on my game.
So we will immediately start with the background, the same background, I went to add a new object, I looked for background, here and I took, I do not know which one, whatever. It must be the background colored sprite, here, background colored land. And I have to add it on my on my game. I resized it, it's a Tilehead sprite, so a mosaic in French like the platforms. If I resize it, it will simply repeat itself. Here, after a while we see that it repeats itself. I just put a little bit bigger than
my screen, but there is a super important thing, it's that if you put your ... So I'll show you right away. If you add your background like that, it actually overlaps all our other objects. Ideally, you should use the layers, so we talked about it in the very first video. What we're going to do is we're going to cheat a little bit. We will simply modify the position on the Z axis. So in two dimensions, normally we have only two axes, X for width, Y for height. But we also have the possibility t
o manage what we call a little bit in English the Z offset, that is to say which layer will display an object. So I select my screen background that fills my whole screen. And in the properties, again the properties we talked about in the very first video, but we never used them. And we will modify the position on the Z axis, we see here that we are at 6. We will put ourselves for example at 0. And there at 0, we see that my background goes directly behind. If you want to be quiet, you can even
put yourself at minus 10. It will not change anything visually, but that means you can put other background elements which would be between the background and for example our character, our platforms and our traps. So that's also something that can be quite interesting in some cases. The ideal being, I repeat, to use layers. So we're done with our background. Not much to say about it. Now we will add our pieces. To add our pieces, very simple, we will put a piece, we put only one for now, on our
level. The rest we leave by default, we will not go to tinker with the properties. And now we want that when our character touches the piece, it disappears. So we will go back to our event sheet to test the collisions with the piece. And so to do that, we will add a new event, add a condition. Player character, we will look for collisions. In the object, we will choose coin. So I did not rename it, I left it in English, or piece if you renamed it. We will do OK. And so if my character touches a
coin, we will add an action and we will destroy this piece. We will simply remove it from the game because our character picked it up. So we go to coin and there we will simply try to delete the object. We do OK. We think about saving. Small preview. OK, it's good, I picked up my coin. Very good. Except that nothing else happens, I have no score, I have nothing that appears. So it's not going to be super exciting. So this coin picking system will allow us to discover the fabulous universe of va
riables, and in particular the variables under which I develop. A variable to schematize globally, you imagine that it is a box in which there is a value. So it can be a number, text, a Boolean variable, like yes or no. For example, to turn horizontally, it's a Boolean, yes or no. Quite simply. So it can be according to the type of the variable, according to the type of the box. It can be either text, or a number. The interest of this variable is that we will be able to modify what is in it. If
I take the example of my box, I don't know what we could put in a box. Shoes, we will be able to add a shoe, then another, then another. But we will also be able to remove a shoe. Let's imagine it's a box, we will be able to remove a shoe. We will be able to remove a shoe, then another, then another. I hope the analogy is clear enough. On the other hand, an important thing is that a shoe box cannot contain glass, for example. And vice versa, a glass box cannot contain glass. So we will be able t
o add a shoe, then another, then another. But we will also be able to remove a shoe. Let's imagine it's a shoe box, we will be able to add or remove shoes. We can add them one by one, remove them one by one, or add them ten by ten, etc. But a glass box cannot contain shoes. Even if technically we agree that in a shoe box you can put whatever you want. But it's just an example, imagine a shoe box can only contain shoes. And overall, the variables will work a little bit like that. So I simplified
a lot, but I think it's an analogy to get an idea that seems close to reality. So, to get a score, we need a variable. Our variable will be our box, which will contain points. It's a box of points, in which we will be able to add points, possibly delete points when we hit a spike, for example. You remember the little traps we created earlier. Rather than restarting the game, we could simply remove points. It can also be an idea of evolution. So we will have to create this box, this variable, in
several ways. Either we will have what we call global variables, which will be available throughout the game. For example, for the score, it can be interesting to have a global variable which will keep the score in memory. A box in which we will store the score, and all our game levels, all our cards, all our menus, etc. will be able to see this score. They will be able to read the amount of points in the box. We also have the scene variables. Same thing, except that the scene variable will be c
ontent to be available only in the scene in which it is created. So here, my scene is called game, quite simply. So I could only have access to the content of my box in this scene. And finally, we have object variables which will be stored on objects. For example, on my character, on the piece, on the spikes. I don't know if you want to make spikes with different powers. You can have a variable, a power box, in which you put, for example, between 1 and 3. And if your spike is at 1, and your char
acter touches the spike, then he will only lose a point. If your spike is at 2, then your character will lose 2 points of life, or 2 points of life, whatever. And if the spikes are at 3, it kills automatically. So these are just examples. It's up to you to decide what you want to do. For us, for the score, it's not necessarily a bad idea to use a global variable. We could store the score on the character, and then transfer it to another global variable. So make a character variable, then a globa
l variable. We will rather directly create a global variable. To do this, we will go to the project manager, the two little squares plus the vertical rectangle at the top left. We will click on it. And we will simply have a line called global variable. We arrive on a new table with a button Add a variable. Here we will have three important fields. The first is the name of the variable. So don't call them variable1, variable2, variable3, because you will quickly be lost. So take 3 seconds to find
a name for your variable, and a name that corresponds to its function, to its utility. Then we will see the type of the variable. Like earlier, the example of shoe boxes that can only contain shoes, glass boxes that can only contain glass, etc. And finally the value, the number of shoes we already have in the box. In the game launch, do I already have shoes in the box or not? We will see that right after. So the name of the variable, we will not do original, we will type score, because it is th
e score we want to save. Then the type, we have different types, character chain, number, boolean, tableau, structure. Character chain is basically letters and numbers, for those who know, you are old, I reassure you. So character chain is simply a mix of all characters, well, globally all characters available on a computer keyboard. So letters, numbers, possibly special characters, etc. Be careful with special characters, it is not always well supported. And that is valid even in a more general
way on computer. Special characters sometimes are not always the right plan. Then we have the numbers, well, it speaks of itself. And finally the booleans, as I said, either yes or no. The booleans will be very useful, much more than we could believe. But we will rather focus on the numbers. Tableau and structure, we will not talk about it for now, because it will be sets of variables. It will be a variable, a box that contains other boxes, to be able to mix glasses and shoes. So we will take a
number, the rest we will talk about it another time. We will take a number, and my default score, when the player will launch the game, I want it to be zero, so the score will be set to zero. If, for example, we want the number of life points, we would go for example on 5, if we want the player to have 5 life points at the start. Or 3, or 27,000, whatever. Here, we want the score to be zero, we want the score to go up as the player collects coins. We will apply. Now, when we are going to collec
t a coin, we will have to add a point to the score. We will go to our event sheet, and here, still in our character, the player is in collision with coin, we have deleted coin, so we will remove the object, and we will add a point to our score. This allows us to have two actions, or more, in one event. We will delete coin, add an action, and we will look for variable, it's not on an object. And we will check, each time it's a bit of a pain, can I look for global too? Yes, if we look for global v
ariable, we will modify the numerical variable, which is related to number. Unlike a textual variable, or, by the way, little translation error, the textual variable which will concern a character chain, the boolean which will concern booleans, etc. We will modify the numerical variable. In the variable, you see the name of the score variable which appears. If it's not there, you click on variable, and you have a list of available variables, global variables you have already created. For now, we
only have one, score. Imagine, you could have HP, speed, skin, etc. We will select score, choose an operator, we could put an equal, the old value of our score variable, add 1, or we will simply add 1. On a numerical variable, you see you have 5 actions, I don't even know how to count, 5 different actions, add, subtract, multiply, divide, or make equal to another value. We will simply add, and the value we will add will be 1 point. Of course, for motivation purposes, it can be interesting to ad
d more points, even if it's a bit wrong. Adding 100 points when you collect a piece is more rewarding for the player. For now, we are discovering the software, so we will stay on a simple consideration. I collect a piece, I earn 1 point. We will click OK. We will save. The problem is that if I make a notice, nothing will happen. In fact, something will happen. We will add 1 point to our score variable, but I don't know where I see my score. We can take advantage of it, since we are discovering t
he software, we will go to the debugger. We will go back to our scene, we will add some little pieces. We are happy. Instead of clicking on the notice, we will click on the little arrow down there. We will click on start the notice and the debugger. Debugger. It always makes me laugh in French. Start the notice and the debugger, which will allow us to check the state of our variables. Among other things, we will be able to check many other things while our game is running. Start the notice and t
he debugger. I have my notice. I have my notice with my classic game, no problem with that. We will click on the inspector behind, not the Inspector Gadget or the Inspector Columbo. We will click on update. Update will give us a list of the different instances, which are all the objects we put on our map and their number. Here, the red platforms, we see that we have four of them. If we check on our level, we have one, two, three and four. Everything is fine. The spikes, we see that we have two.
Everything is fine. The coins, the coins, we have five. Our character, we only have one. We can check the number of instances we have. Why it can be interesting to look at these values, especially when you are going to make games with projectiles coming out of the screen. If you don't take the time to destroy the projectiles coming out of the screen, you will have an infinite number of instances. After a while, your computer will crash. Computer or mobile, tablet or smartphone, of course. This i
s important, that's why I take a few seconds to talk about it. What will interest us more, I was talking about the set variables, we don't have any. What will interest us is the global variables. We will click on it. We see here a list of all our variables. For now, we only have one, which is called score, which is of type number, number in English. Its value is zero. Everything is fine. We haven't picked up anything for now. We have zero coins. Now we will play. We will pick up two coins. I go
back to the debugger. I refresh. We still have the score variable, still of type number. We haven't changed its type, fortunately. Its value has gone to 2. That's it. We have picked up two coins and our score is increasing well. I pick up my five coins. I go back, I refresh. Value 5. Everything is fine. I have my score which is recorded when I pick up coins. We will close our preview. We will close the debugger. We saw that our score was recording. Everything is fine. Now, what we will have to d
o is display this score. We will go back to our game scene. Add a new object. We will not go to the resource store, but we will go to new object from zero. We will display a text. Ideally, for your games, it would be to use a bitmap text based on images to have much more interesting and much more graphic character policies much nicer on the screen than a simple text. We will really go for something very simple. We will take a text file, a text object. We will call it score. We will call it score
. We will call it score. We will call it score. We will call it score. We will call it score. We will put the size, I don't know, we will put 40. And 60, let's be crazy. And initial text displayed, we can put 0. The policy here, you will be able to use character policies that you would have found on the Internet or that you would have created. Remember to check the rights of use of the policies that you download, because you are not allowed to use certain policies on certain projects. We will st
ay by default, we will really use the default policy. In color, we have a blue background, so we will leave it black. We will put fat, so that the text is a little more visible. And even rather than 0, we will also do the manipulation of the character chain. We will type score, space, two points, and then we will apply. I will put my score, it is clearly visible. In 60, we can't miss it. We never know the compression, I think of you and your eyes. We have text that is displayed, it displays 0. I
f I launch the preview, I pick up pieces, it will always be displayed 0. We will have to program the change of text here, and the update of 0. It will become our value of the variable score, of the global variable score. We come back to our event sheet. And here, when we are in collision with a piece, with a coin, we delete the coin, we change the variable score, we add 1. And now we will modify the text that is displayed here to take the new value of the score. To do that, we will add an action
. We will select our object score. That's why I like to call them txt underscore score, for example. It's more visual. We take our object score, and here we will select modify the text. Sign of the modification, we will define A. And the text we will add, that we will put, will be our score. We will type here global variable. And you see that it directly adds a toString function. I will come back to it later. The name of our variable, in quotes, very important, not very important. The light. For
tunately, GDevelop is talking about it. We will take our variable score. Except that you remember, our variable score is a number. Except that a number can't be displayed as it is in a text object. Except if it's a number in a character chain, where it will be displayed directly. But we have defined a pure number, that can only be a number. That's why we need the toString function, that is created and managed by GDevelop directly, that will modify our number, our score, it will modify the number
in a character chain. In reality, it won't change much for you visually, it won't change anything at all. Except that GDevelop will be able to display the score since it has become a character chain. We will click on OK. I don't know if I was very clear on this. Don't hesitate to ask me in the comments if you want more details on this. Basically, the number becomes a character chain. There you go. It can be a number. We will click on View and we will have a weird behavior. I tell you right away
. Score 0. I picked up a piece. I did pass to 1, but my score is not displayed anymore. It's a bit lame. Why? When we change the score, and we manipulate the character chain, I try to show you a lot of things. We will display our score, but we will replace everything. We will delete all the text to replace it with the score. I will reopen this panel. Now we will concatenate character chains. We will take two pieces of sentences and we will paste them piece by piece. We will not add them. Even if
we use a plus sign, we can't add letters. We will concatenate the character chains. We will go back to our text to display. We will put before the toString and we will type this time score 2.space and after the closing quotation of score, we will type space plus space. The plus sign, normally we can even pass spaces, I think. Yes, but I find it more readable to put them. What we will do is to display score 2. and next to it the score, the value of our score. Thanks to this little plus, we have
put piece by piece two character chains, two pieces of sentences. We will click OK. We save. If everything is fine, we only see fire. It's pretty cool, isn't it? Now, we will go to one of the last important elements. We will not see the sounds in this series of videos. Why? Because the sounds are quite complicated to find on the Internet. There are plenty, but you have to find sounds with licenses that you can use. I will make a video dedicated to music and sounds soon. Don't worry. We will fina
lize our project by adding a menu screen. A menu screen on which we will come back when our character will exit the screen or when it will touch spikes. It will also be our game over menu. But it will be the finalization of our project. To create a new scene, since I developed this cut in scene, different screens that make up the game, we will go to Project Manager and in Scene, below, add a scene. The titleless scene, we will rename it to Menu and click on it to open it. We come to an empty scr
een. I remind you that a little over an hour ago, we were exactly on the same thing on our game scene. We start again from scratch. We will start by adding a button. To add a button, it's quite simple. You are lucky, a few months ago, it was less simple. We will go back to Create and add a new object. We will go back to New Object from scratch. In User Interface, we have a button, Panel Sprite. We will click on it. We will be able to choose the design of the button we want. There is no importanc
e for the rest of this tutorial. I will take the yellow button. We click on it, it is added. We will immediately rename it to Player. And we will slide our button on our scene. We will click on it. We will even double click on it. We will be able to modify its font. If you have chosen another font, another font, you will be able to use the same font as the one you had to display the score. We will especially change the initial text to display. We will call it Play. We will apply. You have a lot
of options. I will let you search if you want. Here is the text displayed on the button. We will click on Apply. My button is ready. Now, we will have to add the program to go on our game scene. Do not hesitate to go back a little bit. Here, we already have something. You will see that it will be quite simple. We come to our menu event sheet. This time, not the game, but the menu. We will add an event. We take our button Play. Do not hesitate to put prefixes in the names. I often call them btn u
nderscore the functionality of the button. I find it easier to find. We select our button and we will look for Is Clicked. If we click on the button, we click OK. We will simply launch the scene. It will be Change the scene. Choose a scene. We will take the menu. If we restart the same scene, we will launch Change the scene. OK. We save. We will make a little preview. When we click on the button, it lights up. It's beautiful. I click on it and it's gone. I play. OK. Now, I want to add a little t
hing to make you understand the interest of global variables. Be careful, you should not put all variables necessarily global. You will need information only on one scene, on one object, etc. I show you the score in global variables. The global variable should not become an automatism. Far from it. Take the time to think where you want to put your variables and the most relevant. The closer they are to the object they use, the better. We know we will need it in all levels. It depends on the type
of game. I chose to put the score in global variables. It could be more interesting to put it in scene variables and not global variables. Be careful, global variables are only valid in this example. We will surely make a video dedicated to variables soon. Now, we would like to display our score. It could be really cool. And make our menu a little nicer. To make our menu a little nicer, I will add a background. I will add the same background as in my game. I have several options. I can go back
here, add a new object, and look for the same background. Is it useful? It could be useful if you use another background image. In this case, I will use another background image. We will stay on this. What I wanted to tell you is that we can make global objects. We can make them usable in all scenes. We will do it for the score. We go back to our game scene. We select our score object. We will choose three dots. And we will try to define as a global object. This means that this text object, no m
atter where I modify it, if I modify it in my game scene, in my menu scene, in my game over scene, it will be modified everywhere in the game at the same time. It can be useful, but don't put all your objects in global. I don't need my character in the menu. It's useless to put it in global. Same for the pieces, the dots. Don't put only what is necessary in global, like variables. To define as a variable object, we have a warning message that tells us that this operation can't be canceled. If I
realize that I don't need my score everywhere, I can't remove it from global. Think about it before and don't put it in global. Don't put it in global. Think about it. It's a decision that is irrevocable. Unless you delete the object and create it again. It's very slow. I'm sure that my object name is italic, slightly inclined. If I go back to my menu, my score object is there. We can put it here. I let you do the design of your game. We will have to retrieve and display this score. At launch, i
t will be at 0. If I collect 2 pieces and I touch spikes, I go back to the menu. This time, my score will be marked 2. We won't see a long-term backup system in this series of tutorials. We will make a video dedicated to this later. We will program the display of our score and our event sheet. Add a new event, add a condition. We will look for the scene at the launch of the scene. As soon as the scene is loaded, we will perform our actions. Our action will be the same as in our game screen. Add
an action, score, modify the text, choose an equal operator. We will type score space 2.space close the quotation marks, space plus space. I remind you that the two spaces around the plus are purely visual so that it is more readable. Then we will transform something into a character chain. ToString, in parentheses, global, I have to learn to write, global variable, and the name of the variable, which is my score. It offers it to me directly. We click OK. We will save. In general, at the launch
of the scene, I always show it above. You can take the little blue checkmark and move your events to order them. It doesn't really matter for the moment. It doesn't really affect your game, but it's more readable at the launch of the scene. When we want to do actions, we know that it will be at the top of our event sheets. Now, I have to get to this scene, menu. When we have a game over, we go back to our game event sheet, since it is from the game that we will go to the menu scene. We will modi
fy it. We go to the scene, we click on game, and we select our scene menu. Same thing when we touch the spikes. We save. To test the whole loop of our game, we go back to our menu. We will do preview, score 0, play button, let's go. We play. This time, I just touched Epic, I go back to my menu, and my score is displayed. That's pretty cool. If we put aside the sounds, overall, you already have some basics to create a platform game. Why do I tell you some basics? It's simply that if you want to c
reate several levels of game, you will use the same thing, you will go to level 2, level 3, level 4, etc. When do we go to level 2? When you are in collision with a panel, you create a panel object, when you touch the panel, you go to level 2. When you touch the panel of level 2, you go to level 3, etc. In our example, the score will follow all levels, since we put our variable in global and our display object in global too. It could be very useful if you want to create several levels. Normally,
you have all the tools and all you need to do it yourself. That's all for this series of three videos on the discovery of the GDevelop5 software by creating a small platform game to discover a little bit how it works. There are a lot of things to see on the software, but we will develop all of this later via mini-series of videos like this one, or unique series, especially, you will see next week, the management of groups, of object groups. For example, I have spikes, but I would like other tra
ps, for example, carnivorous plants, etc. Instead of programming each time the character is in collision with spikes, the character is in collision with carnivorous plants, etc. We will use object groups and you will see that it will greatly simplify the creation of your games.

Comments

@metoxyyy9870

Pour tous ceux ce demandant comment réinitialiser le score il suffit d’aller : «Votre menu de jeu (événement) -> Bonton is cliked -> action ( de bouton is cliked) -> « Changer la variable global (score) définir à 0 » » en gros vous allez dedans et vous copier coller ce que vous avez mis pour « coin » avec le «  ajoutez 1 » mais vous changez en « définir à 0 » et c’est bon ! Liker et répondez moi si vous avez une question pour que je l’a vois

@eriencharmely

merci pour vos tutos , je viens de le finir j attends la suite avec impatience UCkszU2WH9gy1mb0dV-11UJg/m8MfY4jbFsWJhL0PyouA2Ak

@slyker8778

merci beaucoup ! je regarde tout et franchement c'Ets super !

@michelcabartier2755

parfait je pense que j'ai les bonnes bases maintenant sur Gdevelop 5 ;) merci Jean

@user-zr3rx7uu7n

merci pour le tuto mais peut tu faire une vidéo ou on fait un jeu a multiple joueur s'il vous plait

@KatoneMugen

Hello, merci pour ces videos c'est top ! J'ai une question (je ne sais pas encore si ce sera traité dans les videos suivantes). J'ai exactement le meme setup que dans ton tuto. Je lance le jeu, j'appuie sur play, je recupere 3 pieces => tout va bien au niveau du scoring Je meure => all good je retourne a l ecran menu, et mon score est consérvé (3) J'appuie sur Play = ça relance une nouvelle partie et mon compteur est a zero, je prends une piece = le compteur passe de 0 a 4. Je n'ai pas trop d'idée de comment gérer ce probleme et ce n'est pas traité dans ta video. As tu une idée de comment gérer cela ? Merci pour ton aide!