WEBVTT

00:00.520 --> 00:08.070
Know that we have most of the game working I want to start focusing on the game States.

00:08.170 --> 00:13.650
So the intro and game and game over.

00:13.750 --> 00:25.810
So if we are in the update game function and if we actually finish killing all the aliens so the number

00:25.810 --> 00:32.930
of humans we have left is zero then we should kind of restart the game.

00:32.930 --> 00:37.760
So when I say game level plus

00:40.640 --> 00:46.040
and are going to make sure that the games level can't exceed

00:49.210 --> 00:51.210
10 in this case.

00:51.490 --> 00:54.310
So the level

00:59.380 --> 01:08.430
and to do that we're just going to say modulus 10 but we're going to add one because it's one game of

01:08.560 --> 01:10.820
really one to 11.

01:10.960 --> 01:12.920
So.

01:13.810 --> 01:20.170
So then we'll put the game in the wait state.

01:22.510 --> 01:25.390
Or a certain amount of time

01:29.670 --> 01:40.740
and we'll make a new function call the reset game you know take game the player aliens and the shield.

01:40.760 --> 01:43.970
It's because you have to reset all of those things.

01:50.630 --> 01:54.270
And we should be making some constants these

01:56.740 --> 02:07.880
say we each time and also what levels 10

02:18.950 --> 02:20.480
a week time

02:27.290 --> 02:30.760
is OK.

02:30.800 --> 02:36.200
So we're going to declare Game of

02:42.520 --> 02:44.380
Character nothing.

02:49.730 --> 02:54.140
And take the game by reference whereby reference

02:59.590 --> 03:01.890
and warm

03:06.920 --> 03:08.380
shields

03:11.410 --> 03:15.580
shields.

03:15.770 --> 03:24.080
It's meant this shouldn't be too hard.

03:24.280 --> 03:25.090
So

03:31.360 --> 03:36.330
basically going to have more have reset player.

03:36.440 --> 03:36.940
Remember

03:42.880 --> 03:50.560
they are going to need some kind of resetting of the shields because what if some of them got hit during

03:50.740 --> 04:04.700
game and we need to kind of re re-establish the shields so of that and going to re-initialize

04:06.710 --> 04:08.090
the alien.

04:08.190 --> 04:09.620
It's well

04:14.530 --> 04:15.330
niche.

04:15.390 --> 04:16.780
You know this is called

04:19.890 --> 04:20.290
K.

04:20.300 --> 04:30.520
So really we just need to omit this one.

04:30.920 --> 04:32.020
Copy this.

04:37.920 --> 04:39.230
Clear of

04:46.980 --> 04:49.960
don't think each change game at all.

04:56.240 --> 04:56.900
You

05:02.350 --> 05:03.130
you it's

05:06.030 --> 05:08.230
so here.

05:10.690 --> 05:13.610
It's implemented.

05:14.410 --> 05:19.990
But we actually have a bunch of the stuff we need for research fields.

05:20.170 --> 05:32.440
So let's actually take some of the things that we had in the initialize initialize of shields that was

05:35.630 --> 05:50.660
so here and actually just take them take it and you will sort of follow the same pattern.

05:50.730 --> 05:58.030
So essentially want is to take this stuff.

05:58.030 --> 06:00.340
So actually just going to copy this for now.

06:03.080 --> 06:11.850
And we won't need it since we are going to use to take away all this stuff.

06:11.930 --> 06:17.960
We're not going to need it we're going gonna set all the positions and all that stuff elsewhere.

06:18.320 --> 06:22.830
And we're also going to copy it elsewhere.

06:24.080 --> 06:35.640
So initially Shields is really just making the new call or clicking clicking the memory that we need.

06:36.110 --> 06:43.740
So here in reset shields you don't need to do this all

06:49.230 --> 06:53.750
and really that's itch.

06:54.000 --> 06:56.770
We're just going to kind of do it again.

06:56.850 --> 07:04.120
Essentially So inside of the shields now on

07:11.030 --> 07:14.620
down here to say reset to shew it's

07:24.270 --> 07:31.450
like so and so kind of make it all and then it'll reset it.

07:31.500 --> 07:35.550
So now that we have that working

07:38.400 --> 07:43.480
I want to go back to a

07:51.710 --> 07:53.300
game maze

07:59.160 --> 08:09.260
so now that we have this we just did let's actually since since we're beginner level let's actually

08:09.560 --> 08:13.490
set the level in the initialize game.

08:16.020 --> 08:24.290
So we don't we don't need this here we're actually going to move this is going to move it right below

08:24.340 --> 08:33.920
also the start of the game the level is 1 K so we're going to move that from there.

