How to program a user text input box (Highscore) [SOLVED!]

Discussion in 'Programming' started by Architheutis, Oct 10, 2019.

  1. Architheutis

    Architheutis Member

    Joined:
    Nov 9, 2018
    Posts:
    51
    Hi Folks,

    my game is in the fine adjustment...
    ... I programmed a highscore table with a text input box.
    So the player is able to type his name via keyboard.
    That works on PC or laptop aso.

    But what about a mobile unit like a smartphone or tablet?
    It´s set with a keyboard_string = " ", displayed via draw-event (draw-text).
    That works fine on PC & Co. as said before. But does it work on mobile
    units too?

    If not:
    Has anybody an idea to take it with another possibility,
    that works for both platforms (PC & Mobile)?

    I consider about an initial-editor, where you can see a user-table,
    the letters can be choosen via arrow keys and with touching
    the mobile screen?

    Hope I could explain my goals good enough!?
    Have a nice day.

    Archie.
     
  2. marasovec

    marasovec Member

    Joined:
    Sep 15, 2016
    Posts:
    325
  3. 3dgeminis

    3dgeminis Member

    Joined:
    Jun 21, 2016
    Posts:
    130
    Something like the picture?
    [​IMG]
    The idea is to take the position of the mouse on both axes and decide which letter or number is being pressed accordingly.
    For example if x=4 and y=2 the key would be L.
     
  4. Architheutis

    Architheutis Member

    Joined:
    Nov 9, 2018
    Posts:
    51
    Hi there,

    I´m back again from working down several points of my to-do-list.
    Now I am back on my game. Thank you for responding. I already tried
    to solve it via the grid. But I´m preffering a retro-version of spelling the
    player name for highscore.

    Please take a look on my actual status. In the following PNG you can
    have a rough imagination of what I already worked out. But there are
    some points to solve.

    I´m thankful for every time and efforts to take a look on it, even
    giving me hints to solve the explained problems inside of PNG.

    I tried so many ways, but now I ask you for giving me help.
    Previous thanks!!!

    Best regards,
    Archie. :rolleyes:

    HS_Explanation.png

    Code:
    //All events are in "oSpelling". These are just attempts... I need professional eyes on it!
    
    CREATE:
    
    image_index = 0;
    image_speed = 0;
    if !audio_is_playing(au_HighscoreSound){
        audio_play_sound(au_HighscoreSound,1,true);
    }
    
    txt = "";
    drawLetter = "";
    
    
    STEP:
    
    if keyboard_check_pressed(vk_left) var leftscroll = true; else var leftscroll = false;
    if keyboard_check_pressed(vk_right) var rightscroll = true; else var rightscroll = false;
    
    if leftscroll{ image_index = image_index - 1; }
    else{
        if rightscroll{ image_index = image_index + 1; }
        }
    
    
    DRAW:
    
    draw_set_font(Kiddybox_Font3);
    var letterCount = 1;
    if letterCount <= 1{
    draw_text(x,y+121,txt); letterCount ++;}
    else{
        if letterCount > 1{
        draw_text(x,y+121,txt+""); letterCount ++;
    }
    }
    draw_set_halign (fa_center);
    draw_set_valign (fa_center);
    
    
    BUTTON PRESSED-EVENT:
    
    txt = drawLetter;
    
    if image_index = 0 { drawLetter = "A" }
    if image_index = 1 { drawLetter = "B" }
    if image_index = 2 { drawLetter = "C" }
    if image_index = 3 { drawLetter = "D" }
    if image_index = 4 { drawLetter = "E" }
    if image_index = 5 { drawLetter = "F" }
    if image_index = 6 { drawLetter = "G" }
    if image_index = 7 { drawLetter = "H" }
    if image_index = 8 { drawLetter = "I" }
    if image_index = 9 { drawLetter = "J" }
    if image_index = 10 { drawLetter = "K" }
    if image_index = 11 { drawLetter = "L" }
    if image_index = 12 { drawLetter = "M" }
    if image_index = 13 { drawLetter = "N" }
    if image_index = 14 { drawLetter = "O" }
    if image_index = 15 { drawLetter = "P" }
    if image_index = 16 { drawLetter = "Q" }
    if image_index = 17 { drawLetter = "R" }
    if image_index = 18 { drawLetter = "S" }
    if image_index = 19 { drawLetter = "T" }
    if image_index = 20 { drawLetter = "U" }
    if image_index = 21 { drawLetter = "V" }
    if image_index = 22 { drawLetter = "W" }
    if image_index = 23 { drawLetter = "X" }
    if image_index = 24 { drawLetter = "Y" }
    if image_index = 25 { drawLetter = "Z" }
    if image_index = 26 { drawLetter = " " }
     
    Last edited: Oct 16, 2019
  5. 3dgeminis

    3dgeminis Member

    Joined:
    Jun 21, 2016
    Posts:
    130
    I made an example, I hope it will help you:

    CREATE EVENT
    Code:
    letter="ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_!?"
    position=1
    name=""
    limit=10
    w=room_width/2
    h=room_height/2
    
    STEP EVENT
    Code:
    if keyboard_check_pressed(vk_right)
      {
       position+=1
       if position>string_length(letter) {position=1}
      }
     
    if keyboard_check_pressed(vk_left)
      {
       position-=1
       if position<1 {position=string_length(letter)}
      }
    
    if keyboard_check_pressed(vk_down)
      {
       if string_length(name)<limit {name+=string_char_at(letter, position)}
      }
    
    if keyboard_check_pressed(vk_delete) {name=string_delete(name, string_length(name), 1)}
    DRAW EVENT
    Code:
    draw_set_halign (fa_center);
    draw_set_valign (fa_center);
    draw_text(w, h-60, string_char_at(letter, position))
    draw_text(w, h, name)
     
    Architheutis likes this.
  6. Architheutis

    Architheutis Member

    Joined:
    Nov 9, 2018
    Posts:
    51
    Hi 3dGeminis,

    that is exactly what I wanted!
    And it looks pretty simple. But I was absolutely on a wrong way.
    First I wanted to solve it with things I already learned. Wasn´t enough (sigh!).
    Still collecting experience. ;-) Now one experience more!

    Again: Thank you very much!!!

    Best wishes!
    Archie.



     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice