GML Basic Coding Help

Discussion in 'Game Design, Development And Publishing' started by guitarmonkeys14, Jan 19, 2019.

  1. guitarmonkeys14

    guitarmonkeys14 Member

    Joined:
    Jan 19, 2019
    Posts:
    10
    I keep getting these rectangles in my text and I have no idea how to eliminate them. Please help

    upload_2019-1-18_20-39-21.png

    upload_2019-1-18_20-38-27.png

    Thank you in advance
     
  2. IndianaBones

    IndianaBones Member

    Joined:
    Jul 5, 2016
    Posts:
    2,202
    GMS is attempting to draw the Tab characters I assume.

    You could build your text using a different method, use '\n' for newlines, put all your text on one line, separated by new line characters.

    Code:
    text = "First line\nSecond Line\nThis is the third line"
    draw_text(room_width/2, 200, text)
    
    Also, it would be great if you could paste your code as text next time, and put it between code tags, ie.

    [ c o d e]

    code goes here

    [ / c o d e]

    (remove the spaces - I had to include spaces or it you wouldn't be able to see the example).
     
  3. FrostyCat

    FrostyCat Member

    Joined:
    Jun 26, 2016
    Posts:
    4,537
    No, it's 100% possible to show the [code] and [/code] tags without spaces, and the method has been in the clear for years.

    If you want to see how it's done, quote this post in the reply field, then select "Use BB Code Editor" (paper with wrench icon at top-right corner).
     
    Yal, IndianaBones and GMWolf like this.
  4. GMWolf

    GMWolf aka fel666

    Joined:
    Jun 21, 2016
    Posts:
    3,440
    using the [plain] and [/plain] tags?

    so [plain] [code] [/code] [/plain]
    of course that last example was written like so:
    [plain][plain] [code] [/code] [/plain] [/plain]

    etc etc

    @guitarmonkeys14
    The issue does seem to be the tab character.
    i would recommend you build you strings like this instead:
    Code:
    draw_text(x,y, "Score 1000 points to win\n" +
                   "UP: move\n"+
                   "L/R: Change direction\n"
    etc etc
    
    
     
  5. Yal

    Yal GMC Memer GMC Elder

    Joined:
    Jun 20, 2016
    Posts:
    3,688
    He's not using a fixed-width font, though (looks like Arial to me), this isn't a foolproof method... for instance if every line doesn't start with tabs (e.g you have headings on the left side and numbers/stats on the right of them) this gets unreliable quickly.

    Personally, I prefer to solve situations like this by drawing more than one string (at different coordinates). Gives you much more control over how much stuff is aligned. You can also get the size of a string with string_width() and string_height() if you need to align other stuff to the text.
     
  6. GMWolf

    GMWolf aka fel666

    Joined:
    Jun 21, 2016
    Posts:
    3,440
    But the tabs op was seeing was from the code formating, rather than intentional tabs in the text.
    Or rather, that it what it looks like to me.
     
  7. guitarmonkeys14

    guitarmonkeys14 Member

    Joined:
    Jan 19, 2019
    Posts:
    10
    Thank you all for your responses, I definitely found the best option to be setting it up as follows

    Code:
    draw_text(
               room_width/2, 200,
               "Score 1,000 points to win!\n" +
               "\n" +
               "UP: Move\n" +
               "L/R: Change Direction\n" +
               "SPACE: Shoot\n" +
               "\n" +
               ">> Press ENTER to Start <<\n"
    
    Resulted in this :)))
    upload_2019-1-20_19-23-59.png

    I appreciate everyone help
     

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