We're archiving the forums and going read only! You'll be able to see old threads, but new topics and replies have been disabled.

Visit the Game Jolt community for new questions and conversations.


Update 2/25/16 - This thread is quite old, but I appreciate how much traction its consistently getting. I improved the formatting. If you're willing to spend $0.99, check out this Smooth Dialogue Engine I released on the YoYoGames' Marketplace.


A game with dialogue can be drastically improved with a "typewriter" effect, in my opinion at least. Not only is it aesthetically pleasing, but can ease the burden of a lot of text on-screen. Though this example is written for Game Maker, it can be adapted to other languages with ease. Absolutely no credit is necessary, as this took only two minutes to write.


Create Event:

		
			//write your messages in an array, starting at 0, like so
message[0] = "Hello there! Welcome to the world of Pokemon!";
message[1] = "My name is Oak! People call me the Pokemon Prof!";
message[2] = "This world is inhabited by creatures called Pokemon!";
message[3] = "For some people, Pokemon are pets.";
message[4] = "Others use them for fights.";
message[5] = "Myself...";
message[6] = "I study Pokemon as a profession.";

message_current = 0; //0 is the first number in our array, and the message we are currently at
message_end = 6; //6 is the last number in our array
message_draw = ""; //this is what we 'write' out. It's blank right now
increase = 0.5; //the speed at which new characters are added
characters = 0; //how many characters have already been drawn
hold = 0; //if we hold 'Z', the text will render faster

message_length = string_length(message[message_current]); //get the number of characters in the first message
		
	

Step Event:

		
			if (characters < message_length) { //if current character count is less than the amount in current message* 
    hold = keyboard_check(ord("Z")); //hold is true or false if we hold 'Z' or not
    characters += increase * (1 + hold); //increase speed based on hold
    message_draw = string_copy(message[message_current], 0, characters); //copy string to current character
} 
else { //if current character is more than the amount in the current message
    if (keyboard_check_pressed(ord("Z"))) { //if we press Z...
        if (message_current < message_end) { //if there are more messages left to show (0 -> 6, in our case)
            message_current += 1; //increase the message by 1
            message_length = string_length(message[message_current]);  //get the new character length for message
            characters = 0; //set the characters back to 0
            message_draw = ""; //clear the drawn text
        }
        else { //if our messages are done (we reach 6, in our case)...
            instance_destroy(); //destroy the object
        }
    }
}
		
	

Draw Event:

		
			draw_text(x, y, message_draw); //draw the text at the coordinates
		
	

Page 3 of 85 replies.

about 8 years ago

thanks im using this code for my undertale fangame

about 8 years ago

Not working with Cyrillic, just dont show words, I'm typed text in Russian, and get nothing. Any solutions?
P.S. dots and commas shows, but not words.

UPD: Fixed. Added range in font to cyrilic words.

Last modified on August 29, 2017 by Artem Darkov @darkpro1337

almost 8 years ago

When I remove or add a new message, the game crashes.

almost 8 years ago

cool it works good

over 7 years ago

Nice! It works perfectly!

over 7 years ago

Yes a fellow pokemon fan! Very helpful though, thanks!

over 7 years ago
In response to %{ user }@Ufoul

huh im making one too

over 7 years ago
In response to %{ user }@smellsfishy

lol i commented that like a year ago fuck making an undertale fan game in 2018

over 7 years ago

How do you change the font?

over 7 years ago
In response to %{ user }@endode

draw_set_font(font name here);

Make sure you added the font into game maker.

over 7 years ago
In response to %{ user }@ryguyft4444

Draw event:
draw_set_color(c_yellow)
draw_text(x, y, message_draw); //draw the text at the coordinates

over 7 years ago
In response to %{ user }@jjdev

Change the variable that is telling the program there is 6 messages to however many you want

over 7 years ago
In response to %{ user }@MrEpicIsHere777

The sound plays too fast is there a way to delay it for a second?

over 6 years ago

how do you add sound on characters now?

over 6 years ago
In response to %{ user }@dreamheartguy

Because joo git to go to da 🏠 mon. It keep me drip off me head. O ye n we don say mon!

over 6 years ago
over 6 years ago

Question: How do i add a custom font to it?

over 6 years ago

Two Questions: One, How Do I Add A Font To It, And Two How Do I Add A Text Sound Effect To It?

about 6 years ago

Thanks so much man! I am going to use this with my game, Meruvian Simulator!

about 5 years ago

nortep

almost 5 years ago

Is there a way to add a speech sound?

about 4 years ago

thanks u almost 8 years old but still perfection

almost 4 years ago

как сделать дистанцию ​​для игрока. то есть текстовое поле работает даже на большом расстоянии, что мне делать?

over 3 years ago
In response to %{ user }@NotSoLliGcM

To change it to enter instead of Letters, you type

keyboard_check_pressed(vk_enter)
VK stands for virtual key so anything like vk_space or vk_shift or vk_backspace