Know we can choose the name for the player.
But now we want to add in that once they choose their name if you press space that will actually add
that name and the score to the high score table.
So one thing we're going to need is in the case space bar of handle input says and input.
So once the player is dead I want to set the all that position cursors game be in initial state.
For each session.
Or zero
ish
I think that in essentially all we're going to be doing is copying we had in the game.
So what I'm going to do is I'm actually going to make any function this
we'd use.
It's a game
or game maybe game over session cursors
game
and we done here
going to implement this you know we're going to take what we had in the
pattern here.
In We're going to keep this and we're to say reset.
Game over.
Shane we're Jean since what we called it
over
use it's
misspelled.
Game over.
Position cards.
OK.
It's like that so I just cut the
cut all that code and then it's going to pieces here because I call it multiple times actually it's
that.
So you've taken taken from in games or in a game and in the handle
handle
the input here and input.
So doing this is going to reset.
Game over.
An cursors past game.
That.
So the reason why we're doing this is whenever say they played one game when they got a game over and
then they play another game.
It'll still have the same name that they used.
And we don't want that.
OK.
You want to be kind of reset each time.
So that's why we're resetting cursors.
OK.
So now in
also I think I also want to do
the well this is fine.
So now I want if they have a game over I want to add their score to the high score table.
So what I'm going to do is going to say game up player and name of the max number of characters in the
name.
So this is at the very end of the player name.
Ok I am going to set that to beat an all character.
It's a proper C string.
And I'm going to say I'm going to say add
high score to something right.
So I want to actually add the high score here and you don't know what this is going to take yet.
So well actually we do but it's over quickly.
So we have a high score table but we're not using it.
And same with the scores we're not using it.
So in tex invaders what we're going to do is in the main aren't to make a high score.
Call it table this way.
So we have the high score table and we're actually going to pass it into Hindol input.
So it puts here say high score table reference the table
a copy copy that put it down here
and put that
an input.
Here also pasand table
so OK so now our high score we're going to pass it table so it can add to it player's score.
And the men are actually going to make a string here string of games player name that.
And so this this will actually make a C++ string given R C array.
They see straight.
And we don't have this function yet.
Right.
So let's make it
copy this
here.
Say high score and it's going to take a score table.
It's going to take a score and to take a string.
The name
in we're going to do it.
So how we implement it.
Simple.
We're going to say score high score.
This is just the score type that we made in our data Way back when.
Which religious has a score and then he gets it.
So we're just going to set those things.
We get past them past in score and score high score.
Neme is
set it.
And then in our table we'll actually add it.
So Chris back high score
this k.
So one problem though is that we need to have it be ordered right.
So we kind of want the high score table to be like any other Arcade's high score table which has a highest
score at the top and then all the highest scores after that.
Right.
So any lower or higher score is after.
Right.
So it's kind of in descending order.
So we'll need to sort the table after we at it.
So let's do that.
So we're going to include
to include algorithm or sort
and just like we did before also going to need a comparison function say pool and or call it score compare
or compare the match.
It's going to take two scores score one score to
match.
It's going to compare them.
Down here to implement score compare
So really that's going to do is say return score one day.
The score is greater than scores to watch score.
So this will make it an the sending order.
So the high score will be at the top and the lowest score at the bottom.
So now we need to sort it out.
So say sort
able to watch
scores dot gain and table scores dot and in score compare
OK.
So now we have our table that we can actually add things to you.
It's pretty nice.
It actually sort it OK.
So now I want to actually draw diceware table.
And in fact we have to have the states and all that stuff.
So
it's have a high score state.
Second one we did.
So once they actually press enter and once you see the high scores.
OK.
So we're going to make a new function
call it draw I score table in we're going to give it game
and we need the game for the for the window size
and we're also going to have the score.
Wow.
Course
so should be fairly simple.
We just want a string to for the title title and scores
that.
And we will get the exposition
or the cult the title exposition
and be in the middle of the screen.
Two at each title.
It's the two it's.
And we'll put it this
at 5.
Sure.
And we're also going to have some padding between the title and the actual score.
So let's say having that.
So I'm going to use an answer which underline the title
drawstring
Idle's exposition.
It's action hydel
it I'm going to turn off that attribute.
OK.
And then I'm going to draw all the high scores you see for it.
Zero is less than tabletops scores.
Size.
And also I kind of just want it only have a certain amount like the 10 highest scores so I'm going to
limit this also by saying it's less than 10
and it's in a few conditions because what if I only have one high score so I'll just show that.
Right but the maximum will be 10.
So now I'm going to say score is going to get the current score table.
I like that.
And we're just going to use cursus directly here because we make it formatted string y position class.
That's one adding.
So the padding we also have so also have like two units of padding between the scores.
So those are
suppose or title pause.
It's minus
X or
characters.
I mean
it'll be so saying I have have some space between the between the scores and the kind of you know the
three characters to the left of the titles.
Exposition is what is saying so far and you have the formatted string 8 percent S and then have the
the slash t is tab.
So tab in twice and then output a integers.
Percent.
Score dot.
Name.
E-string mean score.
So this might have been slightly confusing what I'm doing here but it's really just you know position
it nicely.
Again you can come up with your own positioning if you like.
And then this is a format string right.
I think I went over this for this format string and saying put the string here and then have two tabs
between it and then put it into here.
OK.
So that's what that's saying.
And then I give it the string so the percent as matches to this and the percent I matches to this.
So the order in which I put the format's matters so first string is a string.
And then the integer just the injury.
OK.
So now that we have the high score table we want to drive each.
So in
here and handle input it's
here
so in our game over
in our game over a section of the the section of the handle input we want to suddenly set after we've
added the high score table you want to set the new game state current state to be G-S high scores.
And now in
now in the high score when we press space we want to go back to the intro.
So also need.
Else if
watch current state is Hutu G-S high score scores.
Right.
You want to go back to the initial state.
So instead of having the reset game here I want to have the recent games in high school.
So take these two and it was going to paste it right here.
OK.
So really all it's going to do.
It's going to go back to the intro and reset the game.
OK so now we need to actually draw the high score table right because we're not doing that yet.
So we here game we're going to also pass the high score table
and change it in any way.
Copy this
in game here.
Pass this in.
So.
So in dreich game now
in drug game we're going to say if games current state is high score it
and if it is a draw.
I score table game scores or I think your called Table
J in do you declare the draw scores appear.
That is all
set.
Score table.
So I think hopefully that should work.
No need to pass table.
Well.
Here
we run this
air.
The misname the reset.
Game over.
Position cursor is down.
We define it.
See this is showing cursors ID.
So let's run this.
So let's just kind of name it something and then press enter so bad goes.
So we get bad.
And it actually goes to the high score table which is nice and the score 0 obviously x we haven't actually
done anything.
So if we press space for time back to space invaders press space over time we're playing so now that
we're done that we don't actually save the the scores yet.
Right.
So in the next lecture.
Let's actually do some file input and save the scores that we've now are able to draw.
OK.
So see you then.