08:34.650 --> 08:43.020
And now we're going to do is in the update aliance

08:50.120 --> 08:50.600
is

09:00.020 --> 09:01.890
here.

09:02.710 --> 09:15.150
When we redid this like line minus minus Well if you if the line is at 0

09:22.330 --> 09:25.050
then we will.

09:25.360 --> 09:28.360
Well the game's over right there at the bottom.

09:28.360 --> 09:32.140
So are you going to say current state is.

09:32.170 --> 09:32.560
Yes.

09:32.560 --> 09:37.320
Game over in poker turn false.

09:37.320 --> 09:43.370
And since this is being passed by constant references needs to be passed by reference.

09:43.450 --> 09:47.580
Now the above here is say

09:50.520 --> 09:52.520
that each.

09:52.660 --> 09:55.000
So now in Drog game

09:58.930 --> 10:00.520
it's not here.

10:03.340 --> 10:11.470
We also need some other drawings right because we need to be able to draw

10:14.750 --> 10:20.190
the game over screen and the intro screen.

10:20.210 --> 10:23.960
So I say yes over

10:28.140 --> 10:29.260
hurts it's

10:31.900 --> 10:39.610
catch on to make new functions called draw over screen

10:42.080 --> 10:43.350
as game

10:46.230 --> 10:48.810
repressing the game for the screen.

10:48.900 --> 10:50.470
Right.

10:51.270 --> 10:58.800
And also for if game current state is in intro

11:01.860 --> 11:05.280
then we'll draw our interest in

11:09.280 --> 11:13.220
going to pass it game as well.

11:13.570 --> 11:18.820
So now that we have that science we back up here.

11:23.520 --> 11:31.570
And let's declare the draw over screen

11:34.450 --> 11:35.880
and change the game at all

11:38.630 --> 11:42.700
we need to draw.

11:44.380 --> 11:52.060
And these will be pretty simple all we're going to say is game over in the gamer screen and kind of

11:52.150 --> 11:56.990
welcome to text readers and your screen.

11:57.180 --> 11:59.070
So what's copy's

12:04.060 --> 12:05.020
here.

12:09.930 --> 12:16.540
You will draw the game or at the intro screen screen.

12:16.640 --> 12:28.950
So start with the rescreen and real say is Konst char and uber string.

12:29.370 --> 12:30.820
Well actually we could.

12:31.050 --> 12:36.100
Sure using string regular string.

12:36.100 --> 12:40.330
We will be Salt's include string this

12:44.970 --> 12:49.780
so year or so since string

12:52.650 --> 13:01.890
over string this in say more and also say

13:04.490 --> 13:06.100
space string

13:10.210 --> 13:17.730
say press space bar to continue.

13:17.960 --> 13:22.000
And basically when you press the spacebar go back to.

13:22.070 --> 13:23.170
Interesting.

13:23.440 --> 13:28.550
OK so now we're going to

13:31.360 --> 13:32.590
format it properly.

13:32.610 --> 13:36.330
So to say

13:44.550 --> 13:52.790
why pause will be the dot each new size

13:55.950 --> 13:57.690
height over 2.

13:57.710 --> 14:06.790
For now so be kind of in the middle of the screen and we'll say

14:15.970 --> 14:29.450
we'll say the counts in each game over exposition will be the number one the size

14:32.740 --> 14:40.680
over to minus the length of the game over screen or over a string sorry

14:43.870 --> 14:45.370
link to

14:53.440 --> 14:59.660
that also for the press.

14:59.960 --> 15:25.370
Base position.

15:25.450 --> 15:30.120
So now that we have these two need to drives.

15:30.310 --> 15:37.350
So you don't have any kind of drawstring function.

15:37.650 --> 15:38.970
We could

15:41.260 --> 15:44.760
so in our utilities.

15:45.010 --> 15:58.140
Let's make a new function drawstring take it by the exposition in the White position and we'll pass

15:58.140 --> 15:59.490
in a string.

15:59.580 --> 16:03.590
So I need to include spring here.

16:07.440 --> 16:16.220
Passed by conc string reference string.

16:20.700 --> 16:21.570
Copy that.

16:23.370 --> 16:27.740
In the low draw Spryte Cedras drawstring

16:35.120 --> 16:38.460
and will say in the

16:40.820 --> 16:45.000
W Y pause X pause right.

16:45.090 --> 16:58.020
So that's why then X and string dot string.

16:58.120 --> 17:05.330
So now we'll just say draw string

17:07.680 --> 17:09.210
and say

