Typo - Typewriter lib
Typo - Typewriter lib
Typo is a simple library that allows you to effortlessly add a typewriter effect to your game. All you need to do it pass it in the text, delay, width to wrap, alignment, x position, y position and the font!
I made a tutorial on how to create this effect, and I will add a link here and remove this text once it is uploaded. It shows the basic principles of how to create such an effect without this library if you wish to do so.
Source code and download can be found on GitHub: https://github.com/sonic2kk/Typo
Please suggest any changes or additions I could make!
Have a great day, and thanks for checking this out!
Changelog:
1.1
Added colours
1.0
Original Release
I made a tutorial on how to create this effect, and I will add a link here and remove this text once it is uploaded. It shows the basic principles of how to create such an effect without this library if you wish to do so.
Source code and download can be found on GitHub: https://github.com/sonic2kk/Typo
Please suggest any changes or additions I could make!
Have a great day, and thanks for checking this out!
Changelog:
1.1
Added colours
1.0
Original Release
Last edited by Eamonn on Sun Aug 10, 2014 3:01 pm, edited 2 times in total.
"In those quiet moments, you come into my mind" - Liam Reilly
Re: Typo - Typewriter lib
This is pretty neat, I could easily see this be updated for RPG Dialogs. Only thing missing is special characters for coloring text.
Re: Typo - Typewriter lib
Colours: Got it! Adding it now!Rukiri wrote:This is pretty neat, I could easily see this be updated for RPG Dialogs. Only thing missing is special characters for coloring text.
Special Characters: Not sure what you mean. It should support special characters such as Ö,Ø, etc already. If you could clarify I'd be more than happy to help
EDIT: Colours have been added! Still not sure what you mean by Special Characters
"In those quiet moments, you come into my mind" - Liam Reilly
Re: Typo - Typewriter lib
I think what they mean is like how you use the
tags on the forums, to set certain parts a color.
Code: Select all
[color][/color]
GitHub | MLib - Math and shape intersections library | Walt - Animation library | Brady - Camera library with parallax scrolling | Vim-love-docs - Help files and syntax coloring for Vim
Re: Typo - Typewriter lib
Ohh... Hm, I'll look into how to do this. I'll add it along with support for special characters, which I know know is a problem and isn't so easy to tackle. I'm using string.byte and string.char to hopefully help Thanks to telling me this though. I guess for the color tags I'd just need to add a parser of some sort, right?davisdude wrote:I think what they mean is like how you use thetags on the forums, to set certain parts a color.Code: Select all
[color][/color]
"In those quiet moments, you come into my mind" - Liam Reilly
Re: Typo - Typewriter lib
Definitely. I took something like this on about last year, and you can feel free to take a look at it. Or Robin's library. To be honest, I based the first styling of mine off of Robin's.
GitHub | MLib - Math and shape intersections library | Walt - Animation library | Brady - Camera library with parallax scrolling | Vim-love-docs - Help files and syntax coloring for Vim
- Sam Storms
- Prole
- Posts: 11
- Joined: Tue Jul 15, 2014 6:39 pm
Re: Typo - Typewriter lib
Very nice, I'm starting on a platformer, I'm gonna use typo on it
Re: Typo - Typewriter lib
Awesome! Glad to see it's useful. I hope to add more to it eventually (such as being able to get certain properties)Sam Storms wrote:Very nice, I'm starting on a platformer, I'm gonna use typo on it
Trying to figure out how to do the string parsing, but I'll get there. I want to write it myself, so that typo has 0 external dependencies (except for Lua and LÖVE, of course ). Then you can add some more colorful things to your text.
"In those quiet moments, you come into my mind" - Liam Reilly
- Sam Storms
- Prole
- Posts: 11
- Joined: Tue Jul 15, 2014 6:39 pm
Re: Typo - Typewriter lib
I'm looking forward to it If I ever get to your level of understanding, I'll help with whatever you need help withEamonn wrote: Awesome! Glad to see it's useful. I hope to add more to it eventually (such as being able to get certain properties)
Trying to figure out how to do the string parsing, but I'll get there. I want to write it myself, so that typo has 0 external dependencies (except for Lua and LÖVE, of course ). Then you can add some more colorful things to your text.
Re: Typo - Typewriter lib
I don't know how much this would help you, but this is my old code for a textbox dialogue system for game maker that I wrote quite awhile ago.Eamonn wrote:Awesome! Glad to see it's useful. I hope to add more to it eventually (such as being able to get certain properties)Sam Storms wrote:Very nice, I'm starting on a platformer, I'm gonna use typo on it
Trying to figure out how to do the string parsing, but I'll get there. I want to write it myself, so that typo has 0 external dependencies (except for Lua and LÖVE, of course ). Then you can add some more colorful things to your text.
Create Event:
Code: Select all
textbox_surface = surface_create(256,224);
surface_set_target(textbox_surface);
draw_clear_alpha(0,0);
surface_reset_target();
text_entire = line_break_support(global.textbox_text);
text_letter = "";
draw_x = 0;
draw_y = 0;
current_position = 1;
max_position = string_length(text_entire) + 1;
color_1 = c_white;
color_2 = c_white;
global.cur_pos = current_position;
global.max_pos = max_position;
keyboard_clear(vk_space);
Code: Select all
if(current_position <= max_position) {
if(draw_y <= 30) {
text_letter = string_copy(text_entire,current_position,1);
switch(text_letter) {
case "]":
color_1 = c_aqua;
color_2 = c_blue;
break;
case "^":
color_1 = c_red;
color_2 = c_dkred;
break;
case "~":
color_1 = c_lime;
color_2 = c_green;
break;
case "`":
color_1 = c_white;
color_2 = c_white;
break;
case "#":
draw_x = 0;
draw_y += 15;
break;
default:
surface_set_target(textbox_surface);
draw_set_font(global.textbox_letters);
draw_text_color(view_xport+draw_x+28,view_yport+draw_y+161,text_letter,color_1,color_1,color_2,color_2,1);
surface_reset_target();
draw_x += string_width(text_letter);
draw_set_font(-1);
if(draw_x >= 195) {
draw_x = 0;
draw_y += 15;
}
}
current_position += 1;
}
}
// setup continue cursor
if(current_position >= max_position) {
current_position = max_position;
draw_x = 0;
draw_y = 0;
if (keyboard_check(vk_space)) {
instance_destroy();
}
}
Code: Select all
draw_surface(textbox_surface,view_xview[0],view_yview[0]);
draw_set_font(global.textbox_letters);
draw_set_color(c_ltgray);
if(current_position >= max_position) {
draw_sprite(spr_block,-1,view_xport+draw_x+113,view_yport+draw_y+175);
}
draw_text(x,y,draw_x);
Code: Select all
draw_surface(textbox_surface,view_xview[0],view_yview[0]);
draw_set_font(global.textbox_letters);
draw_set_color(c_ltgray);
if(current_position >= max_position) {
draw_sprite(spr_block,-1,view_xport+draw_x+113,view_yport+draw_y+175);
}
draw_text(x,y,draw_x);
Code: Select all
if(draw_y >= 45) {
instance_destroy();
textbox(string_copy(text_entire,current_position,string_length(text_entire)-current_position+1),color_1,color_2);
}
Create:
Code: Select all
global.textbox_letters = font_add_sprite(spr_letters,ord('!'),1,1);
global.textbox_text = "";
Press Enter:
Code: Select all
textbox("Testing a very long text message, maybe the pointer will get a ~hint?");
Who is online
Users browsing this forum: Ahrefs [Bot] and 6 guests