Know that we have that play moving left and right let's also have when you do shoot.
So in TX invader's h.
Let's put another sprites in here.
This is just going to be a regular Sprite or Chaar anyway in order to say Play your
miso sprite
that inj is going to be this vertical bar here.
OK.
So I have a nice play or missile and are going to make it so that the player can shoot ch.
So how are we going to do that.
So we're going to go into our next innovator's to BP and in this handle input first of all we should
have this return and put
it so and we have another case for the fire with the space bar like that and we'll make a function call
players shoot that.
It's clear the function of peer.
It's not going to return anything.
He didn't take place by reference
so
and implement the player shoots method here.
And it's said in the description here that there can only have one missile shot on screen at a time.
So that means that if the plane or missile
is not in play
right and I'm just using X here instead of y it doesn't really matter.
These should be both.
Both really should be non play.
But either or.
So I can do this as well.
Player missile y is not in play.
Ok then we can actually shoot
then put it in the proper position and actually fire it.
So what is the proper position.
Well proper position is we're basically going to rerun this when it shoots it's actually going to appear
right above the a.
Wherever that is.
And so if he was over here you'd shoot here.
Right.
So I went in.
So you have the missile up here right above the A part case a part is his gun or missile launcher or
whatever.
So
here then I will say play or die.
Missile.
Why is that paired up position.
Why mine is one.
So one row above the player.
OK.
And the exposition should be missile that X is the player position X plus the essentially the size Spryte
size.
But with over two.
So we'll see his missile shot right there.
And let's actually get it to draw the players missile as well.
So inside of the draw game you should have a new function for this.
I'm actually going to make a draw player as well.
Players are going to have more than just he's
just his regular sprite.
It's going to have a bunch of stuff so draw player this in.
Player
here.
And I'm also going to pass in his Sprite want to draw
this is going to change some time.
That's what he's got here he is exploding or something that well in take this inning and move this here.
Staed instead hear him say draw player.
In she's going to draw players.
Now passed through the sprint.
So in addition if the player datt missile thoughts and again doesn't really matter which we choose.
If it's not equal it's not in play meaning it isn't.
And I'm going to drop it.
So I'm going to say draw character
the player Giat
write draw character player dot midsole dot X..
So we're using the youtoo curses utils draw character.
Next year soz x is y and the actual player missile.
Here.
Populace
that
so now if I run this in I say that you can actually see my missile when it press the space.
OK that doesn't work.
Now they re redo it.
Right.
It's still in play and I am pressing SPACE and it doesn't do anything.
It's still in play.
So I need to be able to update this player missile.
This so need to actually move across the screen.
OK so let's implement that in.
HALL That's Lloyd D.
Ms.
Player.
Copy this.
And here's some more.
This whole
so if the missile
matter is not equal to not in play.
So it is.
Then we will actually update the missile itself.
OK.
So we'll need an actual speed for the missile.
Another one speed we're slow speed and we'll say the missile speed is one.
Now that's
so square dot missile.
Why.
Right because it has to go vertically.
Minus equals player disciples.
I like that.
And if the missile hits the top of the it's the top of the screen.
So if he where da misfile Y is less than zero.
Great or less than less than zero.
So if it goes off the screen then we will reset the missile to be kind of not in play anymore.
So now that we have this update missile we should call it an uptick in the
SO.
Claire K you know that we don't need the game here for how for the screen bounds because we know that
it's 0 0 is the top so it's less than zero.
That must be off the screen right.
So we run this
in we keep pressings.
I can hear him pressing the space bar.
You may notice that we don't really see anything.
In fact we can kind of see something sometimes but it's so fast I can't make it out.
OK.
And that is because we are going too fast.
K The loop is going too fast.
So this loop is going too fast so move just like before.
What we did was we kind of limited the frame rate.
So here space we want to see time.
So and you will want in our text invader's the frames per second.
And we'll put it to be 20 for now.
OK.
So we'll want our clock t and we call this the last time that clock so
and here we're going to say clock the current time
is the clock ticks and we'll say clock DTG is current time minus the last time.
So the current time we check the clock minus the last time.
So if that is greater than the clocks per second at over
the frames per second
then we will actually have the
and of course we have to also say last time was current time to save all the cycles.
That
OK.
So we went over this before in the last sections.
If you want the full explanation.
So now if you read this in see a smooth missile that
it's going off the screen and that can shoot again.
D-Nice
if I really jam on the spacewalks going I can make another one.
So which is good.
So now we're shooting a missile.
So I want to in the next lecture I want to go over the.