WEBVTT

00:00.510 --> 00:07.970
Know that we have that play moving left and right let's also have when you do shoot.

00:08.450 --> 00:11.560
So in TX invader's h.

00:11.570 --> 00:13.480
Let's put another sprites in here.

00:13.520 --> 00:22.300
This is just going to be a regular Sprite or Chaar anyway in order to say Play your

00:24.880 --> 00:27.620
miso sprite

00:30.210 --> 00:34.410
that inj is going to be this vertical bar here.

00:34.530 --> 00:35.870
OK.

00:35.880 --> 00:49.120
So I have a nice play or missile and are going to make it so that the player can shoot ch.

00:49.140 --> 00:53.340
So how are we going to do that.

00:54.260 --> 01:05.360
So we're going to go into our next innovator's to BP and in this handle input first of all we should

01:05.360 --> 01:07.220
have this return and put

01:12.280 --> 01:26.610
it so and we have another case for the fire with the space bar like that and we'll make a function call

01:26.610 --> 01:35.010
players shoot that.

01:35.220 --> 01:40.250
It's clear the function of peer.

01:40.750 --> 01:42.990
It's not going to return anything.

01:44.800 --> 01:48.290
He didn't take place by reference

01:51.140 --> 01:51.620
so

01:56.460 --> 02:00.030
and implement the player shoots method here.

02:04.190 --> 02:17.480
And it's said in the description here that there can only have one missile shot on screen at a time.

02:17.900 --> 02:23.450
So that means that if the plane or missile

02:28.150 --> 02:29.760
is not in play

02:35.910 --> 02:43.730
right and I'm just using X here instead of y it doesn't really matter.

02:43.740 --> 02:45.250
These should be both.

02:45.330 --> 02:48.340
Both really should be non play.

02:49.040 --> 02:50.690
But either or.

02:50.910 --> 02:52.540
So I can do this as well.

02:52.540 --> 02:57.600
Player missile y is not in play.

02:59.830 --> 03:01.870
Ok then we can actually shoot

03:07.090 --> 03:10.930
then put it in the proper position and actually fire it.

03:10.930 --> 03:15.280
So what is the proper position.

03:17.260 --> 03:27.600
Well proper position is we're basically going to rerun this when it shoots it's actually going to appear

03:27.600 --> 03:29.120
right above the a.

03:29.340 --> 03:31.070
Wherever that is.

03:31.090 --> 03:35.430
And so if he was over here you'd shoot here.

03:35.440 --> 03:35.940
Right.

03:35.970 --> 03:37.440
So I went in.

03:37.450 --> 03:46.650
So you have the missile up here right above the A part case a part is his gun or missile launcher or

03:46.650 --> 03:47.610
whatever.

03:48.420 --> 03:49.020
So

03:52.110 --> 03:54.300
here then I will say play or die.

03:54.330 --> 03:57.310
Missile.

03:57.490 --> 04:03.100
Why is that paired up position.

04:04.120 --> 04:05.420
Why mine is one.

04:05.420 --> 04:12.620
So one row above the player.

04:12.810 --> 04:13.340
OK.

04:15.420 --> 04:37.210
And the exposition should be missile that X is the player position X plus the essentially the size Spryte

04:37.230 --> 04:38.470
size.

04:42.200 --> 04:48.780
But with over two.

04:49.410 --> 04:54.300
So we'll see his missile shot right there.

04:55.110 --> 05:02.440
And let's actually get it to draw the players missile as well.

05:02.760 --> 05:14.010
So inside of the draw game you should have a new function for this.

05:14.430 --> 05:18.210
I'm actually going to make a draw player as well.

05:21.270 --> 05:25.810
Players are going to have more than just he's

05:28.480 --> 05:30.270
just his regular sprite.

05:30.310 --> 05:38.750
It's going to have a bunch of stuff so draw player this in.

05:40.970 --> 05:41.950
Player

05:44.540 --> 05:45.500
here.

05:46.560 --> 05:50.500
And I'm also going to pass in his Sprite want to draw

05:54.570 --> 05:57.860
this is going to change some time.

06:01.100 --> 06:15.060
That's what he's got here he is exploding or something that well in take this inning and move this here.

06:15.320 --> 06:21.920
Staed instead hear him say draw player.

06:27.280 --> 06:31.520
In she's going to draw players.

06:37.490 --> 06:42.230
Now passed through the sprint.

06:43.810 --> 07:00.350
So in addition if the player datt missile thoughts and again doesn't really matter which we choose.

07:00.710 --> 07:05.310
If it's not equal it's not in play meaning it isn't.

07:08.700 --> 07:10.130
And I'm going to drop it.

07:10.160 --> 07:15.220
So I'm going to say draw character

07:21.270 --> 07:24.480
the player Giat

07:48.990 --> 07:58.040
write draw character player dot midsole dot X..

07:58.150 --> 08:03.190
So we're using the youtoo curses utils draw character.

08:05.740 --> 08:16.520
Next year soz x is y and the actual player missile.

