• Hello [name]! Thanks for joining the GMC. Before making any posts in the Tech Support forum, can we suggest you read the forum rules? These are simple guidelines that we ask you to follow so that you can get the best help possible for your issue.

Question - Code Strings are being drawn with these weird boxes adjacent to them.

E

Exabella

Guest
Trying to do the "Space Rocks" tutorial and I came across this weird issue. I'm trying to display the text across the screen using the @. All the other font like the title directly above it display fine. It's only happening when trying to use the @. It's probably something really stupid but I spent like 30 minutes trying to figure it out and I can't.

I have a screenshot but I cannot post it cause of the initial no screenshot rule apparently. I linked it in my profile feed.

Code:
        draw_text(room_width/2, room_height/2-100,
            @"SCORE 1000 POINTS TO WIN
     
            UP: move
            LEFT/RIGHT: change direction
            SPACEBAR: shoot
     
            >> PRESS ENTER TO START <<
            "
        );
mod edit: the screenshot in question
 
Last edited by a moderator:
B

Brian@PizzaBoxStudio

Guest
I'm also having the same issue. Seems to be related to using the @ to open up lines of text, as it is the only section that does it.
 
B

Brian@PizzaBoxStudio

Guest
I found a quick fix - remove the tabs in front of each of the lines of text. I breaks the tabbed readability but still works. Its apparently reading the tabs as actual font characters.

@"SCORE 100 POINTS TO WIN!
UP: move
LEFT/RIGHT: change direction
SPACE: shoot
>> PRESS ENTER TO START <<
"
 

YoKoNo

Member
I too have this issue. Be good if we didn't have to tab back to get the font to not show up the boxes. Perhaps a new bug has been incorporated in the new build since FriendlyCosmonaut did her tutorial in October so was all working fine then.
 
Last edited:
E

Exabella

Guest
I found a quick fix - remove the tabs in front of each of the lines of text. I breaks the tabbed readability but still works. Its apparently reading the tabs as actual font characters.

@"SCORE 100 POINTS TO WIN!
UP: move
LEFT/RIGHT: change direction
SPACE: shoot
>> PRESS ENTER TO START <<
"
Oh thank you!! I wasn't actually expecting to see a solution.
 

tiberionx

Member
So im annoyed that pressing enter also shows those stupid boxes
so I just repeatedly drew the text
1593618940616.png
1593619184120.png
Im sure there a lot more better ways to do this but .... im doing the beginner tutorial sooo......
 
For all you beginners. It's not really a bug, it's just directly drawing a character that does not exist (most font sets doesn't have a representation for tab, obviously), so it diverts to the square thingie. This is because of the @ symbol being used, which draws the following text directly as it is typed. So typing tab tries to make it draw something. Instead of using multiple draw calls, there's a more interesting and quicker way to achieve the returns:
Code:
draw_text(room_width/2,500,"SCORE 1000 points to win!\nUP: Move\nLEFT/RIGHT etc");
Note there is no @ before the string. \n is the command to "display" a return (pressing enter) in a string. It's interesting because there's a whole series of other commands that might come in useful at some point, for instance if you ever want to type " and have it actually display in the string (normally it will end the current string, instead of displaying) you can use the \" command. These are called escape characters. You can read all the ones that exist and exactly how they work here: Strings.
 

Rami1114

Member
Alternatively, you can keep the multi-line string but replace the tabs with nothing:
GML:
draw_text(room_width/2, 200,
            string_replace_all(@"Score 1,000 points to win!
            
            UP: move forward
            DOWN: reverse
            LEFT/RIGHT: change direction
            SPACE: shoot
            
            >> PRESS ENTER TO START <<", "\t", "")
        );
 
Top