Know that we have most of the game working I want to start focusing on the game States.
So the intro and game and game over.
So if we are in the update game function and if we actually finish killing all the aliens so the number
of humans we have left is zero then we should kind of restart the game.
So when I say game level plus
and are going to make sure that the games level can't exceed
10 in this case.
So the level
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
really one to 11.
So.
So then we'll put the game in the wait state.
Or a certain amount of time
and we'll make a new function call the reset game you know take game the player aliens and the shield.
It's because you have to reset all of those things.
And we should be making some constants these
say we each time and also what levels 10
a week time
is OK.
So we're going to declare Game of
Character nothing.
And take the game by reference whereby reference
and warm
shields
shields.
It's meant this shouldn't be too hard.
So
basically going to have more have reset player.
Remember
they are going to need some kind of resetting of the shields because what if some of them got hit during
game and we need to kind of re re-establish the shields so of that and going to re-initialize
the alien.
It's well
niche.
You know this is called
K.
So really we just need to omit this one.
Copy this.
Clear of
don't think each change game at all.
You
you it's
so here.
It's implemented.
But we actually have a bunch of the stuff we need for research fields.
So let's actually take some of the things that we had in the initialize initialize of shields that was
so here and actually just take them take it and you will sort of follow the same pattern.
So essentially want is to take this stuff.
So actually just going to copy this for now.
And we won't need it since we are going to use to take away all this stuff.
We're not going to need it we're going gonna set all the positions and all that stuff elsewhere.
And we're also going to copy it elsewhere.
So initially Shields is really just making the new call or clicking clicking the memory that we need.
So here in reset shields you don't need to do this all
and really that's itch.
We're just going to kind of do it again.
Essentially So inside of the shields now on
down here to say reset to shew it's
like so and so kind of make it all and then it'll reset it.
So now that we have that working
I want to go back to a
game maze
so now that we have this we just did let's actually since since we're beginner level let's actually
set the level in the initialize game.
So we don't we don't need this here we're actually going to move this is going to move it right below
also the start of the game the level is 1 K so we're going to move that from there.
And now we're going to do is in the update aliance
is
here.
When we redid this like line minus minus Well if you if the line is at 0
then we will.
Well the game's over right there at the bottom.
So are you going to say current state is.
Yes.
Game over in poker turn false.
And since this is being passed by constant references needs to be passed by reference.
Now the above here is say
that each.
So now in Drog game
it's not here.
We also need some other drawings right because we need to be able to draw
the game over screen and the intro screen.
So I say yes over
hurts it's
catch on to make new functions called draw over screen
as game
repressing the game for the screen.
Right.
And also for if game current state is in intro
then we'll draw our interest in
going to pass it game as well.
So now that we have that science we back up here.
And let's declare the draw over screen
and change the game at all
we need to draw.
And these will be pretty simple all we're going to say is game over in the gamer screen and kind of
welcome to text readers and your screen.
So what's copy's
here.
You will draw the game or at the intro screen screen.
So start with the rescreen and real say is Konst char and uber string.
Well actually we could.
Sure using string regular string.
We will be Salt's include string this
so year or so since string
over string this in say more and also say
space string
say press space bar to continue.
And basically when you press the spacebar go back to.
Interesting.
OK so now we're going to
format it properly.
So to say
why pause will be the dot each new size
height over 2.
For now so be kind of in the middle of the screen and we'll say
we'll say the counts in each game over exposition will be the number one the size
over to minus the length of the game over screen or over a string sorry
link to
that also for the press.
Base position.
So now that we have these two need to drives.
So you don't have any kind of drawstring function.
We could
so in our utilities.
Let's make a new function drawstring take it by the exposition in the White position and we'll pass
in a string.
So I need to include spring here.
Passed by conc string reference string.
Copy that.
In the low draw Spryte Cedras drawstring
and will say in the
W Y pause X pause right.
So that's why then X and string dot string.
So now we'll just say draw string
and say
the game over exposition in the wives action in the game over string that way and then we'll say draw
string.
Press this base exposition and it'll just be right below the game over on.
So that will draw the game over screen and let's do it for the intro screen.
So say
string start is great.
And this is just say welcome to Tex
meter's
and now the string called in press piece string.
And just like four we need to have like the y position image make it.
Now in middle
just for you just want to get the middle of the screen.
Next pause
exactly the same as above and see drawstring
start ch starting position y position Sturtze string
Smillie draw string.
Why is this one is Speace string that.
Now we have our interest screens and you can go as crazy as you want with it but it is going to do something
simple.
Now now that we have these two functions it will draw.
We still need to make it actually.
If you actually do hit spacebar you actually go with the proper thing.
So now in
handle input space
will need some extra
extra things in here to go to the right spot.
Essentially so are Assi else if
game.
Current state is Jesus came over.
If it's game over then we'll say game.
Each current state intro so can't go back to the intro once the game's over and we will
essentially
reset.
Said game
to have.
So we don't really have too much.
So we need the handle input on need a few other things right.
So need the aliens.
Need shields.
Or it's
modify and put
you in put here.
And when to has everything.
She's well and she U-Mass
she.
Or Shields is
in past the player in New Orleans she you.
It's number.
It's
so that should fix fix all that.
So now in
are we also need a yes.
The intro.
So if we're in the interstate we should just press enter as well or not enter that space and then go
to the play games state.
Also in the actually before we do that in the IT game starts in issue as well.
It's run this
so you're in it.
And we actually start in the intro which is very and press space bar in which you can see that we're
playing the game
so that's great.
I want to die three times and see
see what happens.
Subduct wants
heard dodging into things twice.
As good
in Rio.
So I died three times.
So there you go.
Game over.
Good.
So that's working.
So if I press baseball again I'd go back to Texan maters and if I go back into it it resets correctly.
I thought it would and we're playing again.
So that's that's good.
OK.
So seems to be working.
You think thing we need to check in we're going to make our
aliens go really fast again.
So the thing is check is if we go really fast so it should also be a game over.
So if they drop down to zero in the line then shoot over.
Game over.
Good.
So everything's working pretty well.
I think it's good.
So that was kind of the sort of brief overview of the game States.
You know sometimes it's hard to follow.
But really all we did was show you the
so in the update game.
So when we.
So the first thing we did was if we have no means left which I still haven't actually shown is I maybe
we should do that actually before you wrap up.
We go to the next level and then we kind of reset the game.
So everything is working OK.
And then in the trial game we also draw.
Now the game over screen and intro screen.
So it will only draw the player and the alien stuff in play.
Game or the player is dead or waiting.
OK.
And it's changed too much of this
it of course it actually drew the game over screens like this.
Simple.
A new function for draw string.
We reset the shields because they need to be reset every time the game is over and we want to play again.
We also did a reset game.
So what's actually
actually tried to win and see if we can go to the next level.
So I actually try here.
So that my trying is still not good enough.
Well
one more try.
So close
it resets it.
They are actually lower for well.
So everything is working the way we expect.
Just great.
OK.
And there's one last thing and that is we're not showing the players
players like lives and stuff like that.
Right.
So let's let's also show that it's
one drop later.
In drub player will say
say the print w 0 0 score
so Urd's using curses directly for this wise.
Weird.
Score.
Where is k.
And you may be wondering I haven't actually imported or included curses and cirqus.
I actually have.
Because it's part of the curse is Eutelsat h.
So that's why I can actually use it here.
Work so I snatch up my score so I don't actually set the score so see it's a negative.
Something terrible will fix that
in initialize player.
I notice that you never said or score so it.
You're right again
and notice that actually lives went down scores going up.
It kicked them out.
So everything's working which it.
So in the next lecture I want to go over drawing the Alien or the alien UFO that we haven't tried yet.
So see you in the next lecture.