WEBVTT

00:00.650 --> 00:05.730
Know we can choose the name for the player.

00:06.110 --> 00:14.740
But now we want to add in that once they choose their name if you press space that will actually add

00:14.980 --> 00:19.860
that name and the score to the high score table.

00:20.170 --> 00:33.560
So one thing we're going to need is in the case space bar of handle input says and input.

00:33.610 --> 00:46.670
So once the player is dead I want to set the all that position cursors game be in initial state.

00:48.330 --> 00:51.630
For each session.

00:51.720 --> 00:55.290
Or zero

00:59.300 --> 00:59.950
ish

01:03.000 --> 01:12.050
I think that in essentially all we're going to be doing is copying we had in the game.

01:12.140 --> 01:17.900
So what I'm going to do is I'm actually going to make any function this

01:20.470 --> 01:22.470
we'd use.

01:22.510 --> 01:25.800
It's a game

01:29.030 --> 01:34.870
or game maybe game over session cursors

01:38.890 --> 01:39.610
game

01:43.370 --> 01:44.800
and we done here

01:47.720 --> 01:57.770
going to implement this you know we're going to take what we had in the

02:00.870 --> 02:02.140
pattern here.

02:05.100 --> 02:09.910
In We're going to keep this and we're to say reset.

02:09.910 --> 02:11.690
Game over.

02:11.800 --> 02:18.850
Shane we're Jean since what we called it

02:22.980 --> 02:23.650
over

02:27.620 --> 02:28.840
use it's

02:32.720 --> 02:33.400
misspelled.

02:33.440 --> 02:34.210
Game over.

02:34.210 --> 02:35.410
Position cards.

02:37.180 --> 02:37.460
OK.

02:37.520 --> 02:43.410
It's like that so I just cut the

02:46.680 --> 02:51.910
cut all that code and then it's going to pieces here because I call it multiple times actually it's

02:54.510 --> 02:56.700
that.

02:56.880 --> 03:05.130
So you've taken taken from in games or in a game and in the handle

03:10.670 --> 03:11.720
handle

03:14.470 --> 03:17.590
the input here and input.

03:18.100 --> 03:21.900
So doing this is going to reset.

03:21.940 --> 03:23.710
Game over.

03:23.810 --> 03:29.490
An cursors past game.

03:30.940 --> 03:31.720
That.

03:32.920 --> 03:38.920
So the reason why we're doing this is whenever say they played one game when they got a game over and

03:38.920 --> 03:40.650
then they play another game.

03:40.720 --> 03:44.990
It'll still have the same name that they used.

03:45.220 --> 03:46.610
And we don't want that.

03:46.610 --> 03:47.000
OK.

03:47.120 --> 03:49.620
You want to be kind of reset each time.

03:50.050 --> 03:53.500
So that's why we're resetting cursors.

03:53.560 --> 03:54.000
OK.

03:55.420 --> 03:57.880
So now in

04:01.090 --> 04:03.350
also I think I also want to do

04:06.150 --> 04:11.530
the well this is fine.

04:11.610 --> 04:21.660
So now I want if they have a game over I want to add their score to the high score table.

04:22.500 --> 04:36.750
So what I'm going to do is going to say game up player and name of the max number of characters in the

04:36.750 --> 04:39.810
name.

04:39.950 --> 04:42.940
So this is at the very end of the player name.

04:43.060 --> 04:46.130
Ok I am going to set that to beat an all character.

04:46.160 --> 04:48.600
It's a proper C string.

04:49.160 --> 04:54.920
And I'm going to say I'm going to say add

04:59.630 --> 05:05.770
high score to something right.

05:05.800 --> 05:12.000
So I want to actually add the high score here and you don't know what this is going to take yet.

05:12.430 --> 05:17.750
So well actually we do but it's over quickly.

05:17.750 --> 05:19.950
So we have a high score table but we're not using it.

05:19.970 --> 05:22.580
And same with the scores we're not using it.

05:22.580 --> 05:31.950
So in tex invaders what we're going to do is in the main aren't to make a high score.

05:36.300 --> 05:42.060
Call it table this way.

