Building a Crafting Game: GameMaker Studio 2 | Gurpreet Singh Matharoo | Skillshare

Building a Crafting Game: GameMaker Studio 2

Gurpreet Singh Matharoo, GameMaker Mentor and Instructor

Play Speed
  • 0.5x
  • 1x (Normal)
  • 1.25x
  • 1.5x
  • 2x
47 Lessons (4h 54m)
    • 1. Class Introduction

      1:06
    • 2. GameMaker's Interface

      7:32
    • 3. What are Events?

      3:49
    • 4. GameMaker Language: Functions

      7:26
    • 5. GameMaker Language: Variables

      10:25
    • 6. GameMaker Language: Conditions

      12:32
    • 7. Player Movement

      5:31
    • 8. Camera

      6:36
    • 9. Sprites & Animation

      4:02
    • 10. Collisions

      6:58
    • 11. Depth Ordering

      2:36
    • 12. Facing the Mouse

      2:34
    • 13. Breakable Objects

      4:49
    • 14. Creating the Pickaxe

      4:23
    • 15. Lerp

      2:52
    • 16. Using the Pickaxe

      4:47
    • 17. Selector

      4:49
    • 18. Breakable Health

      3:06
    • 19. Creating Resources

      8:19
    • 20. Item Drop Animation

      3:48
    • 21. Adding More Resources

      5:06
    • 22. Stackable Inventory

      8:50
    • 23. Pausing

      6:24
    • 24. Inventory Limiting

      3:52
    • 25. Inventory Interface - Part 1

      11:42
    • 26. Inventory Interface - Part 2

      3:38
    • 27. Crafting UI

      8:08
    • 28. Title Object

      4:41
    • 29. Scrolling

      5:15
    • 30. Item Display

      6:49
    • 31. Recipe

      7:12
    • 32. Crafting!

      12:29
    • 33. Dropping Items - Manual

      6:55
    • 34. Dropping Items - Automatic

      3:26
    • 35. Hearts

      7:19
    • 36. Enemies - Part 1

      7:48
    • 37. Enemies - Part 2

      11:31
    • 38. Attacking Enemies

      6:00
    • 39. Getting Attacked

      7:22
    • 40. Using Items

      6:00
    • 41. Placing Blocks: Pt. 1

      8:22
    • 42. Placing Blocks: Pt. 2

      6:40
    • 43. Placing Mode: Updates

      6:32
    • 44. Juice: Scaling Animations

      10:01
    • 45. Flashing Colors (with Shaders)

      10:16
    • 46. Juice: Player & Enemies

      3:05
    • 47. Conclusion

      0:27

About This Class

Hi there!

This class is all about developing a crafting game, in GameMaker Studio 2. We'll learn to code with GameMaker Language and develop our game from the ground up!

About the Instructor

Hi, I'm Gurpreet S. Matharoo! I've been teaching game development for years, and making games for longer. I've taught over 5 courses on Udemy & Skillshare, published numerous tutorial posts on my blog, and regularly create free tutorials on my YouTube channel, GameMakerStation. I've also been featured on the official YoYo Games blog as a guest writer.

About the Class

Whether you're a beginner with no coding background, or a game developer looking to gain more experience; this course will help you get where you need to be. We're gonna go through many practical lessons, learning something new at each step!

Here are some things we'll be learning in this course:

  • GameMaker Language basics

  • Player movement with pickaxe

  • Resolution handling

  • Breaking objects with pickaxe

  • Setting up data with arrays and enums

  • Stacking inventory using data structures

  • User interfaces

  • Crafting systems

  • and more!

Support

I'm always active in the community, so if you ever need to ask any questions or clear any doubts, I'll be there to answer them!

You'll also be given a download to the finished project, along with all the resource files used. You can simply use the given images to build the game, so that you don't have to create your own sprites.

I'm looking forward to you joining the class. Let's start our journey!

Transcripts

