Please help me with the "Space Rocks" tutorial

L

lindsay

Guest
I am almost done(im at part 4 time stamp 8:11 if you want to watch the clip on YouTube) with the Space Rocks tutorial but I have an issue I need help with. I posted this to Reddit and people have responded but it is so confusing to me. I already re-wrote my code and re-checked it for mistakes but can not find any. Since you are not aloud to post screenshots of code in these forums, I ask you guys to go to my Reddit at https://www.reddit.com/r/gamemaker/comments/cdyyy0/need_help_fixing_my_codescreen/ to view my code vs their code and you can also see my problem I am having. Please view it and then come back to this post and comment what I should do.

***Videos as well as exact, EASY TO FOLLOW steps greatly appreciated

Thank You
 

TsukaYuriko

☄️
Forum Staff
Moderator
Please do not post screenshots of code, and please don't link to a site with screenshots of code, either - it's all in the guidelines. :)

That aside, you're drawing tab characters. You included them in your string, so of course they will be drawn.

The reason why this works in the video you're watching is only because the font in use does not have a tab character, and yours does.
 
L

lindsay

Guest
Please do not post screenshots of code, and please don't link to a site with screenshots of code, either - it's all in the guidelines. :)

That aside, you're drawing tab characters. You included them in your string, so of course they will be drawn.

The reason why this works in the video you're watching is only because the font in use does not have a tab character, and yours does.
if I cant use screenshots of code, how come I found other people on here with code screenshots. That's unfair
 
if I cant use screenshots of code, how come I found other people on here with code screenshots. That's unfair
Because they have also done it wrong, and have most likely been told not to do it (perhaps not publicly it might have been via PM). You are not being singled out, it is a guideline for all of us to follow.
 

TsukaYuriko

☄️
Forum Staff
Moderator
if I cant use screenshots of code, how come I found other people on here with code screenshots. That's unfair
That's beside the point... it's to make it as easy for people to help you as it can be, to increase your chances of receiving help. If others are not following this and making it a pain to help them, that's their loss, and certainly nothing you should be inspired by or idolize. That would both make you a part of an ongoing problem and decrease your chances of getting help.

That aside, did you manage to resolve this? You quoted my entire reply but only responded to a part of it, so I'm unsure if my directions were helpful in any way.
 

Joe Ellis

Member
"The reason why this works in the video you're watching is only because the font in use does not have a tab character, and yours does."
@TsukaYuriko Do you know how to disable the tab character in fonts? or do you need to edit the font and remove it?

Thanks @EvanSki, that was what I thought too
 

Evanski

Raccoon Lord
Forum Staff
Moderator
"The reason why this works in the video you're watching is only because the font in use does not have a tab character, and yours does."
Do you know how to disable the tab character in fonts? or do you need to edit the font and remove it?

Thanks @EvanSki, that was what I thought too
I think you would need to edit the range of characters the font stores, but it would just result in ▯, you would physically have to remove the parts where youve tabbed, so to quote someone else that replied on reddit on the
[fryman22]
I would suggest putting all that text into a variable, then draw the variable to the screen.

var str = "";
str += "Score 1,000 points to win!\n\n";
str += "UP: move\n";
str += "LEFT/RIGHT: change direction\n";
str += "SPACE: shoot\n\n";
str += ">> Press Enter To Begin <<";
draw_text(room_width / 2, 200, str);

The code above is compatible with GMS2, but not GMS1.4. If you're using GMS1.4 replace "\n" with "#" to create line breaks. You can also make that local variable an instance variable in the create event so you don't have to compute it in the draw event every step.
and seeing as the OP didnt know what a local veritable was as pointed out here
what does str mean?
I shall quote Fryman again
My point, the OP is better off dropping that @
 

Joe Ellis

Member
Hmm, I'm still abit confused, I thought that the fonts get rendered onto a sprite sheet, so if you exclude that ▯, from the range, it would show up with nothing, but maybe it puts the ▯ in as a default onto every font sprite sheet
 

TsukaYuriko

☄️
Forum Staff
Moderator
"The reason why this works in the video you're watching is only because the font in use does not have a tab character, and yours does."
@TsukaYuriko Do you know how to disable the tab character in fonts? or do you need to edit the font and remove it?
If you disable the tab character, the placeholder character will be used instead. Same problem, different cause. Disabling that one as well can cause other side effects, though. You'd end up with characters that aren't included in your font literally not being visible at all, without any indicator that they're even missing, so I'd advise against doing so.