05:42.340 --> 05:47.960
So we have the high score table and we're actually going to pass it into Hindol input.

05:47.990 --> 06:00.920
So it puts here say high score table reference the table

06:06.740 --> 06:12.180
a copy copy that put it down here

06:16.510 --> 06:18.280
and put that

06:21.150 --> 06:22.730
an input.

06:22.770 --> 06:24.780
Here also pasand table

06:27.940 --> 06:42.660
so OK so now our high score we're going to pass it table so it can add to it player's score.

06:45.330 --> 06:57.390
And the men are actually going to make a string here string of games player name that.

06:57.530 --> 07:04.540
And so this this will actually make a C++ string given R C array.

07:04.590 --> 07:07.810
They see straight.

07:08.540 --> 07:10.300
And we don't have this function yet.

07:10.410 --> 07:11.070
Right.

07:11.540 --> 07:13.580
So let's make it

07:16.480 --> 07:17.410
copy this

07:20.660 --> 07:21.650
here.

07:23.210 --> 07:34.980
Say high score and it's going to take a score table.

07:35.120 --> 07:46.960
It's going to take a score and to take a string.

07:47.220 --> 07:47.680
The name

07:50.980 --> 07:53.180
in we're going to do it.

08:01.770 --> 08:04.410
So how we implement it.

08:04.800 --> 08:07.440
Simple.

08:07.670 --> 08:12.360
We're going to say score high score.

08:12.450 --> 08:20.770
This is just the score type that we made in our data Way back when.

08:21.820 --> 08:26.080
Which religious has a score and then he gets it.

08:27.350 --> 08:30.420
So we're just going to set those things.

08:30.440 --> 08:39.330
We get past them past in score and score high score.

08:39.550 --> 08:40.960
Neme is

08:43.880 --> 08:44.670
set it.

08:44.700 --> 08:51.720
And then in our table we'll actually add it.

08:51.730 --> 08:55.830
So Chris back high score

08:58.960 --> 09:02.190
this k.

09:02.430 --> 09:12.670
So one problem though is that we need to have it be ordered right.

09:12.670 --> 09:18.190
So we kind of want the high score table to be like any other Arcade's high score table which has a highest

09:18.190 --> 09:23.890
score at the top and then all the highest scores after that.

09:23.890 --> 09:24.180
Right.

09:24.180 --> 09:27.380
So any lower or higher score is after.

09:27.460 --> 09:28.080
Right.

09:28.450 --> 09:31.130
So it's kind of in descending order.

09:31.510 --> 09:35.720
So we'll need to sort the table after we at it.

09:35.740 --> 09:38.380
So let's do that.

09:38.410 --> 09:40.420
So we're going to include

09:44.040 --> 09:48.900
to include algorithm or sort

09:52.000 --> 10:03.400
and just like we did before also going to need a comparison function say pool and or call it score compare

10:06.880 --> 10:08.630
or compare the match.

10:08.650 --> 10:16.620
It's going to take two scores score one score to

10:20.460 --> 10:21.050
match.

10:21.060 --> 10:23.510
It's going to compare them.

10:26.470 --> 10:31.960
Down here to implement score compare

10:38.790 --> 10:44.170
So really that's going to do is say return score one day.

10:44.360 --> 10:51.030
The score is greater than scores to watch score.

10:51.310 --> 10:58.200
So this will make it an the sending order.

10:59.720 --> 11:03.770
So the high score will be at the top and the lowest score at the bottom.

11:05.240 --> 11:07.320
So now we need to sort it out.

11:07.340 --> 11:09.140
So say sort

11:11.600 --> 11:12.710
able to watch

11:15.910 --> 11:27.890
scores dot gain and table scores dot and in score compare

11:31.040 --> 11:31.630
OK.

11:32.540 --> 11:43.270
So now we have our table that we can actually add things to you.

11:43.460 --> 11:44.910
It's pretty nice.

11:44.910 --> 11:49.270
It actually sort it OK.

11:49.390 --> 11:57.000
So now I want to actually draw diceware table.

11:57.320 --> 12:03.030
And in fact we have to have the states and all that stuff.

12:03.110 --> 12:03.710
So