17:11.640 --> 17:27.320
the game over exposition in the wives action in the game over string that way and then we'll say draw

17:27.320 --> 17:30.620
string.

17:31.000 --> 17:50.570
Press this base exposition and it'll just be right below the game over on.

17:50.580 --> 17:58.470
So that will draw the game over screen and let's do it for the intro screen.

18:01.130 --> 18:02.600
So say

18:06.860 --> 18:11.900
string start is great.

18:13.420 --> 18:17.600
And this is just say welcome to Tex

18:20.510 --> 18:21.620
meter's

18:25.970 --> 18:42.960
and now the string called in press piece string.

18:45.040 --> 18:54.250
And just like four we need to have like the y position image make it.

18:54.430 --> 18:56.200
Now in middle

19:07.670 --> 19:12.180
just for you just want to get the middle of the screen.

19:41.490 --> 19:42.500
Next pause

20:06.480 --> 20:11.100
exactly the same as above and see drawstring

20:14.760 --> 20:23.740
start ch starting position y position Sturtze string

20:27.480 --> 20:35.970
Smillie draw string.

20:37.040 --> 20:46.470
Why is this one is Speace string that.

20:46.870 --> 20:53.460
Now we have our interest screens and you can go as crazy as you want with it but it is going to do something

20:53.460 --> 20:54.080
simple.

20:54.090 --> 21:01.480
Now now that we have these two functions it will draw.

21:01.560 --> 21:07.930
We still need to make it actually.

21:08.080 --> 21:12.200
If you actually do hit spacebar you actually go with the proper thing.

21:12.200 --> 21:15.880
So now in

21:20.350 --> 21:22.810
handle input space

21:26.030 --> 21:28.140
will need some extra

21:30.990 --> 21:35.060
extra things in here to go to the right spot.

21:35.070 --> 21:40.710
Essentially so are Assi else if

21:43.180 --> 21:44.610
game.

21:45.160 --> 21:54.740
Current state is Jesus came over.

21:55.130 --> 21:59.870
If it's game over then we'll say game.

22:00.070 --> 22:10.890
Each current state intro so can't go back to the intro once the game's over and we will

22:13.210 --> 22:14.080
essentially

22:16.260 --> 22:21.040
reset.

22:21.270 --> 22:22.400
Said game

22:37.900 --> 22:39.580
to have.

22:39.790 --> 22:41.940
So we don't really have too much.

22:41.990 --> 22:47.610
So we need the handle input on need a few other things right.

22:47.690 --> 22:49.720
So need the aliens.

22:56.750 --> 22:58.790
Need shields.

23:02.270 --> 23:03.490
Or it's

23:07.390 --> 23:09.390
modify and put

23:17.690 --> 23:20.590
you in put here.

23:24.110 --> 23:29.200
And when to has everything.

23:29.300 --> 23:32.540
She's well and she U-Mass

23:35.190 --> 23:36.340
she.

23:39.010 --> 23:41.020
Or Shields is

23:52.650 --> 23:59.320
in past the player in New Orleans she you.

23:59.330 --> 24:01.530
It's number.

24:01.770 --> 24:02.220
It's

24:09.640 --> 24:15.670
so that should fix fix all that.

24:17.490 --> 24:19.320
So now in

24:22.570 --> 24:24.080
are we also need a yes.

24:24.100 --> 24:29.020
The intro.

24:29.250 --> 24:35.790
So if we're in the interstate we should just press enter as well or not enter that space and then go

24:35.810 --> 24:40.980
to the play games state.

24:41.120 --> 24:53.790
Also in the actually before we do that in the IT game starts in issue as well.

24:54.030 --> 24:55.120
It's run this

25:00.550 --> 25:02.360
so you're in it.

25:02.380 --> 25:14.370
And we actually start in the intro which is very and press space bar in which you can see that we're

25:14.370 --> 25:15.630
playing the game

25:22.430 --> 25:25.940
so that's great.

25:26.000 --> 25:28.520
I want to die three times and see

25:32.610 --> 25:34.030
see what happens.

25:34.050 --> 25:35.340
Subduct wants

25:43.160 --> 25:46.180
heard dodging into things twice.

25:46.210 --> 25:46.780
As good

26:09.050 --> 26:10.480
in Rio.

26:10.780 --> 26:12.460
So I died three times.

26:12.760 --> 26:13.350
So there you go.

26:13.360 --> 26:14.460
Game over.

26:14.470 --> 26:15.360
Good.

26:15.940 --> 26:17.050
So that's working.

26:17.050 --> 26:27.110
So if I press baseball again I'd go back to Texan maters and if I go back into it it resets correctly.

