word manipulation with Allegro

Asked

Viewed 108 times

1

Hello, I am in doubt about the string manipulation with Allegro, as well as using "fgets" or "scanf" in C to receive a keyboard word I want to know how you do it with Allegro.

  • Welcome to Stackoverflow Kamila, to make it easier to help you, it is recommended that you place the part of the code that is having the problem next to your doubt, so it is easier to do the debugging. You can click on Edit to ask your question.

  • Which version of Allegro do you refer to?

  • Version 4.4.2 using Codeblocks as editor

  • In this case, I don’t know how to help. I think the OS community in Portuguese doesn’t have much knowledge of Allegro. I suggest you ask this in the English community, or ask this question in some official Allegro forum. The main site that comes to mind is https://www.allegro.cc/

1 answer

1


You can read letter by letter, I still have a function that used to read the player’s name, this function was in a loop together with the textout, which drew the player’s name as the player typed:

 char nome[200];

//FUNÇÃO PARA INSERIR NOMES
void LE_TECLADO()
{
    readkey();
    if(key[KEY_A])
    {
        strcat(nome,"A");
    }
    if(key[KEY_B])
    {
        strcat(nome,"B");
    }
    if(key[KEY_C])
    {
        strcat(nome,"C");
    }
    if(key[KEY_D])
    {
        strcat(nome,"D");
    }
    if(key[KEY_E])
    {
        strcat(nome,"E");
    }
    if(key[KEY_F])
    {
        strcat(nome,"F");
    }
    if(key[KEY_G])
    {
        strcat(nome,"G");
    }
    if(key[KEY_H])
    {
        strcat(nome,"H");
    }
    if(key[KEY_I])
    {
        strcat(nome,"I");
    }
    if(key[KEY_J])
    {
        strcat(nome,"J");
    }
    if(key[KEY_K])
    {
        strcat(nome,"K");
    }
    if(key[KEY_L])
    {
        strcat(nome,"L");
    }
    if(key[KEY_M])
    {
        strcat(nome,"M");
    }
    if(key[KEY_N])
    {
        strcat(nome,"N");
    }
    if(key[KEY_O])
    {
        strcat(nome,"O");
    }
    if(key[KEY_P])
    {
        strcat(nome,"P");
    }
    if(key[KEY_Q])
    {
        strcat(nome,"Q");
    }
    if(key[KEY_R])
    {
        strcat(nome,"R");
    }
    if(key[KEY_S])
    {
        strcat(nome,"S");
    }
    if(key[KEY_T])
    {
        strcat(nome,"T");
    }
    if(key[KEY_U])
    {
        strcat(nome,"U");
    }
    if(key[KEY_V])
    {
        strcat(nome,"V");
    }
    if(key[KEY_X])
    {
        strcat(nome,"X");
    }
    if(key[KEY_Z])
    {
        strcat(nome,"Z");
    }
    if(key[KEY_SPACE])
    {
        strcat(nome," ");
    }
    if(key[KEY_0_PAD])
    {
        strcat(nome,"0");
    }
    if(key[KEY_1_PAD])
    {
        strcat(nome,"1");
    }
    if(key[KEY_2_PAD])
    {
        strcat(nome,"2");
    }
    if(key[KEY_3_PAD])
    {
        strcat(nome,"3");
    }
    if(key[KEY_4_PAD])
    {
        strcat(nome,"4");
    }
    if(key[KEY_5_PAD])
    {
        strcat(nome,"5");
    }
    if(key[KEY_6_PAD])
    {
        strcat(nome,"6");
    }
    if(key[KEY_7_PAD])
    {
        strcat(nome,"7");
    }
    if(key[KEY_8_PAD])
    {
        strcat(nome,"8");
    }
    if(key[KEY_9_PAD])
    {
        strcat(nome,"9");
    }
    if(key[KEY_0])
    {
        strcat(nome,"0");
    }
    if(key[KEY_1])
    {
        strcat(nome,"1");
    }
    if(key[KEY_2])
    {
        strcat(nome,"2");
    }
    if(key[KEY_3])
    {
        strcat(nome,"3");
    }
    if(key[KEY_4])
    {
        strcat(nome,"4");
    }
    if(key[KEY_5])
    {
        strcat(nome,"5");
    }
    if(key[KEY_6])
    {
        strcat(nome,"6");
    }
    if(key[KEY_7])
    {
        strcat(nome,"7");
    }
    if(key[KEY_8])
    {
        strcat(nome,"8");
    }
    if(key[KEY_9])
    {
        strcat(nome,"9");
    }
}

Browser other questions tagged

You are not signed in. Login or sign up in order to post.