12:06.420 --> 12:08.860
it's have a high score state.

12:08.890 --> 12:10.260
Second one we did.

12:10.570 --> 12:15.320
So once they actually press enter and once you see the high scores.

12:15.320 --> 12:15.900
OK.

12:16.480 --> 12:21.340
So we're going to make a new function

12:24.260 --> 12:33.570
call it draw I score table in we're going to give it game

12:37.350 --> 12:42.800
and we need the game for the for the window size

12:45.510 --> 12:50.170
and we're also going to have the score.

12:50.300 --> 12:51.000
Wow.

12:52.560 --> 12:53.150
Course

12:56.510 --> 13:01.270
so should be fairly simple.

13:02.120 --> 13:10.250
We just want a string to for the title title and scores

13:12.780 --> 13:13.910
that.

13:14.880 --> 13:20.790
And we will get the exposition

13:25.290 --> 13:28.200
or the cult the title exposition

13:31.320 --> 13:45.090
and be in the middle of the screen.

13:45.330 --> 13:51.440
Two at each title.

13:51.740 --> 13:58.460
It's the two it's.

13:58.680 --> 14:00.510
And we'll put it this

14:04.080 --> 14:05.940
at 5.

14:05.970 --> 14:07.880
Sure.

14:07.970 --> 14:12.570
And we're also going to have some padding between the title and the actual score.

14:12.590 --> 14:20.850
So let's say having that.

14:21.040 --> 14:27.630
So I'm going to use an answer which underline the title

14:31.810 --> 14:33.340
drawstring

14:39.160 --> 14:42.390
Idle's exposition.

14:42.520 --> 14:45.800
It's action hydel

14:48.590 --> 14:51.210
it I'm going to turn off that attribute.

14:57.970 --> 14:58.340
OK.

14:58.520 --> 15:04.420
And then I'm going to draw all the high scores you see for it.

15:04.610 --> 15:14.170
Zero is less than tabletops scores.

15:15.400 --> 15:21.440
Size.

15:21.490 --> 15:28.240
And also I kind of just want it only have a certain amount like the 10 highest scores so I'm going to

15:28.240 --> 15:32.860
limit this also by saying it's less than 10

15:35.900 --> 15:44.050
and it's in a few conditions because what if I only have one high score so I'll just show that.

15:44.090 --> 15:47.650
Right but the maximum will be 10.

15:48.830 --> 15:59.730
So now I'm going to say score is going to get the current score table.

15:59.750 --> 16:01.650
I like that.

16:02.330 --> 16:14.860
And we're just going to use cursus directly here because we make it formatted string y position class.

16:14.980 --> 16:18.800
That's one adding.

16:19.070 --> 16:26.320
So the padding we also have so also have like two units of padding between the scores.

16:27.460 --> 16:28.720
So those are

16:31.160 --> 16:35.670
suppose or title pause.

16:37.990 --> 16:40.120
It's minus

16:43.630 --> 16:45.240
X or

16:48.830 --> 16:51.040
characters.

16:51.240 --> 16:52.440
I mean

16:56.310 --> 17:08.850
it'll be so saying I have have some space between the between the scores and the kind of you know the

17:08.860 --> 17:14.090
three characters to the left of the titles.

17:14.120 --> 17:22.970
Exposition is what is saying so far and you have the formatted string 8 percent S and then have the

17:24.220 --> 17:27.670
the slash t is tab.

17:27.840 --> 17:33.100
So tab in twice and then output a integers.

17:33.120 --> 17:34.130
Percent.

17:36.160 --> 17:37.570
Score dot.

17:37.770 --> 17:41.580
Name.

17:41.900 --> 17:46.380
E-string mean score.

17:52.670 --> 18:02.610
So this might have been slightly confusing what I'm doing here but it's really just you know position

18:02.610 --> 18:03.770
it nicely.

18:03.820 --> 18:07.670
Again you can come up with your own positioning if you like.

18:08.010 --> 18:12.480
And then this is a format string right.

18:12.510 --> 18:20.940
I think I went over this for this format string and saying put the string here and then have two tabs

18:20.940 --> 18:23.390
between it and then put it into here.

