Implementing The Game Over Scene

9 minutes
Share the link to this page
Copied
  Completed
You need to have access to the item to view this lesson.
One-time Fee
$69.99
List Price:  $99.99
You save:  $30
€67.10
List Price:  €95.86
You save:  €28.76
£55.67
List Price:  £79.54
You save:  £23.86
CA$100.49
List Price:  CA$143.56
You save:  CA$43.07
A$111.96
List Price:  A$159.95
You save:  A$47.99
S$94.87
List Price:  S$135.54
You save:  S$40.66
HK$544.16
List Price:  HK$777.41
You save:  HK$233.24
CHF 62.56
List Price:  CHF 89.37
You save:  CHF 26.81
NOK kr792.29
List Price:  NOK kr1,131.89
You save:  NOK kr339.60
DKK kr500.54
List Price:  DKK kr715.08
You save:  DKK kr214.54
NZ$123.74
List Price:  NZ$176.78
You save:  NZ$53.04
د.إ257.07
List Price:  د.إ367.26
You save:  د.إ110.19
৳8,330.24
List Price:  ৳11,900.85
You save:  ৳3,570.61
₹5,945.56
List Price:  ₹8,494.03
You save:  ₹2,548.46
RM315.51
List Price:  RM450.75
You save:  RM135.24
₦108,149.19
List Price:  ₦154,505.46
You save:  ₦46,356.27
₨19,403.53
List Price:  ₨27,720.51
You save:  ₨8,316.98
฿2,393.75
List Price:  ฿3,419.79
You save:  ฿1,026.04
₺2,454.67
List Price:  ₺3,506.82
You save:  ₺1,052.15
B$425.95
List Price:  B$608.53
You save:  B$182.58
R1,282.09
List Price:  R1,831.63
You save:  R549.54
Лв131.15
List Price:  Лв187.37
You save:  Лв56.21
₩101,234.93
List Price:  ₩144,627.53
You save:  ₩43,392.60
₪254.67
List Price:  ₪363.83
You save:  ₪109.16
₱4,117.86
List Price:  ₱5,882.91
You save:  ₱1,765.05
¥10,949.58
List Price:  ¥15,642.93
You save:  ¥4,693.35
MX$1,405.49
List Price:  MX$2,007.92
You save:  MX$602.43
QR254.12
List Price:  QR363.05
You save:  QR108.92
P963.49
List Price:  P1,376.48
You save:  P412.98
KSh8,999.72
List Price:  KSh12,857.29
You save:  KSh3,857.57
E£3,561.31
List Price:  E£5,087.81
You save:  E£1,526.49
ብር8,689.79
List Price:  ብር12,414.52
You save:  ብር3,724.72
Kz64,250.82
List Price:  Kz91,790.82
You save:  Kz27,540
CLP$69,143.42
List Price:  CLP$98,780.55
You save:  CLP$29,637.13
CN¥510.67
List Price:  CN¥729.56
You save:  CN¥218.89
RD$4,244.94
List Price:  RD$6,064.47
You save:  RD$1,819.52
DA9,440.04
List Price:  DA13,486.35
You save:  DA4,046.31
FJ$162.13
List Price:  FJ$231.62
You save:  FJ$69.49
Q537.12
List Price:  Q767.35
You save:  Q230.22
GY$14,584.29
List Price:  GY$20,835.60
You save:  GY$6,251.30
ISK kr9,693.35
List Price:  ISK kr13,848.23
You save:  ISK kr4,154.88
DH701.59
List Price:  DH1,002.31
You save:  DH300.72
L1,285.64
List Price:  L1,836.70
You save:  L551.06
ден4,127.89
List Price:  ден5,897.23
You save:  ден1,769.34
MOP$558.06
List Price:  MOP$797.27
You save:  MOP$239.20
N$1,283.39
List Price:  N$1,833.49
You save:  N$550.10
C$2,565.21
List Price:  C$3,664.75
You save:  C$1,099.53
रु9,482.30
List Price:  रु13,546.73
You save:  रु4,064.42
S/259.58
List Price:  S/370.84
You save:  S/111.26
K282.68
List Price:  K403.85
You save:  K121.16
SAR262.90
List Price:  SAR375.59
You save:  SAR112.68
ZK1,929.21
List Price:  ZK2,756.13
You save:  ZK826.92
L333.95
List Price:  L477.10
You save:  L143.14
Kč1,686.22
List Price:  Kč2,408.98
You save:  Kč722.76
Ft27,781.83
List Price:  Ft39,690.03
You save:  Ft11,908.20
SEK kr772.17
List Price:  SEK kr1,103.14
You save:  SEK kr330.97
ARS$71,242.69
List Price:  ARS$101,779.64
You save:  ARS$30,536.94
Bs481.71
List Price:  Bs688.19
You save:  Bs206.47
COP$305,135.87
List Price:  COP$435,927.07
You save:  COP$130,791.20
₡35,171.10
List Price:  ₡50,246.58
You save:  ₡15,075.48
L1,769.55
List Price:  L2,528.04
You save:  L758.48
₲543,563.42
List Price:  ₲776,552.46
You save:  ₲232,989.03
$U3,109.25
List Price:  $U4,441.97
You save:  $U1,332.72
zł286.15
List Price:  zł408.81
You save:  zł122.65
Already have an account? Log In

