• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Can't make fonts work

  • Thread starter Gustavo Purificação
  • Start date
G

Gustavo Purificação

Guest
I have 3 lines of text in an empty room.

Each one is an independent object.

I created 2 fonts. One for the first line, another for lines 2 and 3. Set font and color on each one's draw event.

Just can't make it work. Game maker messes fonts and colors. Switching instance order for the room changes it, but when it corrects one line, it messes another one.
 
S

Sake_v2

Guest
Why it doesn't work? What happens? Game maker "messes fonts and colors" is not very specific.

Imagino que fale português/seja br pelo nome. Tenta descrever melhor o problema.
 
G

Gustavo Purificação

Guest
Hi, Sake_v2. Sorry, I'm from Brazil:

It uses the fonts I created (both of them), but not as I set them for each object:

obj1: font1, color red
obj2: font2, color white
obj3: font2, color white

That's how each obj is supposed to be.

But when I run the game, for example, they show like this:

obj1: font2, color white
obj2: font1, color red
obj3: font1, color white

That's just an example. I still could not figure out what's the pattern for the problem.
 
S

Sake_v2

Guest
The problem is with your code.
Doing it like that:

obj1 Draw Event:
Code:
draw_set_font(font1);
draw_set_color(c_red);
draw_text(x,y,"Olá!");
obj2 Draw Event:
Code:
draw_set_font(font2);
draw_set_color(c_white);
draw_text(x,y,"Olá2!");
obj3 Draw Event:
Code:
draw_set_font(font2);
draw_set_color(c_white);
draw_text(x,y,"Olá3!");
should work just fine.
(e eu também)
 
G

Gustavo Purificação

Guest
Hi!

The problem is my code is already exactly as you said, but the difference is mine is using drag and drop.
I created a draw event, and placed every proper action there with the correct descriptions.

I guess drag and drop is the problem, right?
 
S

Sake_v2

Guest
Could be. Its been years and years since I used to use drag and drop, so I couldn't help you too much with that. But if you use code like the one I showed you, its gonna work just fine. Just create a draw event on every one of those 3 objects, and put those codes in there.
You should use the draw_set_font and draw_set_color before your draw_text everytime you're drawing it for it to work properly, with the selected color and font.
 

NightFrost

Member
It could be that in your drag-and-drop code some of the draw text commands are running before the relevant draw set commands. You may already be aware, but: draw_set_* commands affect all subsequent draw commands, not just the next one, including commands in further draw steps. So if you set draw color to red as last thing in a draw step, next step's draw text commands will also use red unless you change it first.
 
G

Gustavo Purificação

Guest
I'm learning about actually coding stuff, little by little, so I can stop using drag and drop. Not that I think it's bad... it's actually very nice for beginners, but I guess you might get stuck because of it sometimes.
Thank you so much, Sake_v2 and NightFrost. You guys helped me a lot.
 
G

Gustavo Purificação

Guest
Just a quick question, so I don't keep creating a lot of threads...

I'm using the "random" (irandom) and "choose" commands on my enemy for a couple of things. I noticed if I use those with a 50-50 percent chance (like irandom=1... wich I guess uses 0 or 1), sometimes the enemy end up doing the same stuff 90% of the time... Like if I'm flipping a coin and 9 out of 10 times I get the same result. Is that a normal behavior?
 
D

DarthTenebris

Guest
Just a quick question, so I don't keep creating a lot of threads...

I'm using the "random" (irandom) and "choose" commands on my enemy for a couple of things. I noticed if I use those with a 50-50 percent chance (like irandom=1... wich I guess uses 0 or 1), sometimes the enemy end up doing the same stuff 90% of the time... Like if I'm flipping a coin and 9 out of 10 times I get the same result. Is that a normal behavior?
You have to insert randomize() at the beginning of your game to keep it random.

Hope I helped :)
 
G

Gustavo Purificação

Guest
Hi!

Thanks for the advice! I'm going to try that!
 
Top