18:23.600 --> 18:24.130
OK.

18:24.240 --> 18:25.500
So that's what that's saying.

18:25.530 --> 18:35.100
And then I give it the string so the percent as matches to this and the percent I matches to this.

18:35.190 --> 18:41.730
So the order in which I put the format's matters so first string is a string.

18:41.910 --> 18:45.570
And then the integer just the injury.

18:45.790 --> 18:46.300
OK.

18:48.290 --> 18:54.430
So now that we have the high score table we want to drive each.

18:54.630 --> 18:56.190
So in

18:59.300 --> 19:02.620
here and handle input it's

19:07.950 --> 19:08.610
here

19:12.770 --> 19:17.460
so in our game over

19:20.520 --> 19:34.920
in our game over a section of the the section of the handle input we want to suddenly set after we've

19:34.920 --> 19:49.930
added the high score table you want to set the new game state current state to be G-S high scores.

19:50.090 --> 19:52.040
And now in

19:55.320 --> 20:00.360
now in the high score when we press space we want to go back to the intro.

20:00.480 --> 20:02.640
So also need.

20:02.640 --> 20:03.330
Else if

20:06.440 --> 20:16.010
watch current state is Hutu G-S high score scores.

20:17.210 --> 20:17.650
Right.

20:17.940 --> 20:24.150
You want to go back to the initial state.

20:24.820 --> 20:33.890
So instead of having the reset game here I want to have the recent games in high school.

20:33.940 --> 20:39.420
So take these two and it was going to paste it right here.

20:43.690 --> 20:44.630
OK.

20:44.770 --> 20:49.370
So really all it's going to do.

20:49.790 --> 20:53.650
It's going to go back to the intro and reset the game.

20:53.930 --> 21:07.280
OK so now we need to actually draw the high score table right because we're not doing that yet.

21:07.300 --> 21:16.840
So we here game we're going to also pass the high score table

21:23.930 --> 21:28.120
and change it in any way.

21:28.260 --> 21:29.340
Copy this

21:32.720 --> 21:36.020
in game here.

21:36.040 --> 21:39.730
Pass this in.

21:39.790 --> 21:45.010
So.

21:45.090 --> 21:47.550
So in dreich game now

21:53.370 --> 22:04.130
in drug game we're going to say if games current state is high score it

22:07.110 --> 22:09.340
and if it is a draw.

22:10.430 --> 22:20.640
I score table game scores or I think your called Table

22:26.700 --> 22:36.400
J in do you declare the draw scores appear.

22:36.750 --> 22:37.720
That is all

22:45.120 --> 22:48.280
set.

22:55.000 --> 23:01.090
Score table.

23:03.650 --> 23:08.960
So I think hopefully that should work.

23:09.020 --> 23:10.730
No need to pass table.

23:10.750 --> 23:11.420
Well.

23:13.480 --> 23:14.110
Here

23:17.850 --> 23:19.170
we run this

23:22.820 --> 23:26.870
air.

23:27.110 --> 23:31.480
The misname the reset.

23:31.520 --> 23:32.090
Game over.

23:32.090 --> 23:34.060
Position cursor is down.

23:34.100 --> 23:35.750
We define it.

23:38.330 --> 23:42.950
See this is showing cursors ID.

23:43.140 --> 23:46.740
So let's run this.

23:46.770 --> 23:55.760
So let's just kind of name it something and then press enter so bad goes.

23:55.810 --> 23:56.860
So we get bad.

23:56.890 --> 24:02.590
And it actually goes to the high score table which is nice and the score 0 obviously x we haven't actually

24:02.590 --> 24:03.740
done anything.

24:03.790 --> 24:16.970
So if we press space for time back to space invaders press space over time we're playing so now that

24:16.970 --> 24:26.700
we're done that we don't actually save the the scores yet.

24:26.730 --> 24:27.120
Right.

24:28.480 --> 24:30.060
So in the next lecture.

24:30.070 --> 24:38.140
Let's actually do some file input and save the scores that we've now are able to draw.

24:38.600 --> 24:38.980
OK.

24:39.000 --> 24:39.880
So see you then.