Transcript

Hello and welcome to the 13th tutorial in the caucus to the Flappy Bird c++ series. And in this part when we're looking at implementing the game over scene, we'll be using the source code as usual from the previous part of the series. So if you don't have it, don't worry the bill link in the description to the source code. The scene will contain four main elements the background, which will be the same as the game and the main anything retrieved by turn a main menu button. The score which will be passed into the scene when it is constructed, hence the scene will need to be modified. But the scoring system we won't be implementing directly yet that is going to be in over the next few tutorials.

So let's add the first let's add the background First, we will just copy and paste the code from the main menu, add it in the same model we use code is literally this one here. Copy and paste the background copy, go to our demo site. That was almost forgot pasted into there the background has been added now we can declare the go to Main Menu scene function and then go to game scene function in the game our scene header so we're going to create a private methods go to the main menu scene and in here I do know I've missed that avoid I'm going to pray in a second goes to the ref Asterix sender and then he'll avoid copy and paste this and the only thing we want to change for this one is going to gain seen as needed. Get rid of the menu and go to game menu scene.

Okay, so before we create the menu and implement the functions, let's include the main menu scene game scene and definitions header. So okay. Hash ping clean game scene as we'll need to access the game scene to restart the game hash include Main Menu thing we'll need this if you click the menu button to go to the main menu theme, and we'll need a definition I hate a bit of stuff like transition time to deaf initial header, we will not implement the go to mini scene and go to gating function so the stand here and void game up in go to Main Menu. And in here, the go to Main Menu we're going to put auto theme, Main Menu scene Cancun create scene. So we're creating a local instance of the main menu scene and witness in an equal voice. And now we just need to replace The quality of the director get instance, replaced seen and him do transition fade Comicon create and for the duration of a trend dish and on the spot time for the scene as for the scene that we just created.

Again, we're not gonna have any color variables keep keep choosing that particular transition. And now what we can do to make this simple and easy for us, we can copy and paste this and all we need to change is to go to main menu to go to gain. Change the main menu here to gain and that is it, we can now add the Create menu items will mean that we can create the menu items and add the menu to the scene. So we'll do that in the constructor right here. Don't do auto retry. Alright, default menu I turn damage colon colon create.

And we're going to be using this right here. So for the normal image we're going to be the retry button a PNG, which is this image right here. For the selected image, we're going to be using this one here we try button clicked. So we'll do retroarch dot png. And for the callback what we're going to specify for the callback is cc underscore call back while the only takes one parameter. Select is going to game overseen CRO Cloonan go to Main Menu theme.

And for the target we're gonna put this and now the next thing we're gonna do is set the position of this so let's retry item vision and the position it can be point it's gonna be centered in the x axis. So I've been brought up with about two plus our agenda x over the y axis that was slightly different. And we're going to do visible sois dot height. Before we fought on employees three, or weakness do the equivalent of time they timed him his boss sized a hide by five, and what this will do is your position that three quarters of the way up and the reason we're doing that is position the other item A quarter of the way up and in between there. Over the next few tutorials we'll be implementing score. We'll show you what we mean when we actually run it.

The next thing we're going to do actually simply copy and paste this in this chain rockin need to change. So change this to Main Menu, we can change this to the menu, we're using These two images Okay, I just made a mistake here. This is just the go to gaming scene. Hopefully you notice that if you haven't, don't worry and this is just the go to Main Menu scene and in here, change this main menu everything looks a okay now and now what we're going to do is simply create our menus so when we goto menu equals menu colon colon create and for the menu, specify the two items and those two words and then the retry item main menu where the hell did them pocus ago in the selector hate what happened? main menu item and what we're gonna do is known right there it is position on the menu.

So menu, set position for this one point column column zero. The reason we're doing this is because we set the individual item position, so we don't need the Menu set at this show you can add the menu. And now we want this Oh, we should have a when we die, we'll have a screen with a background retry button our main menu button click the promoter that should take us again see it click the menu button, it should take us to the menu so let's just died taking a while. And now that we have just done that right there had to also change this to divide by four as we want it to the quarter before do developer four times one, but there's no point doing extra calculation when it's going to end up being Everything is up. So let's run this again. Oh, it's something that you forget.

So let it go down. Boom, we got retry and menu. And like I mentioned before we got the space here, this is where the score and the high score will be displayed on the next few tutorials. Click retry back to the main menu, I mean, go back to the game thing. And once we die again, we'll click the menu button and we'll we should go back to the main menu. Just another thing that I want to mention which really Flappy Bird was more to do with Coco's to dx and how amazing it is.

I mentioned the end that we set in the position to zero. Imagine if you wanted to do some sort of animation where you just wanted to move the entire menu, maybe to the left or the right or you wanted to do something to the entire menu where there was the same for each of its items, instead of saying instead of doing an actual for retry item, then applying I mean running then doing an actual main menu item then running it and however many other items you have, you could just do one action running on the menu and you'll do it for all the items which I think is really really cool. Well for just mentioned that the next tutorial will cover displaying the player's score. If you have any questions feel free to message us at support at sono systems. Dakota UK. email will be in the description you can comment in this video, which is directly messages via YouTube, or the recording for source code will also be in the description.

And as usual, thanks for watching and have a nice day.

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.