Know we have most of the game working.
I want to start working on a way for the player to input their score after the game is over.
So in a game I'm going to say G-S game over.
And so that will start now in the game over screens.
We don't have to play the game each time we go to that screen directly.
And actually for us to do some things in here that we should probably do is set the wait timer and the
game timer to zero at the start.
And in fact in reset game
it is reset game.
I am also going to say
game.
It's
Game wait timer to be
zero in game time to be Ciro's well.
So this isn't strictly necessary but just gonna put it here anyway.
So to actually make the game over screen and look at where we're drawing it right here we're actually
going to need some new data in our game structure.
So in our game structure we're going to need in the position of the cursor.
So I want to draw you what it looks like first and then kind of explain why we're making the choices
that are making.
OK so here I'm going to see up here.
I'm going to make a new string call the name prompt string
and say Please enter your name.
And again this is in the draw scheme of rescreen.
So we're going to basically get the exposition to put in the middle again.
Neme
exposition is game size.
Two minus the name.
String top like to that.
And essentially we're going to
draw the string in
in each
position say give it some space between Tweenies.
That's OK.
And in fact we might actually make this higher up so he'd be over three for the wife has sort of a 2
and we're going to go through a loop
and remember the can only have three letters for your name.
So for in the game over screen the player enters his her three letter name.
They only have three letters in.
Sure.
We have
the constant for that don't do so make one player or max number of characters
in name three it's constant I'm going to use are there.
That's a plus.
OK.
And we're going to say if I could too.
Well actually I'm just going to.
Yeah.
Just for this first one it's first time through the loop say at Tron a underline use attributes here
for the text to draw in and say draw or her and it's going to take the
game.
Two sides
to wit two minus.
Max number of characters.
Two plus I entering into the y position and then I just want to get some space in five say and I'm going
to give it some character
and then I'm going to say if I is 0 turn off underline
OK.
So I run this
so it says game over press spacebar to continue and says Please enter your name.
You can see that we'll be able to choose the letters of our name essentially.
So if I press down it should this first one that's highlighted underlined in this case.
If I press down it'll go to B if I press to the right it'll go to the next to the next character and
press to the left to go back center.
Right.
So you've seen this kind of thing before.
Maybe an arcade games where you can kind of choose your name.
OK.
So that's kind of the idea of what we're going to be doing.
So that's this is that.
So a lot of the game overstuff drawing at least is done but there's going to be a couple more things
to do.
And in our game structure
we're going to need some more data.
So when you say game over.
Horizontal position of the cursor case this will tell us where horizontal cursor is.
OK.
And we're going to need a buffer for character array for the player name in which you use the next number
of characters plus one for the null character.
And we're also going to need each
the vertical
position for each Kurs or for that cursor for each hers.
Sorry.
So we're going to kind of store where we were in the vertical case for each each letter.
So that answer I really need those three those three pieces of data Okay.
So in our leaders dot BP
basically we're going to do is we're only going to highlight the one that we're at.
So it's a if it's equal to the game cursor or game over each position so or sorry then we'll underline
it.
So that's that's where we are horizontally in the name and.
And so now we're done with this drawing.
So draw game over screen is done but now we need to be able to move the cursor and all that stuff.
So
in that game we have
here to set the cursor all the cursor stuff here.
So game over cursor position in action.
Actually there's one other thing we need to do for draw you over in a second.
So we're going to initialize the horizontal cursor to be the this is the first letter
right very left the most letter and are going to go through all of them
in.
Are all the letters in the name and are going to say Play player name are going to start at all at a.
So if you ever again if you've ever played a arcade game they always start at a few name or maybe four
days of them for characters so and for this I'm going to use them all zero.
OK.
So basically be at be a.
So that's it for that.
And back in the game over screen missed something
here this should be the game.
This
K so the player's name at that at that spot.
So that's it for game over now.
So if you're in this see happens so nothing nothing's really changed yet.
Right.
So now we need to be able to move the cursor left and right and up and down for each letter.
OK.
So let's do that.
So we'll do that in hand in put
and.
And let's start with the left and right.
So else if gamed current state which to over
something it's really right.
Right.
He does something.
So here set
game dot horizontal cursor equal to named each until the cursor plus one percent the number HRmax number
characters in the name
like that.
OK.
And for the laugh it's one to say game over simple cursor to name Dutch
over a horizontal position cursor minus one.
And then check to see
if the game Dots.
Horizontal cursor is less than zero.
Then we'll go to the rightmost one.
This is an X mirror.
Characters
in name.
Minus one right.
So it goes from here
doing the modulus because it has to be from 0 to 2 from 0 to Max.
Number of characters in name minus one.
So this is three.
So if I say where I was plus 1 and then modulus this sure I mean I'm still in the bounds of the 0 2
range.
So that's what this is doing.
And this is saying if I go to the right one
or sorry this should be this is the opposite.
This actually is left.
Sorry totally.
That's backwards.
So you like this
down here
button using
like that.
So if I go to the left which is minus 1 right then it is negative a negative value.
I should go to the fair right most of the cursors.
OK.
So if I run this yields kind of see you mean.
So now I should be able to move the cursor left and right so I'm only pressing right.
In fact press it again it goes left and I go to the left it goes to the end.
So this is just choosing which letter I'm changing.
That's all that meant.
So now I want to have new cases in here.
Or a k up.
And we're also going to have case for doubt.
So for the upper case to say if the game current state is game over screen
then
you are.
So if it's the game over screen then in say game dot over vertical position of the horizontal position
or equal to game over vertical position
again.
On proposition minus one and then if
game dot over Go position in
position is less than zero.
We will say game dot.
Game over vertical position and gained each over result.
Equal to when the 6 minus 1.
So if you are not following what I just did centrally what we're going to be doing is in this again
if I press up right.
And if so basically 0 through 25 is going to be the alphabet right so 0 is going to be a and 25 is going
it.
So the is so 0 represents a 25 for Zed.
So if I my current value in the vertical position cursor right which is
an integer but it's not really sure it's really a character.
If if I press up in I met a real saying then go to Zed.
So that's that's really what it means.
And we're going to say game dot where name Dutch
it's all said a plus.
Erkel position is on session.
So the horizontal position tells us where in the vertical position cursor that we are.
So here I'm saying let a or the players name be a plus.
Wherever we are in the vertical position cursor in the vertical vertical position cursors values can
only be from 0 to 25.
And we're using 26 here because that's how many letters of the alphabet there are.
So.
So basically what we're doing is here the game vertical position cursor is set wherever we are in a
horizontal cursor and then we just minus one from that vertical position cursor and if we were less
than zero.
So this will just change to be safer and B This will not be right.
Or C notes B.
So if we're at it's a here be at it.
So wrap around and then update the name and we'll have the same similar thing to the down
gamed.
It hurts th
over then basically just do the exact same thing that
position Mr.
Well one
sent the number in will make group the concert this so add add one to the to the vertical position cursor
at the horizontal position cursor right.
So if it was a now it's B and then make sure that say you are at Zed and we added one.
This will go back to zero.
Roback to zero.
That's what this is saying.
And then we just need to update our name just like
this.
So let's make constant
marks.
It's.
Six.
Six should have that
work.
So if I press down to be for press down it's C D.
If I go over one and I change this right see how it's like rapping.
Still seems kinda messed up actually Zed.
I pressed down.
It's wrong.
It's bad
so it's actually not working exactly correct.
So it's this
it
was it gay.
So this.
So I what I did was I put these in brackets should be plus one like this and then and then the percent
or the modulus the alphabet characters.
So that was a typo.
So now we have all of that working.
So in the next lecture I want to actually start saving the player name when you press enter into like
an actual score table.
So I'll see you then.