08:19.320 --> 08:20.200
Here.

08:22.200 --> 08:22.980
Populace

08:25.540 --> 08:25.990
that

08:29.160 --> 08:43.670
so now if I run this in I say that you can actually see my missile when it press the space.

08:43.860 --> 08:46.790
OK that doesn't work.

08:46.890 --> 08:51.110
Now they re redo it.

08:51.120 --> 08:51.740
Right.

08:51.850 --> 08:57.110
It's still in play and I am pressing SPACE and it doesn't do anything.

08:57.120 --> 08:58.660
It's still in play.

08:59.250 --> 09:04.600
So I need to be able to update this player missile.

09:07.540 --> 09:13.100
This so need to actually move across the screen.

09:13.650 --> 09:20.610
OK so let's implement that in.

09:20.700 --> 09:27.300
HALL That's Lloyd D.

09:28.850 --> 09:30.330
Ms.

09:32.210 --> 09:33.110
Player.

09:36.720 --> 09:41.240
Copy this.

09:41.420 --> 09:43.700
And here's some more.

09:43.890 --> 09:44.570
This whole

09:47.240 --> 09:49.310
so if the missile

09:54.880 --> 09:57.920
matter is not equal to not in play.

09:58.100 --> 09:59.120
So it is.

10:02.920 --> 10:08.140
Then we will actually update the missile itself.

10:08.140 --> 10:08.920
OK.

10:09.380 --> 10:16.880
So we'll need an actual speed for the missile.

10:17.090 --> 10:30.300
Another one speed we're slow speed and we'll say the missile speed is one.

10:30.310 --> 10:33.310
Now that's

10:35.960 --> 10:44.260
so square dot missile.

10:44.470 --> 10:44.980
Why.

10:44.980 --> 10:48.150
Right because it has to go vertically.

10:48.160 --> 10:53.450
Minus equals player disciples.

10:55.430 --> 10:57.200
I like that.

10:57.680 --> 11:07.120
And if the missile hits the top of the it's the top of the screen.

11:07.120 --> 11:16.130
So if he where da misfile Y is less than zero.

11:18.920 --> 11:22.660
Great or less than less than zero.

11:23.000 --> 11:34.100
So if it goes off the screen then we will reset the missile to be kind of not in play anymore.

11:35.280 --> 11:42.870
So now that we have this update missile we should call it an uptick in the

11:45.910 --> 11:47.180
SO.

11:47.560 --> 11:56.600
Claire K you know that we don't need the game here for how for the screen bounds because we know that

11:56.840 --> 12:00.830
it's 0 0 is the top so it's less than zero.

12:00.840 --> 12:03.710
That must be off the screen right.

12:03.810 --> 12:06.620
So we run this

12:09.620 --> 12:12.860
in we keep pressings.

12:12.880 --> 12:17.550
I can hear him pressing the space bar.

12:17.610 --> 12:20.730
You may notice that we don't really see anything.

12:20.730 --> 12:26.890
In fact we can kind of see something sometimes but it's so fast I can't make it out.

12:27.090 --> 12:27.880
OK.

12:28.260 --> 12:33.190
And that is because we are going too fast.

12:34.220 --> 12:36.560
K The loop is going too fast.

12:37.620 --> 12:42.020
So this loop is going too fast so move just like before.

12:42.020 --> 12:46.160
What we did was we kind of limited the frame rate.

12:46.230 --> 12:53.660
So here space we want to see time.

12:53.760 --> 13:02.000
So and you will want in our text invader's the frames per second.

13:03.370 --> 13:06.250
And we'll put it to be 20 for now.

13:08.660 --> 13:09.060
OK.

13:09.280 --> 13:23.040
So we'll want our clock t and we call this the last time that clock so

13:25.760 --> 13:36.250
and here we're going to say clock the current time

13:38.840 --> 13:54.150
is the clock ticks and we'll say clock DTG is current time minus the last time.

13:55.120 --> 13:59.630
So the current time we check the clock minus the last time.

13:59.710 --> 14:10.620
So if that is greater than the clocks per second at over

14:14.380 --> 14:16.510
the frames per second

14:20.740 --> 14:23.980
then we will actually have the

14:28.030 --> 14:38.120
and of course we have to also say last time was current time to save all the cycles.

14:40.190 --> 14:40.760
That

14:43.960 --> 14:44.280
OK.

14:44.330 --> 14:48.090
So we went over this before in the last sections.

14:48.380 --> 14:51.590
If you want the full explanation.

14:52.490 --> 15:01.120
So now if you read this in see a smooth missile that

15:05.310 --> 15:08.280
it's going off the screen and that can shoot again.

15:11.430 --> 15:12.420
D-Nice

15:15.100 --> 15:21.710
if I really jam on the spacewalks going I can make another one.

15:21.930 --> 15:24.550
So which is good.

15:24.610 --> 15:29.720
So now we're shooting a missile.

15:30.110 --> 15:34.780
So I want to in the next lecture I want to go over the.
