Custom Name Input Screen

You must understand the Game Editor concepts, before post here.

Custom Name Input Screen

Postby GuybrushThreepwood » Sat Apr 11, 2015 7:49 pm

Hi, I'm creating my start up screen, and I want to have a name input for three different slots. There would be three different slots, with three different names, which can be named at different times. For the naming, I want to be able to use the arrows keys to move a flashing square cursor from one letter to the next instantaneously. There is also one of these cursors indicating where the next letter of the name will go. And when I press the select key (x), it inputs that letter into the name. And when the name reaches a certain number of characters, I would like the cursor of the naming to move back to the first character. I know this is a lot things to ask for... But any help would be appreciated :mrgreen:
Attachments
TextHelp.jpg
This is what the text select looks like. The blank spaces would be spaces.
Pirate: You fight like a diary farmer!
Guybrush: How appropriate, you fight like a cow!
User avatar
GuybrushThreepwood
 
Posts: 94
Joined: Sun Jul 06, 2008 12:23 pm
Location: Melee Island
Score: 2 Give a positive score

Re: Custom Name Input Screen

Postby koala » Sun Apr 12, 2015 12:40 am

Hey, Guybrush! :D

I made one part of what you've asked. Here you can only input name, but can't change it.
Dimensions of cursor are 20x20, so it would look better if you make a font where characters have those same dimensions.
In this example there are 6 character in two rows:
A B C
1 2 3
When you move cursor you change global integer variable i.
[Left] i--;
[Right] i++;
[Up] i -= 3;
[Down] i += 3;
There's an array of available characters. When you pres [X], cursor pointed character will be added to players name, because its index in array[CHAR] is determined with i.
Global code:
Code: Select all
#define CHAR 6 // number of available characters
#define NAME 7 // length of player's name

int i, j; // i - selected character, j - name length
char array[CHAR]; // available characters
char player_name[NAME]; // name


view -> Create Actor -> Script Editor:
Code: Select all
i = 0;
j = 0;

sprintf(player_name, "");

array[0] = 'A';
array[1] = 'B';
array[2] = 'C';
array[3] = '1';
array[4] = '2';
array[5] = '3';


view -> Draw Actor -> Script Editor:
Code: Select all
if      (cursor.x - cursor.xprevious ==  40)    i++;
else if (cursor.x - cursor.xprevious == -40)    i--;
else if (cursor.y - cursor.yprevious ==  40) i += 3;
else if (cursor.y - cursor.yprevious == -40) i -= 3;


cursor -> Key Down (x) -> Script Editor:
Code: Select all
char letter[2]; // input letter will be converted to string
// letter[0] - character, letter[1] - null pointer, end of string
 
if (i >= 0 && i < CHAR && j < NAME - 1) {
    sprintf(letter, "%c", array[i]); // convert input letter
    strcat(player_name, letter); // add letter to name
    j++;
    sprintf(display.text, player_name); // display name
 
    display_cursor.x += 20;
}
char character;
sprintf(myText.text, "Alfa %c", character);

This function adds character, which is read with format %c, to string "Alfa ", and writes it to myText.text.

So, function
sprintf(letter, "%c", array[i]);
adds character array[i] to an empty string and writes it in letter.
String letter is later concatenated with player_name.

ged and data files:
http://www.mediafire.com/download/p08zl7b8xsc7r2x/name_input.zip
executable:
http://www.mediafire.com/download/p8kg28uabgjy85w/name_input_exe.zip
Attachments
name_input_exe.zip
(777.75 KiB) Downloaded 176 times
name_input.zip
(195.86 KiB) Downloaded 178 times
Phascolarctos cinereus
YouTube: Marko Radivojevic
Google+: Marko Radivojevic
User avatar
koala
 
Posts: 301
Joined: Thu Mar 26, 2015 7:03 pm
Location: Serbia
Score: 30 Give a positive score

Re: Custom Name Input Screen

Postby GuybrushThreepwood » Mon Apr 13, 2015 4:46 pm

Ok, cool. I think I understand that. The only thing I'm not sure about is how to change the input font. I can change all the text actor fonts, but the input characters are still in the original font. How do I change this?
Pirate: You fight like a diary farmer!
Guybrush: How appropriate, you fight like a cow!
User avatar
GuybrushThreepwood
 
Posts: 94
Joined: Sun Jul 06, 2008 12:23 pm
Location: Melee Island
Score: 2 Give a positive score

Re: Custom Name Input Screen

Postby koala » Mon Apr 13, 2015 5:38 pm

GuybrushThreepwood wrote:Ok, cool. I think I understand that. The only thing I'm not sure about is how to change the input font. I can change all the text actor fonts, but the input characters are still in the original font. How do I change this?
Right click on any actor, select Actor Control, and then from list of actors, in Name:, choose display, and then you can change font. The problem is that display is invisible, it is just a space.
Phascolarctos cinereus
YouTube: Marko Radivojevic
Google+: Marko Radivojevic
User avatar
koala
 
Posts: 301
Joined: Thu Mar 26, 2015 7:03 pm
Location: Serbia
Score: 30 Give a positive score

Re: Custom Name Input Screen

Postby GuybrushThreepwood » Mon Apr 13, 2015 5:56 pm

Oh yes, of course... I missed that :oops: Thanks!
Pirate: You fight like a diary farmer!
Guybrush: How appropriate, you fight like a cow!
User avatar
GuybrushThreepwood
 
Posts: 94
Joined: Sun Jul 06, 2008 12:23 pm
Location: Melee Island
Score: 2 Give a positive score

Re: Custom Name Input Screen

Postby Zivouhr » Thu Jun 04, 2015 1:00 am

Nice details and info Koala. 8) Thanks!
City of Rott Game created on Game Editor http://cityofrott.wordpress.com/
User avatar
Zivouhr
 
Posts: 549
Joined: Sat May 17, 2014 2:12 pm
Score: 59 Give a positive score


Return to Advanced Topics

Who is online

Users browsing this forum: No registered users and 1 guest