Creating an arcade style name input

A

Allegro

Guest
Hi all. I'm only a week or so worth of work away from shipping a simple arcade style shooter, and I've hit a pretty major hangup. I have a great grasp of the way highscores work in Game Maker, but I want to give it that authentic arcade edge of having 3 character long names that the player inputs upon reaching a high score.

So, for example: the player loses all of their lives and is within the top ten scores saved by Game Maker:
• We offer them up the "Enter your name" dialogue
• They enter their initials/handle/whatever.
• Save it in a variable
• it gets written to the high score table with highscore_add.

Simple in theory, but in practice I feel a little overwhelmed. From where I'm standing, such a system would require either a very long case statement of what frame a sprite of letters/numbers is on, or (less authentically) a way to have the user type their three letter name from the keyboard and set the variable from there.

Is there a built in way to take care of this that I'm overlooking, or will I just have to essentially brute force my way to success with the aforementioned case statement. Any insight from people who may have tackled this problem before would be great.
 
S

Snail Man

Guest
You can use the chr() function to convert from an integer to a character. In this case, just have a 26 sub image Sprite with the alphabet in it, then when the user presses enter when hovering over a letter, use
Code:
player_name += chr(image_index+65)
 
F

Fuzenrad

Guest
Taking advantage of the comment above ;) you can verify when the player enter 3 characters using string_length, something like this:
Code:
if string_length(player_name)<3 {
player_name += chr(image_index+65);
}
Some functions that you can use to achieve this:
highscore_add
font_add_sprite
draw_set_font
 
Last edited by a moderator:
A

Allegro

Guest
You can use the chr() function to convert from an integer to a character. In this case, just have a 26 sub image Sprite with the alphabet in it, then when the user presses enter when hovering over a letter, use
Code:
player_name += chr(image_index+65)
This worked out wonderfully. Thanks for your help.
 
Top