1. Class Introduction: Hey there. I'm gonna break saying your gamemaker instructor, also known as game equitation on YouTube. This course is all about making a crafting game in game makers todo to first, we're gonna learn about what game maker is and how everything works. And then we're gonna start making our game from the ground up. We're gonna make the player, give them a big cuts, add breakable objects and so on. Then we're gonna add reuse. Also, this an inventory system, a crafting system and more. You're gonna learn a lot about gamemaker through. Making this game from making inventory systems to usually in the faceless will overcome many challenges that you face while making again. All the resources used in the game will be available for download along with the project itself. And I am always active in the community. So if you want to ask any questions, I'll be there to answer them. So join in and I'll see you in the course 2. GameMaker's Interface: Hey there! And welcome to the cause In this lecture will be taking a look at the interface off gamemaker studio too. When you open the program, you're gonna see the screen. So let's take a look at the three buttons here who had this. You can create a new project. Who had this? You can open a project, and with this you can import a project. That's a month. She had video, so we're gonna begin by creating a new project. Now we need to select either Dragon draw Organica language gimmick A language is how you called in game maker. And since the scores is about cording, you're gonna go with gamemaker language. Now we need to enter a name for our project. So I'm gonna enter introduction and hit, Enter and LA via inside of a new project. We're gonna talk about the two main areas off the interface. This is a locked space, and this is where you have your easel cells. So any resources or assets that you create for the game will be lifted here, and those were forces will be at a day that any of our space here No, your lord is that we have it. AB here. This is all about space. So you can add more walks basis, move them around and close them. No, let's take a look at our easel cells. You can see that we have many for lows here. They're all different resource types. So he has brides, dial sides, sounds and many more types. No, down here we have rooms and we already have a room inside it. You can double click on it to open it. It'll open up in a new tab. So here we have our game room. Yes, we're the Game two x place. So your level or your world is created here? No, the size off the room can be changed down here. Currently, it said to 1024 by 7 68 Now, inside a room you can place objects and object is a type of resource. So an object can be created in its folder here. I can right click on it and select, create object so it's gonna create a new object resource. This one is called object zero, but you can name it anything you want. The object of going to open up here in the lab space. Now you can ban around the loch space and zoom in and out. No, an object can function as anything in a game. It can be a player, a coin, a break or anything else. No. If we open the room, we should be able to place the object here so we can drag the object from here and place it in the room. Now, you see a question mark here because the object doesn't have an image yet. Now you can drag and place as many copies as you want. And now we have three copies off the object in the room and each copy is called an InStyle's. So does mean that we have three s tonsils. One object, three. It's on sales. So here in the layers, we have a little called essentials. In this layer you can place and Stansell's. Then we have a little called background. So in death slayer, I contain the color off the background. Now we can go back into the instances layer and access. Are your starters here? No. Let's go back to our workspace. Here we have object. Zero. We're going to give it an image No. An image in game maker is called s bright and you can see here, Dad, the object has most bright assigned to it. So you're gonna make one here in resource is we have a folder for the strides so you can create and manage all the images for the game here. No, I can right click on the folder and create s pride. What does a new sprite resource will be created? Just one is called pride the euro. But again, you can name it anything you want. Now it'll open up here in the box pace. Here we have the size off the image. So we have a 64 by 64 is bright. No. If you want to change the size, you can do so by clicking here. This is where you can enter your new size. So I'm gonna make it 32 by 32 then click on apply. So the size has now changed. Now, to create an image, you have two options. You can either added the image here or import a file. So if I click on import, I can select any image file on my computer. This way an image can be imported into gamemaker. Now I'm gonna bleed this pride and create a new one for this one. I'm gonna click on, add it image. This will open up gamemakers image editor. Now, you can draw anything with the tools here, so I'm gonna draw a square. And now I'm gonna close the image editor and you can see the new image here. So now you're gonna assign it to the object, all open it by the book licking, and then I'll click here and here I can assign is bright to the object. Now I'll open the room tab And you can see that, Dean stances. No having my does. You can also place Morris tonsils, and they'll have the same image Now, you can also scale the instances so you can make them bigger or smaller. Currently, it's snapping to the grid so you can turn it off here and now you should be able to scare it freely. You can also erode at it. So when you got this casa you control their dean stars. No, your law orders that rotation is happening from the spines. So that's the origin binds Tojo. And yet we can go to the Sprite. No, the origin point can be seen here. You can move it around and place it anywhere in this pride. You can also use the list here too. Said the origin. So, for example, you can set it to middle center. The origin will then be in the center of the image. No, I'm gonna go back to the room. I'm gonna or there Dean starts again, and you can see that now it rotates from the center. Now to run the game, you can click on this button here. You can also hit F five on your keyboard to do the same. So when you do that, the game's gonna start compiling. And when the compiling is John, the game will open. Now you simply see your room with all the Stansell's. So this is how you make a simple program in gamemaker? No. We need to learn about interacting with Jesus ourselves so we can do that with events and we're gonna learn about events in the next lecture 3. What are Events?: hairier in this lecture, we're gonna learn about events using events. You can interact with objects and program their behavior. So we're gonna go back into our project. In the previous lecture, we created a Fury's All SOS. So we're gonna go into our object now. You will see that we have an event swindle here. So what is an event? An event is Were you at your chord? So any behavior you want a called for? The object goes inside an event? No, Dad. Cord runs whenever the event runs and the engine decides Vendee event runs not to add an event, you can click on this button. We're gonna add the faster band in the last, which is the creative end. No, here, another window is gonna open up. This is where you write your cord. So any called that you enter here will run when this event runs and this is a creative end . It runs only ones, and that's when the instance is created in the room. So this is the first event that runs in any instance. This means that if you want to set up any data for this object, you can do it in this event. No sense. This event runs only ones. We can't do any input or any movement inside it. For that, we need an event that runs every frame. So we do have an events for that. It is the step event. So from this menu, I'm gonna add a step event. No, dis event runs every frame off the game by default. A game has 60 frames in a second. So this event with Iran 60 times in a second, so we can take input into a movement or program any other behavior for the object. But this event can only handle the logic, behavior, import and stuff like that. If you want to draw something, you can't do that here. So we have another event for the drawing. That is the draw event. So from this menu, I'm gonna add a simple drive end. No deaths event is similar to the step event, and that's because it runs every frame. But in this event, you can draw something in the room. For example, you can draw s pride. Some texts or issue Na VI also have events for keyboard and mouse input. So here you can see a list of most events. These events run whenever some input from the mouth interjected. Then here we have key events for the keyboard, so we have key down, keep rests and key up. No. Under each category, we have all the keyboard keys, so under key down, I'm gonna select space. Then I'll do the same with key breasts and then the same with key up. And now we have three different events, all for the same key. But they are different because they're on a different times. So let's look at the key down event. DS event will keep running as long as you have the space key held down. Now the key pledge event and this will run ones when you press the key. And finally key up Desperate Run wants when you release the key. No, there are many more events, and we learn about them as we create our game. And now in the next lecture will be learning about gamemaker language. So I'll see you there 4. GameMaker Language: Functions: hater. In this lecture, we be learning about gimmick, a language that so if you're gonna quote our game going forward, so we're gonna go into our project here we have the object that we created in the previous lecture in the object. We added some events, so we have created step and drawl. So now we're gonna add some cold in the events and basically learn how to code. So first of all, we'll be learning about functions. When you think of Gordon, you think about giving commands to the computer. So that's what a function ISS and basically gives a commands to the computer to do something. And here are a few examples you can tell it to destroy an instance you can tell you to draw s pride. You can also tell you to go to another room and so on. So these are examples of what you can do. It functions, and the game is basically built around using functions. So we're now gonna test out our first example, which is about destroying an instance. For that we're gonna add a new event, so I'll go on the mouse and select left breast. This event will run when I click on this instance. So when we collect on their sisters, we wanted to be destroyed, and Van Innis stars as the droid. It's removed from their own. So we're gonna do that with a specific function. That function is called instruments destroy. So I'm gonna dive the function name here. Not we actually called a function. We need these parentheses at the end. So that's how you call or run a function? No, this is a statement. And in the statement, we're calling a function now to tell the compiler that the statement has ended. You can add a semi colon at the end. Semi colons are required in many languages, but they are optional in game maker. We are still gonna be using them in this course. No, we're going to run the game and test it out. First of all, your Lord is that the room is empty. No, If you open the room, you'll see that Dean stances are still there. But for some reason, they're not appearing in the game. No, There is a reason why this is happening. If you go into the object, we have a drive. And here and right now destroyed and is empty. There's nothing inside it. So that's why Dean stances are not being drawn. No, you can either lead this event or draw something inside it. So you gonna do the ladder? We're gonna draw something inside. EDS. We are simply gonna draw the instance itself. So there's a function for that. It's called Draw Self. So I'll ride the function name here and then add a parentheses, and now the instant should be drawn. So you're gonna run the game, and now these heating and sound says now you're gonna close it again and go back into our object. If you remember the other solution, Wallst would lead the event. So that is what we're gonna do now. I'm gonna right leg on the drive and and here lead at. So if there simply is no draw event, then the instances will still be drawn and we can go into the game and see that the instances are still drawn. So the lesson here is that you don't wanna have an empty Dr End? No. Here we have a mouse event with instruments. Destroy inside it. So we're going to go into the game and test it out. No. When I click on an instance, it simply gets removed. So they're simply what a function is. It simply performs an action. Now we're gonna learn about function arguments here. We had the parentheses after the function. No, inside these brand theses, you can write some values if required by the function. So those values that you right here are called arguments. So we're gonna use a function that requires some arguments. We're gonna do that in the draw event, so I'll go ahead and add it again. First of all, we're gonna call the draws Health function. Saudi Instruments will be drawn here. As you can see, dysfunction doesn't require any arguments. But now we're gonna use a function that does require arguments. We're gonna call the drawers bride function using dysfunction. You can basically draw s bride. So dysfunction does require some arguments. And the older you have another here because we haven't written any arguments. I know the arguments can be seen down here, so we have the function name double fantasies and inside them the arguments, Saudi arguments, arse brides, sub image X. And by So now we need to create a news bride to pass into dysfunction. I'm gonna go to the sprites faller and create anyone just will simply be a Sprite one. Then I'm gonna go here and click on add it Image. I'll quickly draw a circle. No, back in the sprite, I'm gonna said the origin to middle center. And now we'll go back to our object. We're now gonna draw our newly created Sprite with dysfunction. So we're gonna fail in the arguments. First, I'll make the window smaller so we can see the arguments easily. Now, the first argument here is the surprise. So, inside the parentheses, I'm gonna enter Sprite one, and this is our first argument. Now we're gonna add a comma to move on to our second argument. And the second argument here is the sub image. This is a frame that we want a draw. We are no drawing an animation, so I'm simply gonna enter zero. No, for I would heard and Fort arguments, we have X and by this is simply the position where the sprite will be drawn inside the room and these are two dimensional coordinates. X is the horizontal coordinate. And why is the logical coordinate. And this is how we know where something else inside the room. So we want us pride. Toby drawn exactly where the instances and we can do that by simply entering X and by 40 arguments. So now the image will be drawn exactly where the instances we contested by running the game , and now you see a rat cycle on each instance. Now the draws have function. Here is what draws the instrument's itself. And then this draws bright function is what draws the red circle on the top. So this is essentially what functions do. And now we're going alone about variables. We be learning about them in the next lecture. 5. GameMaker Language: Variables: hairier. Now we be learning about variables. In the previous lecture, we learned what functions are and how we can use them. We also learned about passing in arguments to a function. No one argument that your past in is basically a value. Now there is a way to store these values before directly passing them in into a function. So to store these values, we can use variables. A variable, as I said, stores a value. The value can be a number entering, which is simply some text or a bilion, which is a true or false value. So these are all data types. No variables are generally initialized in the creative end. So we're gonna open that event here. You're gonna initialize our fault. Very about this variable will be called a Now to give it a value, we're gonna ride the equal sign. Then we can enter the value which, for this variable will be it. So now we have a variable called a and its value is eight. So we can now use this variable in a function. And for that we're gonna open the draw event here. We're gonna use a new function. Dysfunction is draw text who had dysfunction weaken Simply draw some text. Now, down here we have the arguments. So I'll make the vendor smaller toe. Bring the arguments closer to the function. No, let's take a look at the arguments. First of all, we have the X and by where that actually be drawn. And then we have the string that will be drawn. So for the X and Ally were simply gonna enter X. And by this way, that X will be drawn wherever Deion starts Els then for tutoring Toby drawn, we're gonna enter our valuable A. No. The variable holds a value that is not a string, it's actually a number. And the argument here in the function requires a string. And you know that we are passing in a number, so this number will automatically be converted into entering when you pass it into dysfunction. And now you can run the game and destiny. No. On each instance, you see the number it and that value is being read from the variable. So this is how you create and read a variable? No. We're going to see how a variable can be modified after being created. So now we'll modify our valuable A in the draw event. So before this line, I'm gonna add this Here we are changing the value off a to 13. This where you can simply modify a variable anywhere. So now you're gonna run the game and see the effect. Now, you can't really see the number because the boss is right And that excess white. So we're now going to go into the project. And, Jane, the color off the box. No, you're gonna run the GAM again and we can see the value now so desperate you can modify a variable whenever you want. Now I'm gonna remove this line, and we're now going to modify this same variable in the step event here. We want to increase the value off the variable by two. So I'm gonna add this here, Novia setting a to be equal toe This expression. The parentheses here are totally optional, but they make the court easier to read. So the expression that we have here is a plus two. So these values are added together and then the result is applied to a this way the value of a is increased by two. No, this is gonna run each frame because we are inside the step event. So we can now run the game and see the effect. And now you can see that the number keeps increasing and in this way we can relatively modify a variable. But there is another way to ride the same statement. So I'm gonna remove this on at this instead. Now this is gonna do the same thing. It's simply gonna increase a by two. Now we contain this plus here with the miners to perform its attraction. And now you can see that the value is going down. Now I'm gonna change us back to plus. So now here we are simply adding to our variable. But we can also add another variable to this variable. So in the create event, we're going to create a new variable. Just for that, this will be called ad and its value will be 10. And now in the step event, we're gonna add the ad variable to a so here they will go up by 10. Since the value off the ad variable s 10. So let's run the game and see the effect. And now the value is increasing at a very far trait. And now we can go back to the creative end. And here, Jane, the value off the air variable to something low, like 0.1. And now, when you run the game, you'll see that the value is increasing at a Laurette. So that shows how you can read and mortify variables. No, Back in the creative end, we're gonna create two new variables so you can agree it add eggs and add by. We'll be adding these values to the X and of I off the red circle soil, open the drawer event and come down to the statement. No, After the X argument here, I'm gonna add those. And then after the lie argument allowed those No, this addition won't do anything because the addicts and advi variables are zero. So if you're on the game, you won't see any difference. So now I will be giving values to these variables, will be doing that in the step event, and here we're actually gonna learn something new about functions. You know, Daddy function performs an action, and you also know that you can pass arguments to a function and now a function can also return a value. For example, we have a function called random. It takes only one arguments called eggs. What it does is that it gets a random number between zero and X. So the function you don't just random number, and then the Stratan value can be stored in a valuable or part into a function as an argument. So we're gonna use that function here. All right, the function name and then double fantasies. The argument for this will be 10. So now we're gonna get a random number between zero and 10. We want to store the results off dysfunction in a variable so we can do that like those. So now the random number will be sold in addicts, and then it will be added to the expedition off this bride. So now we're gonna run the game and see what happens, and you can see that the cycle is basically shaking. This is happening because all the random add X value. And now we can do the same to the advi. I'm gonna pass in Turkey as the argument for dysfunction. So it should move more on the lie axes. Of course, in the draw event. It's added to Dubai. So let's run the game and see what we have. And now the cycle is shaking in both axes. So that shows how a function can be used to send the value off a variable. No, we're gonna learn about some other data types. First we have billions now a 1,000,000,000 Canada be true or false. So in the creative end, we're going to create one. So here we have a variable called Can Draw Psycho. It said too true. So a 1,000,000,000 can either be true or it can be falls. Now, the next day that I that we have is a string entering is simply some text. So now a string can be created like this. First of all, you need these Kardashian months and then that X can go inside them. So now we have a simple text ring here. We can now go into the draw event and draw it with a function I'm gonna use draw text. Now here we have the X and by where that x will be drawn. So we are simply drawing it at it. Buy it now for the string. We are simply passing in this viable. So you're gonna run the game and see what we have and you can see l. A string here, all in stance. Lawyers are drawing in the same position and that position is eight by it. Now, finally, if you're gonna learn about comments so we have these true valuables here right now, without looking at any other events, we want to know what they do. So for that, we can add a comment. Now you can begin a comment with two forward slashes and then you can write whatever you want. So this is simply what a comment is. It doesn't affect the code at all. It's only there to explain some code to the programmer. No, in the next lecture will be learning about conditions. And so I'll see you there. 6. GameMaker Language: Conditions: Hey there, in this lecture, we're gonna learn about conditions. Now. We added a lot of gold, Another project in the previous lecture. So now we're gonna take a look at the draw event. We have many statements here, and they all run. Whenever that draw event runs, they all just unconditionally have to run. But not if we use conditions. We can use a condition to control by the S statement. Runs or not, The most common condition is an if statement. It's basic syntax, as less so here after. If we have the condition and then we have the statement controlled by the condition. So if the condition here is true, then their statement will run. But if the condition is false, then the statement will not run. So no. Back in the draw event, we're gonna apply a condition toe the statement. If you remember here we draw the red circle. So just above their statement, I'm gonna add this. So now we have a condition. Here we are simply checking if is equal to zero. If it is, then the condition will be true. So that spend their statement, we run. But if is not equal to zero, then the statement will not run. Now we have to equal signs here. That's how we do an equality, Jack. In a condition. No. We're gonna open the step event here. We're gonna remove this line so we are no longer adding anything to it? No. In the create event, you can see that the value off is it. So it's not zero. This means that in the drive end this condition, that it be falls and so does pride will not be drawn. So now I'm going to run the game. And now you cannot see the Red Psagot. So that is because off the condition and this condition is false, because is not zero. Now, I'm gonna open the create event. I'm gonna set a 20 Now that should make the condition true. So I'm gonna run the game again. And now these either at circles. So this time of a condition is Truell. No, we're gonna go back to have a condition. We're now gonna inward it, so I'm going to remove the two equal signs from here. In their place are ladders. No, this is checking. If is not equal to zero. So this condition will be true. When is anything but zero and when a zero this condition will be falls. And right now it is zero. And so the condition should be falls. So now we're going to run the game and we don't see that circles. This is because off the invited condition now, we also have greater than and smaller than conditions. So here, in the condition, I'm gonna removed us in its place. All right, there's no we're checking if is greater than zero. So if it is greater than zero, then this condition will be true. I'm also gonna indented their statement by pressing tab. So the shows how their statement is being controlled by this condition. Now we're gonna go into the create event. I want to set a Toby lower than zero. So I'm gonna set it to minus 2 40 and now you're gonna make it go up. So in the strap event, a lot does. Now there simply increases a by one. So right now is negative, but added bind. It's gonna become positive, and that is when this condition will become true. So you're going to run the game and see what we have now is below zero, and we don't see the cycles. And when a becomes bar still, that's when we see the cycles so over greater than condition is working No, back in the drawer event. We're gonna change this to a smaller than condition. So now this will only be true. If is lower than zero, we're gonna run the game to get it out. No is negative. And you see the cycles. Now it's Boston and you don't see them. Now, back in the event, I'm simply gonna clear this condition. In its place. I'm gonna ride. That can draw so called variable. So now the condition will be dependent on this valuable here. And since the variable itself a stroll, then the condition will be true as well. So if I actually ended two falls, then the condition will become falls. So I'm going to run the game and see what happens. And of course, we don't see the cycles. So the condition is false because the valuable is false. No, If we janja to true, then we should see the cycles, and we do so. This is basically how an if condition works and now we're gonna learn about if else basically, when this condition est rule, their statement runs. But when the condition is false, then their statement simply doesn't run. And this is where else comes in. Basically, when the condition is false, then the else part runs so we can adhere Statement here. I'm gonna use the draws bride function. Here we are drawings Bright to that we haven't added yet. We're gonna add it later. First, I need to explain how all of this works when this condition is true. Then their statement is gonna run. So in that case, the else part will be completely ignored. But let's say the condition is false. So in that gays, their statement will be ignored. And then the statement after else would run. So, Mr Adults bright one spry tool will be drawn. So basically either desperate run or dispel, and all over depends on this condition. No, we're going to create a sprite resource for does so I'll go into the sprites faller and created here. I'll click on edit image. I'm quickly draw a star. I'm also gonna said the origin to middle center and now we're gonna go back to the object? No. If the condition astral, dense, bright one will be drawn. And in the creative end, we can see that the variable is Truell. So we're gonna change it to falls. And now in the drive end Sprite to should be drawn Soviet gonna run the game and test it out and received a star only. So the condition is false, Which is why we move on to the else part. No, I'm gonna change it back to drool. I'll run the game and we see the red circles again. So this is how if else works And now we're gonna learn about groping statements. For example, this condition here is controlling their statement. So there's only one statement being controlled. But let's say vive only to control their statement and the statement. So I'm gonna select their statement and cut it. I'm gonna add in new line here, and then I'll based no statement here. No, you were saying that the statements were now controlled by this condition, but they're not. As you can see, we have another here. So to make this work, we need to use Carly brackets using curly brackets. We can grope statements together. So then a group of statements can be controlled by a single condition. So back in the event, I'm gonna start the group here and then end it here and now the editor is gone. So now when this condition is true, the statements will run. And when the condition is false, then both of these statements will not run. Now I'm gonna run the game and we see the red circle and the value off a So this condition is true. All and the statements are running. No, I'm gonna open the creative end. I'm gonna make our condition falls. So now, in the draw event, these statements are not going to run. So I'm gonna run the game, and now we only see the star. We don't even see the value off a Now we're gonna learn about combining conditions in these fantasies Here. We only have one condition, but we can have more than one conditions. So I'm gonna add this here and now we have two conditions joined with end. So that's me that both of these conditions need to be true. If one is Truell and the other is false, then the statements won't run. So basically this condition and this condition have to be true. And that's what this and means. So in addition to our first condition, A also has to be smaller than zero. No, I'm going to go into the creative end and such of a Boolean. True? No. This means that our first condition will always be true. So then the whole condition will be dependent on this one condition. So you're going to run the game and test it out. And now a smaller than you. And so is he, either at soccer and now we don't. So this is because of our second condition. No. In the creative end, I'm gonna set of a 1,000,000,000 to falls. I run the game and now we don't see the red circles at all. No, this is happening because our first condition is false and sales board conditions have to be true for the whole condition to be true. The condition just stops there. So all of this behavior is happening because of how and works. But there's another keeper that we can use here. This one is called or with the or operator. If anyone off these conditions a stroll. Then the statements were run. So let's say dis est rule and death has falls. Then, in this case, the whole condition will be true. So basically, either this condition or disconnection no. In the creative end, you can see that Allah Boolean is false. There's automatically mix. Our first condition falls. But then we have or here so down. If this condition based rule, then the whole condition will be true. So this condition being false one matter. So we're going to run the game and we see the red circle only while a smaller than zero. No, we can also right and and or using symbols. So now for and we can simply write this and then for or weaken simply right. There's so these symbols do the same thing as the key bods. So now we know a lot about conditions and we are not gonna start making our game in the next section 7. Player Movement: hairier in this lecture. We wanna work on the player's movement. I'll open gamemaker. I create a new project and slept gamemaker language here on limit grafter. No, the project's been created. First of all, we need to set up some basic. Rees also is So we'll make a sprite for the player, make the player object and set up the rule soil. Go to sprites and create one our limit s player. I go to the Spice Properties. I click here and here. Genius size 20 to 32 and then a click on apply. So now we have a tardy tool by tornadoes. Pride. No, I'll click on it it image. This opens the image editor. We're going to create a simple placeholders bright for the player. So it's like the fear tools and filters bright with a white color. So we're gonna use this for now, and we learned the actual place brides in a later lecture. Now for the origin. I'll make sure that it's said to Middle Center and now I'll close it. Now I'll go to objects and create one our limit or player in the object. I'll click here and assigned this bride to this object. Now I'll go to rooms and open the default room that we have here. First of all, I'm going to go into the rooms, headings and Jane. The room size now will open the background layer. I'll go to the properties and click here to Jane the background color, and now will open the instances. Layer from the objects are dragon drop Oh player into the room and now it closes. So now the basically is also has happened set up. Now we can start quoting a player movement. So I'll goto a player in de Vence, allowed the create event and in the event allowed this. Here I am initializing some variables for the movement. This is a movement speed off the player. So currently, the playable new one pixel purse strap. Now these valuables stored the actual movement off the player on the X axis, which is horizontal, and the by express, which is where to go. Now I'll add the step event. We're gonna called all the movement. So I'll add this court for taking import from the arrow keys here on creating local valuables for each Iraqi. So we have right left up and down. They use a keyboard check function to get a G input. So these valuables will be one. If the key is held and see, You know if it's not now, we need to convert these input values into X and y axes input X cosine port on the X axis by extracting the left import from the right in port. So when the right key is held and the left key is not held, this is going to be one minor zero. So the result is going to be one No. One that left Keyes held. But the right key is not held. This is going to be zero minus one. So in that gays that result is going to be minus one. Now I'm doing the same here for the UAE access. So pressing down will make it one and dressing up with making minus one. Now these import axes can be added to the instances acts and why, and the instruments should move. But first we need to get the actual movement speed. So for that allowed, this here are multiplying in forex with the most bead and then applying the results to move acts and then I multiplying input. Why with the most be and applying that to move I. Then finally, I'm adding more wax to the x variable and move I to the y variable. So in the end, move ex and move. I store how much superior needs to move. And then they added to the instance Case X and Y coordinates. So let's run the game and test it. I can move around with the Iraqis now. You also want to be able to move with the WSSD keys. So let's implement that. I'll go back to the rear step events here. We're getting the import from the right arrow key. So we should also be able to use the D G to move right. So after this function call All right, this. Now there's keyboard jack function. Jackson, Don Tiki expressed here, you need to use the already function if you want to get input from a Logic E Now here I'm using the or operator soared jacks have the right arrow key order deaky express. So the value off this valuable will be one. When you press either off these G's. So now I can do the same for the rest of the keys. So we have a four left w for and as for down. So now we're on the game and now I'm able to move with a W ere Tiki's. Now. The next thing we need in this game is a camera. So the camera will followed a player on only show apart off the room, so we'll do that in the next lecture. 8. Camera: Hey Dio Indus Lecture We will implement a camera in our game. This way the player will only be able to see the area surrounding the player. So let's begin in the project. I've added a new Sprite called s Background. It's gonna be a temporary background for our rule. So where the style background will be able to see the movement off the camera Now we'll go to rooms and right click. On this room, I click on Rename and Jane The rules name toe I'm game and now will open the rule. I'll open the background layer in the layer properties I can click here to assign a backgrounds cried So it's like this one now it does appear in the room, but only once. So back in the layer properties, I'm gonna enable horizontal tile and medical tire. So now the background completely fills the role. Now in the rooms, properties will increase the room size and now and closes. Now we need to set up the camera so I'll go to objects and create a new one our limit or controller. I place it above or earlier. This controller object will be used to control many off the game systems. So in this lecture, we're gonna use it for creating the camera. So here are allowed the creative and inside the creative and allowed this. This is an Emam call dress. It showed for resolution. An Emam is basically a group off Austrians. So these values are constants, which means that they can't be changed and their global. So these values can be excess from anywhere. This in, um, history members with height and scale, these out of it and the heart off the camera. And this is a scale off the window. So basically, the game enjoy or will be four times larger than the camera itself. Now that set up the actual camera. So after the inner allowed this here, I'm using the camera creative you function to create a camera. The i d off the camera will be stored in this local variable. Knowing the functions arguments, I'm defining the properties off the camera. These are the starting X and Y coordinates off the camera, these out of it, and the height off the camera. And they're taken from the innam. So this is how you use an Inam first you have the Inam name than adult, and then the members name. Now this is the rotation off the camera, so it's set to zero for no rotation. Now this is the object that the camera needs to follow so the camera will follow a player. These are the maximum speeds off the camera on the X and the Y access. So report a limit on how fast the camera can move. We don't want any limits, so I've said both of these values to minus one. Now these are the margins off the camera. The other distance from the place position to the cameras, edge on board access. So to keep the player and the center off the camera, these margins need to be half off the camera size. So for the X margin I've entered, the were divided by two and four, thereby margin the high divide by two. No, this enables the views in the room so that the camera works. Dismisses. The first few is about sort of first fuels. Number A zero. Now here we are, applying our camera to the first view, so we're applying this camera to view zero. Now we'll go to events and add the cleanup event Disip entrance if the stars is destroyed, or if the Romans will not be destroying the controller sons. So this event will run when the rule man's so here are allowed this this simply destroys the currents camera. Destroying the camera removes it from the memory, since we no longer needed now will open the game room. I'll make sure, Daddy Instances Layer is selected and place and it starts off. Or controller here now will close the room and run the game. Now you can see there. The camera is working. It's following the player and only showing apart off the rule. But the game does not appear correctly. The window size and the games A solution is incorrect. So let's work on that. The camera is created in the controller object, so all of this court will run whenever you start a room. But the core detainees of inter size needs to run only once when the game starts. So for that I'll go to rules and create a new one. Our name it arm in it. I'll place it above the game room so that it opens for us. Now we're gonna use this room to change them indoor size. So this room will only run when the game starts, and then we never come back to it. Now we're not gonna add any objects inside it. Instead, we're gonna use the rooms creation cord. You can access it from here, so I'll click on it and this window will open in the rule. So the court that you put in this winter will run when the room starts. So here are allowed this first of all, it re sizes. The games means our fares Using surface resize. At this stage, you don't have to know what surfaces are. Simply put, the application surface is fear that game is drawn. So the size off the applications are fails and the resolution off the game. So here I am, basically modifying the resolution off the game, Davitt and the height from the innam. Now here we are, calculating of it, and the height off the games window sort of it. And the height I multiplied by the scale, then between the size off the window, using windows hat size. Then using this function, it moves to the next rule. So that's where the game starts. and now around the game, you can see there, the window sizes correct. Bears older solution. Scale is four times bigger than the camera itself. So if I change a scale to one, the window will not be scaled at all. So you can see that it's very small, so I'm gonna keep it at four. Currently, the player is only a white square, so we're gonna add a player's brides in the next lecture. 9. Sprites & Animation: Hey there, in this lecture, we're gonna work on the player s brides and animation. 1st 4 I'll go to Strides and open. Ask Claire. I'm gonna change its name to ask player. Underscore Rider. So this will be the idols bride, and there will be a difference. Bride for Brenda. Player moves. Now I'm gonna click on import to import an image file. This is the one I want to import. As you can see, it's a sobriety that has five frames of animation, so I'm simply gonna import it now. The Sprite was imported as a complete image Northern Animation. We won't gamemaker to split this image into five separate frames. So again, I'm gonna click on import I right. Click on this pride and select rename Now, at the end of the file name. But before the PNG attention all time. This So this way gamemakers gonna know that desperate here has five frames, so I'm gonna import it. And now it's imported as an animation so you can play it from here. No, Make sure they're the origin. Settle middle center by default, it will always be sent to top left. But we can change that so go to file and select preference sales here selects plight editor . And here you can change the default origin to middle center. You're gonna need the middle center origin for most of your strides. Now you can hit, apply to save your changes. Now I'm gonna create a news bride and name. It s player. Underscore. Move. I move it up. No, I click on import. I'll important on animation, which has eight frames. So the file name has stripped it at the end. So the animation is here with all over state rams Now I'm gonna go to objects and open or player. I'll open your step around here. We're gonna any man, the player. So at the end of this event allowed this here we have two conditions joined by or Sullivan . Either of these conditions est rule. The following cord will run. So, districts, if move exes north zero. Which means that a player is moving horizontally and this checks if move eyes nor zero, which means that the player is moving vertically. So overall the conditions check if the player is moving. If it is 80 inches a sprite off the playa sands, that is done using a sprite, and that's variable. So here it said to the S. Player moves bride. So that's bride is going to be bled Now we want to flip Dying stars bears on where it's moving. So face right. If moving right and face left it moving left. So here it, except a player is moving horizontally. If it is it modifying the image escape variable that variables told the horizontal scale off the instance. It's sad to the sign off. Move X. Basically, if move access positive, the sign will be one. But if it's negative, the sign would be minus one. So we have on for moving right and minus pond for moving left. So when the in Ajax scale is minus one, the Sprite will be flipped her out. And if it's one, it will be normal. No, here we haven't asked Block, so that's going to run if the player is not moving at all. So in that case, that's right. Could be said to ask clear idea. Now run the game. Now you can see the players idol and moving animations. The instance Also faceless left and right there. John Very. It's moving so Now that we have the movement and the animations implemented, we need to work on the collisions, So we'll do that in the next lecture. 10. Collisions: Haider in this lecture will be working on collisions for testing. The collisions will be making an object called or collision, so that object should basically stopped a player's movement. So let's begin first fall ill open Espoli Idol. Here we need to modify the collision mask off the player so I click here to open the collision. Masked men. You. Now you can see them ask or the head books off the player. It's the area that collides with other objects. No, because of the perspective of our game. We just talked down. We need to reduce the mask to W's legs so only that part should be able to collide. So in the collision mass Manu Algerian the Moor to manual. And now you can modify the mask so I'll make it cover the legs only. No, we need to make sure that only this mask is used. No matter which pride, the player is using soil open or player. Now you can apply a mask to the object here, and only that mass will be used for the object. Currently, though, Damascus taken from the stances pride which you know genius as you move. So I decided to use the mask off s player. I lonely. Now I'll go to surprise and create a new one are lame. It s collision. You likely connected image and medical Simple box. Now back in the sprite, I'll open the collision mask menu. I'll chain the more to manual now will reduce the mask to only the ground area Now in the resources. All right, click on objects. I click on that group Groups can be used to organize objects. So this one did you use for world objects? And so I have named it as such. Now it our take on the group and create an object inside it Our name it or collision. I'll assign this bride here and now. I opened the game room here. I'll place a couple instances off collision if you want you condone off the grid from here , so then you can place them wherever you want. Now we're gonna work on the collision course soil open or earlier. I go to the step event. Now here we are, starting the move acts and move. I variables. So these valuable store how much a player wants to move and here the moment is applied to the instance, so the collisions will be handled here after the movement is calculated but before it is applied. But before, I didn't quote here, we need to make us create for checking collisions. So if we ever want to expand our collision jacking, for example by adding tiles, we can do it in the script. So I'll go ahead and make a new scripts are name it Collision. Now, a script is basically a custom function so you can pass in some arguments and data it on value. So you get to write what happens inside dysfunction and the arguments of debts. So here, all at this now, these are the arguments that the script takes. So it needs the X and the Y were the collisions need to be checked. Now the arguments can be accessed using the argument variables here, I'm using the police meeting function to Jack for object collisions. These are the coordinates where the collisions will be checked so the X and Y are taken from the arguments and you're checking for collisions with the objects localism. Now the place meeting function is going to return either true or false, based on whether a collision was found. And then the script is going to return the same value. So now we can use the script to Jack for billions. So I'll go back to the Blue Strap event. No, right here. Allowed the collision Gold. The collisions are handled separately on the X and the Y axis. Here we have one condition using the collision script. No, these are the X and Y coordinates. There will be checking for collisions. So for the X, we have X plus move X, and for them I will simply have lie. So it, except there's a collision with a player is about to move. Was only if a collision is found. Move access at 20 Soda player stops moving on the X axis. Now here it checks for a collision on the buy access. So here, move eyes, attitude of I and the excess simply X. So if a collision is found on the via access move, I will be set to zero Solis around the game and test the collisions. And they are working the boxer Stop the player from moving. But the collisions aren't complete yet. So to demonstrate what we need I close the game and opened a player's creative end. I'll change the players most B 25 and now we'll run the game. Now, of course, appear moves faster. No one ever the player collides with the box. There is a gap between them and there's a gap and of course there should be no gap. So when a collision is found, we had to move the player towards the collision, pixel by pixel so that there is no gap left. So let's go back to the players step event inside the block for the escalations allowed This this room's off my loop so the loop will keep on running As long as this condition is true and the condition Jackson, there's a collision directly next to the player. Here it is moving. So here it gets a sign off the move X value to add to the X. The sine function under does one. If the value is Boston and minus one, if the value is negative, No. Here we have the exclamation sign. Soviet checking If a collision is not found. So in that case, the player should move a pixel in that direction so it gets a sign off, Move X and answer to the eggs. So that's where the playable move pixel by pixel until a collision is found and the little bricks. Daniel Waxes had 20 so they're the player stops now. We can do the same for the by excess. So allowed this year. As you can see, it's the same logic, but on the Y axis, so decorations are checks on the by express with the sign off Move I, and it moves on the Y axis as well. Now let's run the game and test the new gored. And now, when you collide with a box, there would be no gap. Sort of while loops are doing their jobs. Now, back in the play object, make sure he's had the most B 21 Now in the game. You'll notice that a player appears below the box, so we'll work on that in the next lecture. 11. Depth Ordering: area in this lecture will be implementing dept. Ordering eating stars and gamemaker has a variable called Dept. It's used to, said the order off Wendy. Incenses are drawn. For example, let's say you have two instances here and be the depth Off is 100 the depth of B is 50. So and they're overlapping. B is going to be drawn about a No. That's because bees that is smaller than years, so the lower depths are drawn in the front. So now, if you said is that to minus 100 is going to be drawn in the front. So we're gonna use describe for the extensive start ordering. So let's begin. First of all, I'll open the game room. I'll open the background layer. I'll remove the backgrounds pride by sending it to none. So now it's just a simple color. I'm gonna change it to look like grass, and now it looks better. Now let's work on the depth ordering, so I'll close the room. Now I'll go to objects and open or controller here are allowed any rent, so I'll go on the strap and select and strap now the end step events run after the separate events. So we're gonna use this events for that ordering. So all the instances are gonna move in the normal step event, and then the adapts will be calculated in this and stepparent. So in the event allowed this using word, you can basically run some chord in another instance. So in these brand disease, you can enter the I D often instance or an object. Then the following cold will run in that instance. So instead of specifying annual stars highly, I went at all here sort of code here is going to run in all the instances in that role. Now here I'm changing adept off eating stars. I'm setting here to minus B box bottom. The baby box bottom value is the lie position. Often your starters bought a match. So the greater that Y coordinate is the Lord adapt will be no just run the game and asked it. Now you can see that a player is in front off the box and now it's behind it. So the depth ordering is working. Not currently in our game, WFS goes in the direction it's moving in. But for this game we're going to face the mouse, no matter. Various moving. So we'll do that in the next lecture 12. Facing the Mouse: hater. In this lecture, we make the playoff. Here's a mouse, no matter where it's moving, to implement the change, all open or player, I'll open it. Step around. I scroll down to the end. Now, In this part, the major Experian off the player is set to the sign off. Move X This way, the players simply fierce elsewhere. It moves. So I removed this body. No. Make sure your gold looks like this now at the end, allowed. This first of all, discussed the difference between the mouse's eggs and a player's. That's then did gets a sign off that value and stores it in this variable. So now we have either one or minus one, based on where the mouse is relative to the player. But if the mouse's X is equal to the players X, then the difference will be zero and the sign will be zero as well. So this condition make sure that the sign is north zero. In that case, the sign is applied to the major scale. So this way the player faces a mouse. Now let's run the game and test it. You can see that a player now faces a mouse. But there is an issue. If you move backwards, the animation still most forward. So, of course, it looks off solar school back to the players step event at the end. All of this, first of all, the maid speed is the speed off the animation. So when you started to minus one, the animation players and rewards and then, of course, if you started to one, the animation plays normally. So using these conditions were checking if the player is moving backwards. Basically, if you're checking if the player is facing in one direction and moving in the other direction. Here we are checking if the move X is North zero, which means that a player is moving horizontally. Then we're getting the sign off, move X and comparing it with the sign off the mouth. So we're checking if they're not equal. If they're not equal, it means that a player is facing in one direction and moving in another. So in that case, the maid speed is had to minus one so the animation moves backwards. So let's run the game and desperate. No, If I move backwards, the animation moves backwards as well. If I move forward the animation players. Normally in this section, we set up the player, the camera, the collisions and the animations. No, we'll be starting with the next section. We're going to add a pickaxe, breakable objects and resources. 13. Breakable Objects: Hey, Leo. In destruction, we're gonna add breakable objects. Basically, these are gonna be objects like bushes, trees and rocks that you can break with GOP cats. So these are always happening objects. Now we need a way to group all of these objects into one category for easy interaction. So we want them to be under the breakable category. So for that we create an object called or break about Parent. No dad object will be the parents off all of these objects, and these objects will be the Children off or break about parents. So whenever you use or break about parent to find an instance, the instances off these objects are going to be included as well. So it's a simple way to grope similar objects together. Now, another future of parenting is that the cold you add in the parent will be run in the Children as well. So that's we're going it inside the strides I read in a group Gold World. Inside that group, I have asked Bush industry, Now open the boy Sprite. I'll bring down the origin to the center off its bottom part. If you look at it like a truly model. It'll make sense now. I'll open the tree X prize again. All they are just the origin and now will open the collision mass menu. Algerian the Moor to manual. Now here I will modify the mask to only the area where the player should be able to click on it. And now I'll close it. Now we'll go to objects. And inside the world Group, I create an object are name it or break about parent. Now I'll make the Children object first all Bush and then Ortrie now all assigned, yes, price. Do them. And now let's open or break about parents to set up the parenting. All open the parent menu. Now here we can assign. Children took this object so I'll go to objects and select or bush and or tree. I dragged them and drop them into the Children left. So now, or Bush and notary, our Children off or break about parents. Now you can click here to assign a parent, toe this object soil, open the menu, go into world and select or collision as the parent. So now or breakable, parent is a child off collision. Donald Bush, a notary, our Children off or break about parents. So the bush and the tree our Children off for collision as well. So, for example, in the collision script specifying or collision only buttons or Bush a notary, our Children off for collision, we can collide with them as well. So this is a great use off the banding system and now will open the game room. Here, I'll play some bush and trillions dancers. Now you can see that the Great is too big for the bushels so I can go here and reduce the cell size for the great toe ed by it. So nobody think them should be easier. Now you can see either than dragging the objects from the resource tree into the room, but there is another easier way to place a stances. So after selecting an object in the resource tree, you can hold the old G to place in Stansell's. You can also place multiple instances at bonds. The room is ready for now, so I close it. No in the breakable parents allowed to create event in the event all Oddo's. This is yet to be off the breakable object. So it's simply how many clicks it takes to destroy it. And here I'm simply storing the SB into another variable called at the Max. So later we can use this variable to know the maximum must be off the instance. And now they're just happy event in the event a lot does. If the SP reaches zero, the in stars will simply be destroyed. No, if you open and a child object like the bush, you'll see the same events. There. You can open them here and read them, but you can't edit them, so you can only modify the parent events in the pirate yourself. Now I'll open the tree, and the events are here as well. No, you can right click on an event to override the parents event and write new gored. You can also inherit the parents event and add some core to it. But for now, we don't need any of these options. And now let's run the game. Now you can see the instances and also collide with them. No, we need to add a pickaxe, so we're going to add it in the next lecture. 14. Creating the Pickaxe: Hey Dio, Indus Lecturer will be creating the tickets now here I've imported us bright for the pickaxe. I'll open it. No, in the sprite we need to change the origin to boredom Center sold. A pick axe is going to rotate from that point. No, let's go to objects and at an object. Ford epic Cats. No one simply assigned this bride. For now, we're not gonna add any chord in this object. So let's go to the player. I'll open this create event in this event. We're gonna create the pickaxe, so I'll add this here. It's simply creating an instance off the pickaxe object. Add a player s position. It's I d stored in a variable called Hell's Item. So any item that the player can hold beat up a cat's a sword or something else will be stored in this valuable knowing. When I add the instep different, we'll move the pickax in this event so allowed this here It simply checks if they held item exists in the room. If it does, it simply says the items position to W s position. So the item is basically going to stake to the player? No, no, said. The destroy event in this event allowed this, if the held item is is, is going to destroy it. So when the player instruments is destroyed, the hell's item We were destroyed as well. So let's run the game and see what we have. No, the pick axes there, but it's behind the player. So we need to fix up the debt and adjust disposition. So far, much Ford adapt. I'll open or controller here. I'll open the end step event. No, inside this weblog that runs for all instances. We need to add an exception for the big cats, so I'll add this year, first of all, the jacks. If W. Instance exists, then we get the I d off the players held item. Then we check if this concerns as the players had item. So basically, this court is only going around for the players held item source that will be really used by it. And that's where it'll appear above the player. You can also say that it's eight points above the ground. No, no school back to abruptly object in the end step event we've been are just operation off the held item. So after the exile at this, the expedition off the item is offset by minor three page on the players in a jack scale. So wherever doubly offenses, the item will always be on the cracked side. No, Fordham, why I'll simply air three. Do it. So let's run the game again. And now you can see that because no matter where you face, it's always in the correct position. But the depth is not correct here, because if you move down, you can't see it sort of fixed that. Let's go back, toe or controller instead of subtracting age from the debt agenda to 10. So they should fix topic access. Stepped issue in de conditions were running a function on getting a variable from a new stars? No, Both of these things are done in all in, Star says, because of this word statement. So, for example, if there aren't any in stances in the room, that dysfunction is going to run 10 times in monster. So instead we can make it run only once, and stories result in a valuable you can do the same for eating this valuable from a player . So at the top of this event, allowed this here. I'm checking if w exists and storing it results in this local valuable just way the functional Iran's wants. No, this variable stores the i d off the players held item. So Grantley it's had to know one, which means no instance. If W does exist, it said to the players held item. So this way, Reda players held item valuable only once, then in the conditions you can fill in the local variables instead. So this works the same way, But it's more optimized. So now let's run the game and not a pickaxes being displayed perfectly. Now we need to make the pick axe usable, so we'll actually be able to break the breakable objects in the next lecture. 15. Lerp: Haider in this lecture will be learning about the love function. And just like this circle, the love function can be you, too. Smoothly animated something in the next lecture will be using this function to smoothly animated the big cats. So in this lecture, let's see how the function works. But if you already know about the function, the new miss Give this lecture. So the function DX three arguments A, B and E no is the first value and being the second value. Depending on the value off T, the function is going to return a value from A to B. So if t zero the function, will it on A. If he is one, the function will return B and if t 0.5, then the function will return the value in the middle off A and B No, not say you posit in 10 and 20 as the values. So Biti's had 20 You would get 10 committees had to one you would get 20 and Bt's had 20.5 . You would get 15 because it's in the middle off 10 and 20 so you can use any value between zero and one. So that's for the function does. But we'll be using it in a different way. For example, let's say we're going too smoothly animated The X value often instance, so in the function weakens had acts as the first value. Then we can enter the target as a second value and for the TV could enter zero point fun. And then we can apply the return value back to eggs. So now the X is going to move 10% towards the target 10% because of your 100.1. So if this happens east app, then the X is gonna enemy it. And just where you also get smooth movement, because when the difference is lower, the speed well below as well. So now let's open up Gamemaker and desta function. No, here I have a blank project. So for the demonstration allowed an object in the object allowed the step event, he only lets make the X value an immediate to them also sex here. The first value is the instances acts, and the second value is the Mouse X, which is a target. So each step, the extra gonna move 10% towards the mouth. No, said the draw event and draw simple. So go, so they're simply draws a circle. Adan stances position without hardly do Pixel radius now will open the room and place and in terms off the object here and now we're on the project. Now you can see that the Circles Moodley follows the mouse on the X axis. So using the love function, you can smoothly animate anything. So try applying the same effect on the Y access and see how it looks. So now we'll smoothly animated the rotation off the pick axe in the next lecture. 16. Using the Pickaxe: Hey there, in this lecture, we're gonna make the pick axes about the pick Axe will have a variable court cool down. So in the beginning, it's going to be at zero. But when you use a pickaxe, it will be sad to 20. No. Each step. It's gonna keep going down until it reaches zero. Now you can only use a bigger expend. The cool on value is at zero. So when you use the pickax and the cool down, it's had to 20 and then keep going down. You won't be able to use the pickaxe again until it comes down to zero. So basically, when you use the pick axe, you can't use it again for 20 steps. So let's began. First of all, I'm gonna go to objects and open or pick axe. Here. I'll add the creative end knowledge initial I some valuables here. First of all, we have the coolant variable starting at zero. Now, this is our rotation off the big cat. This will lead to be applied today. Major angle variable. So by default, topic exhorted at a 45 degree angle. Now this was the maximum distance between the player and a breakable object so that you're able to break it. So if a breakable object is more than 32 pixels away from the player, you won't be able to break it. Now let's add the step, and we're gonna do all the breaking so allowed this year in the first line. I'm using love too smoothly. Move the value off rotation toe 45. So whenever you modify the rotation off the pickaxe, it's always going to come back to 45. Now. The major angle variable is what controls the actual rotation, often styles. So for that we're multiplying rotation valuable with the players in a jack scale. The players ex scale can be either one or minus one, depending on where it's facing, so the final rotation off the pickaxe will be based on Weird. A player is facing that way. It's gonna look correct in both cases now dysfunction gas. If the left most button is being pressed so that is stored in this valuable now, this valuable the story. I d off the wreck A 1,000,000,000 stars under their mouth. So for that we're using a function called instance position. It simply gets an instance at a position so that position here is a multiple vision and we're getting an instance off or break about Barrett. It also includes those Children objects or Bush and Ortrie. So if one instance has found add a position, it's gonna get own its I D. If one instance is not found, it's going to be done. No. One, no, we need to operate on that in starts. So a lot this year here we have of with statement of which statement is used to run some cold in another instance. Here you're specifying the breakable InStyle's. So basically all of the scored from this bracket, So this bracket is going to run in the break. A 1,000,000,000 stars. So here we are in the school off that InStyle's so any variables that you read all right here will be from Darren Stars. Now, if no breakable in stars has found at the mouse, underscored will not run. No, here you're getting that the stars between the breakable in stance and a player, So we're using the distance to object function for that and then that it starts a stored in this variable. No, you're checking If the distance a smaller danda break the stars valuable in de pickets. Not be a currently inside the school off the record Bellesiles. So if you want to use a valuable from doing 1,000,000 stars, which is the pickax we have to use other. So that's what we're doing here. We're getting a valuable from the pickaxe by using other. And now we have two more conditions here in the fourth condition. We're checking if the colon off the pick axes at zero so gained were using other No. Here you're checking if the most button is pressed. No, If both of these conditions are true, then we have used our tickets. So first of all, we reduce the SP off the back A 1,000,000,000 stars by Ron. Then we said the rotation off topic extra miners, Eddie. Then finally, the sad topic Access cool down to 20. No, we need the cool down to gradually degrees back to zero. So at the end allowed this. So if the golden is greater than zero, it'll go down by one. And now let's run the game. You can see that Know the pick axes or dated? No. When you click on a bush the angle to India's. But then it goes back. And of course, you can also destroy the break. A balanced answers there destroyed when they experience zero No, in the next lecture will be adding a selector around the selectorial styles. 17. Selector: Hey, Dio Indus Lecture We're gonna add a selector So it'll appear on the breakable object that you have selected Now I was bright for the selector only looks like there's so it's for one corner So we're gonna draw it four times once on each corner off the InStyle's. So let's began. No, In this price, we have a new group, Gordy. Why? So everything that acts as a user interface will going here. So here we have the selectors bride. As you can see, it's an animation. Now we need to draw this at each corner off the selected break A 1,000,000,000 stars. So let me explain how that's gonna work. As an example, I'll go into world and open s Bush. I'll open the collision mask menu so we can see the mark. Now that's a lecture will be drawn at each corner off the mask so you can get them. Ask coordinates using the built in B box valuables. So be box left gives you the X coordinate off the left edge. Be books, right. Gives you the X coordinate off the right edge. Then be Bookstop gives you the by co ordinate off the top urge and be box boredom gives you the bike ordinate off the border match if you remember of you speed box bottom for the death ordering. So using these coordinates, we can get the positions off each corner off the mask. So now let's open up or pickax and work on it. Foretell open the creative meant here. Let's initialize some variables. No, these are some valuables for this lecture. This variables told the i d off the instance that is selected. So currently it said to no one no this variable stores. He made index off the selectors bright So this way we can animate the selector by adding to this variable. Now this valuable stores a total number of frames in the selectors bride. So for that we're using this pride get number function. Now let's open that step event in this condition you're jacking. If the breaking ball in stars is in, the players rage. So if that's true, we want to send the breakable instance as a sectarian stance. So after the condition allowed this so the i d off the breakable your stance is applied to the selector is viable. Now I'll go to events and click on Add event. I'll go in the draw. It's like the draw and event. No, the draw and events run after all the draw events. So everything in the room will be drawn in the draw event and then this electoral will be drawn in the draw and event. So since is drawing after everything else, it'll appear at the top. So in the event allowed this force, we have a condition that Jax left us Electoral stance exists in the room. So if it does, we don't know what statement on that in stars. So inside this word statement will be drawing the selectors. So we have a drug called for each corner. Now be using the function draws tried txt to draw the selector dysfunction allows you to specify some additional options for this pride like the scale, rotation color and al far. And of course, you have this pride the mid index, the X and the by. So this pride is US electoral and the image index is the selector free, invariable. Now this one will be drawn at the top left corner. So for the X, you have B box laughs and for the value have be bookstore. So the Gordon in exchange for each corner. So here you have the top right corner. Then you had the bottom right corner and then finally you have the bottom left corner, No. 40 X and a Y scale, the color and the Alfa. We have entered the default values. The only property that's different for each corner is a rotation. So for the top left corner, the angle zero. Then we have minus 90 for the top right corner, one ity for the bottom right corner and 90 for the bottom left corner. So this way the selector is drawn for each corner. No, here be animating the selectors bride by adding to the selector free and variable. Now let's make sure that the frame value doesn't go outside the frame. Limit Soviet checking if the grand frame number is greater than or equal to the total frame number. So that basically means that the playing animation has ended. In that case, we subtract the frame number from the frame value. This way, the animation starts over. Then, at the end, we said this lecturing starts variable to no one. So now let's run the game. And now you can see the selector around the select A new stars. No, each break a 1,000,000,000 stars hasn't be, but you don't see it. So in the next lecture we'll add a health power for the breakable objects. 18. Breakable Health: Hey, Leo in this lecture will be adding a health par for the breakable objects. So let's began for this will be working with the breakable parent object soil open. It's first of all, a click on the variable definitions button. It opens a small window here, so here you can basically create variables like in the create event. You can then go into the room and mortify the variables differently for eating stars. Source. Pretty useful, but we are using it for a different reason, and the reason is that deals has a color picker, so it's easier to create color variables through this window. So I click on the add button to add a variable on Sunday, its name to Ashby Color. So this will be the full color off the health bar. Then I'll Jane the type from Rio to color. Then you can click here to change the color in this variable. Also, make sure you turn the Alfa all the way up. No, my color is ready. Solidly going. Okay, now I closed the Vinto and resize the other ones. Now let's open the create event inside it out at this. This is simply the height off the health bar. Now I'll go into the events. Go in the draw on are the draw and event. So we're gonna draw the help power in this event. So I'll add this year in this condition we're checking. If the HB is smaller than the Mac such be. So we're basically checking. If the player has clicked on desperate Kabbalah stars, at least wants. Only then should the health partial. Now here we have a local valuable for the health pass. Why? So it's simply that the box bottom plus one Now you're getting the health feel amount by dividing the SB by the SP max. So it'll be a value between zero and one. Na Vi is heading the drawer color to DSP color and then we're drawing the health bar by drawing a rectangle so it's top left corner will be at the B box left and the health passed by then. Here we have the right eggs. For that, we're multiplying. This bride were with the SP amount on adding that to be box left and then for the bottom by the adding the SB height to the house passed by then at the end. The zero means that itself will direct angle. Then we are is hurting the color back to white, then flying Livia drawing the health past border here. All the coordinates are the same as before, except the right eggs there were simply entered. Be both right than in the last argument. We have one so that it draws only the border. So now the health power should be drawn with a border. And I feel so Let's test it out. And there you go. You can now see the held or for breaking one instance never knew break the breakable objects. They need to drop some resources like an apple and orange or some would. So we'll be working on that in the next lecture. 19. Creating Resources: Hey there in this lecture will be creating. There is also this so you will be able to collect them by breaking bushes and trees. So let's begin. First of all, under strides, we have a new group called Items. So inside it, we have as apple as orange and s word. So you and I are these three items in this lecture So far, So far, all we need to set up some in 4 40 items. So Ford at I'll go into the scripts and create a new one are simply name it in it short for initialization. Now the script is going to run at the start off the game, so we'll be initializing all global that are here. So to make the scripture on at the beginning, off the game allowed this inside it. The G M El problema function is used to tell the combine er to do something specific. We do there to a command entered in the first argument. So we're using the global command. That command is used to tell the compiler to run some cord before the game starts. So that's before the first rule is loaded. So the court veterans before the game starts, is in de string and in the court were simply calling the in its function. So basically, vendor game starts that ended function runs also It doesn't matter whether Gmail problem of function is placed. You can place it any veal and the effect will be the same. Now we can use the script to initialize the data for the items so allowed this year. Here we have an enema cold item inside it. We have three members Apple, Orange and would no, you're not explicitly giving the inner members any values. So by default their values will be 01 and two. So they essentially indeed yours in ascending order. No, here we have a global larry court items, right. It stores this pride for each item sold off oratory element will be the first item which is the apple and its value is the S apple resource. Then we have this pride for the orange and then does bride for the board. So whenever we want to draw an item, we can get its pride from this or a no, it's time to make the item object. So I go into objects and add a new group. I'll name it. Collectible in the group will create an object Gordo item. So this will be the item that the player can collect. So I'll go into the object and at the create event in the event on our does, this viable simply stores the item, type off the instance so its value will be from the item in, um that we just created. Then this valuable simply stores whether the item has been collected by the player. So by default it's that falls. No, let's add the step event. Let's make a player able to collect the item by adding the scored First, we have a set off two conditions to allow the player to collect the item. So for three jerk, if collected, is false, then we check if the item is colliding with the player using players meeting. So if these conditions are true, it means that the player can collect this item so here will be adding the item to the elementary. But of course we don't have an inventor yet, so we leave this part Mt. Four letter. Now here we are simply is having collected to Drew. So that means that the player has collected this item. So here we have a block off court that only runs if collector is true. So if the item has been collected, we've only to fade away. So we're reducing the image, Alfa. By the your 0.5 we're also using the by by 0.5, so it also keeps going up. So when collected, the item fades of a while also moving up. No, when the middle far becomes smaller than 0.1 the instances destroyed. Now we need to Arkansas pointing the items. So let's go into objects and open or Bush. We need to give this object a creative and off its own, while also running the creative ends off the parent. So for that, we can right click on the event and select inherit event. No, this object has its own creative ends Inside it, we have the event inherited function. It runs the event off the parents. So this create event is not going to override a creative end off the parents. Now we can add court for this object. So we list There is also says that the Bush is going to create here the initializing an area called Dress. It's short for resources. Now. They are a only has one element, which is the apple. So a bush will only give you an apple. Now, let's open that re object. I'm going to do the same here and inherit the create event. I'm gonna initialize arrest. Sorry. Here. No. Here we have three re elements. The apple, the orange and the wood. So what, We can give you any of the three items? No. We work with disarray in the break about parent. So let's all finance. I'll open it. Step event here. If he s punitive, zero Dean stars is destroyed. So we're gonna create the resources inside the same block. So after instance, destroy allowed this. Here we are simply is heading up some variables. This valuable stores the number off. He's also so that would be dropped. So that number will be anomaly chosen from these values. So that's what that use from condo's. It's simply returns are and in value from the arguments. And here we have written 14 times to advice and three only ones. So one has the most chance of being selected and three has Aly shells. No, this viable simply gets the number of resources in. The rest are a it uses. The are a land fondi function, which simply gets the land often array. Now let's create Are your sources so allowed this year here of your running or repeat loop in the argument I've entered the resource count. Now the repeat loop simply repeats the same code a specified amount of times. So let's say if the value off rest count is three than all the cold here will run three times. So each time is gonna create our random resource. From the rest are a no insider repeat loop began the rarely met number off the item that will be created, so basically it's lot I d from the area. So for that, we use the A random function to get her anime teacher from zero to rest. Macs minus bond. Since rest Max is the total number of items in the air. A rest Macs minus one would be the last item in battery. Now we're getting a resource that will be created from the rest are a using the rest. I devalue no Despots Arts of the X and y position with our resource will be created. So for the X, we have the instances acts plus a random number between minus four and four and then we have the same for the by. And here we finally created The item is stars. It's ideas strolled in this valuable and he had he had the position. Then we run a which statement on the newly created and stars inside it. We said that type variable off the item to the resource that we got from the area. Then we said this pride index off the item iStar. So we grant us pride from the global items brighter A. Now the breakables should drop your sources and they should be collectible by the player. So let's run the game and tested out. Now let's break some bushes. So the bush gave us three uppers. This phone dropped one apple and this one as well. So the resource counters organs random. Now the trees can give you would oranges and apples. So along with the resource count, which resources are created is always random. Now, when the items are dropped, they don't look like they're dropping dead. Just appear. So we need to add a dropping animation in the next lecture 20. Item Drop Animation: Hey there in this lecture will be working on the item. Drop an emission. So for that I'll go into objects than into collectible and an open or item. I'll open its create event now, at the end of this event, that's when you should lie. Some valuables he have, you're creating a Z axis. You can see it as that her dimension off the instance after X and Y So using this, the access will be able to make the instance fall down its initial value. It's minus 16 so values created its 16 pixels above the ground. So that's where the instance has free access. So it's basically three D, but the game itself, it's toady. So we have to project the three accidents and two D. So for that, we're simply gonna add the easy access to the lie excellence while dying stars was being drawn. So we'll handle that in the draw event. No, this valuable is simply the speed off the instance on the Z excess. Now let's open the step event and implement gravity. So at the end, a ladders. First we check if the Z is negative by checking ever smaller than zero a negative Z means that Diane Styles is above the ground, so that's when we want gravity to act upon the instance. So here we are increasing the speed by 0.5 Saluzzi. Speed is a gravity's force. So does the speed is then added to the sea. No, here we have gold for endings, studies the ground. So for that Carjacking, if the Z is greater than or equal to zero, So that means that we are now on or below the ground. So in that case, we said the Z and Aziz Bey to zero Saudi Instant Start falling. Now let's go into events and add the droid event. Hear what had this quite a long function call. So here we have draws Bridey X'd so using the function, your manually drawing the instance. So he have you had this pride, the image index, the X Y and all of the other properties. They're all set to their default values except for the by. There we've added a Z to Dubai, so the movement on the Z axis will be visible on the buy access. So let's run the game and test it out. I'll break a tree and you can see that the items fall down and now a break a bush and you can see that the heart from it the items fall down is too high for the Bushes. It would be a little lower for them. So let's close the game and fix that. For this. I'll go into world and open the break about parents. I'll go to it. Step event here we have of which statement that runs all the created item. So here you said the initials E position off the item. So inside the red bloc allowed this. This will be the initial Z value. Often item. It will be dependent on the height off the brake Kabbalah stars. So we get the heart using other. Then we make it negative. Since the Z needs to be negative to be above the ground. Then we divided by two to lower the initials E position. So now the issue should be fixed. So let's test it. I'll break a bush and you can see that the items are not created and the correct height. If I break a tree, the items will be created a bit higher. No, we need to add some more breakable objects and more if also is so. We'll do that in the next lecture 21. Adding More Resources: hater in this lecture will be adding more is all SOS. So here we have some news brides for the new resources. So inside world, we have a stroke and s I and or these will be our new breakable objects. No wonder items we have est Ronan s I am so these will be our new resources. Now we need to set up some data for the new resources. So I'll go into scripts and open in it. No, Inside the item in, um, I lead to more members stone and iron. No, we need to add the spry. It's for these items in the items brighter a So at the end off the script allowed this. So now the sprites off these items are stored in the area. Now let's go into objects. I'll open world and inside it's like two or tree, no one, right click on it and select duplicate. So an obvious simply duplicated the tree object. We're gonna use it to make their own. So what you in just name toe are all I'll open the object here, you can see that it has a big about parents already assigned, so I'm gonna go here and James s pride. Now let's open the creative and to change up the properties here. We're going to remove the aria. Sorry. And in its place will add this. So now in the rest Sorry, we only have one item. The strong. So are all coming. Only give you strong's. No. Here you're changing the HP for the object. The HBO overall will be five. So it'll take five PX to destroy Iraq. Now we also one has had the SP Max valuable to the F B Saudi SP. Valuable is initialized in the parents creative end. And here Viet Union gets only for this object. Now we need to make another breakable object. So for that, I'll duplicate Orrock. I'll name this oi, nor I'm gonna go to the object and changes pride and now will open the creative end. Of course, this object is gonna have different properties. So I removed the previous wants and no allowed this. So now the aria sorry only has iron and DSP often ion or will be ed So it'll be harder to break. And again we is heading the SP Max to Let's be now we'll go to objects and open or Bush to genius that be so all open the creative end? No, after the referee, I'll add this So the Bush is such b would be to and now will open or tree to do the same. Soil opened the creative end, and she and the SB 24 So now each other breakable objects has a different HB. Now I'll go into the game room and play some Mr Office off the new breakable objects. And now we're in the game, and here we have our new a breakable objects Soil, Break Iraq and get some stars now a break and Ionel, which takes longer and get some iron. No, there is a small bug with the hat boss. I click on the nine or and you can see that the health power is overflowing. So there's something wrong with the health bar gold, which we need to fix. So for that I'll open or breakable parent and go to a straw and event. Here we have scored that draws the hatbox feel here we're using Sprite birth to fill the half bar, so that's a very toe off the sprite and here for the border were using the B box coordinates. So the size off the mask and the size of this pride can be different. For example, when Damascus smaller to explain what I mean. I go into strives and open s iron ore. Here you can see that we have gaps are on the item. So this is this bright wit and this is the mask were so in this case does pride where it is clearly larger. Danja Masch Where? So that's why the health bar was overflowing. So for the half bass feel we need to use the mask Where? So let's go back into or breakable parent here after the amount valuable, I'll create a new one. It'll be the overt off the mask. So it'll simply be the B box right minus b box left. So that gives us a bit off the mask. So now we can use this viable for drawing. The Phil Swan removes bright wit and use our new variable. So now the issue should be fixed. I'll go into the game and click on an ion or and now the health bar looks OK. Now let's move on to the next lecture. We will be working on the inventory 22. Stackable Inventory: Hey there in this lecture will be working on a stackable inventory. Yes, basically an inventory where your collected items will be stored. What's trackable means that you can have multiple items off one type. For example, you can have five apples, three oranges and 10 boards. So each item Indian men tree hostile properties type and count. The type is the item type and the count. Just how many items you have off that type? No. 40 elementary will create ideas lest Adi s list is like canary but more flexible so you can easily add or remove items. So eat item type that you collect will be added to the DS list. But we also need account for each item. So instead of adding the item tied to the last, we'll add a smaller A. That area will simply store two things the type and the count. So the inventory list will simply be a list over is an eatery will have that items type and got. That's how are stackable. Infantry will work. Let's get to it. First of all, to initialize the inventory all open or controller here I'll open the create event here were simply gonna make the inventory list. So are the anti ladders. We create a list using the S Let's create the I. D off the list Strolled in This valuable. So true, This viable. We can now access the inventory list. Now I'll go into the events and open the cleanup event here we are simply going to destroy the list. So vendor romance used Yes, let's destroy to destroy the inventor list. Now for adding items into a death list, we're gonna make a script, so I'll go into scripts and push and a group our name it inventory? No. Inside the group, I make us grabs an image I envy. Yet Seville used their script for adding an item. Two of the inventory, No, in the script allowed this another script, extra arguments, the item type and the item got So here we are, taking the arguments and storing them in these local variables. Now, here I'm getting the I D. Often Ventria lives from, or controller. I'm storing galex tidy in this local variable. Now we can access the same list, but through a different variable. Because you know, typing this is easier than typing. There's now to add the item to the list as honorary. We could do this here. We're using the S list. Add to add something to the list. What we adding to the list is an array data has two items the item type and the cult so pretty simply Andrea is added to the less. But this is not what people want. I mean, is gonna add a new worry for every item that you collect. So let's say you collect two apples. So this way you're gonna have to separator is for the two apples. Of course, that's wrong. There should be only one array for an apple. And when you collect another, the count would go up. So here's what we're gonna do. We're gonna Jack, if the item exists in the last, if it does, we're gonna increase the count. Otherwise, we're going to create a new worry and add that to the list so less true that I'm going to remove this line and in its place allowed this Now in this part will be checking if the item already exists in the list. So first, I'm getting the size off the list using the s less size that size of Strode and this local variable. Then we're running a four loop for each item in the list. So the I variable goes from zero up to the last size when the loop stops. No, inside the loop, we can hear a store in the list at I No reading something from a D s Less is very similar to one array. But you need this vertical bar for a list. If you don't agree, would it is control in error? Now, you know they're the item. Die was in the first lot off the area. So we get the item type from the array by guiding slaughter zero. Then we check if it's equal to the new item type. So if they are equal, it means that the item already exists in the list. So in that game, we're going to increase the item count. The count is in the seconds, Lord, so he modifies Lord Bond, we simply increase it by the new ground. And now let me explain what this is. It's called an excessive, like the one we watch for the list. If you're going to modify honoree that you got out of a list. You have to use the addicts as well. That's what we are doing here. We're modifying Gunnery, that we got from a list. So that's why we need to use the addict for So So we found the item in the list and then being created. Scout. So at this point, we're going to end a script and to end a script, we can use return. So here the loop and the script will stop. But if we don't find the item inside the list dental script Wiki going and finally the loop will end. So that means that the item Maria doesn't exist in the list and used to be created. So in this part, you can add a new area. So here I'm creating the array with the item type and account. Then I'm simply adding the area in the list. So now the script is ready to be used, so I'll go into objects, go under collectible and open or item. He'll open the step event. No, this is we had a player collects the item here. We have an empty spot for adding the item to the inventory. So here are allowed This. So we're using I envy add to add the item to the inventory. This is the item type which is a valuable of this object. And this is the count. So using dysfunction, it's pretty simple. Now, before testing, we need to draw the contents off the list so that we could see what I don't see air. We'll do that in or controller soil brass control a D and start for controller here. So this way, any resource can be opened quickly. Now we're gonna add a new event, so I'll go in the draw. It's like that draw. Do I event anything that you draw in death Cement is drawn directly on the screen and north in the room. So here the coordinates zero by zero would be the top left corner off the game. Vinto nor the room. We'll be drawing the inventor here soil. Add this. By the way, this is only a test. We're going to remove the score later anyway. So writing the score does not requirements door. I command you to do so. Now here we're getting the size off the list and here we're running a four loop. So we're simply going through all the items in the less like we did in the script. So here we're getting the area from the list. And then from the array began the item tied and the count. So we're gonna draw both of these things? No, he have You have the position where the item will be drawn on the screen. So for the X, we simply have it then. Ford Ally, we have eight plus 20 in tow, I So, for each item, thereby position will increase by 20. No, You getting this bright off the item from the items brighter? A. Then we draw this pride using draws bright, it's drawn and the items position. And then finally we draw the count off the item using draw text Exposition is X plus for and by minus true. So now the items in the inventory and the account should be drawn. So now let's run the game. And after it out now a break a rock I'll collect the stones And now you can see them here. So I go three off them. No, we'll break another oak and get only one stone. So the count went up by Von to four. So now if I collect a different item, tie it, lad, and you were a and collecting more items off the same type increases the count in the same way. No, as I've had before, this was only a test for our game. We need an actual polls menu where we'll be drawing the inventory so we could never corn, pausing in the next lecture. 23. Pausing: Hey there in this lecture begun of our corn pausing. So here's what we're gonna do. We're gonna use the escape key for pausing So Andy escape g expressed. We're gonna deactivate all instances. So all the instances in the room will be disabled. No, Brenda Pleo presses the escape key again. All those transfers will be activated. So that's basically how posing is gonna work. So let's began. I'm gonna go into objects and open or controller here, I'll open the creative end. No, At the end off the event allowed, this describable simply strolls whether the game is paused. So by default, it's that falls. No, I'm gonna go into events and there are those type event We're gonna handle the pausing in this event soil at this. First of all, you're checking if the escape key was pressed. So now we need to eat a pause, the game, or on board it in this spot, we're gonna Paul's again. Sylvia checking if balls is false. If it is, we started to drool, then views the stars, deactivate all to simply the activate or list others. So all this translators in the room will be temporarily disabled. No, India argument we have true the argument controls if the current instance she has activated . So if you said it too falls, all instances will be deactivated, including this instance of all controller. But we want or controller to stay active. How else are we gonna impose the game? So we said the argument to true and or control honesty is active. No. Here we have a nice block Deschenaux run if the game is already bald. So in that case, we've had balls to falls on, then pause the game. Then we use and starts activated all to simply activate almost answers. No, let's run the game And after it out and I'm gonna press escape and you can see that everything disappears because you know all the ants ourselves having deactivated, so they don't do anything and they don't draw anything. So as a result, you only see the background when you press escape again. All their stance has come back. So now the pausing does work, but you can't see anything while the game is bald. You should be able to see the last frame before the game was boss. So here's how are we gonna do that four days, we will you sell for cells. Plus our fears is basically an empty canvas Where you control anything? No. Every game has a defaults office called Application Surface Dash, where the game is drawn. Source. Basically the output off the game. No Ford opposing. We're gonna create our own surface. And a meatball, sir. No. When the game is balls, we're gonna go be the applications office into the boss, sir. So now we have a snapshot off the game with all dying stances. Then you can draw that snap short while the game is paused, so practically will still be able to see the game. So let's do, Dad. Let's go into the controller object and open. The creative meant no idea and allowed this. This variable is gonna stroll the poor surface. Currently, there is no software is. So I'm sending it to minus one non Isobel in this happy event. No, This is where we pause the game and deactivated Donna Stansell's. So we'll be creating the post office here. So, after instruments reactivate all allowed this here we are simply creating us office using the surface create function. This is a big toe off the surface. And this is the height. So the size off the surface is simply the resolution off the game. Now we want a copy the applications office into the boss's office. So for that, we're gonna use office copy. This is a target where the GOP, it's obvious, would be basted. So of course it's boss off. And this is the souls, which would be called bead. So that is the applications office. No, this is the position inside the post office where the applications office would be bested. No way. It can also be destroyed so the applications office will be copied into the boss off. No. When the game is on Paused, we won't up also appears to be destroyed. So I'll come down here where the game is on pause and after instruments activate. All allowed this. Here we are checking if the ball so affairs I lives. Then we are destroying the surface by using surface free so the surface is removed from memory. But you might be wondering, might be a checking if the surface I've lived before destroying it. We're doing that because officers can could destroyed automatically. So before doing anything with those offers you need to share keep it exists. And I'm gonna open the cleanup event, and we're going to destroy the surface here as well. So we're making sure that the self is destroyed when the romance now we just need to draw up also appears when the game is paused. So for that allowed a new event. Go in the draw and add the drawer. Geo, I begin event deserve entrance before the draw. Do I haven't sort of also office will be drawn before energy. Why elements So in the event on our days, first of all of your checking, if the game is paused and then we're checking if the boss obvious I was just in that game, we simply draw this office using draws office. This is the stuffing is that would be drawn. And these are the coordinates where that's office would be drawn. So now let's run the game and test it. I'm gonna pause the game by hitting escape, and now you can see a snapshot off the game with old honest on serves. So now pausing is working properly? No, Before walking on the inventory, inter pares we wanna put a limit only elementary. So when the elementary is full, he won't be able to collect any more items. So we'll do that in the next lecture. 24. Inventory Limiting: Hey, Dio in destruction, we're gonna be working on an inventory limit, so let's begin. First of all, I'm going to go into scripts and open in it here at the end. We're gonna create a macro. A macro in this case is basically a global constant. The value off a constant cannot be changed. So we have a constant called I envy size with a value off 12 sold as a maximum number of items allowed in the infantry. Since this is a global constant, it can be used anywhere in the game. And I'm gonna go into scripts again. Go on during the country on open I envy ad. We're gonna modify the script, We're gonna make it. So died a script returns either true or false, based on whether the item was added in the list. So if the item that we begged up was added into the elementary is gonna return True, But if the inventory is already full, is Connery downfalls? Knowing this part off the old, we find the item in the list and agrees the count and then we used returned to end the script. So here the item is added Indian of entry and the script shorted on True. So here, after it on I'm simply gonna true So here we have our first exit point in the script introduced rule because the item was added Indian of entry. Knowing this part, we adding on Yuri Indian men tree since the item doesn't already exist in the list. But before doing that, we want to make sure they are dean men tree He is not fall. So just above that pot on add this here we have a condition for our second. A good point we're checking if the last size is greater than or equal to the i n v size macro the value off that macro is well So if we already have 12 items Indian men tree introduced falls Otherwise we keep going and create on your e. So that way the item is added Indian men tree. So after adding the area to the list, the script shorted untrue. So at the end of the script were simply gonna add return. True. So now we have three exit points in the script nominee to make use, author it on value. So I'll head control t an open or item I Lobel in its step in and no, here we're calling the I N V at function, So we need to stall. It's a don value to do that on at this before the function call Solder it on value off the function stored And this local variable No, here we're starting collected to drew. We want to make a dependent on the added valuable Swifty item was added It was collected. But if the inventor Iwas fall, then the item should not be collected. So to do that, I'm simply gonna make elected equal to add it. So now we just need to test it. For that. I'll open the Indus script. No, here. I'm gonna Jane, The value off this macro to three this way will easily be able to test it. Now let's run the game. I'm gonna collect summaries. All sos. And now I have treaties. Also those. So my elementary is now full. If I try to collect afford item, it won't work. Saudi elementary limiting feature is walking. No, Make sure that's what about the inventor Kasay's back to 12 and now we start walking on the inventory in the base in the next lecture 25. Inventory Interface - Part 1: Haider in this lecture, We're gonna work only in my entry interface. First of all, I'm going to go into a controller here. I'm gonna open the drawer. Do I event now? This is where we're drawing the items. Indian men tree for now. Since we're gonna make the real in venturing into pairs, we don't need to score now, so I select all over it and then press control gay documented out. So now the cold is simply disabled without being removed and Albany to do another thing. I'll come here and open the drawer. Do I begin? Event? No. This is where we draw the post office when the game is bald. Using the draws obvious function. So now I'm gonna replace the draws. Obvious function. Withdraw Safia CST. This way I can pass in some more data for the drug call. So now, after the X and by we had the x scale and of I scale, so I'm gonna send them toe one and one. Then we had the rotation, which I'm gonna set to zero. And then we had the blend color. This is a property that we're going to modify the color that you specify here will be multiplied with the color off the surface. So why does not hang and black make the totally dark? I want to make it Bartley dark, so I'll use a gray color. And lastly, I'm gonna send the Alfa or a pastie toe one. So let's run the game. And after it out now, our press escape to pause again and you can see that the screen is now dark. That's because we're drawing the post office with a grave land color. And now let's start working on the actual inventory interface. We're gonna start with the buttons soil had into objects, and here create a new group. I'll name a do why inside it will create an object and aim it orbiting Barents. This will be the parent for all the button objects in the game. So now in the object, I'm gonna add the create event. Let's initialize some valuables here. No desire, simply Davitt and the height off the button. No, this valuable stores, whether the mouse is hovering on this button and these valuable store, whether the left and right, most buttons for breast. Now we take the imports in the begin step event, so I'll go ahead and add it. No, in the event allowed this here, we're getting the most position on the Julia. If you simply use the mouse X and most Y valuables, they're going to give you the most coordinates inside the room. But we do not born the room. US coordinates. We want the mosque coordinates on the Geo. Isla says that's where the buttons are going to be drawn. So for that, we can use these functions. So now that we have the position off the mouse, we can check after suffering over this button. So for that we can use the point in a tangle function. It's simply jacks if a point, which is the mouse, is inside a rectangle, which is a button. So here we have the point coordinates. And here the rectangle coordinates. So direct angle, which is the buttons area, starts at X and by and ends at X plus, we're and Y plus height, sort of function is gonna return drool. If the mouth is inside the button, baritone value will be stored in the Howard variable and now be getting the click import for the left, most button and the right mouse button for that. We're using the mouth jag button breast function that function on Lee Jackson. A mouse button is pressed salons, so holding it is not gonna do anything. And now we need to draw the button. So I'm gonna go into events and add a draw. Do I event in this event? Let's add this. First of all they're using draws that color tow chain the drug color. And we have this in the argument. No, I feel never seen anything like this before. It might look weird to you. This is called a tannery operator, and it's basically a small condition. This is a condition. This is a true value, and this is the force value. So if this condition is Truell, we're gonna get this value. Otherwise we get this value. So here's what we're doing here. If, however, is rule the dro color is that to gray? Otherwise, it said to black Soviet changing the color off the button depending on the hover value. Then I'm setting the draw far too syrup on four. And here we're drawing a rectangle. Here we have the rectangle coordinates. They're the same coordinates that we use for the input into begin step event. No. The last argument stairs whether the drone rectangle is failed or only an outline. So zero is four failed, and one is only for the outline. Since we have the row here, we're drawing a filled rectangle. No, I'm resetting the alpha and the color to their default values. So for the alpha, it's one. And for the color, it's white. So now with the default alpha and color, I'm gonna draw another rectangle district angle is only an outline, since I have one in the last argument, the rectangle coordinates here are the same as before. Except for the first point here. I'm subtracting one from the X, and by this way, the outline of BS properly. Now I'll go into the objects under the do I grew up. I'm gonna create another object. This will be a child off the button parent and will be used for the inventory items so on. And this object or button I envy. So for each item, we're gonna have a button. No, in the object. I'm gonna open the parents window. Click here to select a parent, then go under. Do I and slash or button, parent. Now we're gonna come back to this object later. First, we're gonna place the buttons on the pause menu. So for that, I'll go into objects on open or controller in the object. I'm gonna add a new event, so I'll go into water, then user events, and are you serve and zero. These events don't run automatically, so you can run them whenever you want. That's why they're called user events. Now, in this event, we're gonna create the inventory interface. So in the description, I'm gonna type this. So the description Denna B. S here? No. In the event, we're gonna create some valuables for the elementary and affairs soil. At this Here we have the margin, which is said to 10. The margin is basically the distance between the edge off the window and the buttons. Then we had the sap, which is short for separation. This is the distance between each button. And then we had the south size, which is the size of each button. No, here we have the horizontal and vertical size off the inventory. So vertically we have two lines or buttons, and on each line we have six buttons. So in total we have second toe, toe, toe al buttons and that matter of the limit or team entry from dining script Naevia Calculating the position often, men tree interferes, so we have the elementary X on inventory. By now, the Elementary X is simply the margin, and here we have some calculations Ford inventory by. This is more complicated, since we've owned elementary to be displayed at the bottom of the window. So we have to get the total height off the inventory and subtract that from the height off the game. So that's exactly what we're doing here in these Brantas he's We had the total height, all the inventory. Of course. It also includes the margin at the bottom. So here we have margin plus separation, plus cell size multiplied by the side of life. Then we subtract that from the rest hide. So now we had the position off the inventory and we can place the buttons. So now at this now here we have X and Y valuables that will be used for placing the buttons in this four. Luke. They're basically the current column and row values. That's why they start at zero. Not a for loop goes from zero to the I N V five. No, inside the for loop were first calculating the position off the button. It's aboard the button acts and button by start at the elementary, X and inventory by than in the brackets for bold. We had the separation glasses health size. So Ford about next we multiply dad by the EDS and for the button by the multiply dad by the by. So now we have the position where the button needs to be created. So then we created using a stance create depth. So here we have the buttons X and y and adapt, which is zero. Then we have the object that you're creating, which is all button I envy. So the installs is created on this idea. Strolled in this variable. Now we need to apply some properties to the button. So we're on the with Statement on the button is tasked in the which statement we send a slower I d off the button. So I So this button is gonna show the item in, Just log in the elementary, then we sent of it and the hide off the button to the cell size. And now we're out all the gridlock here. You're adding one toe acts This way. We move onto the next column. No. When we at the end off the role, we want to move on to the next one. So that's what we're doing in the spot in the condition we're checking if the X is equal to the size X, so that means that we are at the end off the roll. So in that case, the said the extra zero, then we move on to the next role by adding one toe. Why? So the four loop creates a button for each lot Indian men tree. And that's what we do in user. Even zero we created in mentoring ain't Affairs. And now we need another user event for removing the inventor interface soil going to add event. And I do servant one in the description for this event, all tied this now for removing Dean of entry into pace. I'm gonna add this year here, I'm simply destroying all instances of a button I envy. And now that we have the user events ready, we need to use them. So for that I'll open this happy event. Now this is very pause again and created the post office. So this is where the inventory in affairs should be created. Now I'll go here and call you servants. Zero sort of call a user event. We used the event user function. And since we have zero here, the golden you serve and zero is going to run. No, this is really on pause a game. So I'm gonna go here and call user event one. So venue in Basel game The inventory in the past will be removed. So now let's run the game and act it out. I'll pause again by hitting a scare. And here you can see Dean entry buttons when you have over a button is color changes from black to grey. That's because of the binary operation in the button. Now we need to draw the items inside the buttons so we'll continue this in the next lecture 26. Inventory Interface - Part 2: here. They're not gonna continue walking on the inventory interface. We may deem entry buttons. And are we gonna draw the items on the buttons? So, first of all, I'll go into resources and create a new fart. I'll name it after you. Why we're after he stands for For this is a four time gonna use in the buttons for displaying the item count. No indifference. Properties here, you can select a fart and you can change the size here. I'm also gonna turn off anti losing for this pond. In that way, it looks better when topics a lot. No. In the preview, the fort looks very small, but since the game has a low resolution, it's gonna look fine there. Now I go into objects, then GeoEye and open or button I envy. No, here we have all the events from the parent, so all right. Click on, create and inherited. No. In the event allowed, this describable stalls the inventory slot number for this button By default. It's gonna be at zero, and its value is set when a button is created in the controller nominee to draw the item in that slot. Indian men tree So I'm gonna go into events and inherit the draw G Y event here, we're gonna draw the item at the center off the button. So allowed this year here, we want to get this lottery from deem entry. So first of all, I'm getting the inventor is less tidy from the controller. Then from that list, I'm getting the slaughter A to get it. I'm using this lot. I d off the button. But there may not be injury in that slot in the list. So we want to make sure that we found in a hurry in that slot. So for that we're using the Israel function. It's basically gonna check if this is an area and if it is, we wanna draw the item inside it. So began the item. I d from theory, which is in the heart element. So know that we have the item I d We can get this pride for that item. So we do that using the global idol Strider A and all we had this pride that we need to draw. So then we draw it at the center, off the button using draws bride. So this is a sprite And this is the image index No. 40 X. We have X plus haft of it than four. Divide, we have lie plus after height. So that gives us the center off the button. And now we need to draw the item count. So here we got the item count from the area, which is in the second element. Then we sent the phone to after you why? Which we just created. And then we draw the ground using draw text. I'm drawing it at extra stool and Y plus for your phone might be different. So you might need to play our own with these coordinates. And now this is that. Actually, I'm drawing we just simply the count. So now let's run the game and test it. Currently, I have no items sodium entry is empty, so I'll go back into the game and collect some resources. And now if I pause the game, you can see the items here and you can also see the item count sold in venturing interfaces , working. We can now collect items and see them in the Bosman you. And now we're gonna start working on something exciting which is crafting. So in the next section we're gonna build are crafting system standby step. So let's continue 27. Crafting UI: Hello, DEA. In this lecture, we cannot start working on the crafting you, I So here you can see it. A pause menu. We're gonna create the crafting when you hear it will simply be a little items that can be crafted. So here we have buttons for four items, and the empty spaces here are for the titles of each category. So let's start working on it. First of all, I'm gonna go into objects inside the G Y group. I'll create a new object. We're gonna create the button that will be used in the crafting menu so early in this orbiting craft. Each item in the crafting menu will be in Istanbul off this object. I'll go into the object and opened up, and many I'm going to send the parent to a button. Barrett. So now this is a button with all the events off the parent and I will come back to this object later. First, I'm gonna go into scripts on open the Indus script here. We need to create new items that can be crafted. So I'm gonna go to the Eid a minimum now, after the last item, which is iron, I'm gonna add a coma. After that, I learned some new items. You're gonna get these items by crafting them in the crafting menu we're gonna set up. There's brides in disarray, but in a later lecture right now, we need to set up the crafting minyan. We need a way to lay out the menu and set up house can appear. Since the crafting menu is simply a list of buttons, we can lay it out in an array. So at the end of the script allowed this here, I'm creating a global, very cold crafting menu. So here we have the array brackets from here to here inside. Then we have the Ori elements. Dera make soft drinks and items dust rings here our titles that Libya in the crafting menu and the items here will appear as crafting buttons. So you can see that we have laid out the whole crafting menu in disarray. So we can later read this Sorry and create the buttons. So now the need is great for creating a crafting button. So under scripts, I'm gonna create a new growth. A name? It ey no. Inside the group, I'm gonna create a script I'll name it. Create button craft. No, inside the script. I'll add this. First of all, and the talk, We have the description off the script. It's not required in any way and can be escaped. And here we have the required arguments. So here we have the X and Ally off the button and end of it and the height. And then we have the item that can be crafted with this button. And then we got the arguments and sold them in these local valuables. No, Here we created the botanist ours, using a stance create depth. We created a deposition from the arguments and this is the object that we're creating? No, Here we're setting some properties off the button using of it statement here, we're setting love it. On the height, they will be equal to the values from the arguments. And then we're setting the item variable so this variable will hold the item that will be able to craft with this button. Then at the end, we returned the I d off the botanist on. It doesn't matter if you're gonna use the I d or not. It's just good practice to return the I d off the created in storms in the script. So now we can make usual descript for creating the crafting menu. So I'll go into objects and open or controller. I go into user and zero. This is where we Greer denied entry interface. So we're gonna create the crafting menu here as well. But first we need to grow up all of the score together. So for that, we need to make use or regions. So at the top, I'm gonna start the region by typing this. So here I'm creating a region called Inventory. Now we need to end this region at the end. So I'm going to scroll down to the bottom and are this year so not a region is ready. Now, I can come up here and close the region, so as you can see, this makes it very easy to manage long cord. So I'm gonna keep just region closed. And after this, add another I'll name just one crafting. So, as you can probably tell, we're gonna create the crafting when you hear. So inside the region I'm gonna add this here he is heading up some properties for the crafting menu This is a bit off the crafting menu and this is the height of each crafting button. No, here we have the position off the crafting manual. We've ordered to appear at the right side or the window, as you can see here. So here we have the starting ex Alta crafting manual. No, here we could divert off the menu, lost the margin for the right edge. Then we subtract bad from the bit off the game. Then for the lie, we simply have the CEP. No, that's a valuable from the inventor region. It's simply the separation between each button. And of course, the margin is from the previous region as well. Then finally, we have the height of East title. No, we can create the crafting menu by reading. This are a so inside the same region. I'm gonna add this here. I'm simply guarding the crafting many Aurier. So I'm copying it into this local valuable so that it's easier to type. And then I'm getting the size all the Ari using dysfunction so it gets how many elements there are in the area. So now that we have the total size or theory, we can look through it using a for loop. So the loop here starts had zero and stops at the size. No, inside the loop, we get the item from the Ari at I. If you remember the array, this is either a string or an item. If it is a string, it's on Idol. So in desk condition, we're checking if it's suffering Soviet using theist oring function. If this condition is true, we want to create an idol object, and that's what we would do here. But instead we only have a comment here. For now, we're going to create a function to create a title button in the next lecture. So until then, we're gonna leave this space empty and now just come down here. You can see that I'm adding something to Divi. I'm doing that so that we can move on to the next button position. And since it's a political menu, of course we're gonna add to Divi. So what we're adding here is simply that Idol hide blast us up. So that's what happens if this is a title. But if it's not a title, the need starcraft herbal item. So in that case, there's as block runs here we create a crafting button using dollar script. So in the arguments we pass in the X lie wet height and item slow. Did these properties are crafting? Button is created, and with that button, this item can be crafted. And then down here we had something to divi. What we add is the buttons, height plus tricep. So we do. There's for each element in the area and that's where we created the crafting menu. Now I'm gonna open user event one we have we destroyed the interface. So in the event that this and here we are simply destroying the crafting buttons. So now let's run the game and see what we have. No, in the game, I'll press escape. And here we have the crafting menu. In theory, we have to look at, agrees with two items age, and that's what we see here. Now there's only empty spaces where the title should be. So we're gonna work on the title buttons in the next lecture 28. Title Object: Haider in this lecture will be walking on the title buttons. These buttons will only show that idol text. Other than that, they don't do anything that in all the button would do. So let's work on it. First of all, I'm gonna go into fonts here. I wanna duplicated the after you I found. So all right, click on it and do that. I'm gonna name this new phone after Deibel. So you can tell that the foreign tributes for the titles No, inside the foreign properties, I'm gonna increase the size from fall to six. So the phone has begun. Now, now we're going to create the title button, so I'll go into objects and then into G. Why? I'm going to create the object inside this girl. A name it or but in people knowing the object, I'm gonna make it a child off the button parent. So now we have all the about events here. First of all, you can 900 the create event, so no inside inherited event allowed this? No, this valuable. You're simply the title text. So by default, it's an empty string nominee to draw that act in this valuable But we don't want to draw the button. The button is drawn in the draw. Do I vent that's inherited from the parent. So if we override that event, then the button will not be drawn. So right click on the event and select Override. So know this new event is overriding the event off the parent. So here you can draw the title at the center off the button, so I'll add this year. First of all, be attending the phone to after Datil. And then we are changing the alignment off the text by default. The alignment is stopped left, but we wanted to India to middle center. So but dysfunction we change the horizontal alignment and then dysfunction. We, Jane the vertical alignment. So we said the horizontal alignment to center and the vertical line mental middle. And then we draw the text, the droid and the center off the button. So to get deposition, we had half the size to the X and y. My text was tell a bit off center soy added three to the by. No, here we had the strain that we're drawing no. After drawing that X, we need to reserve the alignments, and that's what we're doing here. Very exciting the alignments to left and all. So now this button is gonna draw that idol. And now we need a script for creating a title button. So under you, I I'm gonna create a script. I'll name it Greed button title. And now let's go into the script and had some cord. No. First of all, the script of spirit, A similar to demand that creates a crafting button. The difference is that this one creates all that'll. Button? No, here the arguments are X. Why wit height and that idol. Then down here, we store the arguments in local variables, and here we create any instance of a button title. And then we said some properties in this witch statement we sent of it and the height variables, and then the title variable. Then finally, the script ends. Now we can use the script for creating the title buttons. So I'm gonna go into objects and open or controller. I'm gonna go into user and zero. No, down here, we have a parliament. Very title button should be created. So we're gonna remove that comment and call our new script there. So now it's gonna create an idol button here we Boston, the X lie and of it. And then for the height, we passing that idol height. Then we pass in the area element as the title. So if a string is found in the array, it's going to create a title button. And now let's open user event one here, we're gonna destroy the title buttons. So both user events on already and we contest the game, all press escape to open the crafting menu so you can see the titles. And now it really looks like a menu, not a menu that we have currently perfectly fits in this window. But if we have a longer menu, we're not gonna be able to see it completely. So we should be able to scroll if we have a longer list. So we're gonna lock on strolling in the next lecture 29. Scrolling: Hey there, in this lecture, we're gonna implement scrolling into our crafting manual. So let's begin. First of all, we're gonna go into scripts and open in it. We're going to come down here to the crafting January here, we're gonna add some extra items to make them a new longer. So after the last element, I'm gonna add this. So here we have a new section simply called test, and then we have to test items which has had to minus one. So now that we have a longer menu, we can start working on scrolling. So I'm gonna go into objects and open or controller. I'm gonna come here and open the create event here. We're gonna create some valuables for the crafting menu. So are the end off the event coladas? So here we have the crafting menu or semen, your valuables. Now this is a scroll variable. It basically stoles How much we have scrolled in the crafting menu. So it will be an amount in pixels. No, here we have a height valuable. It's gonna stole the height of the crafting menu. But this height will only be for the part that's not visible now. we're gonna open this type event. This is we're gonna handle the scrolling, But first, I'm going to create a region for the old cord. And now let's close that region after the region, I'm gonna add this. So here we have a new block. That block is controlled by this condition. So it's only gonna run when the game is paused. No, in this part, we're getting input from the mouse wheel dysfunction here. Gas after mouse wheel is being strolled up and dysfunction gets. If the mouse wheel is being scroll down Slovis up, dragged down from up this way, we get one when the wheel is going up and minus one. When the deal is going down, then we multiply that value by it. So that's how fast we scroll bar step. So if you wanna make it faster or slower, he want to modify this value. No. Here you're adding that value, Toto scroll variable! And then we're moving the buttons in the crafting menu. So here we have of it statement for all buttoned graft. And then we have another with statement for all buttoned idol. And then inside these two with blocks, we have the same statement. So let's see what it does here. We are modifying the buy off the button since we're schooling radically. No, here we have. I thought it's the y coordinate where the button was created. So it's the original by position off the button so that by value we can add a scroll variable. So that's how the scroll value will be reflected on the buttons. And of course, since we are inside a red log, we can I use other to access this variable. So then we do the same for the other with block. So let's run the game and act it out. I'm gonna pause it. And now I'm able to scroll in the crafting menu and see the rest of the items. But there is a problem. Currently, there's no limit on the scrolling, so I'm able to scroll indefinitely and make them a new disappear. So novel and I fix that back in no controller, we're gonna open user event zero. This was really created the crafting manual. Now here, we're gonna send the seam and you hide variable. So I'm gonna go to the end off the crafting region after the four loop is over. I'm gonna add this. So I'm setting the height to the vie variable. The Y value increases whenever you create a new button. So by the end, off the four loop, a ball is basically the total height, all the crafting menu. But that's not exactly what we want. We want the height off the part that's not visible. So I'm gonna is here. No BS attracting the height off the game from the height off the menu. That way, the height only represents the extra Bart off the menu. Not to implement the actual limiting. I'm gonna open the step event now. This is where we had the ville input to the scroll variable. So when I implement a limiting after that line so we can I had this year No. The scroll value should be between zero and minus height. So here we are, simply making sure that it stays in that range. So for that we use the clan function, it simply limits the value toe arrange. So this is the value, and this is the range, and this is the minimum limit, and this is a maximum limit. So now the scrolling should be limited. So let's go into the game. And now the sprawling is limited. You can only scroll as far as the menu cause No back Indian yet. Script. Make sure you remove the extra items in the crafting manual. No, in the next lecture with the number one item display. 30. Item Display: Hey there, in this lecture, we're gonna log on item display quietly. Another game. The crafting buttons are empty, so we're gonna draw the item details on them. So let's begin. First of all, you're gonna create a new way to set up item data soldiers going to scripts and open in it to see what we already have. So here we have an area called Items. Pride here restored us pride for each item. And now we want to create more arrays like item name and I don't recipe. So of course they're gonna store the name and the recipe for each item. So we're gonna create those air raids, but we're not gonna do it this way. We actually cannot remove the spot. So we're going to create a script to set up an item we're going to call the script. In it item, you're gonna be able to start the name Pride and SP often item at once. So let's go ahead and make the script. I'll name it, innit? Item. I'll place it here for convenience. Now I'm gonna go into the script and that does no. Here we have the arguments. The first argument is the item that were neutralizing. And then we have the properties for dad Item. So we have the name, That's bride. And there has to be the recipe. There'll be an array of items required for crafting this item. Now, here we're getting the item. I d from the first argument. And here we are setting up the property or is so first up, we have the item Name the element I D here is the same as the item i d. Saudi item name is taken from argument one. Then here we have this pride for the item died a stricken from argument to then find Leviev binary for the recipe. So the recipe is taken from argument tree. Now we're gonna go back toe in it and make use or the new script. So I'm gonna come down here and you move the spot in its place. I'm gonna add this So Naevia, using of a new script to set up the items. So for each item we're passing in the name, the pride and the recipe. Now these are the four items in other crafting menu. So we have the portion syrup, one block and iron block I've already important as brides for these items. Let me show you real quick under sprites and then items. I have the new slides here. And now let's go back to the script. In the last parameter, we have the recipe array, but currently its empty. So we're gonna fill in the recipes in the next lecture, and now we're gonna look on the item display. So we're gonna go into objects then? Gee, why an open or button craft? No. Here. We need a draw. Geo event. Since we already have one from the parent, we're going to inherit it. The button will be drawn in the parents event, so investment will be drawing the item and it's name. So let's have some court here. Here we are simply is heading up some valuables? No, this will be the margin. 40 inside off the button. No. In this part, we can calculate the scale off the image. We're doing that because the item images are small. They're only eight by eight in size, so drawing them normally would make them appear small. So we want to scale them up and make them fit in the button. So here we had the size of the image. It said by eight. So we have it here. No, this is a new target size off the image. That's how big we wanted Toby. So to get that size, we have this. So here's what we're doing here. We simply subtract two margins from the height. The two modern czar for the top and about Imagine So now we have the new size off the image , and now we need a scale value for the Sprite. And that's what we have here to get the scale. We simply divide the new size by the old size Novik and draw the image and the name. So after the cold allowed this now, each crafting button has an item assigned to it. Dad Item I d. Is stored in dis viable so we can usually to get the Sprite and the name of the item. So here we're getting this pride off the item and then views draws Priety extremely to draw the sprite. So here we have the sprite and here we have the imagine debts. Then here we have the X and Y position were the sprite is drawn. So let's look at the X. Here we have the X off the button plus a margin, and India adding the new size off the image. But that is divided by two so that vadis pride is drawn at the center. So then we had to say in for Dubai, we have I plus margin plus after new size. Then in the next line we have some more arguments. So here we have the X and y scale bought are said to the scale valuable. Then we have the angle, which is a Toledo. Then the color is white and the all fires one. So there's no draws the image off the item. Now we can move on to drawing the name. So here we got the name from the item Nammari So getting the name often item is that simple ? Then we said the phone to after you I and then find Levy drone attacks using draw text. The tax will be drawn to the right off the image. So if you have the X here, first of all, we have X plus margin multiplied by two and then we have plus size new. So that's way that X is drawn to the right off the image. Then four. Dubai we have by plus margin love too. The blast, too, is only a little adjustment. And then we had the string that we're drawing. It's simply the name of the item. And now this event is John. And the item display should be working. So let's run the game and check it out. Oppressors game. And here you can see the buttons. They now display the item that you can craft. No, Before we're able to craft these items, we need recipes for them. So recipe would be a list of ingredients that you need to craft a sort an item. So we're gonna work on that in the next lecture. 31. Recipe: Haider Indus lecture will be walking on recipes. So as you can see in disagree, Apple will be able to see the recipe overnight. Um, when we hover over it. So without wasting any time, that's going to scripts and open in it. No, Down here we have the four craft herbal items. So let's start with the portion. In the last parameter, we have the empty recipe array. So now we're gonna fill it with ingredients. No, each ingredients and death. Sorry, will be its owner. A. So each ingredient or a will have two elements. They'll be item and count. So let me explain how that's gonna work. I'm gonna click in between the array brackets and create a new line. No, you I'm gonna add one ingredient re So for the item will enter apple and for the ground under four. So this is our first ingredient inside the main disappear E. We have disarray, so this basically means that we need four apples to craft a portion. So this is how you gonna set up our recipes? I'm not gonna do it for the syrup. So again, in the recipe ery I'll create a new line and here I'm gonna create an ingredient. Terry Saudi item here will be orange and the counter before, but this time we're gonna have to ingredients. So I'm gonna add a coma. And you saw the new line, and here will be adding another array. So for this, the item will be apple and the count will be too. So this is our recipe for the syrup. We just need four or Indians and two apples. And Nagano's had other recipes for the bloc's. So far, the one long we need five would and 40. I unlock. We need four iron. So now the recipes are all set up. Not gonna work on drawing recipes. So ahead, Control D And here, open or button craft. I'm gonna close this event, and now we're gonna add a new event. So I go in the draw and had to draw geoeye and event No deaths. Event runs after the draw GeoEye event. So index events all the buttons will be drawn. And then in desa vent, the recipe will be drawn. Sold A recipe will appear above all the buttons. So know that sad? Some gold in the event? No, The recipe should only be drone when the mouse is hovering over this button. So here, I'm gonna add this condition. So now in this block, we can draw the recipe. Let me explain. How are we gonna do it? We're going to draw a cell for each item in the recipe. And inside each cell, we draw the item and account. So now let's add this year. No. Here we have some variables. This is the size of an item. It said to it because our items are it by eight. Then we have the margin around each item. And here we had the size overshadow. So we multiply the margin with two and add their toe the sides. No, we had the position we have. The recipe would be drawn, so we had the X and Ally. So we simply got the mosque position on the Geo idea and 40 X. We also add four. So they're just move it a bit to the right. So this is where the recipe will be drawn on the juelia? No, here We got the recipe. Every for the item. So we now have the area with all the ingredients. Then here began the size of battery. Slothful dad feels dysfunction. So now we know how many ingredients this recipe has. No. Before drawing the cells, we need to draw the background. So here we had the drug color to dark gray and then we draw rectangle. The starting X and Y are simply the X and divine that we set up here. Then here we have the ending eggs. Here we multiply those health size by the recipe sides and envy. Add that to the eggs. And here we have the ending by that simply the live plus cell size. And we said the last argument to zero to draw a filled rectangle. And then we said, the color toe white. Now we're gonna draw the cells for the ingredients. So I'm gonna restyled of Indo and then add the code here. No, here we have a for loop. The loop starts at the room and stops at recipe size. So the loo bronze for each ingredient in the recipe. Now, inside the loop, we got the drop position, all of the cell. So we have the troll acts and the draw lie. So for the d X, we have this so here we multiply those health size with the eye and then we add that to the X. So this way, this hell's our place was only no. Here we have the D by that's simply equal to Dubai. So this way it's cell is on the same by level No, here we're getting from data about the ingredient forest of all of the guardian greedy entry from the recipe array. So now this is the ingredient, Terry. So from disagree, we can now get required item and the required count. So that's what we're doing here. So here began the item from the array and then here because the count so know that we have the item I d we can cut its image and that's what we're doing in this line. We're getting this pride for the item from the items brighter a Then here, have you draw it using draws bride. So here we have this pride and here we have the made in debts. No, here we have the expedition here we divide the south side by true and add that to the D X. And here we have the by we do the same here, but when the de vie. So this way the item is drawn at the center of the cell. No, In this part, we draw the required count. So here we send the phones to after you I and then we draw the gown to the draw text? No, here we had the exposition here. I'm multiplying the cell size with zero point age and then adding that to the DS. And then for the buy we do something similar. We multiplied the Southside with 0.7. Then they're there to the Divi, so the count will be drawn near the bottom right corner off the south. And of course, in the last parameter we have the college itself. So now the court has finished when you have Ah, what? This button, you'll see its recipe. So let's run the game invested out. How about it? I'll have over a crafting button and now we can see the recipe. So now that we have a recipe set up, we should be able to craft these items. So we're gonna work on crafting in the next lecture 32. Crafting!: hater in this lecture we're gonna work on crafting so you can hold the mouse on a button to craft that item. So let's begin. First of all, we're gonna go into scripts here. Let's open Denham Entry fall Oh, and here create a new script. Real name describes I envy Got item or a So let me explain what it does You know how the invent tree in this game is A list over is eatery has the item i d and account So the descript weaken got the array of an item So we pass in the item i d and got it sorry from deem entry So let's go into the script. And at this year now, here we have the only argument, which is the item i d. So here we stole the argument and this local valuable. Then here we get the I. D often Ventria list from the controller. So now we can access the inventory list were just viable then here we get the size of that list. So for that views the DS list size function. So now we can look through the list to find the area for the item so here. We're in a for loop that go from zero to let size than inside the loop Regard theory from the list. So we get the less element at I. And of course, we used a lift access. Er, no. Here we're running a condition to make sure that this is an array. So if it isn't, array were underscored here. We got the item i d from the array. So we created for element. And now here we have a condition. We are checking if the item from the array matters the item that we want. In that case, the script returns the array. So we found the item that we wanted and we got its or a soared. Despite into the script ends, no discord runs for each item Indian men tree. And when the item is found, the loop ends and sold as a script. But if the item is not found, then the loop finishes and the script continues. So in that case with included on minus one, so descript as an often ist we're gonna start working on crafting soil hit control D and here, open or button graft. I'll close this event. No, here we have the creative end from the parent. So we're gonna inherit that event. And in the event you can add this. This is the value of the crafting an emission. It goes from 0 to 1. So right now it's at zero. When you click on the button, it starts to animate from 0 to 1. And when it reaches one, the item is crafted. And now we're gonna go into events and at the step event I re size of indoor because we're about to add a lot of cord. Sort of sad this in the event. First of all, they're getting from mouse input. We are checking if the left mouse button is being held on this button. So we have the condition here for us to check if the mouse is hovering over this button and then we Jack, if the left most button is pressed and then the results off this condition either true or false, stored in this valuable, then in this part we're getting the mouse in port and checking if the item can be crafted. If it can, we start the crafting animation. So let's break it down here. We're checking if the muscles held on this button and then we're checking If Kraft Anim is at or below zero, so does means that the animation hasn't started yet. So not even a jack if this item can be crafted. So here we got the recipe for this item. So now we have the recipe are a Then here. We got the size off that recipe array. So now we're gonna loop to the recipe, eerie and check all the ingredients. No, here we have a valuable called can craft. It stores whether we can crafty item or not. So, by default, it's at the drool. It means that we can graft this item. But we are gonna check the ingredients in this part. So if we don't have any required ingredients, then this will be set to falls. So he every on the four loop that goes from zero to recipe size. So we go through each ingredient in this loop inside the loop began ingredient data. So here we got dearie for this ingredient from the recipe array and from the ingredient Tory. We got the item I D. And the required count enough from our inventory. We want a good theory for this item. And if you remember, we discredited a script for that. And we're using Dad script here, which is I envy Get item are ready. So we got dearie for the required item really get their here. But if the item doesn't exist in the infantry, and then it's not gonna be in a rare so that's what gets checking in this condition here, you're checking if this is not an earlier slow. If this condition is true, all it means that we don't have the required item. In that case, we said can craft to falls. So now we cannot graph this item. And then here we break the loop. So this means that the loop ends here. So this is what happens if the item doesn't exist in the elementary. But if it does, then this part doesn't run and the court continues. Swifty item doesn't live. We know habits are a So from battery, we got the count. The count is a second element in the array. So now we want to make sure that we have enough ground for the ingredients, but instead we cannot check the opposite. So in this condition we check if we have less ground, then what is required? If this is true, it means that we don't have enough gold for the ingredients. So in that gays with that can graph toe falls and then we break the loop. But if we do have enough count, then this doesn't run and the loop continues. So we're underscored for each ingredient in the recipe. If an ingredient is not found, then can craft has had two falls, Otherwise it stays true. Now, down here we started crafting animation, so he every jack Afghan craft is Truell. If it is, we sat craft and him tow this value this way we started crafting animation. So to start the animation, we only need to start this viable above zero. So now we need to process the animation after it has started. For that, we'll add some more gold at the end of the event. No, here we have a set of two conditions here. The A checking if the mouse has held on this button and then via checking if Kraft anim is above zero. So this means that the animation has started and the most button is still held on this button. So in that case, the increase craft and in with value. So this way it animates from 0 to 1. And then here we have a condition where we check if craft and him is that fun soldiers means that the animation has finished. In that case, we don't use or even zero in dad events people, not crafty item. And then we sat a craft and him 20 to restart the animation. No, here we haven't else blogged a drones when these conditions are falls. So in that block, we simply sat graft and him to zero. Now we're gonna crafty item. So are going to events and argue servant zero No, up here via goodness had the description to craft item. And in the event we're gonna limply in various also shows. Another crafted item sold us out this year. No, you were getting the recipe. That so here we got the recipe eerie with all the ingredients. And then we got the size of battery. Not gonna loop through the recipe array. So we have the four loop here again. The loop goes from zero to recipe size. No, in the loop, we get ingredient that are so here began the ingredient Tory from the recipe area. And then we got the item and account from the ingredient Ray. So now you cannot deplete the item from the actual inventory. So here we got the are a 40 item. So now we have the area for this item from the inventory. No industry. We can modify the count to deplete the item. So that's what we're doing here. We're modifying the seconds Lord, in theory, which is the count and here, using the addicts or so this way. The original Ari is mortified. We subtract this amount from the ground, and this amount is the required gold from the ingredient saw. The four loop with the bleeder is also one by one. So after they have all been depleted, we come down here. Here we simply add the crafted item to the inventory. So this is the item I d. That's added, And this is the count. So now the crafting system should be walking. But we also need to show the animation. So for that, we're gonna open the drawer. Gee, why event? No, This is where the button is drawn from the parents event. So we're gonna show the crafting animation after this line So allowed this year. First of all, we check if Kraft anim is greater than zero. So that means that the animation is running. In that case, we draw or a tangle. It simply starts at the buttons X and by and here we have the ending X for three multiplied of it. Witchcraft and him and envy Adah till the eggs. Now for the ending Why we simply have by plus height and then the last argument is at 20 to draw a filled rectangle. Now we can run the game and test it out. Now let's open the postman. You. If I click owner crafting button, nothing will happen. And that's because I don't have any items yet. So I'm gonna go ahead and collect some apples and now I should be able to craft a portion. So I click here, the animation will start and the item will be drafted. So there you go over crafting system is working. Now I have collected some more items, so I'm gonna go ahead and craft a syrup. So now we have a syrup in our elementary and we have less orange does. We had seven, but four were used to make the syrup. No, there is a problem that we have to fix. No, you. I have four apples in my inventory, and we need exactly four apples to make abortion. So let's go ahead and do that. And now you can see that I have zero apples, so I don't have any apples left. In this case, the item should be removed from deem entry, but as you can see, it's still here. So we're gonna work on removing items from the inventory in the next lecture. 33. Dropping Items - Manual: Hey, Dio Indus Lecture We're gonna work on dropping items so you can drop an item by clicking on it. We'll be working on manual dropping. An automatic removal manual dropping is when you right click on an item to remove it from the inventory. And automatic removal is when an item is removed from deem entry when it's gone. Treaty zero. So let's start with manual dropping. First of all, we're gonna go into scripts and then invent Tree Here will be creating a script to remove an item from the inventory, so I'll create a new script and name it. I am very moved. Let's go into the script window and add some court here. Excellent. Sad does no. Here we have the only argument required for the script. It's the position in the list where the item will be moved. So here we got the argument and story it in this variable. And then here began the I. D off the inventor realist from the controller and Novik and remove the area from the list . So here we are, heading this lot in the list. We want to remove the array in this lot, so we just started to minus one. Just makes us Lord empty Datz y V organs. Jack refinery is valid using dysfunction because it might be minus one instead of Honore. Now we're gonna make use or descript for manual dropping. So I'll hit control D and through here open or but nine V dis button shows the items in the inventory sort of implements manual dropping. We're gonna add a step event here. You're gonna add this? No. Here we have two conditions. First we Jack, if the mouse is hovering over this button and then be Jack if we're right clicking So overall your jacks, if you're right clicking on this button in that case, we come down here. So here we're getting the array for this button from Denham entry and hear views as Lord I d. Valuable to get the area from the list. So now we're gonna check if this is a valid Eri. So now we're gonna add this year. So in this condition, we are simply checking. If this is an array, no, here's what we're gonna do. We'll get the item from the area and drop it around the Blair and then we'll remove it from the elementary for us our recile the window for the cord we're about to add. And then in this block, all our does. Now you know that these buttons are only displayed when the game is paused and when the game is bossed, all the in game ist also saw deactivated. So if you want to access and instance by being in the PAS menu, we have to activate it in discord. We wanna accessed a player. So here we activating it so beyond dysfunction or no player. Then here we get the item and the count from disarray. So now we know which item we are dropping and how many of you dropping? And then here we are on a repeat loop Oraibi loop. Simply repeat some bold a specified amount of times data mode is given here, So this code would simply baby there this many times. So let's say we have five apples in the array. So then this would be item apple and this would be five. So in that case, I guess scored would be done five times. And, of course, it simply drops an item. Soldiers breaking down line by line. Here you're getting the X and Y position of er the item will be dropped. So here we got the players acts and by than to the x and y we had this dysfunction simply gets our and a medida in this range on the range here is 12 to 20 so display each item will drop in a different position. Then here we create an item Istante So here we have the X and Y position and here we have the layer And of course, here we have item the I d off the new item Istante is stored in this valuable Then here we don't have read statement on that instance here he's had the type to the item i d and then here who has had this bright bears all the item So we got it from this are a Then here we sent a Z value to minus 20 No, After the repeat loop is over, we wanna deactivated w again So here we're honest Last e accurate object were only It's on the player and then we don't it again on oh item this deactivates the items that we dropped in this event and then finally removed the item from the inventory. So for the position, we simply pass in the slot. I d Now there's one more thing we need to do. Let's go into scripts. And here open I in Viet. Now in the spot, we increase the count in an existing gory. But here we are not jacking if this is an array, so now I'm gonna add that condition here, Donald joined these two conditions would end. Now we're going to run the game and act it out. I'm gonna collect some items. No, here I have three oranges. All right. Click on it. And it's gone. All process, Gabe. And three orders are now here. But now there is a problem. If I collect the three orders to go into a noose lodge, they should be going into this empty slot here. But they don't. So we're going off accidents in the next lecture 34. Dropping Items - Automatic: Hey there. No, We're gonna continue from the previous lecture. We're gonna make the collected items go into empty slots. So here we have the i n v adds kept open down here. We have a loop of every look for the item. Indian men tree. If the item is found, we increase its got. So after this lube, we're going to run another loop in this new lube. We're gonna look for empty slots. So if yes, Lord is empty, we learned the item there. Solar side, the loop, not a loop. Goes from zero to list size. Inside the loop, we can derive from the list. So we got the list element at I No, here in disc condition. We're checking if this is not in our area. So if it's not injury, it's an empty slot. So in that, gays, we want a boat on Yuri in this lodge. So here we are, setting the last element at I we're setting gear. Toe deaths are a in the area, Simply has the item I d on the count and then we don't rule because the item was added Indian country. So no, let's run the game and see if the issue as fixed First, I'll collect some items. You I have some wood which I'm gonna drop, and I'm gonna collect some new items. And now you can see that event into the empties lot. So, Naevia done with mental dropping, we're gonna move on to automatic removal. So when the count often item reaches you, it should be removed from the elementary. So back in the project, I'm gonna hit control T and here, open or button and we here, we're gonna add in your event. So I go in the stab and select and step the end strap event trans after the step event, the items are crafted in the step event, and then the automatic removal happens in the end step event. So here lets out, there's no here. You're getting the ari for dislodged from Denham entry. Then here we check if it's a Valerie. If it is, we got the ground from the area. So novocaine, Jack, if the ground is zero and that is what we're doing here, we're checking if it's equal toe or smaller than zero. And if it is, we removed the item from deem entry. So we're on Iron Media. Move on the slot. I d this way. We should have automatic removal. Working. So now let's go into the game. No, I have four apples. I'm gonna craft abortion, which requires four apples. And now you can see that the apples are gone. So we have automatic removal of arcane. And with this lecture, we are done with crafting. Now we're gonna move on to a new section, so I'll see you there. 35. Hearts: Haider in this lecture, we're gonna implement hearts and to our game w I will have an HB value. So if the HB is three, you'll see three hearts envy Also good neighbourly men's half hearts. So if the HB is 2.5, you'll see two full hearts and 1/2 heart. So let's begin under strides. I have a new folder for the hard inside it. I have as heart no industry, right? We have to some images one for a full heart and one for 1/2 art. Also, make sure that the origin here is that a top left for hard enjoy elements We mostly use a top left origin. No, we're gonna open or Blair here. Let's open the creative end. No. At the end of this event, I'm gonna add this. So here we have the HB valuable were just after three and then we have the HB max viable, which is said to the F B the SP viable will go down whenever the player is heart. So using the SB Max valuable, we can know what the maximum HBs and now we're gonna open the step event at the very bottom off this event. We're gonna add this. No, this is very simple. If TSB is at or below zero, the player instance will be destroyed. So basically, when the SP reaches zero, the player will die, and now we're gonna work on drawing the heart. So I'll hit control T And here, open or controller. And this object on open that raw geoeye event? No. Here we have some more gold for the infantry, which we no longer use usually recommend outscored because we might need it letter. But we don't need this so we can safely remove it. And in its place, we're gonna add this here. We're setting up some properties before drawing the hearts. So he have you had the margin for the HUD. It also acts as a distance between each heart. Then here we have the star ticks and the start by were the hearts are displayed. We want to display the hearts at the top, left corner off the window. So we simply aside the X and a Y two margin. No, here we have the size of the heart image. So to get that views dysfunction, it simply gives us the height over Sprite. So here we pass in as hard to get its height. No, here we have the distance between the coordinates of each heart. So Dad is simply the size has a margin. And now you're gonna draw the hearts. So allowed this here. We're running over its statement on the player. This way, we can easily access and modify the yet to be variable. And if w star doesn't have worst, then this won't run. So inside the deadlock, we have a four loop. We're gonna draw the hearts using this lobe, so the loop goes from zero to a B. Now, inside the loop, we wanna figure out which sub means you want to draw. You know, we have to sub images and astride one for the full heart and one for the half heart. So we have some image zero and submit Iran. So here we create a job image variable, which we set to zero. And here the check. If the slab image should be one, that means we're going to draw 1/2 heart. So this is the condition we have for half heart reject that by getting a difference between DSB and I. So let me explain how you're gonna jag if we need to draw 1/2 heart. Let's say they had to be a three. According to the for loop condition here, I needs to be smaller than that be. And here you can see that I goes up by one. So I starts. Admiral goes upto one, then two and then stops at three. I saw the last heart is drawn at two. No, here. If you do that b minus, I he would get one. Saudi at B is a whole number and there are no half hearts here. Now let's say the F. B s troop on five in that gays the difference would be 0.5. So that's when we need to draw 1/2 heart. This is, however, condition works. So we got the difference between HB and I and then which kept it smaller than or equal to 0.5. In that case, we sent the Saba means to one. Now here we are drawing the heart bride So views draws bride and here passengers pride, which is as hard and then the sub image. Then here we have the exposition. For that we multiply that the Stones would I. And then we add that to start acts. And that's where the hearts are laid out horizontally. And then for the vie position, we simply have to start. Why, no, After the four loop, we have some deep accord. That's where we contest out of the heart system. Here we are drawing some tax using draw text. No, What we're drawing is the HB off the Blair and be a drawing it at disposition. Now in the spot, we're modifying the HB. So here we attacking if the left arrow key expressed So in that gays the F B go zone, then here via jacking if the right arrow key is pressed. So in that case, the SB goes up, so we simply subtract and add 0.252 tsp value. So desperate. So now let's run the game. And here you can see the three hearts and here the value off HB. And now I can use the arrow keys to modify DHB. If I said it to 2.5, we now get 1/2 heart. And if I radio so it all of it down to zero w and eyes Now make sure you remove the TBA gold from here. And in the next lecture, we're gonna start working on enemies. 36. Enemies - Part 1: highly Indus Lecture will be walking on enemies. Our enemies will have two states room and follow by default daily roaming. So they'll be moving around randomly. Where the enemy was created in the room, there will be an imaginary circle so the enemy will only room inside it. Now there will be another imaginary cycle for player deduction. So if the player happens to be inside this circle, the enemy will follow it. An imaginary circle were technically only be a distance from the center point. So let's begin walking on it now. I'm gonna go in this brides. And here I have a new folder for the enemies inside the folder. I have s enemy zero. So this will be our first enemy. No industry, Right? We have a four frame animation. It seems too fast. So here, I'm gonna change us. Be tow it. No. Before making the enemy object, we have to work on a couple parent objects. So force will be creating an NBC Barrett. So this will be the parent object for all the NBC's and enemies. Then we'll create another barrier which itself will be a giant off the NPC parent. This will be the enemy parent. So it'll be the parent object for all the enemies. Solar. Start working on the NBC parent. We're gonna close the sprites folder here and open objects. Now here of your gonna duplicated the player object to clear the NBC parent. So all I click on it and slag duplicated, not the name for this new object will be. Oh, NBC parent. Now, the object so far is only a duplicate off the player. So, no, you're gonna make some changes. Let's open the create event. First of all, we have some gold here for creating the pickax. Of course, the big cats is only for the player, so we're gonna remove it from here. Then at the end of the event, I'm gonna add this. No. Here we have some variables. 40 in part. We have input, eggs and input by. They'll be used for moving the enemies. And here we have tools, pride, valuables. This will be the pride for Wendy. NBC is idle. So by default, it said to s player Idol. And this is a surprise for Wendy. NBC is moving. So by default, this is had to explain. Move so by having thes valuables. We can usually, Jane, the surprise often, NBC? No. We're gonna open the destroy event here we are simply destroying the held item. But you know that an NPC doesn't have a held item, so we simply cannot lead this event. And now you're gonna open the end step event here we are moving the held item when there's instance again, we don't need this. So I'm gonna go ahead and delete this event, and finally, we're gonna open the step event. Now, here you can see that we're taking input from the keyboard, so we have the right left up and down keys. Of course, keyboard input is only for the player. So we're gonna remove this from here. And now here we have the import axes. You can see that they are local variables. They are then used here for the movement. No, in the creative end, we have these variables, so we're gonna use them in the step event. So here I'll remove these local variables, and where they are used are simply remove the underscores. No. We're gonna scroll down a bit and come down to this part here. We are simply changing his pride bears on whether the NPC is moving. So here we will be using the variables that we created in the create event. So let's go back and down here, replace s player, move when its variable. Then we're gonna do the same for s player idol. If you want. You can do the same in the player as well. No, down here we have some cold for flipping. The NBC says discord is from the player. The flipping is based on the most position 40 NBC's We want them to flip in the direction they're moving in. So here and there sine function I'm gonna lead the parameter in its place are simply enter . Move, acts. I know the name of this valuable still signed miles. So I delete mouse and simply called Sign. And I'll do the same wherever the variable is used. Now the NPC parent is done. So I'm gonna close that, you know, we're gonna start walking on the enemy parent. So let's go into objects. And here create any agro on a M desk group enemies. I created the enemy parent inside this girl. So it will be called oh, enemy parent. No, in the object. We're gonna open that pattern. Many likely a cure and send a parent toe or NBC Barents. So, no, this is a child off the NBC parent. We have the parent events here. So first of all, we're gonna inherit the create event. No, inside inherited event vehicle does. Now here we have different speeds for the enemy movement. This is the speed for when the enemy is roaming. And this is the speed for when the enemy is following the player. So you can see that when the enemy follows a player, it moves faster. Now, here we are, setting them all speed to the Rome speed Dass Pickles. The enemy is roaming by default. No, Here we have target eggs and target by variables. This is the position where the enemy in Easter more That's why we call them the target. Now, here we have a variable called following. If this is true, it means that the enemy is following the player. And if it's falls, it means that the enemy is just roaming. So by default it is had two falls. Now here we have a following distance. This is the distance at which the enemies to Astro followed a player. So if the distance between the enemy and a player is less than 80 pixels than the enemy will start to follow the player. Now, here we have variables used for the roaming. This is the wrong distance. It's how far the enemy can go by roaming. And this is a roaming time. It's basically a time a variable that we're gonna use for the roaming. This way we can set a new target position every two seconds. Now we're gonna build the enemy I so we'll continue in the next lecture. 37. Enemies - Part 2: Hey there. We're not gonna continue making other enemies. In the previous lecture, we've had up the creative end off the enemy parent. So now we're gonna build the enemy. I any new event? So here I'll go on the strap and Adam, begin step event. First, we're gonna work on the gold for the roaming. So in the event a lot does here we have a condition to make sure that the enemy is not following the player. So that means that the enemy is just roaming. In that case, who has had the most bead to the moves be drawn now, in this part, we're gonna set a new target position where the enemy needs to move. So we do that when the room time is equal to zero. Now, here you're getting a random land value. It's how far the target point will be from the point where the enemy was created. So it will be a random number between zero and the room distance. Now, here you're getting a random direction value, So this will be a random number between zero and 3 60 So the target bond will be this fire of a in distraction from the enemy of starting point. So now we have a land and interaction and now we need to convert the land and the direction into X and Y values. So that can be done using the land stare functions. So here we have Leinster X, which gives us an X value. And here we have Leicester by which gives us a by value so into the function we pass in the land and the direction. So we passed in the same values into both functions. In this way, one function gives us the axe and the other gives us the lie. So after you get the eggs, we added to the EC start. This is the X where the instance was created in the room and that becomes the target X. Then we do the same for the target. By so far we got the buy from the last year of I function and then we add to the life start . So now this is where the enemy should more. Now here we are, setting the wrong time to 1 20 Since one second has 60 stabs, there's Estelle seconds. This means that after two seconds, a new target location will be selected. So after you said their own time to 1 20 dis condition here becomes falls. So in that case, we come here to the else part here. We simply really used their own time by one and that may it keeps going down until it's back at zero. Now, here we want a jack if the player is near enough to be followed. So for us, we have a condition. We every Jack, If the player exists in their own, then we have another condition joined with end no index case. This condition will only be evaluated if this condition is drool. So here we are, getting the distance from the enemy to the player. Then we are checking if it's smaller than the fall understands. So if this is true, it means that the player can before Lord. In that case, we simply said following toe Truell No, that makes disconnection falls. So now we need an ass block for the following system. First, I'm gonna resize the window. Then after other previous block, I'm gonna add this. No, here we haven't asked. Blob! This runs when the following variable ist rule. So here we are setting the most be to move speed, follow someone following the player, the enemy moves faster. Now here we are, gay and evaluating the conditions that make the enemy followed a player so far. Three. Jack If the player exists in the room Then again we can't understand from the enemy to the player we jacket for smaller than this value and the value here is simply the fall of the styles multiplied by 1.3. So now you're probably wondering why Death distance is larger than the one here. Basically wants the enemy stars to follow the player. It should be harder to get out off that dead. So that's why the distance is larger here. So know if these conditions are true, then the enemy should fall on a player. So here we found the target X and target by two The players X and by and here we haven't asked block in case the enemy can't follow the player. So they simply set following two falls This where the enemy will start running again. Now you're gonna make the enemy move to the target position. For that, we modify the input X and by variables And that's where the enemy, with more so back in the begins type event at the very end, allowed us in this condition. We're making sure that the enemy is not at the target position. So we do that by getting under stones from the enemy to the target. And for that we use the point distance function Dysfunction gives us that the stars between two binds. So this is the first point. And this is the second point. Novia getting Galveston's between the enemies acts and by and the target X and by via checking if its creator, Dan demo speed. So in that case, we come down here where Bs adding Dean, put eggs? No, here we have a clamp function. The three arguments and dysfunction are value men and Max, So the function stops the value from going below the minimum, and it also stops it from going above the maximum soiled basically keeps the value in a range. So here is our value. We're getting the difference between the target X and X via then limiting bad to a D minus one toe, one range. So Dad becomes over input eggs, Then we do something similar for the import by. So the value here is targeted by minus phi. And then we limit that to the miners Oneto one range. So this will make the enemy move. And now here we haven't asked block. And this will Iran when disconnection here is false. So this means that the enemy is already at the target position, though it won't be exactly at the same coordinates anywhere. In that case, Dean put X and by will be Satu zero. So this means that the enemy will stop moving. No, this is all the cord we need for our enemy parent. So we're going to create our first enemy. Let's go back into the enemy's faller inside objects. Here, I'll create a new object. This will be all enemy zero now in the object here, I'm gonna sign the enemy's bride. Then I'm gonna open the parent menu and click here to start a parent. I'll go on the enemies and said it toe enemy parent. No, We're gonna come here and inherit the create event. No, inside the event, if you're gonna add this here we are setting up does prides used by this NBC. You can see that we're setting both the idol and more variables toe the same bright No. We're gonna go ahead and play some enemies in the room. And now you're going to run the game here. You can see the enemies roaming around the only roaming around in their little circle. And now I have been deducted by an enemy. So the enemy has now started following me. Solo roaming and following is working. But there is one problem. If you get multiple enemies to follow you, this starts happening. They all sort of blend together any single position. This happens because there are no collisions between the enemies. So no, if you're gonna fix that for those, we're gonna have to go back into our enemy parent. We're gonna open that begin step event. No. At the very end of this event, we're gonna add this here We are simply gonna stop the enemy from moving If it's moving into another enemy, this lonely be functional when the enemy is following the player. So this block is only executed a following a straw? No. Here we're creating local valuables called New X and new by. This is the position where the enemy is gonna move in the step event. So, for example, for the new X, we multiply the input X when the most be. Then we add that to the X so that becomes of any webs then for the new why we multiplied input by with normal speed. Then we add that to Divi. So now that we know where the enemy is moving, weaken Jack for collisions there We're gonna do that with the players meeting function here . In the arguments we pass in the X and Abi, we everyone a check for religions Then here we have the object with virtually a checking for collisions. We want to do this with all the enemies. So we simply pass in the enemy parent Ethical is unis found Then this will be true and we'll enter this block here we simply sad Dean Poor tax And by 20 Sovann Nikola June has found with another enemy doesn t me will stop moving So now let's run the game and acted out I'll get the enemies to follow me and now you can see that they move more like a group What we need now is the ability to attack them, and they, too, should be able to attack the player. So let's continue working on the enemies in the next lecture. 38. Attacking Enemies: Hey, Leo. In this lecture, we're gonna work on attacking the enemies. When we hit an enemy with a pickax, we wanted such be to go down in that moment. We also on apply and dog back to the enemy. No Ford. Irregular movement of any NPC. We have more backs and move by. But for the not back, we're gonna create new variables. These will be boast X and both. Why? So let's begin. First of all, we're gonna open or NBC parent here, we're gonna open the creative end. No, here. After more speed, I'm gonna add Does this will be the speed off the knock back. And now here. After move ex and move by, I'm gonna add Does Here we are simply initializing both acts and both. Why, No, you're gonna apply that Both variables in the step event? No, in this part, we're calculating the movement. So we applying the import to Demel wax and move I No, after this part of your gonna apply the boost. So here. I'm gonna add those. Now here we are rounding both stacks. We are done adding the rounded value to move X. And then we are rounding both why? And adding that to move by so desolate, how the boots will affect the movement off the NPC. Now we want doubles to keep going down. So in this part, we're using love to move both X and both y to zero. Of course, we don't apply the results to the same variables. So this way the both will keep dying down. No, we're gonna open or pickaxe for the actual attacking here. We're going to open the create event, and now here we have a break distance. This is from how far we can break a breakable in Stan's. Now we need a similar distance. Viable, but 40 attacking. So here we're gonna add the attack this times. So if the enemy is more than eight pixels away from the player, then you won't be able to attack it. And now you're gonna open the step event. Here we have gold for interaction. Red breakable objects. We want something similar for interacting with the enemies. So we are simply going to copy the scored. So I'm gonna select it from here to here. I'll copy it. Then I'll come down here and passed it. So now we have a copy here. Now we're gonna replace older, breakable would enemy. So I'll do it in the comment than in the valuable name here. Then in the statement and then here in the object name. So now this is gonna find an enemy stunts at the mouse. And then a bit statement will be run on Darius Tanz. And then here we got data struggles between the enemy and the player. Then we check if that distance a smaller down the break, this trance. No, even I used the attack that starts here. And so I'm gonna do that. So if the enemy isn't range, then we'll come down here. Here we are setting the selector instance, valuable to the i d. This way a selector will be drawn around the enemy. Then here we have a pair off conditions. First, we're checking if the golden off the pick cuts is at zero and then be attacking if the most button is pressed. So if these conditions are truell, it means that they are attacking the enemy. And in that case, reader jewels. It's at B. And then we started the rotation and golden off the big cats. So This is where it currently ends. But we also wanted to apply and not back to the enemy. So now we're gonna do that here? No. We applying the knock back here to double stacks and both y variables. First of all, here we are getting a direction off the not back. And for that we're using born direction. So we're getting the direction between two. Bynes. The first point is a player exposition and the second point as a position off the enemy. So we're getting the direction from the player towards the enemy? No. Here we have the letter X function. No, for the land we're passing in the knock back speed and here we are passing in that direction. Now, the result off this is applied to both X and then here we have landed nearby. We are passing in the same land and our action. Then the result others is applied to boost. Why so this way the enemy will get a knock back. And now we're going to run the game. Now there's a selector around the enemy. I'm gonna click to attack it and the enemy and got knocked back. I can do it again. And now we have cared the enemy. If you're having trouble clicking on the enemy, you can make its mast larger. Make sure the moan here is set to manual. So that said for this lecture, we're going to continue to the next one. 39. Getting Attacked: Hey there in this lecture will be walking on the player getting attack so the enemies will be able to attack the player. No, You're gonna start by creating any will script. I'll create a new girl called Attacking Inside it. I'll create a new script. This will be called Get attacked. So this will run in an enemy or in the player when they are attacked? No. Inside the script we're gonna add those dysfunction is only gonna take one argument. And that is the I. D off the attacker. That would be the other renaissance that's attacking this instance. So that idea is gonna be stored in this local variable. And then here we are, reducing the SB off this instance. Now we need to apply and not back. The court for that is currently in orbit cards, so we're gonna go to it. We're going to open those type event. I'm gonna scroll down, and here we have the part. We had a player attacks and any means in this line. We are reducing dsb What? We already added that in the script, so I'm gonna removed us from here Now, here we have the code for the knock back. So we're gonna selected and then cut at We're not gonna put it in the script, so I'll go back to it and down here are best at I'm going to select this part and press shift to remove the indentation. Knowing the knock back code. The attacker is all player Soviet gonorrhea placeless where the attack are variable. No, the knock back will be applied to the instance that's running the script. We're not gonna use the script back in or pick ads. We're back in the box from Bear. We caught the knock back cord. So in that part, we're gonna use the script instead. So allowed this Here Here we are running the get attacked function, the attacker is or player and the instance Getting a tag is the enemy that we are clicking on. We are inside the school off that enemy because off this with statement and sold a function as running in the enemy. Now, nothing has really changed here we have only moved of accord to a script. But now we can use the same script in the player as well. No, to implement the enemy attacking. We're gonna open or enemy parent. We're gonna go into the creative meant here. We're gonna add this. This is the cold on 40 enemies attacking area similar to the golden system that we have in the pickaxe. So when the enemy attacks, it won't be able to attack again for some time. Then here we have the areas off the attacks. Local. We will be using a collision circle to attack the player. No, we need a step inland in the object. We do have one here from the parent. So vehicle 900 dead. Then in the event, we're gonna add those here. We are attacking the player if a collision is found. So for the collisions with Blair were using collision circle. If the player is colliding with the cycle, then the condition will be true. So here we have the position off the cycle and then we have the radius. Here we have the object that we are colliding red and then we have a couple options that were starting to falls. This option is for precise collisions. And this one is for excluding d current estan. No. After this, we have a second condition joined with end here we are simply checking if the attack golden is equal to zero. So only then will the enemy be able to attack. No. If the conditions aren't rule, then become here. Here we are never its statement on the player Inda player were under gather at function for the attacker we use other other refers to the InStyle's outside off the word statement. So in this case, it's the enemy that's attacking the Blair Now, After the red statement, we found the attack. Hold on to 20. So now the enemy can't attack for 20 steps? No, we're gonna add those here. We are checking if the attack a well known is greater than zero. If it is video said by one so at a point it will become zero again. No one the enemy at extra player. We want a player too. Got a knock back, but the player doesn't have any No back code right now, So we're gonna open oh player and added, we're gonna go into the creative end here. We're gonna initialize the knock back speed Slovenia initializing just variable with a default value or four. And now we're gonna initialize the both variables so we have boast acts. Animals try both Starting off at zero. No, in the step event. We're gonna implement the knock back moment. So this is where he is heading the move ex and move by. After this, we're gonna apply the boast for that, we'll add Does No. This is exactly the same chord that we added in the NBC parent. First we around the ball sacks and both y and then we add them to the move ex and move by and then views Love to bring down the bush. 20 So now the player can receive knock backs, no end. A player dies. We've owned the room. Toby restarted. So I'm going to scroll down to the very bottom in the spot. When the SP reaches zero, we destroy the instance. So you can I use an alarm to restart the room one second after this. So now in the same block, we're gonna add us here. We are setting an alarm button or controller. Soviets adding alarm 0 to 60. Now that alarm in no controller will run after 60 steps. So that's one second. No, we're gonna go into o controlar here. We're gonna add anyway. Event. The event is alarm. Zero Indus event were simply gunnery. Start the role for that will use dysfunction. Now the room will simply restart one second after WR dies. But you're probably wondering who I reported the alarm in the controller and not the player . We did that because the various tones is destroyed when the player dies. So if the instance doesn't excess, then you can't run alarms in it. That's why we had to put the alarm in the controller. No, you can run the game and destined out, and not a player can be attacked by the enemies. And Brenda Player dies. One second letter. No room. We starts. So that said for this lecture. 40. Using Items: Hey there. Indus Lecture will be implementing the ability to use items. So when you click on abortion, you'll get a heart for this. We're gonna go into a button I envy. And this is the button for each item in deem entry. No. Here. We're gonna open the strap event here. We have a condition. We have your checking If we're hovering on the button and were pressing the right mouse button So this is the gold for when we right click on the item to drop it from deem entry. And now we're gonna add good for the left mouse button, which will enable us to use the item. So at the top before the existing code, a lot does. Here we are checking if the player is hovering over this button and pressing the left mouse button. So this means that they are left clicking on the button. In that case, we come here here, we're getting the array off the item from the inventory. So here we get the inventor realist from the controller and from that list, we read this lot. Desist us, Lord, I d off this button. So we got the item away for this lot, and then we, Jack, if it s an array, if it is, we're gonna use the item insiders. So inside this block, we're gonna add code for that. But first I need to resize the window. No, back in the block. I'm gonna add this here we are simply getting the item and account from the array. Then we're creating a local valuable call used Right now it's that two falls, the simply stores, whatever used the item and we thought it to True, when we do use it, No. When the game is paused, all the game objects are deactivated. So here we are, activating only the player. Of course, we can only use an item on the player if we activated. So that's why we have to do this here. Now we come to a sweat statement. This is similar to an F condition. If there's variable is equal to this value than discord will run Soviet. An If statement, you would write those we use, which, because what those? You can have multiple care sales so you can have a guess for item, portion item, apple item, orange and more. And after the board for each gays, You need to have a break. Otherwise the next case will be executed as well. So now if the item is a portion, then discord will run Here we have a red statement running on the player NW. We have a condition. We are checking. If DSP is below the SB Max, this means that the player doesn't have full hearts. So in that case, we increased the F B by one. And then we've had used to drool. No, we want to make sure that the HP doesn't go above the limit. So be Jack. If the SB is greater dandy SB max. And if it is above at the Max, we make it equal to the SB Max. Then we're closing the blocks and then breaking the gates sort. Okay, starts here and ends here. We will be adding one more case later in the lecture. Now, here we are, deactivating the player again. We no longer need it. No. If he used the item, even renews its count in the inventory. So just after this line, I'm gonna add this now. Here we have a condition. Were be a checking if we used the item. If we did have, you're gonna reduce the count in the array. So that's what we are doing here. The count is in the second element. And to modify it, we're using the addax ESA. Now we are printing a message to the output log. This is a message that we are printing, So this way we'll know whether the item was used or not. Now, here we have an s block electrons. When the item was not used. So in this case, reprints toe the log that the item couldn't be used. So either just message will be printed or this fell. No, we're gonna go into the game. I'm gonna collect some apples and random graft A portion? No. When I click on the portion, nothing happens. And in the output log, you can see that the item couldn't be used. Now this is happening because we already have full hearts. So you're gonna get hurt a little under news TSB and now we should be able to use the portion. So I'll click on it and in the art. But log it sells out. The item was used and as a result, back in the game we have another heart? No. Back in the sweet statement, we can add more castles for more items. So after the break for the scales, I'm gonna add this Now Here we have code for what happens when the apple is used. We run a bit statement on the player, then we check if TSP is below the SB max and then be increased the SP by 0.5. Of course, we also have used to Truell no one. We use an apple in the game. It gives us 1/2 heart. So that's where you can use any item. Indian Venturi. You only need to keep adding cases. And this which statement? Just don't forget to add a break after each case. Now I have a challenge for you. I got the name off the item that was used and then bring its name in the out. But log when it's used Saudi and result should look something like this. Do let me know if you have any questions and I'll see you in the next lecture 41. Placing Blocks: Pt. 1: Hey there in this lecture will be adding a future for placing blocks. You're going to create a wood block that can be crafted from board. So you will be able to place it in the game and you'll also be able to break it So this one block will be a child off. Hopeless about parent. These are objects that you can place in game. No, the possible parent itself will be a child off or breakable parents. So all place a bus will be breakable. No, let's start working on it. Here in the sprites, we have asked block on the scoreboard. This is only the icon that Libya Indian mentally, many for the actual place. Herbal. We have this pride in the bald grew up. This is ask passable block would. And this is the actual passable block that a player can place in the room. Now, here, I'm gonna sad the origin to middle center. Then we're gonna add just the mosque. All said, the more to manual and bring the mask down toe only the ground level. And that's where the player can move behind it in this part. Now we're gonna go into scripts and open in it. Here we have all of our items and their recipes on this line. We have the wood block. The recipe here requires five would No. You're gonna make it do instead. So you can now craft a wood block. Went to award? No. We're gonna work on the place of balls, so under objects, we're gonna open the world. Grew up here, we're gonna add another girl. This group will be called possible. Here. We're gonna add the opiates about parent in its barren menu. We're gonna make it a child off. All break about, parent. Now we're gonna add of a wood block object in the same group. This will simply be or what block. Now, this will be a child off all possible parent Saudi in height, industry for the subject goes or collision the no breakable parent, the no possible parents And then or would block? No, I'm gonna send this bride here and then Vehicle nine. Harried Do create event here. We're gonna start some properties for the breakable part off the object. Disarray has the resources that this object can drop. So here we only have one, then DSP off despicable is it? And then the SP Max is awesome. Now we're gonna go into a script on open in it. Item. We used the script to set up an item. So we passed in the item, the name, the sprite and the recipe. And now you're gonna add one more argument. This will be place Herbal. So this is the place herbal object for this item. So for the item block, would this would be or one block? Now these brackets here mean that deaths argument is off. No. So you don't have to specify it for every item, but this doesn't make it automatically off. No, it's something we have to do in the court. So now, at the end of the script, I'm gonna add this here we are creating a new worry for storing the possible. It's simply called Global Island. Place a ball here we have a basic gunnery operation. This is the condition. Here we are checking if the number of arguments is greater than four. So these are the four required arguments. If you only pass in these arguments than the argument count with before. But if you pass end up less about as Well, then the argument count will be five. So that's what we are checking in this condition. So if this condition est rule, it means that the place of all argument was given. In that case, we use argument for for the place Ball now deserves stuff left argument since argument index layers start at zero. Now, in case the condition is false, we're then gonna use a default constant value, so that value is here and it's no one. So if you don't specify the place herbal argument, then no one will be used for the possible off this item. Now we're gonna open the in its crypt and come down to the block world, the sister s apiary for this item. It ends here so we can add our next arguments after this. This argument is the place herbal, so you cannot pass in the or would block object. So death is the object that would be placed when you use this item? No. Before walking on the placing feature, we need one more script, so I'll create a new script. This will be called Paul Struggle. Using descript, any object will be able to pause or on pause the game. Now the code for this is already in or controller. So you're gonna open it? We're gonna go into the steppe event, and here we have the code for pausing or in pausing the game. Currently, it Ron's when you press the escape key. So I'm going to school down, select the court from here to up here and then cut it. Well, then go back to the script and then pasted here. Now we want the score to run in or controller. No matter where you call it, so are the top. I'm gonna add a statement running on or controller. And then at the end, I'm gonna close of a block. No, back in, no controller. We're gonna go to the part from where we can't the cord were simply gonna call our new script here, So this will function as it always dead. There's no real change here. No, we'll be going into or button I envy in the strap event. We have gold for when we click on this button to use the item. The switch statement here is what handles what happens when you click on a specific item. So currently we have cases for portion and apple. And now we'll be adding in UK is for our item block would. And then you also need a break. No, If you have more possible items, then you should add them to the same case so you could have a block iron or any other block . Then they would all run the same court because they're all place a bles. Currently, we only have one possible. So I'm gonna removed arrest. And now inside this case, I'm gonna add this. First of all, we're running bar struggle, so this will simply Ian paused again. Then we run a bit statement on the player here he is having a variable called placing or BJ . This is the object that the player will be placing. So we got it from the global item place about our A. We used the item I d to get it. So four hour item block would this would be all one block and then we're on the user of an zero in the player. This is an event will be adding to the player in the next lecture. It'll simply enabled a blessing more in the player. Now we're simply starting you to do. True. Now we know that we are imposing the game here. So this makes all instances Actel. But down here we are deactivating a player again. We should know only do this if the game s still passed. So before the function, we are simply gonna add a condition. So be Jack if the game is paused and then VDs compared the player No, we'll be working on the placing more inside the player in the next lecture. 42. Placing Blocks: Pt. 2: Hey there. We're not gonna continue working on about placing more. We're gonna go into or player. We'll be opening the creative and and setting up some variables for the blessing Lord. Now there simply souls. But other placing more is enabled or not. So if they say is true, then you will be able to place an object. Now, the object that you'll be placing in the placing mood will be stored in this variable. So this can be or what block or any other possible object that you have created? No. Where new place a block. It's gonna create an instance in their own. And so the i d off the Aniston's will be sold in this variable. Now we'll be adding the user event zero de seven will enable top blessing more and so all right. This in the description and then in the event allowed does. Here we are deactivating the pickaxe held by the player. It's Ali. Isn't this variable? So when your blessing a block, you cannot use topic ads. Now, here we are starting placing more troll so the placing more will be enabled. Then here we're creating an instance. After placing object the stars will be created at the most exposition. It'll be created in this layer. And then, of course, the object will be taken from this valuable. Now, the I d off the new instance will be stored in this variable so they fail. Stop, flexible and strong that we are placing. Now we're gonna set its Alpha 20.5. So I'll be a placing the instance. It'll be a little transparent then. Finally, we were on the mouse. Clear function. This basically resets the mouse in port for a button. So that button is and be left. You're not gonna have to press it again. Here is the reason why they're using dysfunction. When you click on a possible item, we enter the user event zero off the player. So currently in this frame, the mouse expressed at this point, we need to detect another click toe disabled, a blessing moored. But the mouse is already pressed in this frame. So it's gonna be like that, and disabled are placing more so in the same frame, blessing more will be enabled, and then it'll be disabled. And that's why we use most clear in this event. So Now the placing mood will not be disabled in the same frame. No, we'll be adding the user event. One in this event will be disabling the placing more. So I'll write this in the description. And then in the event a lot does no it dysfunction. We're activating of a pick axe again. And then we're starting placing more to falls. So this means we are disabling the blessing moored No. When we created of a blessing insolence and user of and zero reset its offer to 0.5. So now, in user and bon, we're gonna started back toe one saw the instruments that replaced will now before the visible. And of course, we are done placing bad instance So we don't need a society anymore. And that's why we are is heading this variable by siding get to know one. And now again, we're clearing the most import on and be left. If we don't do this, then the pickaxe will attack the same mouse input. And if that happens, then the pickaxe may attack your new block. Since we don't want that to happen, we use most clear no, between user of an funeral and you serve at one placing more will be managed in the end step event. So in this event, we're gonna add Thus, first, we are jacking if blessing more as an abled and then we attacking if the blessing externals exerts. So overall, this means that we are end up placing more, and we are placing an instance. So if there's extra, will we come down here? You can see that we are running a bit statement on the placing instance. We're simply moving it to where the mouse s. So this will allow you to place the new block with your mouths. Now, here we have a condition. We have your checking. If the player press the left mouse button, if they did, we're gonna run the user event one. And you know that desperate disabled, a blessing moored so these conditions will become falls. Now we can run the game and after it out, I have some would now. So I'm gonna craft a one block. If I now click on it, I'll enter placing more. So now the pickaxe is disabled and we can place our block wherever we want. It's a world object now, with collisions and everything, and you can also break it. So you will get some blood back. No one issue, but this is that you can play set perfectly wherever you want, but there should be an invisible grid for the placing board. So let's implement that. We're gonna go into the script, which I have open here at the top. We're gonna create a macro. A macro is a global content value that you cannot change. Now, this is the size of each cell in our invisible grad. So itself will be 16 by 16. Now we'll be going into or player. We're going to go into the end step event here. We simply move the instance that we are placing toe the mouth now to enable the grid. We cannot remove those on our debts. Instead, let's take a look at what we are doing. 40 x. Here we are dividing the mouse X. With the size off the grid, the full give us the cell number, which can be 012 or more. But of course, we may also get decimal values. So to eliminate does we're rounding the value now. It will only be indeed your values so we multiply that have integrated size. So now the X can be 0 16 30 to 48 or more Now here we do the same for the by now they're showed enabled a grade for the placing more And now you can also create more Place a balls If you have any questions, do that. We know and I'll see you in the next lecture. 43. Placing Mode: Updates: Hey there in this lecture will be walking on some updates on our placing more. We'll also be adding any irreplaceable. First, there's an issue that we need to fix. Took her after a one block. You need to what pieces? So when we break a wood block, we should get exactly to what pieces back. But here we only got one. No, I'll break another one. And again I got one. No, In this case, I actually got three. So that is one extra we should only get to since that's how many of you to craft this block . No, To fix this, we're gonna go into or breakable, parent. I'm going to open its create event now. Here will be creating a new variable. This will be rest. Count on its default value will be minus one. No, this is how many resources? Just breakable. Short drop efforts minus one. Then the current will be random, like before. But if you send us to a number save on two or three, then that number will be used. So we're gonna make that change industrial event. Now this is a very random restaurant is selected. We get a random number from their stools function, and then we store that in this local variable. So after this line, I'm gonna add this Here we are checking after s count. Variable is not minus one. So in that case, the local rest count is that to this value? So now this is how many res. Also, this will be dropped. Of course, this will only happen if it's not minus one. Now, if you're gonna go into or what block, I'll go into the create event and here are initialized. RS count also added toe to So now that would block will only give us to what pieces out of state by going into the game. And when I break it, I get to what pieces? Now I'll break more and I'll always get to What pieces? So four that would block there s count is not random anymore. No. I'm gonna show you how you can add any possible first of all industry rides. I'm gonna go under items. This new item is s angry statue. So this is the icon that LaPier Indian men tree. Make sure you said the origin to middle center. Now I'll go back into sprites. I'll go under the vault Grew up. Now here I have explicit ble angry statue. This will be placed in the room. I'm gonna said the origin toe de spined, and I'm also gonna modify them. Ask I'll make the more manual and limit collisions toe the spot. Only now I'm gonna close brides and open scripts. I'll open the in its crypt. I'm gonna go into the script, and here we have the item in, um, we're gonna create a new entry. 40. Angry. Gradual. So this is I want you item down in the script. We're gonna side of the properties off that item we're using, innit? Item does add up the item. This is the item we're setting up, which is really angry statue than this is its name. And this is this bride 14 men tree. Then we have the recipe are a took her off the angry statue. You need three stones? No. In the last argument, we have the place of battle object. You're gonna create the subjects on. First, we're gonna go into our crafting many worry. We need to add a bust at you here. So all career a new section for that and then add the item. So now the angry statue will appear. Another crafting menu. We're not gonna go into objects, then world, and then place a ball or would block is the only place about we have right now. So we're gonna duplicated to create or angry statue. Now in the new object. I'm gonna send this pride. So that's accessible. Angry statue. Then we're gonna open the create event in there is orders are a I'm gonna replace word of which dawn. Then I'm gonna start the rest count to three. So there's no Magister recipe. Now, the final thing we need to do is an all button I envy. We need to be in the strap event. No, in this with statement here we have cases for portion. Apple and Block would No. The block world is a place herbal so we can add of a new place herbal in the same case. So I'll advocates for item angry statue. Now, for both of these items, the same chord will run No in the game weaken graft and angry statue with three stones. So here we have it. And now we can place it in the world. So I'm gonna place it here and now I'm gonna break it. So we should get three strong. Let me kill this enemy for us. So we shouldn't get three stones when we break it. And we do Now, there's a bug that we need to fix for that. I'm gonna go into placing more. Now I'm gonna breast escape to pause the game. No. When I un pause it, you'll see that the pickaxes back and we are still in placing more. So this list a bug and via gonna fix it now for this, we need to go into the cost of a script. We run the script when we want to pause or on pauses again. So you're gonna handle that bug here at the top off the script? I'm gonna add this here. We are running a rich statement on the player than in the red statement. We're checking. If the placing more is enabled, effort is. Then we want to disable it. So in that case, we own user event won this event simply disabled. Stop blessing More So the short fix the bug. I'm gonna try doing the same again. So vile and placing mode. I'm gonna press escape now. When I un paused, the game will be out off placing more. So when I pressed escape, placing more gore disabled and where the the bug is fixed. So that said for this lecture, let me know if you have any questions and I'll see you in the next lecture. 44. Juice: Scaling Animations: Hey there in this lecture will be walking on some jewels, Jules, or simply when the player. There's something in the game and they get a nice feedback. So every action off the player should give them satisfaction. For example, compare does till death. The 2nd 1 obviously figures much better. And that's what we're gonna do in these lectures. We'll be doing this wet scripts. So in the scripts we have Juice Crear Jewell step and you'll straw when we want to enable jewels for an object. We simply run these scripts in the create step and draw events. No to apply jewels toe the object at any moment. We have another script. That script is called Jules Underscore. Apply. Scaling. So what? That function will be able to apply scaling animation story instance like this. So let's begin by opening up gamemaker. I'm going to start by going into the scripts and creating any a group. This group will be called Jules now, create a script and just grow up, and this will be Jews. Underscore creates no in the script. Were simply can initialize on via balls. So I'll add, Does These are the X scale and the by scale 40 instance. So we're not using the built in image at scale and image by scale. Variables animating these variables may cause issues with collisions. That's because they apply to the mosque as well. So this is the reason why they're using our own at scale and why scale variables. Then we have at scale target and why Scale target. These are used for animation. Saudi X scale and of I scale will be animated to go towards the target values. Then we have the scaling speed. This is basically how fast the scale variables and go to the target. No, we need a script for the step event. So I'll go into scripts on Under the Jews group. I'll create a new one. This will be used underscore. Step in the script were simply gonna anime does gato the target? So all our does here, here we as having the exhale here we are using the lab function toe animated this value. So for the current value, we have the X scale and for the target value, we have the exhale target and then the speed is simply the scaling speed. Then on this line, we do the same for the my scale. It simply animates the value from my scale to wife care target. So this is all for the step event. For now. I'm not going to go back to scripts on under jewels. I'll create a new script. This will be used. Underscore. Draw no Indus script. We simply want to draw the Sprite off the instance. That's where we can apply our scale variables. When we draw this pride so allowed this. Now this function takes two arguments. Acts and buy. These are simply the coordinates Read a sprite will be drawn. Now we are taking the X and y as arguments because they might be different for some objects . Now, here we stole the arguments into these local variables. No, make sure to add the underscores. Here otherwise would be mortifying the position off the instance. No, don't. Here we are using draws Bridey X'd to draw the sprite. So for the Sprite and a sub image, we pass in the Sprite Index and the imagine decks. Then we need to pass in the X and ally. So we simply pass nd x and buy from the arguments. Now the next argument is the X scale. So for that before center image X scale, we multiply that with our own ex scale variable. Then we have the by scale, and here we do the same. We multiply the image by scale. We never own wife Gail. So this is how I was killing. Animations are applied to the instance, knowing the next argument to be passing the image angle for the ordination. Then we have image learned for the blend, color and image all far for the Alpha. So what this other Jews create step and draw scripts are done. And now we need a new function for applying the scaling jewels. So I'll go back to script on under jewels. I'll create a new script, and this will be Jews. Underscore. Apply Scaling. Now I'll go into the script and add this here dysfunction appliance Jews on the current instance. As you can see here, it takes four arguments. The 1st 2 arguments are the scale X and scale by, So the scale will be immediately applied to the instance. So that's what we do with those arguments down here. We simply apply them to the X scale and life scale. No. The next two arguments are the scale, X target and the scale by Target. These will be applied to the F scale target and a buy scale target. So that's exactly what we are doing down here. So anything you enter into these arguments will be set as a target for the scaling animation. No, all the jewels scripts already, and we only need to use them. We're first going apply it on the breakables. So for that, I'll open or breakable. Parent. I'll open the career event and here are simply called The Jewels Create script. Then I'll open the strap event and here called the Jewels Step Script. No, for the draw. Script allowed the drive, and here I'll call Jules, draw on in the arguments, I'll enter X and by So this is basically how you enable jewels for an object. You're under scripts in the create step and drive ins. This way, we can now apply scaling animations to unbreakable by running jewels. Apply scaling. I want to do that when the attack a predictable with the pickax, so I'll go into or pickaxe I'll go into this happened scroll down, and this is the part where the attack a break about So you can see here we're introducing the HB off the breakable, and that works because we are inside every block for the breakable. So no, back in that part at the bottom off the block allowed this. Here we are running our jewels apply a scaling function the first part off the arguments as the scale which will be applied immediately. So it's at the scale to 0.7 on X on 1.3 on why that's where the bride will squish robotically. No, this part off the arguments will become the target, so it will slowly go back to one and one. It'll simply reset. Now I'll go into the game. If I attack a breakable, you can see the scaling effect. It already looks a lot better now. I also want to apply the scaling Jews to these items, so when they fall, they should squash a little. For that, I'll go into all item. I will not enable Jews for this object, So I'll open the create event and here called us create Donald, Open the strap event and call Jules step here and now I'll open the drive and you can see if you already have a drop ball here, have your drawing. That's right off the instance. And we are drawing it at X and Y plus Z. So I'll command this out. Red Control. Okay? And then I'll call that you'll straw script in the arguments All interacts and Libras V So this is the reason why we have X and y as arguments and the script. So now this object issues enabled, and we can apply scanning animations to it. For that, I'll go into the steppe event. I'll scroll all the way down, and here we have a part that says ground collision just runs when the item duchess the ground for the first time. At that point, we went up like scaling. So inside this block, a lot does. Here we applying scaling animation with dysfunction. The current scale will be set to 1.4 or necks and your points haven't owned by just where the item will be squashed horizontally. Then the target is set to one and one. Now I'll go into the game and break a tree. When the items fall, they make a nice squashing effect. I'm not going to do one last thing when you collect an item and it fades of a I also wanted to grow thinner, so that would look something like this. So for that, I'll go back to all item. I'll go again into the steppe event, scroll up and come to the spot. This is where the player collects the item. So to apply a scaling animation here are ladders. No, I don't want to change the current scale at all, so I simply send them to the X scale and the scale. So there will be no image here. Change. But I am changing that target. So that will be easier upon five on X on 1.5 on why Saudi item will grow, Tina as it fades away Now I'll go into the game, break a bush and that will give me an apple All collected and they asked the effect It grows tender as it fades away. So you can see how would one little function we can do so much? You can now go ahead and apply this to any object you want. You can also use these scripts in any other project. they should work with almost any kind of game out there and make it look better. But this isn't where other Jews quest ends. We can I implement flashing colors in the next lecture toe, make player actions more satisfactory, so I'll see you there. 45. Flashing Colors (with Shaders): hater in this lecture will be implementing flashing colors into our game so you will be able to make an object flash with any color. Forgers will be using a shayera, so let me explain how we share that works. Let's say you have an instance that's being drawn by default discourse through a shada, the shade against the color and the alpha for each pixel in the image from that extra page and so pixel by pixel it out puts the image. No, there's something girls associated us. After getting the color and the alpha from the doctor page, it gets the image planned, an image all far from the instance. Then it multiplies them with the color and the alfa from the texture. And so the result of this multiplication is what becomes the final color off the image. No, this is the reason why when you said the image blend to see white, nothing happens. And if you said it to something like See red dust own red but also becomes docker. All of that happens because of this multiplication. So this is basically how the default cheddar works. If you want, you can pause a video right now to look at this child. So now I'm gonna show you the default shared accord to explain how it really works for days you can go into any project. So here I have a blank project open. I'm gonna go into shadows and create a anyone. So this will create a new Shada. And just like that, he for one. If you go into the box pace, you will see that we have to windows open the extension for the first while is be a search . And for the second file, it's FSH. Now this is the blood excreta and this is the fragment Cheetah. So once negotiator has two parts who objects and fragment when you're starting out on learning shadows, you don't need to mess with the what extra at all. We only need a fragment shared a for now. So I'm gonna close about extra now. This chart I showed earlier is about the fragment Shader Only everything you can see in the chart happens on this line. So let me explain. What's happening here in this line runs for each pixel in the image. In fact, this whole main function runs ones for each pixel. So when we're talking about getting the color off the image that happens one pixel at a time here we are setting a variable called GL frank color. This is the final color off the pick for so does had this final color for the pixel. We do does. So this is what I showed in the spot on my chart in the spot. We're getting the color and the alpha for the pixel from the lecture page. And in this part, we get the image blend on Image al far from being stance. But if you're using draws bride txt done distributor color and the alpha from the last two arguments. So after getting the blend color and Alfa, we multiply it with the color and alpha from the texture, and then the result is applied to the pixel. So this is basically how did he fall share Their works were not going to create our own shelter for the flashing colors feature. So to explain what we're gonna do in other negotiator, I'm gonna go back to our chart. We're going to modify this part readable and color, and all four are multiplied with that extra color and Alpha. First of all, we're gonna disable the multiplication. Then we're gonna make it so that only the Alfa is multiplied. So there will be no change to the Alfa. So now the question is what we're gonna do in the color. We're simply gonna use the blend color only as a final color. This means that the original texture color will not be used at all. Only the image planned color will be used for the image. So this way, if you said the image planned to see Rod, then the image will actually turn fully read. And if you started to see wide, the little turn completely white. And this is how we can make color objects flash in any color. The flashing image will appear on top off the normal image. And so we can keep changing the Alpha off the flashing image to control the effect. So now we're gonna go into our game project. I'm gonna go into shadows and create anyone only in this at such flash. So this will be our shared a use for the flashing feature now going into the box pace, we again got two files. A what? Actuator and a fragment shadow. So I'll go into the Fragments Theater and close about X one. And now, initiator, we're gonna make other modifications in this spot. This is were the black color and Alpha A multiplied went out extra color and Alfa So all that moved us here. I'm only getting that extra color and Alfa now on the next line, I'll handle the image Alfa saw ladders. Now here I'm getting the image Alpha only which is what? The door a means and here are mortifying the alpha off the big. So I multiply angered with the image al far so, as I've had earlier, there will be no change to the Alpha. It'll still be multiplied like before and now on the next line, we need to handle the RGB color. So our ladders here are modifying the RGB from the pixels color. I'm simply saddened to the RGB from the blend color Saudi image blend color will be set as the final color for the pixel. We're completely over writing. The RGB sort of color from the original texture will not be used so we can now make use off negotiator to implement our flashing colors feature. First, I'm gonna hurt controlled Blast E and go into the jewels. Create script here. I'm going to set up a couple variables for the flashing feature. This is the flash al Far. There simply controls the offer off the flashing image by default. It said 20 So there's no flash. If we said just roll on, then the flash would be fully visible. Then we have the flash color that the full value for this SC lied. But of course we can change it afterwards. Non. When I had control of the again and go into a jewel step here, I'm gonna manage what happens after you send off? Lash out far. So here Orlando's here. We have a condition we'll be attacking if the Flash Alfa is greater than zero. If it is, we wanted to come back down to zero. So in that case with impunity, also it by 0.1. So after you said the Flash Alpher, it'll automatically come back down to zero. Now I'll hit control T again and go into the juice draw script. Here we'll be drawing the flashing image. Whatever new shada. So at the end of the script. A lot does. First of all, we are checking if the Flash Alfa is greater than zero. If it is greater than you, it means that the flash should be drawn. And that's what we are doing in this block in the first line, the Assad Ingushetia toe as such flash. So now whatever you draw will be drawn using this shadow. For now, let's go back to this line here. Here we are simply drawing the instance that's running the script. So view straws Priety X'd to draw the Sprite Index went arrest all the properties, so we're gonna do the same. But on this line to draw the flashing. Imagine no, most of our statement here is the same as the one before, so we're running the same function with the same arguments. Except for the last two. These two arguments are the blend color and Alfa, so we simply pass in the flash, Color and flash are far, so using appreciator, the color off the image will become whatever the flash color is on the final offer off the flashing image will be de flash alpha, so this will be the flashing image on top of our normal image. Now here we are running Shader reset to research the active shooter to the default later. We only wanted to use associated for this one image. So we Santa Shada here then drew that image. And then we said the shadow so know when I will be sad The flash Alpha two Anything above zero. Then the flashing image will be drawn. So sad the flash Alfa and the color You're gonna create another script. So under the Jews grew up, I'm going to create a new script. This will be jewels, Underscore of life Flash. Now I'll go into the script on at this here. Now, as the description says, dysfunction simply applies Flash toe the current instance the arguments that dysfunction takes our color and Alfa So they are the color and the out far off the flashing image. No, here. Yes, having the flash color variable to the first argument. And then we're starting the flash off a variable to the second argument. Soldiers will enable the flashing image starting with this offer and flashing with this color. Now you can make use off the script to make up a breakable splash whenever we attack them. So we're gonna do that in the old pickaxe object. I'm gonna go into the steppe event now, in the event I'm gonna scroll down a little and now we come to the part. We have the apply scaring animation toe a breakable when we attack it. So just below this line, we also going apply the flash we're using of a new function for applying the flash. The color for the flash will be white and the out far will be one. So we can now run the game and a flashing should be functional. I'm gonna hurt a bush on you can see that it flashes white when you heard it. No, Over scaling and flashing effects are more obvious on something big. Like a tree that also has more held. Just hitting a breakable is no more satisfying than it ever boss again, you can apply these effects to any object you want. Just remember to place the jewels queer step and draw scripts. In the next lecture, we'll be applying. The Jew stood a player and the enemies. And so I'll see you there 46. Juice: Player & Enemies: Hey, there in this quick lecture will be applying over juice features to the player and the enemies. Now, going into of a game project, I'm gonna go into objects on open or player I simply when I enable our juice functionality for this object. So I go into the create event and here simply run the jewels, create function now open dust app, event. And here, run the jewels, step function. And now I'm gonna go into events, and they are the draw event. And then in this event, I'm going to run the jewels, draw function. The arguments will be X and by So now we can apply jewels to a player. But we also need to do with those 40 NBC parent. So in this object, I'm gonna play a slow, create strap and draw script. So would create done. I'm gonna open that snap event and do it here. And no need to add the draw event in this event. On run jewels draw at X at lie. So now you can apply Jews to both a player and the enemies. We can apply the animations when they attacked. So for this, we're gonna go into a script and then under attacking, we're gonna open the get attacked script. No descript runs when I would a player or any enemy gets attacked. The argument here is the instance or object that's attacking this restaurants. So if the attacker is the player, then this argument will be the or player object. This means that if the player is the attacker who we know that in Enemy is getting attacked so bad on that we can make the instance flash in a different color, not going to go at the bottom of the script. And that this here, first of all, I'm applying a scaling animation toe. The current restaurants, the image at scale will be sad to 0.5 or necks and 1.5 or like and the target scale will simply be one. Anyone? No. In this part we're making being stance. Flash bears don't holds attacking. First of all of your checking. If the attacker is lovelier, so does me. It doesn enemy is cutting attack. In that case, we simply make it flashlight. So NW attacks on enemy that enemy flashes within white color. Then we have an el spot in case a player is north, the attacker another game. This means that an enemy is attacking W. So in that case, we make doubly after ash with a red color. So simply making its tonsils slash in a different color is a great way to tell the player what is happening with a white flash. They got the signal that that did something good. What were later at flash? They know that something bad has happened. So you're not gonna run the game and test this out? When we attack an enemy, we see the scaling an emission and the light flash. No. When the enemy attacks top layer, we see the same scaling animation, but a rat flash. So they have said for this lecture. If you have any questions, please do let me know and I'll see you in the next one. 47. Conclusion: Hey there. Where? This lecture. The course comes to an end. For now, I'll be adding more lectures. So if you have any suggestions, feel free to send them to me. And if you ever need any help, you can send me a message. And you can also join our discourse over through this link. It's a great and free community for helping each other. So I hope you have a great day and I'm gonna see you in the next cause.