26:27.260 --> 26:30.770
I thought it would and we're playing again.

26:30.890 --> 26:32.660
So that's that's good.

26:35.240 --> 26:35.930
OK.

26:36.000 --> 26:39.080
So seems to be working.

26:39.280 --> 26:44.030
You think thing we need to check in we're going to make our

26:47.390 --> 26:49.600
aliens go really fast again.

26:49.610 --> 27:01.650
So the thing is check is if we go really fast so it should also be a game over.

27:04.550 --> 27:13.550
So if they drop down to zero in the line then shoot over.

27:13.710 --> 27:14.460
Game over.

27:14.500 --> 27:15.410
Good.

27:17.360 --> 27:19.640
So everything's working pretty well.

27:19.640 --> 27:22.830
I think it's good.

27:22.840 --> 27:31.150
So that was kind of the sort of brief overview of the game States.

27:31.420 --> 27:35.660
You know sometimes it's hard to follow.

27:35.920 --> 27:41.570
But really all we did was show you the

27:53.830 --> 27:57.010
so in the update game.

27:57.080 --> 27:58.440
So when we.

27:58.550 --> 28:04.530
So the first thing we did was if we have no means left which I still haven't actually shown is I maybe

28:04.550 --> 28:08.120
we should do that actually before you wrap up.

28:08.450 --> 28:11.590
We go to the next level and then we kind of reset the game.

28:11.590 --> 28:14.380
So everything is working OK.

28:15.980 --> 28:21.200
And then in the trial game we also draw.

28:21.200 --> 28:25.390
Now the game over screen and intro screen.

28:25.880 --> 28:30.720
So it will only draw the player and the alien stuff in play.

28:30.740 --> 28:33.230
Game or the player is dead or waiting.

28:33.260 --> 28:33.600
OK.

28:35.980 --> 28:40.240
And it's changed too much of this

28:43.180 --> 28:48.850
it of course it actually drew the game over screens like this.

28:48.960 --> 28:49.610
Simple.

28:49.680 --> 28:52.370
A new function for draw string.

28:52.990 --> 29:03.450
We reset the shields because they need to be reset every time the game is over and we want to play again.

29:03.850 --> 29:06.840
We also did a reset game.

29:07.060 --> 29:08.650
So what's actually

29:11.380 --> 29:19.740
actually tried to win and see if we can go to the next level.

29:19.800 --> 29:21.890
So I actually try here.

29:33.520 --> 29:36.950
So that my trying is still not good enough.

29:37.490 --> 29:37.800
Well

29:48.390 --> 29:49.310
one more try.

30:12.590 --> 30:13.650
So close

30:23.790 --> 30:25.920
it resets it.

30:25.950 --> 30:30.570
They are actually lower for well.

30:30.640 --> 30:35.070
So everything is working the way we expect.

30:35.090 --> 30:36.210
Just great.

30:36.440 --> 30:37.630
OK.

30:37.630 --> 30:45.290
And there's one last thing and that is we're not showing the players

30:47.870 --> 30:49.920
players like lives and stuff like that.

30:49.980 --> 30:50.450
Right.

30:54.580 --> 31:00.430
So let's let's also show that it's

31:03.100 --> 31:05.670
one drop later.

31:16.220 --> 31:18.780
In drub player will say

31:23.680 --> 31:32.320
say the print w 0 0 score

31:34.830 --> 31:44.350
so Urd's using curses directly for this wise.

31:46.970 --> 31:48.210
Weird.

31:49.730 --> 31:50.950
Score.

31:55.060 --> 32:00.260
Where is k.

32:00.750 --> 32:08.690
And you may be wondering I haven't actually imported or included curses and cirqus.

32:08.730 --> 32:10.470
I actually have.

32:10.560 --> 32:15.240
Because it's part of the curse is Eutelsat h.

32:15.360 --> 32:18.160
So that's why I can actually use it here.

32:18.240 --> 32:27.940
Work so I snatch up my score so I don't actually set the score so see it's a negative.

32:27.940 --> 32:30.940
Something terrible will fix that

32:35.190 --> 32:37.210
in initialize player.

32:37.540 --> 32:44.500
I notice that you never said or score so it.

32:44.630 --> 32:45.730
You're right again

32:48.390 --> 32:56.550
and notice that actually lives went down scores going up.

32:56.790 --> 32:58.620
It kicked them out.

32:59.840 --> 33:04.510
So everything's working which it.

33:04.630 --> 33:14.630
So in the next lecture I want to go over drawing the Alien or the alien UFO that we haven't tried yet.

33:14.680 --> 33:16.600
So see you in the next lecture.
