WEBVTT

00:01.100 --> 00:09.490
That we have the high score table and Draut we need to be able to read it in and save it at.

00:09.560 --> 00:23.490
So let's start doing those functions so just up here I'm going to say for read we save high scorers

00:25.480 --> 00:27.350
it's going to take the

00:30.270 --> 00:31.400
score table

00:34.040 --> 00:35.550
I referenced Scott Streff

00:38.590 --> 00:44.500
and are also going to write the mood ice.

00:46.480 --> 00:50.750
High scores and this can't be hype.

00:50.900 --> 00:53.340
Concert tickets change it.

00:56.190 --> 00:58.330
So this way

01:00.880 --> 01:07.320
so we have the two functions you're declaring and I'm just going to put them down here.

01:09.290 --> 01:11.840
And we're going to implement them yet.

01:11.840 --> 01:15.620
We're just going to use them in the code.

01:15.620 --> 01:28.700
So when I save or add a high score I want to save the high scores they just say save high scores here.

01:31.010 --> 01:37.370
Pass in.

01:38.620 --> 01:41.890
And we up here

01:46.100 --> 01:53.470
here going to say load scores.

01:53.910 --> 01:57.320
Table.

01:58.090 --> 02:00.280
So now we're using it.

02:00.310 --> 02:03.810
And there's one thing I want to do in a row.

02:03.940 --> 02:07.210
Save that for later.

02:07.210 --> 02:11.280
So here now let's actually implement them.

02:11.380 --> 02:16.510
We're going to need while we first need to actually include

02:22.960 --> 02:23.560
stream

02:27.850 --> 02:31.320
that because you have file for file.

02:31.370 --> 02:32.330
Oh right.

02:36.300 --> 02:37.340
OK.

02:37.550 --> 02:49.330
That is now down here and we need to have an off stream file.

02:49.340 --> 03:00.500
Call it and we to open a file and we have to choose whether we want it to be binary file or a text file.

03:00.740 --> 03:07.150
And I think we're going to do a text file for this one and I'm going to put

03:10.480 --> 03:19.900
in put a COTS char star file name here.

03:20.110 --> 03:25.570
And to call a tie score scores table.

03:26.590 --> 03:32.530
Text Vaders script table DXi

03:35.050 --> 03:47.770
So this file name and use or receive a file open file name

03:50.470 --> 04:01.340
and then I'm going to check to see if the file file is open just like for

04:05.720 --> 04:16.870
and if it is then we will say four equals zero or less than table scores.

04:17.060 --> 04:21.470
Will not scores science

04:23.970 --> 04:30.690
and we do the same trick I did for a rate above right here and I'm only a draw are only going to save

04:30.900 --> 04:31.880
10 of them.

04:32.050 --> 04:43.530
I was 10 plus in now that we have to be in two places we probably should have constant for it.

04:44.610 --> 04:55.170
So Max scores 10.

04:55.790 --> 04:56.440
Year

04:59.300 --> 04:59.840
air

05:02.640 --> 05:04.380
and we'll say out file

05:07.450 --> 05:12.200
are going to save the table scores.

05:12.300 --> 05:24.140
I got name in the space between the table scores score

05:26.900 --> 05:34.850
and all like so they and rate here will save file not close

05:37.360 --> 05:37.980
up file.

05:37.980 --> 05:38.350
Sorry

05:40.930 --> 05:41.760
close.

05:41.940 --> 05:43.090
OK.

05:43.390 --> 05:46.580
So this will actually save the high scores.

05:47.050 --> 05:52.280
And now let's load the high scores back.

05:52.440 --> 05:55.380
So I have stream

05:59.910 --> 06:00.870
and file

06:04.790 --> 06:12.910
and say File Open file name for

06:15.560 --> 06:24.770
and want to need string name in the score value.

06:26.240 --> 06:28.500
In roles we need a score

06:31.080 --> 06:32.370
score very well.

06:32.470 --> 06:39.030
While we say if infile Dodge is open

06:41.930 --> 06:47.720
and while not well or not at the end of the file

06:51.360 --> 07:00.210
OK well say infile and get rid of the whitespace.

07:00.450 --> 07:12.320
And if we're at the end of the file then say there is like kind of a blank line break.

07:12.850 --> 07:13.650
Otherwise

07:16.440 --> 07:24.340
say infile name you get a score you

07:27.730 --> 07:44.160
bat and send it to actual score.

07:44.590 --> 07:51.340
They will just add it to the scores.

07:58.120 --> 08:02.860
And notice that we won't have to sort it because it's already in sorted order.

08:04.550 --> 08:07.560
So we just close the file

08:11.210 --> 08:14.320
so they.

