• 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!

Text engine?

P

Pitu

Guest
Hi, pretty dilute and bad question, sorry about that but I'm the furthest thing from a good programmer.
How would I make a text engine for my game? Please don't link me the Shaun Spalding/heartbeast videos I tried them and they are not to my liking and the "super simple text engine" on gamejolt too. I don't require you to write an entire text engine for me can someone just explain how I would handle this? I want it to be very specific like without the box and with sound after each letter is displayed. And how would I store the messages

 
A

Annoyed Grunt

Guest
The more general you get the more ways you have to do it, and there is no single true "right" way to do things in programming.
Drawing text is a matter of drawing only part of the string rather than the entirety of it and just expanding the amount of it you're drawing every tot steps.
Making it fit in a rectangular area is just a matter of using draw_string_ext.
Storing messages, you can do in a hundred ways: arrays, lists, even maps.
 

Nux

GameMaker Staff
GameMaker Dev.
the easiest way to make stationary text would be to use draw_string_ext();
however, scrolling text like in RPGs require a little more coding.

the core things you should need are:
Code:
dialogue = "whatever dialogue you want to say";
textSpeed = [whatever speed] * room_speed; // in seconds
currentCharacter = 0; // for finding how many characters in the dialogue to draw
time = 0; // increment by 1 until textSpeed is reached
every step you will increment time by 1 with: time++;
then check if the current [time] is greater than textSpeed, if it is then draw 1 more character by incrementing currentCharacter++;
example:
Code:
if (time >= textSpeed)
{
    time = 0; // reset
    currentCharacter++;
}
else time++;
now you have the behind the scenes done, you will just need to draw that many characters using a for loop
Code:
for (var chara = 0; chara < currentCharacter; chara++)
{
     // draw character at index chara from dialogue
     var character = string_char_at(dialogue, chara+1);
     var xx = x+(chara*10); // the 10 the spacing, you can use font_get_size (i think) to get an exact value
     // the xx variable makes the characters not be drawn atop eachother
     draw_text(xx,y,character);
}
don't copy paste this since it's an example, but it should give you an idea on how to do scrolling text
I haven't specified how to do lines because that would add a lot more variables and checks. it would involve having a numbOfLines variable, or using a 'flag character' such as # to tell the program when to create a new line. Then, changing the y positions of the characters as well as the x positions
 
Top