To answer the question anyway, the tab character is character 9. Removing that from the font stops it from being rendered, if it is even present in the front in the first place (and not zero-width). Removing the placeholder character (9647) as well stops the placeholder from being rendered instead.


... the proper solution would be to simply not have tab characters in your strings in the first place, though. There's no reason to put a wet bandaid around a wound when you can bandage it up properly. The reason why the code in the tutorial that's being discussed works is a pure coincidence which breaks depending on user settings, anyway, and should not be considered a good practice.

If you need a multi-line string, use the newline escape sequence.
Code:
draw_text(x, y, "This is a multi-line string\nwhich will not screw up drawing.");
If you want it to visually match the drawn text in your code, use string concatenation as well.
Code:
draw_text(x, y, "This is a multi-line string\n"
              + "which will not screw up drawing.");
 

Joe Ellis

Member
I appreciate your explanation but I'm also confused why you didn't post this at the start of the thread. It would've been one answer and one reply then.
 

TsukaYuriko

☄️
Forum Staff
Moderator
Because I figured a long-winded explanation about possible workarounds won't explain it any better than this. :)
That aside, you're drawing tab characters. You included them in your string, so of course they will be drawn.
I intentionally left the solution open as I figured that deriving it from the cause would provide a much better learning experience.

As you can see, the natural progression of this topic has not only resulted in a suitable solution, but also with an exploration of why the original attempt was flawed at the core and why it shouldn't be considered.
 

Joe Ellis

Member
That makes alot of sense, and I love your way of thinking.
I did think originally, just don't use anything that would cause the tab character to be drawn. I wouldn't, but I thought there was a workaround so I wanted to help lol, I guess this was another time where I'm pointless. No actually, I've got plenty of knowledge and always want to help. It just depends where\when that knowledge is useful
 
Last edited:
L

lindsay

Guest
"The reason why this works in the video you're watching is only because the font in use does not have a tab character, and yours does."
@TsukaYuriko Do you know how to disable the tab character in fonts? or do you need to edit the font and remove it?

Thanks @EvanSki, that was what I thought too
Im using the same font she has
 

TsukaYuriko

☄️
Forum Staff
Moderator
That is not the problem.

Focus on the fact that there are tabs in your string. Don't focus on the font, which characters are in the font, which of them aren't, or what the person in the tutorial does.

Remove the tabs from your string.
 
L

lindsay

Guest
That is not the problem.

Focus on the fact that there are tabs in your string. Don't focus on the font, which characters are in the font, which of them aren't, or what the person in the tutorial does.

Remove the tabs from your string.
I don't have any "tabs" that appear in my code. It only appears like that when I run the game. I don't know how to remove them. I did everything she did
 
I don't have any "tabs" that appear in my code.
Yes you do (I took this from your linked posts), and I have circled them for you:
upload_2019-7-18_10-49-51.png
Delete all of those blanks so that the text is back at the very left of the editor and try again.

Now, if you have actually changed this already but not shown us the change, then please do so, so that we can look again.
 

TsukaYuriko

☄️
Forum Staff
Moderator
Doing everything the person in the tutorial does is not always the right thing.


Then let's do this with screenshots, as that seems to be your favored medium anyway. :)

 

TsukaYuriko

☄️
Forum Staff
Moderator
The tutorial doesn't specifically tell you to add tabs to your strings. It just involves carelessly using tabs in a string and the placeholder character happens to not be in the used font resource, so the visual problem that's a result of this combination is never encountered by sheer chance.
 

curato

Member
Never take chance with special characters in your strings.

Code:
\n    Newline
\r    Carriage return
\b    Backspace (0x08)
\f    Form Feed (0x0c)
\t    Horizontal Tab (0x09)
\v    Vertical Tab (0x0b)
\\    Backslash itself (0x5c)
\a    Alert (0x07)
\u[Hex Digits]    Insert hex unicode character
\x[Hex Digits]    Insert hex unicode character
\[Octal Digits]    Insert octal unicode character
 
L

lindsay

Guest
Yes you do (I took this from your linked posts), and I have circled them for you:
View attachment 25801
Delete all of those blanks so that the text is back at the very left of the editor and try again.

Now, if you have actually changed this already but not shown us the change, then please do so, so that we can look again.
Oh okay. Lol thank you for showing me what a tab looks like.
 
L

lindsay

Guest
Why would a tutorial tell you to do that. It is bad form for just the reasons mentioned above.
I don't know why she did it. Maybe to center it but she should have done it another way
 
Top