08:14.410 --> 08:16.090
So now

08:18.760 --> 08:27.350
must think we need to do and that is in our handle input

08:30.880 --> 08:40.910
if the if were in the intro screen right.

08:41.800 --> 08:45.250
We should be able to see the high scores of that screen

08:47.770 --> 08:49.750
or from that screen.

08:50.430 --> 08:52.240
So I'm going to say.

08:52.840 --> 08:55.920
And you have to press S to see the high score.

08:55.930 --> 09:03.340
So if game dot current state is in the intro

09:05.900 --> 09:09.230
then go to

09:11.800 --> 09:13.110
high score screen

09:21.290 --> 09:26.660
so the last thing we need to do is

09:29.920 --> 09:33.690
say this to be true.

09:37.970 --> 09:40.590
And so you break orce

09:45.570 --> 09:47.090
break here.

09:47.430 --> 09:55.010
Courtot So let's run this.

09:55.230 --> 10:03.060
And there's no message here or no message saying you can go to the ice cream.

10:03.090 --> 10:06.070
So it's actually do that as well.

10:08.230 --> 10:10.920
And it's good to draw

10:14.200 --> 10:19.920
draw a screen here and put a new string

10:22.570 --> 10:35.980
press as string Rice -- to the scores.

10:39.960 --> 10:41.110
And need

10:46.030 --> 10:47.320
exposition

11:05.490 --> 11:06.030
so

11:09.370 --> 11:10.810
and string

11:19.940 --> 11:27.900
the string ear.

11:28.030 --> 11:32.940
So it's actually moved this up by five or something

11:36.090 --> 11:37.600
just format it.

11:37.920 --> 11:38.800
It's too high

11:43.820 --> 11:44.730
too.

11:48.050 --> 11:49.640
That's it.

11:50.880 --> 11:54.420
So if I press S I should see the high scores.

11:54.440 --> 11:59.030
There's obviously no high scores yet press space and go back.

11:59.100 --> 12:07.200
Essed scores based back in press space in walks we try again.

12:07.250 --> 12:09.600
It's really gotten hit song Id.

12:15.290 --> 12:19.330
I'm actually trying to get hits of course.

12:19.390 --> 12:24.130
So it's really bad bad get saved.

12:25.270 --> 12:36.340
And the high score table let's exit and let's run this one more time in hopefully we should see the

12:36.340 --> 12:38.070
high score that we just did.

12:39.480 --> 12:41.100
And there it is.

12:41.210 --> 12:44.580
And it's right there right.

12:45.190 --> 12:48.600
So that's really rich.

12:49.210 --> 12:51.240
I think we're done.

12:51.330 --> 12:53.180
Tax Invaders game.

12:53.200 --> 12:56.570
So I really hope you enjoyed it.

12:57.040 --> 13:02.950
Hopefully you programmed along with me and I hope you enjoyed this game and working through it.

13:03.460 --> 13:15.340
I know I went really fast through a lot of the explanations and that's really because you need to when

13:15.340 --> 13:19.210
you're learning something new and trying to get good at it.

13:19.570 --> 13:23.800
It really does take a lot of time to learn.

13:23.830 --> 13:30.730
And often I found these when I was learning this my teacher actually said that you're not going to learn

13:30.730 --> 13:33.540
much from our lectures.

13:33.670 --> 13:36.570
You're going to learn from actually doing it yourself.

13:36.940 --> 13:45.940
And so I kind of skipped a little bit on the actual explanations of a lot of these functions because

13:45.970 --> 13:54.280
I really want you to kind of pause the video understand the code kind of step through it step by step

13:54.280 --> 13:59.680
and see see really what's going on and why it needs to be that way.

13:59.780 --> 14:00.130
OK.

14:00.160 --> 14:00.970
So a lot of.

14:00.970 --> 14:09.210
So I have to put a lot of responsibility on you to actually kind of grasp what's happening.

14:10.590 --> 14:15.970
So I hope you enjoyed this project with a lot of fun for me.

14:16.110 --> 14:25.810
This is quite a quite a big project seed's almost twelve hundred lines of code to actually do but keep

14:25.810 --> 14:34.900
practicing and come up with some some of your own projects and see see how well you can actually see

14:34.900 --> 14:38.100
how well you can actually program those projects and come up with.

14:38.160 --> 14:41.850
I made I made these all look a lot easier than they are.

14:41.860 --> 14:47.440
This would probably take you quite quite a bit longer than it took to pass through here but that's OK.

14:47.440 --> 14:57.090
It's all really part of learning of programming and you just keep doing it and know and you'll get better.

14:57.160 --> 15:02.680
So I'm going to wrap up the course in the next lecture.
