Game Over Screen

7 minutes
Share the link to this page
Copied
  Completed

Transcript

Havior In this lecture, we'll make our game over screen. So on that screen, you will be shown your score, and we have the option to play again or go back to the menu. So let's begin. First of all, I'll open the room RM game, I'll go to the layers. I'll click here to create a new task layer. I'll right click on it and rename it to goi this layer will be used for drawing the game over screen using the GA UI event.

We had to make a new layer for that because we already have our player and manager in the stances layer drawing the health and the score. So we'll have our game over object in the UI layer, so it'll be thrown above the health and the score. So now we'll close the role. Now we'll go to objects to create the game over object. I'll name it or game over. Here I'll add a create event.

Here we need to add the circumstance alpha action I'll set the starting alpha to zero. So the game over screen will start with an alpha of zero and will fade in. So for the fading, I'll add the step event. Now I want the alpha to slowly increase to 0.8. So I'll add an if condition. The variable I check is of course image alpha, I wanted to increase to up to 0.8.

So I'll check if it's less than that value. If it is, I want you to slowly increase, so I'll add the alpha action and attach it to the condition. I'll enter 0.02 here and declarative. So now the alpha will go up until it reaches 0.8. Now let's draw the game over screen. So for that, I'll add the GA UI event.

Here we need to add the sad row alpha action. I'll set the alpha to image alpha. So everything drawn after this will be drawn using the image alpha. Now we also need to add the saturation. interaction. I'll add two of them here.

So the first one will be used to change the color and the second one will be used to reset it. So anything that we draw in between these two actions will be drawn using cutting edge color. So first of all I disable the use all four checkboxes. If you enable them, the alpha from the color here will be used and this alpha will be ignored. So that's why we disable them when we are using our own alpha. Now I'll click here to change the color to black.

Now we'll basically draw a big black rectangle that will fill the screen so in the actions are search rect and add the draw rectangle action. I'll drop it between the color actions. These are the left and top x&y coordinates of the rectangle and these are the right and the bottom x&y coordinates. We want this rectangle to cover the whole screen. So I'll set the left and the top to zero The right will be the room width, and the bottom will be the room height. We also need to take fail otherwise it will just draw an outline.

Now we need to draw some text. So in the actions also add font and add the set phone to action. I'll add it after the color is reset. I've had the phone to fit score. Now we need to change the alignment to center. So I'll add the setbacks line mat action, I'll add two of them.

So again, the second one will be used to reset the values. So in the first one, I set the horizontal and vertical alignments to center and middle. Now in between these two actions, I'll draw some text. So in the actions, also a score and add the drawing style score action. I'll drop it in between these two actions. First of all, I'll apply this action to all manager since a score isn't that object, then we'll change the caption to say your score.

Now, for the coordinate I'll type room width divided by two. So horizontally it will row in the center. The y position will be the room height multiplied by 0.3. So vertically it will be drawn at 30% of the game's height. Now we need to change the font again, so I'll add another set font action. This time I'll change the phones to fit indicator because I need a smaller font.

Now also as draw an add the draw value action. Now in the caption, or simply enter, press enter to play again, I leave the value empty. In the x again, I'll enter a room width divided by two, and in the y I'll enter a room height multiplied by 0.6. So vertically, this will be drawn at 60% of the game's height. Now I'll add the same action again. For scaption.

I'll enter press Escape to quit. The x will be the same again. The y for this will be room height multiplied by 0.7 Now we'll add another central alpha action. I'll add it at the end, we change the alpha in the first action. So here we reset the alpha back to one. Now this event is finished, so I'll go to add events go under key breath enslaves enter.

This controls when you press enter. So in the actions also restart and add Are you stockroom action. So when you press enter, the room will simply restart. Now we'll go to add event again, I'll go under key pressed, then others and then select escape. Here all sorts go to an ad the go to room action. For the room, I select our menu.

So when you press escape, it will take you back to the main menu. Now we'll open our manager. I'll go to alarm to dismount rooms one second after the player dies. So currently, the game simply restarts when the player dies. Solid lead this action in its place, we want to create an instance of the game over object. I'll click here and select all game over.

In the layer, I'll enter g y, which is a layer we created for this object. Now when the game ends, we want to show the creation of any enemies. Enemies are created in alarm one, so we'll have to disable it. So I'll add the alarm action here. I'll set alarm one to minus one. So by setting an alarm to minus one, you can stop it from running until you set it again.

Now we also want all the existing enemies to die. So I'll add the Assign variable action. I'll click on this arrow and apply this action to enemy. Now here I'll set the variable HP to zero, so the existing enemies will simply die. Now finally, I'll run the game. I click on play, and now it's time to lose.

You can see the enemies being destroyed as A game over screen fades in. I can now press enter to play the game again. If I press escape, I'm taken back to the main menu where I can play the game again or quit. So the game over screen is finished. Now let's move on to the next lecture we will implement a high score system

Sign Up

Share

Share with friends, get 20% off
Invite your friends to LearnDesk learning marketplace. For each purchase they make, you get 20% off (upto $10) on your next purchase.