[20230128] Highscore input...harder than you think



I create a game. There are many hurdles to overcome. Especially when you work with an environment that is new to you. What can the engine do and especially how do I implement my ideas...after months of hard thinking + creativity, after you have already finished 70% of the game, you remember...there is still something missing...

The highscore input

At the beginning this is no challenge...how hard can it be...count a few values up and down...move the cursor to the right position based on these values and you have your highscore entry ready.

Unfortunately the world is not made that easy :)

But let's start from the beginning. The first thing I did was to conjure up the selectable letters on the monitor. Huiii that was fast...just quick -> ABCDEFGHIJKLMNOPQRSTUVWXYZ...then some numbers 1234567890 and that was done.

Next...I had to get through these letters. Shouldn't be that hard after all. Just count the number of letters...then a variable that starts at 1 and counts to the end, then quickly count the variable up or down using the arrow keys and each number represents a letter in the list. That was not difficult at all (I'm good).

Ok...but I can't see which letter I just selected. Hmmm...a bit stupid if you don't know which letter you are standing on.

Would certainly be good if you could color code the letter you are standing on, but how? Each letter consists of two triangles (yes is in 3D) 38 letters + numbers....hmmm I would have to color the vertices, but the right ones. So approach the mesh...quickly find out which index fits to the selected letter. Count up the index (there are four vertices) and color it. After a few tries it works...phew, that was not so easy.

Now the selected letter must be stored somewhere. No problem...quickly create a string...when the player presses enter just copy the current letter into it, but what if the player makes a wrong input. He should be able to delete the last letter with [Del]. Ahhhhhhhhhhhh that's stupid....so get to work.

When the player presses backspace or delete, then got the string and removed the last entry. That was faster than I thought. Fortunately I don't have to do that by hand :) there are methods for it. I was lucky, but I still have to adjust the code here and there.

This works quite well now, but the player can enter hundreds of characters. Of course, he should not do that. The limiting is fast. Yes, it is fast, but at the end the letter hangs from the selection list....hmmm looks stupid. So again here and there variable bend around so that also really only max. 12 characters are represented and behind nothing hangs over it.

All well and good, but the navigation is not smooth. I always have to press and release an arrow key, but it would be better if I hold down a key and the cursor moves. So again to the code even more variables....

It works, but is not what I wanted. So add another timer....now I press and only after a second the cursor moves on. That feels better...BUT....ok....yet another timer...The cursor gets faster the longer I stay on the key.

FINALLY....yes that feels good. You don't notice the speed increase, but it feels good when navigating through the letter list.

There is still something missing...The current letter in the list. You should already recognize that it is the cursor. As another blinking programmed.

Finally ready....

No not yet....When you press Enter/Return the selected letter is taken over into the highscore list, but when is the input finished? When does the player want to finish typing?

My solution was to add an extra letter [ED] for edit or end...but the font doesn't have that....

So download software to edit fonts. Take the current font and add the special character....save it again and load it into the engine...but now it's done :) When the player stands on the character [ED] and confirms with the keyboard, the input is completed.

So extensive it can be to create an input in a highscore list :) just wanted to share this....

Get FirstStrike - (Arcade Shoot'em Up)

Leave a comment

Log in with itch.io to leave a comment.